From 9049cfaecbc826f17751f9f86278066beee0db41 Mon Sep 17 00:00:00 2001 From: ASP1234 Date: Tue, 21 Jun 2016 19:59:59 +0000 Subject: Minor Fix in EVTDLY_c --- data_structures_correct/ANDLOG_f.js | 2 +- data_structures_correct/EVTDLY_c.js | 4 +- data_structures_correct/IFTHEL_f.js | 6 +- details.js | 9 +- 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; } } diff --git a/details.js b/details.js index 47a7d4c..1ee4f00 100644 --- a/details.js +++ b/details.js @@ -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]); diff --git a/index.html b/index.html index 7cc3436..be41782 100644 --- a/index.html +++ b/index.html @@ -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 --> -- cgit