diff --git a/Projects/Superalgos/Function-Libraries/ActionSwitch.js b/Projects/Superalgos/Function-Libraries/ActionSwitch.js index 3d822a641..2a29a46c3 100644 --- a/Projects/Superalgos/Function-Libraries/ActionSwitch.js +++ b/Projects/Superalgos/Function-Libraries/ActionSwitch.js @@ -467,6 +467,16 @@ function newSuperalgosActionSwitch() { functionLibraryMineFunctions.addAllDataMineDataDependencies(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes) } break + case 'Add All Layer Panels': + { + functionLibraryChartingSpaceFunctions.addAllLayerPanels(action.node, functionLibraryUiObjectsFromNodes) + } + break + case 'Add All Layer Polygons': + { + functionLibraryChartingSpaceFunctions.addAllLayerPolygons(action.node, functionLibraryUiObjectsFromNodes) + } + break case 'Add All Mine Layers': { functionLibraryChartingSpaceFunctions.addAllMineLayers(action.node, action.rootNodes, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) diff --git a/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js b/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js index 6698837e4..ff39a5544 100644 --- a/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js +++ b/Projects/Superalgos/Function-Libraries/ChartingSpaceFunctions.js @@ -1,5 +1,7 @@ function newChartingSpaceFunctions() { thisObject = { + addAllLayerPanels: addAllLayerPanels, + addAllLayerPolygons: addAllLayerPolygons, addAllMineLayers: addAllMineLayers, addMissingDashboards: addMissingDashboards, addMissingTimeMachines: addMissingTimeMachines, @@ -280,4 +282,62 @@ function newChartingSpaceFunctions() { } } } + + function addAllLayerPanels(node, functionLibraryUiObjectsFromNodes) { + if (validateReferences(node) !== true) { return } + let plotterModule = node.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') + layerPanel.payload.referenceParent = plotterPanel + } + } + + function addAllLayerPolygons(node, functionLibraryUiObjectsFromNodes) { + if (validateReferences(node) !== true) { return } + let plotterModule = node.payload.referenceParent.payload.referenceParent.payload.referenceParent + + if (plotterModule.shapes === undefined) { + node.payload.uiObject.setErrorMessage('Referenced Plotter Module does not have a Shapes child.') + return + } + + for (let i = 0; i < plotterModule.shapes.polygons.length; i++) { + let polygon = plotterModule.shapes.polygons[i] + let layerPolygon = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Layer Polygon') + layerPolygon.payload.referenceParent = polygon + } + } + + function validateReferences(node) { + /* 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.') + return + } + if (node.payload.referenceParent.payload === undefined) { + node.payload.uiObject.setErrorMessage('You need to have a reference parent node 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.') + 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.') + 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.') + 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.') + return + } + return true + } + } diff --git a/Projects/Superalgos/Schemas/AppSchema.json b/Projects/Superalgos/Schemas/AppSchema.json index 7df73edc5..155862e31 100644 --- a/Projects/Superalgos/Schemas/AppSchema.json +++ b/Projects/Superalgos/Schemas/AppSchema.json @@ -14984,6 +14984,9 @@ "actionFunction": "payload.executeAction" } ], + "title": [ + "Use Reference Parent" + ], "initialValues": { "config": "{ \n\"status\": \"on\"\n}" }, @@ -15024,6 +15027,9 @@ "actionFunction": "payload.executeAction" } ], + "title": [ + "Use Reference Parent" + ], "initialValues": { "config": "{ \n\"status\": \"on\"\n}" },