diff options
author | ASP1234 | 2016-06-21 19:59:59 +0000 |
---|---|---|
committer | ASP1234 | 2016-06-21 19:59:59 +0000 |
commit | 9049cfaecbc826f17751f9f86278066beee0db41 (patch) | |
tree | 261fb2fe5f8f3ba6b5e701feadbd176be73d5da2 | |
parent | 37b75115baf7927bdaa138c38426e89559bf4b8a (diff) | |
download | xcos-on-web-9049cfaecbc826f17751f9f86278066beee0db41.tar.gz xcos-on-web-9049cfaecbc826f17751f9f86278066beee0db41.tar.bz2 xcos-on-web-9049cfaecbc826f17751f9f86278066beee0db41.zip |
Minor Fix in EVTDLY_c
-rw-r--r-- | data_structures_correct/ANDLOG_f.js | 2 | ||||
-rw-r--r-- | data_structures_correct/EVTDLY_c.js | 4 | ||||
-rw-r--r-- | data_structures_correct/IFTHEL_f.js | 6 | ||||
-rw-r--r-- | details.js | 9 | ||||
-rw-r--r-- | index.html | 389 |
5 files changed, 286 insertions, 124 deletions
diff --git a/data_structures_correct/ANDLOG_f.js b/data_structures_correct/ANDLOG_f.js index 674a653..0fe3b2f 100644 --- a/data_structures_correct/ANDLOG_f.js +++ b/data_structures_correct/ANDLOG_f.js @@ -1,6 +1,6 @@ function ANDLOG_f() { - ANDLOG_f.prototype.internal = function() { + ANDLOG_f.prototype.internal = function ANDLOG_f() { var model = scicos_model(); model.sim = new ScilabString(["andlog"]); model.out = new ScilabDouble([1]); diff --git a/data_structures_correct/EVTDLY_c.js b/data_structures_correct/EVTDLY_c.js index 16e5101..46b336c 100644 --- a/data_structures_correct/EVTDLY_c.js +++ b/data_structures_correct/EVTDLY_c.js @@ -1,6 +1,6 @@ function EVTDLY_c() { - EVTDLY_c.prototype.internal = function() { + EVTDLY_c.prototype.internal = function EVTDLY_c() { var dt = 0.1; var ff = 0.0; var model = scicos_model(); @@ -21,7 +21,7 @@ function EVTDLY_c() { } - EVTDLY_c.prototype.define = function EVTDLY_C() { + EVTDLY_c.prototype.define = function EVTDLY_c() { this.dt = 0.1; this.ff = 0.0; var model = scicos_model(); diff --git a/data_structures_correct/IFTHEL_f.js b/data_structures_correct/IFTHEL_f.js index ff1a229..ebe8c6e 100644 --- a/data_structures_correct/IFTHEL_f.js +++ b/data_structures_correct/IFTHEL_f.js @@ -1,6 +1,6 @@ function IFTHEL_f() { - IFTHEL_f.prototype.internal = function() { + IFTHEL_f.prototype.internal = function IFTHEL_f() { var model = scicos_model(); model.sim = list(new ScilabString(["ifthel"]), new ScilabDouble([-1])); model.in = new ScilabDouble([1]); @@ -27,7 +27,7 @@ function IFTHEL_f() { return block; } - IFTHEL_f.prototype.define = function IFTHEL_F() { + IFTHEL_f.prototype.define = function IFTHEL_f() { var model = scicos_model(); model.sim = list(new ScilabString(["ifthel"]), new ScilabDouble([-1])); model.in = new ScilabDouble([1]); @@ -54,7 +54,7 @@ function IFTHEL_f() { return new BasicBlock(this.x); } - IFTHEL_f.prototype.details = function IFTHEL_F() { + IFTHEL_f.prototype.details = function IFTHEL_f() { return this.x; } } @@ -273,7 +273,10 @@ function ScilabDouble() { for (i = 0; i < this.height; i++) { for (j = 0; j < this.width; j++) { this["data" + i + j] = new data(); + if(array[i][j] % 1 == 0) this["data" + i + j].realPart = array[i][j].toFixed(1); + else + this["data" + i + j].realPart = array[i][j]; this["data" + i + j].line = i; this["data" + i + j].column = j; } @@ -327,7 +330,7 @@ function createInstanceTag() { function CLKIN_f() { - CLKIN_f.prototype.internal = function() { + CLKIN_f.prototype.internal = function CLKIN_f() { var model = scicos_model(); var port = 1; @@ -350,7 +353,7 @@ function CLKIN_f() { function CLKOUT_f() { - CLKOUT_f.prototype.internal = function() { + CLKOUT_f.prototype.internal = function CLKOUT_f() { var model = scicos_model(); var port = 1; @@ -373,7 +376,7 @@ function CLKOUT_f() { function CLKSPLIT_f() { - CLKSPLIT_f.prototype.internal = function() { + CLKSPLIT_f.prototype.internal = function CLKSPLIT_f() { var model = scicos_model(); model.sim = new ScilabString(["split"]); model.evtin = new ScilabDouble([-1]); @@ -255,6 +255,19 @@ var config = mxUtils.load('config/keyhandler-commons.xml').getDocumentElement(); editor.configure(config); + graph.isCellSelectable = function(cell) + { + if(cell.getStyle() == 'Split') { + return false; + } + return true; + }; + graph.resizeCell = function(cell, bounds, recurse) { + if(cell.getStyle() == 'Split') { + return null; + } + return mxGraph.prototype.resizeCell.apply(this, arguments); + } /* For a new edge on the graph, check if that edge satisfies one of the port constraints. @@ -268,6 +281,7 @@ edgeSource = edgeSource.source; } + /* // If the edge violates any port constraints, return null. if (!((edgeSource.getEdgeCount() == 0 && edgeSource.isVertex() && target.getEdgeCount() == 0 && target.isVertex()) || @@ -291,6 +305,116 @@ } return null; + */ + if(source.isEdge() == true) { + graph.getModel().beginUpdate(); + try + { + var edgeSource = source; + while (edgeSource.isEdge() == true) { + edgeSource = edgeSource.source; + } + var cell = graph.insertVertex(graph.getDefaultParent(), null, '', source.sourcePoint.x, source.sourcePoint.y, 10, 10,'Split', false); + if (edgeSource.value == 'ExplicitOutputPort') { + createPorts(graph, cell, ['EXPLICIT'], [], ['EXPLICIT'], ['EXPLICIT']); + cell.name = 'SPLIT_f'; + var someEdge = graph.insertEdge(parent, null, '', cell.getChildAt(1), source.target,'ExplicitLink;'); + graph.insertEdge(parent, null, '', cell.getChildAt(2), target,'ExplicitLink;'); + } + else if (edgeSource.value == 'ImplicitOutputPort') { + createPorts(graph, cell, ['IMPLICIT'], [], ['IMPLICIT', 'IMPLICIT'], []); + cell.name = 'SPLIT_f'; + var someEdge = graph.insertEdge(parent, null, '', cell.getChildAt(1), source.target,'ImplicitLink;'); + graph.insertEdge(parent, null, '', cell.getChildAt(2), target,'ImplicitLink;'); + } + else { + createPorts(graph, cell, ['CONTROL'], [], ['COMMAND', 'COMMAND'], []); + cell.name = 'SPLIT_f'; + var someEdge = graph.insertEdge(parent, null, '', cell.getChildAt(1), source.target,'CommandControlLink;'); + graph.insertEdge(parent, null, '', cell.getChildAt(2), target,'CommandControlLink;'); + } + cell.getChildAt(0).setVisible(false); + cell.getChildAt(1).setVisible(false); + cell.getChildAt(2).setVisible(false); + var waypoints = source.waypoints; + var sdsd = graph.view.getState(source); + var seg = mxUtils.findNearestSegment(sdsd, source.sourcePoint.x, source.sourcePoint.y); + //console.log(graph.view.getNextPoint(graph.view.getState(source), graph.view.getState(cell), false)); + graph.removeCells([source], true); + source = graph.insertEdge(parent, null, '', source.source, cell.getChildAt(0),'ExplicitLink;'); + //var seg = mxUtils.findNearestSegment(source, source.sourcePoint.x, source.sourcePoint.x); + //console.log(seg); + console.log(waypoints); + console.log(sdsd.absolutePoints); + console.log(seg); + if(waypoints != null) { + var waypoints1 = []; + for(var i = 0; i < seg; i++) { + waypoints1.push(waypoints[i]); + } + var waypoints2 = []; + for(var i = seg; i < waypoints.length; i++) { + waypoints2.push(waypoints[i]); + } + source.geometry.points = waypoints1; + someEdge.geometry.points = waypoints2; + } + cell.getChildAt(0).setConnectable(false); + cell.getChildAt(1).setConnectable(false); + cell.getChildAt(2).setConnectable(false); + cell.setConnectable(false); + graph.refresh(); + } + finally + { + graph.getModel().endUpdate(); + } + return null; + } + if(target.isEdge() == true) { + graph.getModel().beginUpdate(); + try + { + var edgeSource = target; + while (edgeSource.isEdge() == true) { + edgeSource = edgeSource.source; + } + var cell = graph.insertVertex(graph.getDefaultParent(), null, '', target.sourcePoint.x, target.sourcePoint.y, 5, 5,'Split', false); + if (edgeSource.value == 'ExplicitOutputPort') { + createPorts(graph, cell, ['EXPLICIT'], [], ['EXPLICIT'], ['EXPLICIT']); + cell.name = 'SPLIT_f'; + graph.insertEdge(parent, null, '', cell.getChildAt(1), target.target,'ExplicitLink;'); + graph.insertEdge(parent, null, '', cell.getChildAt(2), source,'ExplicitLink;'); + } + else if (edgeSource.value == 'ImplicitOutputPort') { + createPorts(graph, cell, ['IMPLICIT'], [], ['IMPLICIT', 'IMPLICIT'], []); + cell.name = 'SPLIT_f'; + graph.insertEdge(parent, null, '', cell.getChildAt(1), target.target,'ImplicitLink;'); + graph.insertEdge(parent, null, '', cell.getChildAt(2), source,'ImplicitLink;'); + } + else { + createPorts(graph, cell, ['CONTROL'], [], ['COMMAND', 'COMMAND'], []); + cell.name = 'SPLIT_f'; + graph.insertEdge(parent, null, '', cell.getChildAt(1), target.target,'CommandControlLink;'); + graph.insertEdge(parent, null, '', cell.getChildAt(2), source,'CommandControlLink;'); + } + cell.getChildAt(0).setVisible(false); + cell.getChildAt(1).setVisible(false); + cell.getChildAt(2).setVisible(false); + graph.getModel().setTerminal(target, cell.getChildAt(0), false); + cell.getChildAt(0).setConnectable(false); + cell.getChildAt(1).setConnectable(false); + cell.getChildAt(2).setConnectable(false); + cell.setConnectable(false); + graph.refresh(); + } + finally + { + graph.getModel().endUpdate(); + } + return null; + } + return mxGraph.prototype.addEdge.apply(this, arguments); } // Shows a "modal" window when double clicking a vertex. @@ -473,52 +597,74 @@ Used Preorder traversal for edges. */ editor.addAction('deleteBlock', function(editor, cell) { - var cells = []; - var selectionCells = graph.getSelectionCells(); - for (var k = 0; k < selectionCells.length; k++) { - var portCount = selectionCells[k].getChildCount(); - cells.push(selectionCells[k]); - // Finds all the port with edges of the selected cell, and calls getEdgeId() for - // each edge object of that port. - for (var i = 0; i < portCount; i++) { - var edgeCount = selectionCells[k].getChildAt(i).getEdgeCount(); - if (edgeCount != 0) { - getEdgeId(selectionCells[k].getChildAt(i)); - - for (var j = 0; j < edgeCount; j++) { - var edgeObject = selectionCells[k].getChildAt(i).getEdgeAt(j); - getEdgeId(edgeObject); - } + graph.getModel().beginUpdate(); + try { + function getEdgeId(edgeObject) { + var cellStack = []; + if(edgeObject != null && edgeObject.isEdge() == true) { + cellStack.push(edgeObject); + while(cellStack.length != 0) { + var tempEdgeObject = cellStack.pop(); + if (tempEdgeObject.edge == true && (cells.indexOf(tempEdgeObject) == -1)) { + cells.push(tempEdgeObject); + } + if(tempEdgeObject.source.parent.name == "SPLIT_f") { + //console.log(tempEdgeObject.source.parent.getChildAt(1).getEdgeAt(0)); + //console.log(sdsd); + if(tempEdgeObject.source == tempEdgeObject.source.parent.getChildAt(1)) { + console.log('sdsd'); + var sourceEdge = tempEdgeObject.source.parent.getChildAt(0).getEdgeAt(0); + var target = tempEdgeObject.source.parent.getChildAt(2).getEdgeAt(0).target; + graph.getModel().setTerminal(sourceEdge, target, false); + cells.push(tempEdgeObject.source.parent); + } + else { + console.log() + //var points = graph.view.getState(tempEdgeObject.source.parent.getChildAt(1).getEdgeAt(0)).absolutePoints; + var sourceEdge = tempEdgeObject.source.parent.getChildAt(0).getEdgeAt(0); + var target = tempEdgeObject.source.parent.getChildAt(1).getEdgeAt(0).target; + graph.getModel().setTerminal(sourceEdge, target, false); + cells.push(tempEdgeObject.source.parent); } } + if(tempEdgeObject.target.parent.name == "SPLIT_f") { + if(cells.indexOf(tempEdgeObject.target.parent) == -1) { + cells.push(tempEdgeObject.target.parent); + } + cellStack.push(tempEdgeObject.target.parent.getChildAt(1).getEdgeAt(0)); + cellStack.push(tempEdgeObject.target.parent.getChildAt(2).getEdgeAt(0)); + } + } } - - - /* getEdgeId() find all the associated edges from an edge. - Pushes the object of that edge into an array of mxCell objects. - */ - function getEdgeId(edgeObject) { - var cellStack = []; - if (edgeObject != null && edgeObject.isEdge() == true) { - cellStack.push(edgeObject); - while (cellStack.length != 0) { - var tempEdgeObject = cellStack.pop(); - if (tempEdgeObject.edge == true && (cells.indexOf(tempEdgeObject) == -1)) { - cells.push(tempEdgeObject); - } - for (var j = 0; j < tempEdgeObject.getEdgeCount(); j++) { - cellStack.push(tempEdgeObject.getEdgeAt(j)); - } - } + } + var cells = []; + var selectionCells = graph.getSelectionCells(); + for (var k = 0; k < selectionCells.length; k++) { + if(selectionCells[k].isEdge() == true) { + getEdgeId(selectionCells[k]); } + else { + var portCount = selectionCells[k].getChildCount(); + cells.push(selectionCells[k]); + for (var i = 0; i < portCount; i++) { + var edgeCount = selectionCells[k].getChildAt(i).getEdgeCount(); + if (edgeCount != 0) { + for (var j = 0; j < edgeCount; j++) { + var edgeObject = selectionCells[k].getChildAt(i).getEdgeAt(j); + getEdgeId(edgeObject); + } + } + } + } } - - // The mxCells to be deleted are first highlighted, - // and then the selection is deleted in a single go. - graph.getSelectionModel().setCells(cells); - editor.execute('delete'); + //graph.getSelectionModel().setCells(cells); + //editor.execute('delete'); + graph.removeCells(cells, true); + } + finally { + graph.getModel().endUpdate(); + } }); - addToolbarButton(editor, toolbar, 'toggle', 'Expand All', 'images/navigate_plus.png'); toolbar.appendChild(spacer.cloneNode(true)); @@ -528,7 +674,7 @@ toolbar.appendChild(spacer.cloneNode(true)); - addToolbarButton(editor, toolbar, 'delete', '', 'images/delete2.png'); + addToolbarButton(editor, toolbar, 'deleteBlock', '', 'images/delete2.png'); addToolbarButton(editor, toolbar, 'undo', '', 'images/undo.png'); addToolbarButton(editor, toolbar, 'redo', '', 'images/redo.png'); toolbar.appendChild(spacer.cloneNode(true)); @@ -576,7 +722,7 @@ var enc = new mxCodec(mxUtils.createXmlDocument()); /*var array=[],key; for (key in diagRoot.model.cells) { - + if(diagRoot.model.cells[key].connectable == false) { array.push(diagRoot.model.cells[key].inst); @@ -590,7 +736,7 @@ textarea.value = str; /*var j = 0; for (key in diagRoot.model.cells) { - + if(diagRoot.model.cells[key].connectable == false) { diagRoot.model.cells[key].inst=array[j++]; @@ -2009,92 +2155,105 @@ Implements a perpendicular wires connection edge style --> <script type="text/javascript"> - mxEdgeStyle.WireConnector = function(state, source, target, hints, result) { - // Creates array of all way- and terminalpoints - var pts = state.absolutePoints; - var horizontal = true; - var hint = null; - - // Gets the initial connection from the source terminal or edge - if (source != null && state.view.graph.model.isEdge(source.cell)) { - horizontal = state.style['sourceConstraint'] == 'horizontal'; - } else if (source != null) { - horizontal = source.style['portConstraint'] != 'vertical'; - - // Checks the direction of the shape and rotates - var direction = source.style[mxConstants.STYLE_DIRECTION]; - - if (direction == 'north' || direction == 'south') { - horizontal = !horizontal; - } + mxEdgeStyle.WireConnector = function(state, source, target, hints, result) { + state.cell.waypoints = state.cell.geometry.points; + // Creates array of all way- and terminalpoints + var pts = state.absolutePoints; + var horizontal = true; + var hint = null; + // Gets the initial connection from the source terminal or edge + if (source != null && state.view.graph.model.isEdge(source.cell)) { + horizontal = state.style['sourceConstraint'] == 'horizontal'; + } + // If the source terminal is a Split Block, set the horizontal false + else if(source != null && source.cell.name == 'SPLIT_f') { + if(state.cell.source != null) { + // If the port is the third child of splitBlock, only then set the horizontal as false + if(state.cell.source == state.cell.source.parent.getChildAt(2)) { + horizontal = state.style['sourceConstraint'] == 'horizontal'; } - - // Adds the first point - var pt = pts[0]; - - if (pt == null && source != null) { - pt = new mxPoint(state.view.getRoutingCenterX(source), state.view.getRoutingCenterY(source)); - } else if (pt != null) { - pt = pt.clone(); + } + } + else if (source != null) { + horizontal = source.style['portConstraint'] != 'vertical'; + // Checks the direction of the shape and rotates + var direction = source.style[mxConstants.STYLE_DIRECTION]; + if (direction == 'north' || direction == 'south') { + horizontal = !horizontal; } - - var first = pt; - - // Adds the waypoints - if (hints != null && hints.length > 0) { - for (var i = 0; i < hints.length; i++) { - horizontal = !horizontal; - hint = state.view.transformControlPoint(state, hints[i]); - - if (horizontal) { - if (pt.y != hint.y) { - pt.y = hint.y; - result.push(pt.clone()); - } - } else if (pt.x != hint.x) { - pt.x = hint.x; + } + // Adds the first point + var pt = pts[0]; + /* @jiteshjha splitBlock + */ + if(state.cell.getGeometry().getTerminalPoint(true) != null) { + source.cell['sourcePoint'] = state.cell.getGeometry().getTerminalPoint(true); + } + /*if(target.cell != null) { + target.cell['targetPoint'] = pt; + }*/ + if (pt == null && source != null) { + pt = new mxPoint(state.view.getRoutingCenterX(source), state.view.getRoutingCenterY(source)); + } else if (pt != null) { + pt = pt.clone(); + } + var first = pt; + if(state.cell.getGeometry().getTerminalPoint(false) != null) { + target.cell['sourcePoint'] = state.cell.getGeometry().getTerminalPoint(false); + } + // Adds the waypoints + if (hints != null && hints.length > 0) { + for (var i = 0; i < hints.length; i++) { + horizontal = !horizontal; + hint = state.view.transformControlPoint(state, hints[i]); + if (horizontal) { + if (pt.y != hint.y) { + pt.y = hint.y; result.push(pt.clone()); } + } else if (pt.x != hint.x) { + pt.x = hint.x; + result.push(pt.clone()); } - } else { - hint = pt; } - - // Adds the last point - pt = pts[pts.length - 1]; - - if (pt == null && target != null) { - pt = new mxPoint(state.view.getRoutingCenterX(target), state.view.getRoutingCenterY(target)); - } - - if (horizontal) { - if (pt.y != hint.y && first.x != pt.x) { - result.push(new mxPoint(pt.x, hint.y)); - } - } else if (pt.x != hint.x && first.y != pt.y) { - result.push(new mxPoint(hint.x, pt.y)); + } else { + hint = pt; + } + // Adds the last point + pt = pts[pts.length - 1]; + if (pt == null && target != null) { + pt = new mxPoint(state.view.getRoutingCenterX(target), state.view.getRoutingCenterY(target)); + } + if (horizontal) { + if (pt.y != hint.y && first.x != pt.x) { + result.push(new mxPoint(pt.x, hint.y)); } + } else if (pt.x != hint.x && first.y != pt.y) { + result.push(new mxPoint(hint.x, pt.y)); + } + // If the target of the edge is a splitBlock, push final coordinate as vertical. + if(state.cell.target != null) { + if(state.cell.target.parent.name == "SPLIT_f") { + result.pop(); + result.push(new mxPoint(hint.x, pt.y)); + } + } }; - mxStyleRegistry.putValue('wireEdgeStyle', mxEdgeStyle.WireConnector); - // This connector needs an mxEdgeSegmentHandler mxGraphCreateHandler = mxGraph.prototype.createHandler; mxGraph.prototype.createHandler = function(state) { - var result = null; - - if (state != null) { - if (this.model.isEdge(state.cell)) { - var style = this.view.getEdgeStyle(state); - - if (style == mxEdgeStyle.WireConnector) { - return new mxEdgeSegmentHandler(state); - } + var result = null; + if (state != null) { + if (this.model.isEdge(state.cell)) { + var style = this.view.getEdgeStyle(state); + if (style == mxEdgeStyle.WireConnector) { + return new mxEdgeSegmentHandler(state); } } - - return mxGraphCreateHandler.apply(this, arguments); - }; + } + return mxGraphCreateHandler.apply(this, arguments); + }; </script> </head> |