diff --git a/01_Code/.DS_Store b/01_Code/.DS_Store deleted file mode 100644 index 9e590ec8f16bcb601558a4c31c4dd79d41f2a26f..0000000000000000000000000000000000000000 Binary files a/01_Code/.DS_Store and /dev/null differ diff --git a/01_Code/physical_computing_interface/globals.js b/01_Code/physical_computing_interface/globals.js index 68b28baf0f3b6d44d7e651f014b8ec415b5deb1a..0c7caf66df228d006256fdc7b00199d1e85c8501 100644 --- a/01_Code/physical_computing_interface/globals.js +++ b/01_Code/physical_computing_interface/globals.js @@ -357,6 +357,22 @@ globals.prototype.selectNode=function (x,y,z){ }); document.dispatchEvent(selectNodeEvent); }; + +globals.prototype.selectEdge=function (){ + var selectEdgeEvent = new CustomEvent('selectEdge', { + detail: + { + // x:x, + // y:y, + // z:z, + // id:'[' +x +"," +y+","+z+']', + // posX:p_x, + // posY:p_y, + // posZ:p_z + } + }); + document.dispatchEvent(selectEdgeEvent); +}; ////////////////////////////////////////////// //////////////////////utils////////////////// diff --git a/01_Code/physical_computing_interface/graph/graph.js b/01_Code/physical_computing_interface/graph/graph.js index ba46d6a8abfee6ffbe5cda84d6e71a643257fcff..07efccc332dd104402193a4bdfd1f18af0b0fe0b 100644 --- a/01_Code/physical_computing_interface/graph/graph.js +++ b/01_Code/physical_computing_interface/graph/graph.js @@ -88,6 +88,8 @@ function initGraph(){ selector: ':selected', style: { "border-width": 3, + 'line-color': color4, + 'target-arrow-color': color4, "border-color": color4 } } @@ -165,7 +167,7 @@ function initGraph(){ ] }); - //expand and collapse + //expand and collapse and min cut and bottleneck cy.cxtmenu({ selector: 'core', menuRadius: 50, @@ -186,24 +188,55 @@ function initGraph(){ commands: [ { + //expand content: '<span class="fa fa-expand-arrows-alt fa-1.5x"></span>', select: function(){ + cy.edges().unselect();//unselect the rest api.expandAll(); } }, { + //min cut //TODO NOT WORKING/RELEVANT + content: '<span class="fa fa-cut fa-1.5x"></span>', + select: function(){ + var ee=cy.edges('[first<1]'); + // console.log(ee.length); + // console.log(cy.elements().length); + // console.log(cy.elements().difference(ee).length); + cy.edges().unselect();//unselect the rest + var ks = cy.elements().components()[0].kargerStein(); + ks.cut.select(); + console.log(ks); + } + + }, + { + //collapse content: '<span class="fa fa-compress-arrows-alt fa-1.5x"></span>', select: function(){ + cy.edges().unselect();//unselect the rest api.collapseAll(); } + + }, + { + //find bottleneck or max data flow + content: '<span class="fas fa-wine-bottle fa-1.5x"></span>', + select: function(){ + cy.edges().unselect();//unselect the rest + var max = cy.edges().max(function(ele){ + return ele._private.data.flow; + }); + max.ele.select(); + } + } ] }); ///////////////////////// - // addLayerNodes(GLOBALS.gridSize/2); - // addNeighborhood(); + /////////////////neighborhood groups///////////////// function addLayerNodes(n){ for(var i=0;i<n;i++){ cy.add({ @@ -262,7 +295,6 @@ function initGraph(){ } - function findNeighborhood(node){//when add new node var neigh=node.neighborhood(function( ele ){ return ele.isNode(); @@ -358,8 +390,8 @@ function initGraph(){ } } } - + ////////////////////////////////////////////////// //select node //TODO: HIGHLIGHT NODE IN THREEJS @@ -383,10 +415,13 @@ function initGraph(){ //select edge //TODO: FIX cy.on('tap', 'edge', function(){ - var nodes = this; + var edge = this; var pos=utils.getXYZfromName(this.data('id')); - GLOBALS.selectNode(); - GLOBALS.selectedjson=this._private.data; + // GLOBALS.selectNode(); + cy.edges().unselect();//unselect the rest + edge.select(); + GLOBALS.selectedjson=edge._private.data; + GLOBALS.selectEdge(); }); @@ -416,6 +451,8 @@ function initGraph(){ }); document.addEventListener('addNode', function (e) { + cy.edges().unselect();//unselect the rest + var neighborhood=0; cy.add({ @@ -482,14 +519,14 @@ function initGraph(){ tgt=cy.$id('[' +i1 +"," +j1+","+k1+']'); var valOut=tgt._private.data.data.state; tgt._private.data.data.neighbors.push('[' +x +"," +y+","+z+']'); - + cy.add([ { group: "edges",data: { name:valIn, source: '[' +x +"," +y+","+z+']', target: '[' +i1 +"," +j1+","+k1+']', - id:'[' +x +"," +y+","+z+']'+'to[' +i1 +"," +j1+","+k1+']'}} + id:'[' +x +"," +y+","+z+']'+'to[' +i1 +"," +j1+","+k1+']',flow:valIn,flowRate:20/valIn,first:0,weight:valIn}} ]); cy.add([ { group: "edges",data: { name:valOut, target: '[' +x +"," +y+","+z+']', source: '[' +i1 +"," +j1+","+k1+']', - id:'[' +i1 +"," +j1+","+k1+']'+'to[' +x +"," +y+","+z+']'}} + id:'[' +i1 +"," +j1+","+k1+']'+'to[' +x +"," +y+","+z+']',flow:valOut,flowRate:20/valOut,first:1,weight:valIn}} ]); } } diff --git a/01_Code/physical_computing_interface/json/json.js b/01_Code/physical_computing_interface/json/json.js index cb31dcd6c3e3a9306f8d013cf3f081a5ead7fbf1..ebc2aebdfe12e5f83b1bafee60fe7623bc99c195 100644 --- a/01_Code/physical_computing_interface/json/json.js +++ b/01_Code/physical_computing_interface/json/json.js @@ -29,6 +29,10 @@ function initEditor(){ editor.set(GLOBALS.selectedjson); }, false); + document.addEventListener('selectEdge', function (e) { + editor.set(GLOBALS.selectedjson); + }, false); + // get json //set info // document.getElementById('getJSON').onclick = function () { // var json = editor.get(); diff --git a/01_Code/physical_computing_interface/style.css b/01_Code/physical_computing_interface/style.css index 831151e55ed91b06f5d5abbe2399019cdedd3a05..062963debf668ebfb2a5e3f7f0c537f02f1ab6a4 100644 --- a/01_Code/physical_computing_interface/style.css +++ b/01_Code/physical_computing_interface/style.css @@ -170,8 +170,8 @@ body,html{width:100%;height:100%;padding:0;margin:0;} } #jsondiveditor { - width: 90%; - height: 80%; + width: 95%; + height: 90%; left: var(--top); top:var(--top); float: right;