diff --git a/ChartingSpace/TimeMachine.js b/ChartingSpace/TimeMachine.js index b9fa5471f..bcd25a4b2 100644 --- a/ChartingSpace/TimeMachine.js +++ b/ChartingSpace/TimeMachine.js @@ -142,6 +142,7 @@ function newTimeMachine() { function initialize(callBackFunction) { timeFrame = INITIAL_TIME_PERIOD loadFrame(thisObject.payload, thisObject.container.frame) + setInitialPosition() saveFrame(thisObject.payload, thisObject.container.frame) recalculateCoordinateSystem() @@ -158,6 +159,21 @@ function newTimeMachine() { callBackFunction() } + function setInitialPosition() { + let centerOfScreenX = browserCanvas.width / 2 - browserCanvas.width / TIME_MACHINE_WIDTH / 2 + let centerOfScreenY = browserCanvas.height / 2 - (browserCanvas.height - TOP_SPACE_HEIGHT - COCKPIT_SPACE_HEIGHT) / TIME_MACHINE_HEIGHT / 2 + + if (thisObject.container.frame.position.x === 0 && thisObject.container.frame.position.y === 0) { + let timeMachineIndex = findChildIndexAtParentNode(thisObject.payload.node) + let dashboardIndex = findChildIndexAtParentNode(thisObject.payload.parentNode) + let timeMachinesCount = thisObject.payload.parentNode.timeMachines.length + let dashboardsCount = thisObject.payload.parentNode.payload.parentNode.dashboards.length + + thisObject.container.frame.position.x = centerOfScreenX + thisObject.container.frame.width * timeMachineIndex * 2 - timeMachinesCount * thisObject.container.frame.width + thisObject.container.frame.position.y = centerOfScreenY + thisObject.container.frame.height * dashboardIndex * 2 - dashboardsCount * thisObject.container.frame.height + } + } + function onKeyPressed(event) { thisObject.edgeEditor.onKeyPressed(event) } diff --git a/DesignSpace/Workspace/FunctionLibraries/ChartingSpaceFunctions.js b/DesignSpace/Workspace/FunctionLibraries/ChartingSpaceFunctions.js index 453752151..f58d93b0c 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ChartingSpaceFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/ChartingSpaceFunctions.js @@ -112,7 +112,7 @@ function newChartingSpaceFunctions() { let mineProducts let timeMachine = functionLibraryUiObjectsFromNodes.addUIObject(dashboard, 'Time Machine') timeMachine.payload.referenceParent = session - timeMachine.name = session.name + ' ' + session.type + timeMachine.name = session.name + ' ' + session.type + ' ' + networkNode.name timeMachine.payload.floatingObject.collapseToggle() timeMachine.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 /* diff --git a/DesignSpace/Workspace/FunctionLibraries/CryptoEcosystemFunctions.js b/DesignSpace/Workspace/FunctionLibraries/CryptoEcosystemFunctions.js index c5c2f3743..579d3a0c9 100644 --- a/DesignSpace/Workspace/FunctionLibraries/CryptoEcosystemFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/CryptoEcosystemFunctions.js @@ -377,7 +377,7 @@ function newCryptoEcosystemFunctions() { for (let i = 0; i < timeMachines.length; i++) { let timeMachine = timeMachines[i] let session = timeMachine.payload.referenceParent - if (session === undefined) { + if (session === undefined || session.cleaned === true) { /* This is what usually happens, that the intall process make these time machines to lose their reference parent since the install diff --git a/Panels/Layer.js b/Panels/Layer.js index 191540e89..885280d3e 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -162,8 +162,9 @@ function newLayer() { 'Data Product->' + 'Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->Data Product Folder->' + 'Bot Products->Data Mine Products->Trading Mine Products->' + - 'Market Data Products->Single Market Trading Data->Exchange Data Products->' + - 'Session Reference->Data Mines Data->Trading Mines Data->Exchange Trading Products->Trading Mines Data->Data Storage->Network Node->' + + 'Market Data Products->Exchange Data Products->' + + 'Market Trading Products->Session Reference->Exchange Trading Products->' + + 'Data Mines Data->Trading Mines Data->Data Storage->Network Node->' + 'Data Storage->Network Node->' + 'Backtesting Session->Paper Trading Session->Forward Testing Session->Live Trading Session->' + 'Trading System Reference->Trading Engine Reference->Trading System->Trading Engine->' + diff --git a/Spaces/ChartingSpace.js b/Spaces/ChartingSpace.js index f42e0c77c..6fcc122c5 100644 --- a/Spaces/ChartingSpace.js +++ b/Spaces/ChartingSpace.js @@ -345,8 +345,6 @@ function newChartingSpace() { timeMachine.payload.uiObject.setValue('Loading...') /* Setting up the new time machine. */ - timeMachine.container.frame.position.x = browserCanvas.width / 2 - browserCanvas.width / TIME_MACHINE_WIDTH / 2 - timeMachine.container.frame.position.y = browserCanvas.height / 2 - (browserCanvas.height - TOP_SPACE_HEIGHT - COCKPIT_SPACE_HEIGHT) / TIME_MACHINE_HEIGHT / 2 timeMachine.initialize(onTimeMachineInitialized) function onTimeMachineInitialized() { diff --git a/Utilities/Meshes.js b/Utilities/Meshes.js index 44144bf95..834cb48e1 100644 --- a/Utilities/Meshes.js +++ b/Utilities/Meshes.js @@ -11,7 +11,9 @@ function findNodeInNodeMesh(node, nodeType, nodeName, connectedViaPayload, findI function scanNodeMesh(startingNode, depth) { if (startingNode === undefined) { return } - if (startingNode.payload === undefined) { return } + if (connectedViaPayload === true) { + if (startingNode.payload === undefined) { return } + } if (nodeFound !== undefined) { return } if (depth >= MAX_DEPTH) {return} diff --git a/Utilities/NodeChildren.js b/Utilities/NodeChildren.js index 43889d8df..5e59b2295 100644 --- a/Utilities/NodeChildren.js +++ b/Utilities/NodeChildren.js @@ -142,4 +142,46 @@ function findAndRecreateChildWithReference(startingNode, childType, referencedNo child = functionLibraryUiObjectsFromNodes.addUIObject(startingNode, childType) child.payload.referenceParent = referencedNode return child +} + +function findChildIndexAtParentNode(startingNode) { + /* + This functioin scan all the children of a node's parent and returns the child + index at the node property array that contains it. + */ + if (startingNode === undefined) { return } + if (startingNode.payload === undefined) { return } + if (startingNode.payload.parentNode === undefined) { return } + + let parentNode = startingNode.payload.parentNode + + let nodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + if (nodeDefinition === undefined) { return } + + /* We scan through this parent node children */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + /* We ignore these types of children. */ + } + break + case 'array': { + let startingNodePropertyArray = parentNode[property.name] + if (startingNodePropertyArray !== undefined) { + for (let m = 0; m < startingNodePropertyArray.length; m++) { + let arrayItem = startingNodePropertyArray[m] + + if (arrayItem.id === startingNode.id) { + return m + } + } + } + break + } + } + } + } } \ No newline at end of file