Commit 2e4a896c authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Implement delegate for physical markers table

Hide expand button if all children are hidden
parent 09c6328c
......@@ -183,6 +183,7 @@ Project {
"components/DialogImportSnapshot.qml",
"components/DialogOpenNetworkDefinition.qml",
"components/DialogPrintDatasheet.qml",
"components/DimensionsList.qml",
"components/ExpandableGroup.qml",
"components/InstanceCreator.qml",
"components/SymbolPlug.qml",
......
......@@ -5,10 +5,11 @@ import QtCAN.CanTestBench 2.0;
ExpandableGroup {
id: base;
expandable: (dims.shouldBeVisible || !toggleShowOnlyEditable.checked);
iconItem: Rectangle {
color: block.color;
implicitWidth: Style.spacingBig;
implicitHeight: Style.spacingBig;
implicitWidth: Style.iconSize (1);
implicitHeight: Style.iconSize (1);
}
uidLabel {
text: block.uid;
......@@ -24,98 +25,41 @@ ExpandableGroup {
signal needVisible (Item item);
Repeater {
model: [
DimensionsList {
id: dims;
dimensionsList: [
block.pivotPos,
block.size,
block.angle,
block.absoluteAngle,
];
delegate: ExpandableGroup {
id: delegateDimensionTable;
visible: (phyValEditableCount || !toggleShowOnlyEditable.checked);
uidLabel {
text: delegateDimensionTable.dimension.uid;
font.italic: true;
}
ExtraAnchors.horizontalFill: parent;
readonly property BasicObject dimension : modelData;
readonly property var phyValList : {
var ret = [];
switch (dimension.family) {
case ObjectFamily.POSITION:
ret.push (dimension ["onLeftToRight"]);
ret.push (dimension ["onBackToFront"]);
ret.push (dimension ["onBottomToTop"]);
break;
case ObjectFamily.SIZE:
ret.push (dimension ["toLeft"]);
ret.push (dimension ["toRight"]);
ret.push (dimension ["toBack"]);
ret.push (dimension ["toFront"]);
ret.push (dimension ["toBottom"]);
ret.push (dimension ["toTop"]);
break;
case ObjectFamily.ANGLE:
ret.push (dimension ["yaw"]);
ret.push (dimension ["pitch"]);
ret.push (dimension ["roll"]);
break;
onNeedVisible: {
base.expanded = true;
base.needVisible (item);
}
onValueEdited: {
if (dimension === block.absoluteAngle) {
var oldAbs = phyVal.val;
var newAbs = value;
var delta = (newAbs - oldAbs);
var relVal = null;
if (phyVal === block.absoluteAngle.yaw) {
relVal = block.angle.yaw;
}
return ret;
}
readonly property int phyValEditableCount : {
var ret = 0;
phyValList.forEach (function (phyVal) {
if (phyVal.min !== phyVal.max) {
++ret;
}
});
return ret;
}
Repeater {
id: repeaterDimensionsPhyVal;
model: delegateDimensionTable.phyValList;
delegate: DelegatePhyValTable {
id: delegatePhyValTable
phyVal: modelData;
visible: (editable || !toggleShowOnlyEditable.checked);
ExtraAnchors.horizontalFill: parent;
onNeedVisible: {
delegateDimensionTable.expanded = true;
base.expanded = true;
base.needVisible (item);
}
onValueEdited: {
if (delegateDimensionTable.dimension === block.absoluteAngle) {
var oldAbs = phyVal.val;
var newAbs = value;
var delta = (newAbs - oldAbs);
var relVal = null;
if (phyVal === block.absoluteAngle.yaw) {
relVal = block.angle.yaw;
}
else if (phyVal === block.absoluteAngle.pitch) {
relVal = block.angle.pitch;
}
else if (phyVal === block.absoluteAngle.roll) {
relVal = block.angle.roll;
}
else { }
if (relVal) {
var tmp = (relVal.val + delta);
relVal.val = (tmp > relVal.max ? relVal.max : (tmp < relVal.min ? relVal.min : tmp));
}
}
else {
phyVal.val = value;
}
}
else if (phyVal === block.absoluteAngle.pitch) {
relVal = block.angle.pitch;
}
else if (phyVal === block.absoluteAngle.roll) {
relVal = block.angle.roll;
}
else { }
if (relVal) {
var tmp = (relVal.val + delta);
relVal.val = (tmp > relVal.max ? relVal.max : (tmp < relVal.min ? relVal.min : tmp));
}
}
else {
phyVal.val = value;
}
}
}
......
......@@ -5,6 +5,11 @@ import QtCAN.CanTestBench 2.0;
ExpandableGroup {
id: base;
iconItem: SvgIconLoader {
icon: (expanded ? "filetypes/folder-opened" : "filetypes/folder-closed");
size: Style.iconSize (1);
color: Style.colorForeground;
}
uidLabel {
text: group.uid;
emphasis: true;
......
......@@ -3,15 +3,38 @@ import QtQmlTricks.UiElements 2.0;
import QtQmlTricks.SmartDataModels 2.0;
import QtCAN.CanTestBench 2.0;
MouseArea {
ExpandableGroup {
id: base;
height: implicitHeight;
hoverEnabled: true;
expandable: (dims.shouldBeVisible || !toggleShowOnlyEditable.checked);
iconItem: SvgIconLoader {
icon: "others/target";
size: Style.iconSize (1);
color: Style.colorForeground;
}
uidLabel {
text: marker.uid;
font.pixelSize: Style.fontSizeBig;
}
titleLabel {
text: marker.title;
font.pixelSize: Style.fontSizeBig;
}
ExtraAnchors.horizontalFill: parent;
property PhysicalMarker marker : null;
signal needVisible (Item item);
// TODO : add visual components
DimensionsList {
id: dims;
dimensionsList: [
marker.relativePos,
marker.absolutePos,
];
onNeedVisible: {
base.expanded = true;
base.needVisible (item);
}
onValueEdited: { }
}
}
......@@ -6,6 +6,7 @@ import QtCAN.CanTestBench 2.0;
MouseArea {
id: delegatePhyValTable;
height: implicitHeight;
visible: (current || editable || !toggleShowOnlyEditable.checked);
hoverEnabled: true;
implicitHeight: (layoutValPhyTable.height + layoutValPhyTable.anchors.margins * 2);
ExtraAnchors.horizontalFill: parent;
......
import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtQmlTricks.SmartDataModels 2.0;
import QtCAN.CanTestBench 2.0;
Repeater {
id: base;
model: physicalValuesTree;
delegate: ExpandableGroup {
id: delegateDimensionTable;
visible: (modelData ["highlightCount"] > 0 ||
modelData ["editableCount"] > 0 ||
!toggleShowOnlyEditable.checked);
uidLabel {
text: dimension.uid;
font.italic: true;
}
ExtraAnchors.horizontalFill: parent;
readonly property BasicObject dimension : modelData ["dimension"];
Repeater {
id: repeaterDimensionsPhyVal;
model: modelData ["phyValList"];
delegate: DelegatePhyValTable {
id: delegatePhyValTable
phyVal: modelData;
ExtraAnchors.horizontalFill: parent;
onNeedVisible: {
delegateDimensionTable.expanded = true;
base.needVisible (item);
}
onValueEdited: { base.valueEdited (delegateDimensionTable.dimension, modelData, value); }
}
}
}
property var dimensionsList : [];
readonly property var physicalValuesTree : {
var ret = [];
dimensionsList.forEach (function (dimension) {
var phyValList = [];
switch (dimension.family) {
case ObjectFamily.POSITION:
phyValList.push (dimension ["onLeftToRight"]);
phyValList.push (dimension ["onBackToFront"]);
phyValList.push (dimension ["onBottomToTop"]);
break;
case ObjectFamily.SIZE:
phyValList.push (dimension ["toLeft"]);
phyValList.push (dimension ["toRight"]);
phyValList.push (dimension ["toBack"]);
phyValList.push (dimension ["toFront"]);
phyValList.push (dimension ["toBottom"]);
phyValList.push (dimension ["toTop"]);
break;
case ObjectFamily.ANGLE:
phyValList.push (dimension ["yaw"]);
phyValList.push (dimension ["pitch"]);
phyValList.push (dimension ["roll"]);
break;
}
var editableCount = 0;
var highlightCount = 0;
phyValList.forEach (function (phyVal) {
if (phyVal.min !== phyVal.max) {
++editableCount;
}
if (phyVal === highlightPhyVal) {
++highlightCount;
}
});
ret.push ({
"dimension" : dimension,
"phyValList" : phyValList,
"editableCount" : editableCount,
"highlightCount" : highlightCount,
});
});
return ret;
}
readonly property int shouldBeVisible : {
var ret = false;
physicalValuesTree.forEach (function (entry) {
ret |= (entry ["editableCount"] > 0 ||
entry ["highlightCount"] > 0);
});
return ret;
}
signal needVisible (Item item);
signal valueEdited (BasicObject dimension, PhysicalValue phyVal, real value);
}
......@@ -7,8 +7,9 @@ Item {
id: base;
implicitHeight: (layoutMain.height + layoutMain.anchors.margins * 2);
property alias iconItem : icoLoader.component;
property alias expanded : layoutItems.visible;
property alias iconItem : icoLoader.component;
property alias expanded : layoutItems.visible;
property alias expandable : chevron.visible;
readonly property alias uidLabel : lblUid;
readonly property alias titleLabel : lblTitle;
......@@ -61,6 +62,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter;
}
SvgIconLoader {
id: chevron;
icon: (layoutItems.visible
? "actions/chevron-down"
: "actions/chevron-right");
......
......@@ -747,136 +747,140 @@ NetworkDefinition {
toBottom.val: 1;
}
}
PhysicalBlock {
id: blockWheelFR;
uid: "WHEEL_FR";
title: "Wheel Front Right";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: +3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: +12;
}
size {
toTop.val: 1.5;
toLeft.val: 0;
toRight.val: 0.5;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
}
}
PhysicalBlock {
id: blockWheelFL;
uid: "WHEEL_FL";
title: "Wheel Front Left";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: -3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: +12;
}
size {
toTop.val: 1.5;
toLeft.val: 0.5;
toRight.val: 0;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
}
}
PhysicalBlock {
id: blockWheelRL;
uid: "WHEEL_RL";
title: "Wheel Rear Left";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: -3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: -2;
}
size {
toTop.val: 1.5;
toLeft.val: 0.5;
toRight.val: 0;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
}
}
PhysicalBlock {
id: blockWheelRR;
uid: "WHEEL_RR";
title: "Wheel Rear Right";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: +3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: -2;
PhysicalGroup {
uid: "CHASSIS";
PhysicalBlock {
id: blockWheelFR;
uid: "WHEEL_FR";
title: "Wheel Front Right";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: +3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: +12;
}
size {
toTop.val: 1.5;
toLeft.val: 0;
toRight.val: 0.5;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
}
}
size {
toTop.val: 1.5;
toLeft.val: 0;
toRight.val: 0.5;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
PhysicalBlock {
id: blockWheelFL;
uid: "WHEEL_FL";
title: "Wheel Front Left";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: -3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: +12;
}
size {
toTop.val: 1.5;
toLeft.val: 0.5;
toRight.val: 0;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
}
}
}
PhysicalBlock {
id: blockBarFront;
uid: "BAR_FRONT";
title: "Wheel Bar Front";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: 0;
onBottomToTop.val: -1.5;
onBackToFront.val: +12;
PhysicalBlock {
id: blockWheelRL;
uid: "WHEEL_RL";
title: "Wheel Rear Left";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: -3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: -2;
}
size {
toTop.val: 1.5;
toLeft.val: 0.5;
toRight.val: 0;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
}
}
size {
toTop.val: 0.5;
toLeft.val: 3.5;
toRight.val: 3.5;
toBack.val: 0.5;
toFront.val: 0.5;
toBottom.val: 0.5;
PhysicalBlock {
id: blockWheelRR;
uid: "WHEEL_RR";
title: "Wheel Rear Right";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: +3.5;
onBottomToTop.val: -1.5;
onBackToFront.val: -2;
}
size {
toTop.val: 1.5;
toLeft.val: 0;
toRight.val: 0.5;
toBack.val: 1.5;
toFront.val: 1.5;
toBottom.val: 1.5;
}
}
}
PhysicalBlock {
id: blockBarRear;
uid: "BAR_REAR";
title: "Wheel Bar Rear";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: 0;
onBottomToTop.val: -1.5;
onBackToFront.val: -2;
PhysicalBlock {
id: blockBarFront;
uid: "BAR_FRONT";
title: "Wheel Bar Front";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: 0;
onBottomToTop.val: -1.5;
onBackToFront.val: +12;
}
size {
toTop.val: 0.5;
toLeft.val: 3.5;
toRight.val: 3.5;
toBack.val: 0.5;
toFront.val: 0.5;
toBottom.val: 0.5;
}
}
size {
toTop.val: 0.5;
toLeft.val: 3.5;
toRight.val: 3.5;
toBack.val: 0.5;
toFront.val: 0.5;
toBottom.val: 0.5;
PhysicalBlock {
id: blockBarRear;
uid: "BAR_REAR";
title: "Wheel Bar Rear";
color: "#3C3C3C";
referenceBlock: blockBase;
anchorSide: Sides.BOTTOM;
roundedAxis: Axis.LEFT_TO_RIGHT;
pivotPos {
onLeftToRight.val: 0;
onBottomToTop.val: -1.5;
onBackToFront.val: -2;
}
size {
toTop.val: 0.5;
toLeft.val: 3.5;
toRight.val: 3.5;
toBack.val: 0.5;
toFront.val: 0.5;
toBottom.val: 0.5;
}
}
}
PhysicalBlock {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment