diff --git a/app/js/app-cy.js b/app/js/app-cy.js index a031e6fc4..e5c9b89d5 100644 --- a/app/js/app-cy.js +++ b/app/js/app-cy.js @@ -585,7 +585,7 @@ module.exports = function (chiseInstance) { result = true; }); - return !node.data()["expanding"] && result && !chiseInstance.elementUtilities.isResizedToContent(node) && (cy.zoom() > 0.5); + return !node.data("onLayout") && result && !chiseInstance.elementUtilities.isResizedToContent(node) && (cy.zoom() > 0.5); }, resizeToContentFunction: appUtilities.resizeNodesToContent, resizeToContentCuePosition: 'bottom-right', @@ -751,18 +751,28 @@ module.exports = function (chiseInstance) { }); cy.on("expandcollapse.beforeexpand",function(event){ - var node = event.target; - node.data("expanding", true); - + var currentGeneralProperties = appUtilities.getScratch(cy, 'currentGeneralProperties'); + if(currentGeneralProperties.recalculateLayoutOnComplexityManagement){ + var node = cy.nodes(":selected"); + if(node.length == 1 && event.target.selected()) + node[0].data("onLayout", true); + } + }); + + // To redraw expand/collapse cue after resize + cy.on("noderesize.resizeend", function (e, type, node) { + if(node.isParent() && node.selected()) + node.trigger("select"); }); + /* cy.on("expandcollapse.afterexpand",function(event){ var node = event.target; node.data("expanding", false); }); */ //Updates arrow-scale of edges after expand cy.on("expandcollapse.afterexpand", function(event) { - var currentArrowScale = Number($('#arrow-scale').val()); - cy.edges().style('arrow-scale', currentArrowScale); + var currentArrowScale = Number($('#arrow-scale').val()); + cy.edges().style('arrow-scale', currentArrowScale); }); //Changes arrow-scale of pasted edges @@ -1271,6 +1281,12 @@ module.exports = function (chiseInstance) { updateInfoBox(node); } }); */ + + cy.on("layoutstart",function(event){ + var node = cy.nodes(":selected").nodes(":parent"); + if(node.length == 1) + node[0].data("onLayout", true); + }); cy.on('layoutstop', function (event) { /* @@ -1298,7 +1314,7 @@ module.exports = function (chiseInstance) { chiseInstance.elementUtilities.fitUnits(ele, locations); //Force fit }); */ - cy.nodes().forEach(function(node){node.data("expanding", false); }); + cy.nodes("[?onLayout]").forEach(function(node){node.removeData("onLayout"); }); }); // if the position of compound changes by repositioning its children diff --git a/app/js/app-menu.js b/app/js/app-menu.js index 5f6525995..a461e7afe 100644 --- a/app/js/app-menu.js +++ b/app/js/app-menu.js @@ -97,7 +97,7 @@ module.exports = function() { topologyGrouping.clearAppliedFlag(); // unlock graph topology in case it is locked - chiseInstance.elementUtilities.unlockGraphTopology(); + chiseInstance.elementUtilities.unlockGraphTopology(); // if the event is triggered for the active instance do the followings if ( isActiveInstance ) { @@ -109,13 +109,47 @@ module.exports = function() { $('#inspector-map-tab a').tab('show'); } - if ( $('#inspector-console-tab')[0].style.display == "block") { - $('#inspector-console-tab')[0].style.display = "none"; - + if ($('#inspector-console-tab')[0].style.display == "block") { + $('#inspector-console-tab')[0].style.display = "none"; } + } + }); + + // Event triggered before file loaded by URL/URI + $(document).on('sbgnvizLoadFromURL sbgnvizLoadFromURI', function(event, filename, cy) { + var chiseInstance = appUtilities.getChiseInstance(cy); + + var urlParams = appUtilities.getScratch(cy, 'urlParams'); + + // get current general properties for cy + var currentGeneralProperties = appUtilities.getScratch(cy, 'currentGeneralProperties'); + + // inferNestingOnLoad and compoundPadding must be set before file loaded + if (urlParams) { + // filter map properties from the url parameters + var mapPropsFromUrl = appUtilities.filterMapProperties(urlParams); + + if("inferNestingOnLoad" in mapPropsFromUrl) { + currentGeneralProperties.inferNestingOnLoad = (mapPropsFromUrl.inferNestingOnLoad == 'true'); + } + else { + currentGeneralProperties.inferNestingOnLoad = false; + } + + if("compoundPadding" in mapPropsFromUrl){ + currentGeneralProperties.compoundPadding = Number(mapPropsFromUrl.compoundPadding); + chiseInstance.setCompoundPadding(Number(mapPropsFromUrl.compoundPadding)); + } + else { + currentGeneralProperties.compoundPadding = 0; + chiseInstance.setCompoundPadding(currentGeneralProperties.compoundPadding); + } } + // set 'currentGeneralProperties' on scratchpad of cy + appUtilities.setScratch(cy, 'currentGeneralProperties', currentGeneralProperties); + }); $(document).on('updateGraphEnd', function(event, cy) { @@ -565,6 +599,14 @@ module.exports = function() { // filter map properties from the url parameters var mapPropsFromUrl = appUtilities.filterMapProperties(urlParams); + + if(!("inferNestingOnLoad" in mapPropsFromUrl)) { + mapPropsFromUrl.inferNestingOnLoad = false; + } + + if(!("compoundPadding" in mapPropsFromUrl)){ + mapPropsFromUrl.compoundPadding = 0; + } // merge the map properties coming from url into // the map properties read from file diff --git a/app/js/app-utilities.js b/app/js/app-utilities.js index e846cfcac..d199c31ed 100644 --- a/app/js/app-utilities.js +++ b/app/js/app-utilities.js @@ -751,11 +751,10 @@ appUtilities.defaultGeneralProperties = { allowCompoundNodeResize: true, mapColorScheme: 'black_white', mapColorSchemeStyle: 'solid', - mapType: function() {return appUtilities.getActiveChiseInstance().getMapType() || "Unknown"}, + mapType: function() {return (appUtilities.getActiveChiseInstance().getMapType() || "Unknown");}, mapName: "", mapDescription: "", - enableSIFTopologyGrouping: false, - experimentDescription: "", + experimentDescription: "" }; appUtilities.setFileContent = function (fileName) { @@ -839,11 +838,11 @@ appUtilities.getExpandCollapseOptions = function (_cy) { var cy = _cy || self.getActiveCy(); if ( !self.getScratch(cy, 'currentGeneralProperties').recalculateLayoutOnComplexityManagement ) { - cy.trigger('fit-units-after-expandcollapse'); +// cy.trigger('fit-units-after-expandcollapse'); return; } self.triggerLayout(cy, false); - cy.trigger('fit-units-after-expandcollapse'); +// cy.trigger('fit-units-after-expandcollapse'); }, expandCollapseCueSize: 12, expandCollapseCuePosition: function (node) { @@ -2417,6 +2416,8 @@ appUtilities.setMapProperties = function(mapProperties, _chiseInstance) { chiseInstance.setShowComplexName(currentGeneralProperties.showComplexName); chiseInstance.refreshPaddings(); // Refresh/recalculate paddings + cy.edges().css('arrow-scale', currentGeneralProperties.arrowScale); + if (currentGeneralProperties.enablePorts) { chiseInstance.enablePorts(); } @@ -2439,9 +2440,6 @@ appUtilities.setMapProperties = function(mapProperties, _chiseInstance) { chiseInstance.omitCompoundSizes(); } - cy.edges().css('arrow-scale', currentGeneralProperties.arrowScale); - cy.style().update(); - // reset 'currentGeneralProperties' on scratchpad of cy appUtilities.setScratch(cy, 'currentGeneralProperties', currentGeneralProperties); @@ -2476,7 +2474,12 @@ appUtilities.launchWithModelFile = function() { // attach url params to the object to be used on sbgnvizLoadFileEnd event // it will be cleared immediately after usage - appUtilities.setScratch(cyInstance, 'urlParams', paramObj); + if(url_path || uri_path) { + appUtilities.setScratch(cyInstance, 'urlParams', paramObj); + } + else { + appUtilities.setScratch(cyInstance, 'urlParams', undefined); + } var promptInvalidURIWarning = this.promptInvalidURIWarning; var promptInvalidURLWarning = this.promptInvalidURLWarning; @@ -2489,9 +2492,6 @@ appUtilities.launchWithModelFile = function() { tutorial.introduction(true); function loadFromURL(filepath, chiseInstance, promptInvalidURLWarning){ - // get current general properties - var currentGeneralProperties = appUtilities.getScratch(cyInstance, 'currentGeneralProperties'); - var currentInferNestingOnLoad = currentGeneralProperties.inferNestingOnLoad; var loadCallbackSBGNMLValidity = function (text) { $.ajax({ @@ -2540,12 +2540,12 @@ appUtilities.launchWithModelFile = function() { success: function(data){ // here we can get 404 as well, for example, so there are still error cases to handle if (!data.error && data.response.statusCode == 200 && data.response.body) { + $(document).trigger('sbgnvizLoadFromURL', [filename, cyInstance]); var fileToLoad = new File([data.response.body], filename, { type: 'text/' + fileExtension, lastModified: Date.now() }); - currentGeneralProperties.inferNestingOnLoad = true; chiseInstance.loadNwtFile(fileToLoad, loadCallbackSBGNMLValidity, loadCallbackInvalidityWarning); } else { @@ -2557,11 +2557,6 @@ appUtilities.launchWithModelFile = function() { } }); - $(document).one("sbgnvizLoadFileEnd", function(){ - currentGeneralProperties.inferNestingOnLoad = currentInferNestingOnLoad; - appUtilities.mapTabGeneralPanel.render(); - }); - } function loadFromURI(uri, chiseInstance, promptInvalidURIWarning){ @@ -2574,8 +2569,6 @@ appUtilities.launchWithModelFile = function() { chiseInstance.startSpinner('paths-byURI-spinner'); - var currentGeneralProperties = appUtilities.getScratch(cyInstance, 'currentGeneralProperties'); - var currentInferNestingOnLoad = currentGeneralProperties.inferNestingOnLoad; var currentLayoutProperties = appUtilities.getScratch(cyInstance, 'currentLayoutProperties'); $.ajax({ @@ -2587,9 +2580,8 @@ appUtilities.launchWithModelFile = function() { if (data.response.statusCode == 200 && data.response.body) { var xml = $.parseXML(data.response.body); $(document).trigger('sbgnvizLoadFile', [filename, cyInstance]); - currentGeneralProperties.inferNestingOnLoad = false; + $(document).trigger('sbgnvizLoadFromURI', [filename, cyInstance]); chiseInstance.updateGraph(chiseInstance.convertSbgnmlToJson(xml), undefined, currentLayoutProperties); - currentGeneralProperties.inferNestingOnLoad = currentInferNestingOnLoad; chiseInstance.endSpinner('paths-byURI-spinner'); $(document).trigger('sbgnvizLoadFileEnd', [filename, cyInstance]); } @@ -3010,19 +3002,23 @@ appUtilities.resizeNodesToContent = function(nodes){ var chiseInstance = appUtilities.getActiveChiseInstance(); var cy = appUtilities.getActiveCy(); var collection; - if(nodes.length == 1){ - collection = cy.collection(); - collection = collection.add(nodes[0]); - }else{ - collection = nodes; - } - - if(!chiseInstance.areCompoundSizesConsidered()){ - collection = collection.difference(":parent,[class*='compartment'],[class*='submap']"); - } - chiseInstance.resizeNodesToContent(collection, false); - cy.nodeResize('get').refreshGrapples(); - cy.expandCollapse('get').clearVisualCue(); + if(nodes.length == 1){ + collection = cy.collection(); + collection = collection.add(nodes[0]); + }else{ + collection = nodes; + } + + if(!chiseInstance.areCompoundSizesConsidered()){ + collection = collection.difference(":parent,[class*='compartment'],[class*='submap']"); + } + chiseInstance.resizeNodesToContent(collection, false); + cy.nodeResize('get').refreshGrapples(); + cy.expandCollapse('get').clearVisualCue(); + // To redraw expand/collapse cue after resize to content + if(collection.length == 1 && (collection[0].isParent() || collection[0].data('collapsedChildren')) && collection[0].selected()) { + cy.$(':selected').trigger('select'); + }; }; diff --git a/app/samples/drosophila_cell_cycle.nwt b/app/samples/drosophila_cell_cycle.nwt index 59f1844eb..fecb8c87f 100644 --- a/app/samples/drosophila_cell_cycle.nwt +++ b/app/samples/drosophila_cell_cycle.nwt @@ -562,7 +562,7 @@ - + @@ -617,13 +617,13 @@ - + - + @@ -653,12 +653,12 @@ - + - + @@ -679,7 +679,7 @@ - + @@ -699,7 +699,7 @@ - + @@ -743,7 +743,7 @@ - + @@ -751,7 +751,7 @@ - + @@ -767,7 +767,7 @@ - + @@ -788,7 +788,7 @@ - + diff --git a/index.html b/index.html index b1a2658d9..005564b89 100644 --- a/index.html +++ b/index.html @@ -914,7 +914,7 @@

About

-

Newt Editor version 3.0

+

Newt Editor version 3.0.1

diff --git a/package.json b/package.json index 21a458ec4..5d836205f 100644 --- a/package.json +++ b/package.json @@ -23,20 +23,20 @@ "chise": "^3.0.0", "chroma-js": "^1.3.4", "cytoscape": "github:iVis-at-Bilkent/cytoscape.js#master", - "cytoscape-autopan-on-drag": "^2.2.0", - "cytoscape-clipboard": "^2.2.1", - "cytoscape-context-menus": "^3.0.7", - "cytoscape-edge-editing": "^2.0.0", + "cytoscape-autopan-on-drag": "2.2.1", + "cytoscape-clipboard": "2.2.1", + "cytoscape-context-menus": "3.1.0", + "cytoscape-edge-editing": "2.0.1", "cytoscape-edgehandles": "~2.13.1", - "cytoscape-expand-collapse": "^3.2.1", - "cytoscape-fcose": "^1.2.1", - "cytoscape-grid-guide": "^2.3.1", - "cytoscape-layout-utilities": "^1.0.1", + "cytoscape-expand-collapse": "4.0.0", + "cytoscape-fcose": "1.2.3", + "cytoscape-grid-guide": "2.3.2", + "cytoscape-layout-utilities": "1.0.2", "cytoscape-node-resize": "3.2.1", "cytoscape-panzoom": "~2.5.2", "cytoscape-popper": "^1.0.2", - "cytoscape-undo-redo": "^1.3.3", - "cytoscape-view-utilities": "^4.0.0", + "cytoscape-undo-redo": "1.3.3", + "cytoscape-view-utilities": "4.1.0", "file-saver": "^2.0.2", "intro.js": "2.9.3", "jquery": "~3.3.1", @@ -49,7 +49,7 @@ "multer": "^1.4.2", "natives": "^1.1.6", "request": "^2.81.0", - "sbgnviz": "^6.0.0", + "sbgnviz": "^6.0.1", "tippy.js": "^3.4.0", "nodemailer": "6.4.5" },