From ed02e53982d948c3faa44e8b29cf69477a4b0d68 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 8 Nov 2020 13:27:10 +0100 Subject: [PATCH] Layer Panels and Plygons --- .../ChartingSpaceFunctions.js | 67 +++++++--- Projects/Superalgos/Schemas/AppSchema.json | 116 ++++++++++++++---- 2 files changed, 141 insertions(+), 42 deletions(-) diff --git a/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js b/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js index ff39a5544..1912f11a8 100644 --- a/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js +++ b/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js @@ -64,6 +64,28 @@ function newChartingSpaceFunctions() { functionLibraryNodeDeleter.deleteUIObject(layer, rootNodes) } } + /* + For each of the layers we will not create the Layer Panels and Layer Polygons. + */ + allLayers = UI.projects.superalgos.utilities.branches.nodeBranchToArray(botLayers, 'Layer') + for (let j = 0; j < allLayers.length; j++) { + let layer = allLayers[j] + let menu = layer.payload.uiObject.menu + menu.internalClick('Add Missing Children') + + layer.layerPanels.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 + layer.layerPolygons.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 + + menu = layer.layerPanels.payload.uiObject.menu + menu.internalClick('Add All Layer Panels') + + menu = layer.layerPolygons.payload.uiObject.menu + menu.internalClick('Add All Layer Polygons') + + layer.layerPanels.payload.floatingObject.collapseToggle() + layer.layerPolygons.payload.floatingObject.collapseToggle() + layer.payload.floatingObject.collapseToggle() + } } } } @@ -285,7 +307,9 @@ function newChartingSpaceFunctions() { function addAllLayerPanels(node, functionLibraryUiObjectsFromNodes) { if (validateReferences(node) !== true) { return } - let plotterModule = node.payload.referenceParent.payload.referenceParent.payload.referenceParent + let layerNode = node.payload.parentNode + + let plotterModule = layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent for (let i = 0; i < plotterModule.panels.length; i++) { let plotterPanel = plotterModule.panels[i] let layerPanel = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Layer Panel') @@ -295,10 +319,12 @@ function newChartingSpaceFunctions() { function addAllLayerPolygons(node, functionLibraryUiObjectsFromNodes) { if (validateReferences(node) !== true) { return } - let plotterModule = node.payload.referenceParent.payload.referenceParent.payload.referenceParent + let layerNode = node.payload.parentNode + + let plotterModule = layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent if (plotterModule.shapes === undefined) { - node.payload.uiObject.setErrorMessage('Referenced Plotter Module does not have a Shapes child.') + node.payload.uiObject.setWarningMessage('Referenced Plotter Module does not have a Shapes child.') return } @@ -313,28 +339,39 @@ function newChartingSpaceFunctions() { /* Validations to see if we can do this or not. */ if (node.payload === undefined) { return } if (node.payload.uiObject === undefined) { return } - if (node.payload.referenceParent === undefined) { - node.payload.uiObject.setErrorMessage('You need to have a reference parent node to execute this action.') + + if (node.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('You need to have a Layer node as a parent to execute this action.') return } - if (node.payload.referenceParent.payload === undefined) { - node.payload.uiObject.setErrorMessage('You need to have a reference parent node to execute this action.') + if (node.payload.parentNode.payload === undefined) { + node.payload.uiObject.setErrorMessage('You need to have a Layer node as a parent to execute this action.') return } - if (node.payload.referenceParent.payload.referenceParent === undefined) { - node.payload.uiObject.setErrorMessage('You need to have a reference grand parent node to execute this action.') + let layerNode = node.payload.parentNode + + if (layerNode.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference parent node to execute this action.') return } - if (node.payload.referenceParent.payload.referenceParent.payload === undefined) { - node.payload.uiObject.setErrorMessage('You need to have a reference grand parent node to execute this action.') + if (layerNode.payload.referenceParent.payload === undefined) { + node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference parent node to execute this action.') return } - if (node.payload.referenceParent.payload.referenceParent.payload.referenceParent === undefined) { - node.payload.uiObject.setErrorMessage('You need to have a reference grand grand parent node to execute this action.') + if (layerNode.payload.referenceParent.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference grand parent node to execute this action.') return } - if (node.payload.referenceParent.payload.referenceParent.payload.referenceParent.payload === undefined) { - node.payload.uiObject.setErrorMessage('You need to have a reference grand grand parent node to execute this action.') + if (layerNode.payload.referenceParent.payload.referenceParent.payload === undefined) { + node.payload.uiObject.setErrorMessage('The Layer node needs to have a reference grand parent node to execute this action.') + return + } + if (layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('The Layer node to have a reference grand grand parent node to execute this action.') + return + } + if (layerNode.payload.referenceParent.payload.referenceParent.payload.referenceParent.payload === undefined) { + node.payload.uiObject.setErrorMessage('The Layer node to have a reference grand grand parent node to execute this action.') return } return true diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json index 155862e31..c8de9e9c7 100644 --- a/Projects/Superalgos/Schemas/AppSchema.json +++ b/Projects/Superalgos/Schemas/AppSchema.json @@ -14898,27 +14898,9 @@ "actionFunction": "uiObject.configEditor.activate" }, { - "action": "Add UI Object", - "label": "Add Layer Panel", - "relatedUiObject": "Layer Panel", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add UI Object", - "label": "Add Layer Polygon", - "relatedUiObject": "Layer Polygon", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add All Layer Panels", - "label": "Add All Layer Panels", - "relatedUiObject": "Layer Panel", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add All Layer Polygons", - "label": "Add All Layer Polygons", - "relatedUiObject": "Layer Polygon", + "action": "Add Missing Children", + "label": "Add Missing Children", + "relatedUiObject": "Layer", "actionFunction": "payload.executeAction" }, { @@ -14953,16 +14935,56 @@ "properties": [ { "name": "layerPanels", - "type": "array", - "childType": "Layer Panel" + "type": "node", + "childType": "Layer Panels" }, { "name": "layerPolygons", - "type": "array", - "childType": "Layer Polygon" + "type": "node", + "childType": "Layer Polygons" } ] }, + { + "type": "Layer Panels", + "menuItems": [ + { + "action": "Add UI Object", + "label": "Add Layer Panel", + "relatedUiObject": "Layer Panel", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add All Layer Panels", + "label": "Add All Layer Panels", + "relatedUiObject": "Layer Panel", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete", + "iconPathOff": "delete", + "actionFunction": "payload.executeAction" + } + ], + "addLeftIcons": true, + "level": 3, + "chainAttachesTo": { + "compatibleTypes": "->Layer->" + }, + "propertyNameAtParent": "layerPanels", + "properties": [ + { + "name": "layerPanels", + "type": "array", + "childType": "Layer Panel" + } + ], + "icon": "bitcoin" + }, { "type": "Layer Panel", "menuItems": [ @@ -14999,13 +15021,53 @@ "compatibleTypes": "->Plotter Panel->" }, "chainAttachesTo": { - "compatibleTypes": "->Layer->" + "compatibleTypes": "->Layer Panels->" }, "propertyNameAtParent": "layerPanels", "properties": [ ], "icon": "bitcoin" }, + { + "type": "Layer Polygons", + "menuItems": [ + { + "action": "Add UI Object", + "label": "Add Layer Polygon", + "relatedUiObject": "Layer Polygon", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add All Layer Polygons", + "label": "Add All Layer Polygons", + "relatedUiObject": "Layer Polygon", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete", + "iconPathOff": "delete", + "actionFunction": "payload.executeAction" + } + ], + "addLeftIcons": true, + "level": 3, + "chainAttachesTo": { + "compatibleTypes": "->Layer->" + }, + "propertyNameAtParent": "layerPolygons", + "properties": [ + { + "name": "layerPolygons", + "type": "array", + "childType": "Layer Polygon" + } + ], + "icon": "bitcoin" + }, { "type": "Layer Polygon", "menuItems": [ @@ -15042,7 +15104,7 @@ "compatibleTypes": "->Polygon->" }, "chainAttachesTo": { - "compatibleTypes": "->Layer->" + "compatibleTypes": "->Layer Polygons->" }, "propertyNameAtParent": "layerPolygons", "properties": [