Plotting Modules
This commit is contained in:
1 parent
31d10d09e0
commit
1ed6a48488
10 files changed
+258
-6
No files matched your search
@@ -199,6 +199,7 @@ function newPlottersManager () {
|
||||
connector.panels = []
|
||||
|
||||
if (product !== undefined) {
|
||||
/* Here we setup the panels associated with this plotter */
|
||||
for (let i = 0; i < plotterModule.panels.length; i++) {
|
||||
let panel = plotterModule.panels[i]
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ function newUiObject () {
|
||||
formulaEditor: undefined,
|
||||
uiObjectTitle: undefined,
|
||||
circularProgressBar: undefined,
|
||||
isExecuting: undefined,
|
||||
isRunningAtBackend: undefined,
|
||||
isRunning: undefined,
|
||||
shortcutKey: undefined,
|
||||
isShowing: undefined,
|
||||
@@ -35,8 +35,11 @@ function newUiObject () {
|
||||
setErrorMessage: setErrorMessage,
|
||||
resetErrorMessage: resetErrorMessage,
|
||||
setValue: setValue,
|
||||
resetValue: resetValue,
|
||||
setPercentage: setPercentage,
|
||||
resetPercentage: resetPercentage,
|
||||
setStatus: setStatus,
|
||||
resetStatus: resetStatus,
|
||||
physics: physics,
|
||||
invisiblePhysics: invisiblePhysics,
|
||||
drawBackground: drawBackground,
|
||||
@@ -1817,7 +1820,7 @@ function newUiObject () {
|
||||
if (icon !== undefined) {
|
||||
if (icon.canDrawIcon === true) {
|
||||
let additionalImageSize = 0
|
||||
if (thisObject.isExecuting === true || isReadyToReferenceAttach === true || isReadyToChainAttach === true) { additionalImageSize = 20 }
|
||||
if (thisObject.isRunningAtBackend === true || isReadyToReferenceAttach === true || isReadyToChainAttach === true) { additionalImageSize = 20 }
|
||||
let totalImageSize = additionalImageSize + thisObject.payload.floatingObject.currentImageSize
|
||||
if (canvas.floatingSpace.inMapMode === true) {
|
||||
totalImageSize = canvas.floatingSpace.transformImagesizeToMap(totalImageSize)
|
||||
@@ -1843,7 +1846,7 @@ function newUiObject () {
|
||||
|
||||
if (executingIcon !== undefined) {
|
||||
if (executingIcon.canDrawIcon === true) {
|
||||
if (thisObject.isExecuting === true) {
|
||||
if (thisObject.isRunningAtBackend === true) {
|
||||
const DISTANCE_FROM_CENTER = thisObject.container.frame.radius / 3 + 50
|
||||
const EXECUTING_ICON_SIZE = 20 + thisObject.container.frame.radius / 6
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
function newNodesErrors () {
|
||||
const MODULE_NAME = 'Nodes Errors'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
onRecordChange: onRecordChange,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let rootNode
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
rootNode = undefined
|
||||
}
|
||||
|
||||
function initialize (pRootNode) {
|
||||
rootNode = pRootNode
|
||||
}
|
||||
|
||||
function onRecordChange (currentRecord) {
|
||||
evalNode(rootNode, currentRecord.array, 0, applyError)
|
||||
}
|
||||
|
||||
function applyError (node, errorMessage) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.uiObject === undefined) { return }
|
||||
if (errorMessage === '') {
|
||||
node.payload.uiObject.resetErrorMessage(errorMessage)
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage(errorMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
function newNodesHighlights () {
|
||||
const MODULE_NAME = 'Nodes Highlights'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
onRecordChange: onRecordChange,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let rootNode
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
rootNode = undefined
|
||||
}
|
||||
|
||||
function initialize (pRootNode) {
|
||||
rootNode = pRootNode
|
||||
}
|
||||
|
||||
function onRecordChange (currentRecord) {
|
||||
evalNode(rootNode, currentRecord.array, 0, applyHighlight)
|
||||
}
|
||||
|
||||
function applyHighlight (node, value) {
|
||||
if (value !== 1) { return }
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.uiObject === undefined) { return }
|
||||
node.payload.uiObject.highlight()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
function newNodesProgress () {
|
||||
const MODULE_NAME = 'Nodes Progress'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
onRecordChange: onRecordChange,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let rootNode
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
rootNode = undefined
|
||||
}
|
||||
|
||||
function initialize (pRootNode) {
|
||||
rootNode = pRootNode
|
||||
}
|
||||
|
||||
function onRecordChange (currentRecord) {
|
||||
evalNode(rootNode, currentRecord.array, 0, applyProgress)
|
||||
}
|
||||
|
||||
function applyProgress (node, value) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.uiObject === undefined) { return }
|
||||
node.payload.uiObject.setPercentage(node, value)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
function newNodesRunning () {
|
||||
const MODULE_NAME = 'Nodes Running'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
onRecordChange: onRecordChange,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let rootNode
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
rootNode = undefined
|
||||
}
|
||||
|
||||
function initialize (pRootNode) {
|
||||
rootNode = pRootNode
|
||||
}
|
||||
|
||||
function onRecordChange (currentRecord) {
|
||||
evalNode(rootNode, currentRecord.array, 0, applyExecution)
|
||||
}
|
||||
|
||||
function applyExecution (node, value) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.uiObject === undefined) { return }
|
||||
if (value === 1) {
|
||||
node.payload.uiObject.isRunningAtBackend = true
|
||||
} else {
|
||||
node.payload.uiObject.isRunningAtBackend = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
function newNodesStatus () {
|
||||
const MODULE_NAME = 'Nodes Status'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
onRecordChange: onRecordChange,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let rootNode
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
rootNode = undefined
|
||||
}
|
||||
|
||||
function initialize (pRootNode) {
|
||||
rootNode = pRootNode
|
||||
}
|
||||
|
||||
function onRecordChange (currentRecord) {
|
||||
evalNode(rootNode, currentRecord.array, 0, applyStatus)
|
||||
}
|
||||
|
||||
function applyStatus (node, status) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.uiObject === undefined) { return }
|
||||
node.payload.uiObject.setStatus(node, status)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
function newNodesValues () {
|
||||
const MODULE_NAME = 'Nodes Values'
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
let thisObject = {
|
||||
onRecordChange: onRecordChange,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let rootNode
|
||||
return thisObject
|
||||
|
||||
function finalize () {
|
||||
rootNode = undefined
|
||||
}
|
||||
|
||||
function initialize (pRootNode) {
|
||||
rootNode = pRootNode
|
||||
}
|
||||
|
||||
function onRecordChange (currentRecord) {
|
||||
evalNode(rootNode, currentRecord.array, 0, applyValue)
|
||||
}
|
||||
|
||||
function applyValue (node, value) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.uiObject === undefined) { return }
|
||||
node.payload.uiObject.setValue(value)
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,9 @@ function newPlotter () {
|
||||
function draw () {
|
||||
try {
|
||||
thisObject.container.frame.draw()
|
||||
plotChart()
|
||||
if (productDefinition.referenceParent.shapes !== undefined) {
|
||||
plotShapes()
|
||||
}
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err = ' + err.stack) }
|
||||
}
|
||||
@@ -489,7 +491,7 @@ function newPlotter () {
|
||||
}
|
||||
}
|
||||
|
||||
function plotChart () {
|
||||
function plotShapes () {
|
||||
try {
|
||||
/* Clean the pannel at places where there is no record. */
|
||||
let currentRecord = {
|
||||
@@ -792,7 +794,7 @@ function newPlotter () {
|
||||
|
||||
logged = false
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotChart -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] plotShapes -> err = ' + err.stack) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
This function scans a node hiriatchy recursively. At each node it calls the callback
|
||||
provided with the corresponfing value of the array.
|
||||
*/
|
||||
|
||||
function evalNode (node, array, index, callback) {
|
||||
if (node === undefined) { return }
|
||||
if (array === undefined) { return }
|
||||
if (index === undefined) { return }
|
||||
if (callback === undefined) { return }
|
||||
|
||||
callback(node, array[index])
|
||||
|
||||
/* Now we go down through all this node children */
|
||||
let nodeDefinition = APP_SCHEMA_MAP.get(node.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children.
|
||||
for (let i = 0; i < nodeDefinition.properties.length; i++) {
|
||||
let property = nodeDefinition.properties[i]
|
||||
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
evalNode(node[property.name], array, index + 1, callback)
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'array': {
|
||||
if (node[property.name] !== undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
evalNode(nodePropertyArray[m], array, index + 1, callback)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user