Skip to content

Commit

Permalink
Merge pull request #592 from iVis-at-Bilkent/unstable
Browse files Browse the repository at this point in the history
Merge unstable to master
  • Loading branch information
hasanbalci authored May 20, 2020
2 parents ebb8d84 + 376e370 commit 2ae5159
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 69 deletions.
30 changes: 23 additions & 7 deletions app/js/app-cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
/*
Expand Down Expand Up @@ -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
Expand Down
50 changes: 46 additions & 4 deletions app/js/app-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
66 changes: 31 additions & 35 deletions app/js/app-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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({
Expand Down Expand Up @@ -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 {
Expand All @@ -2557,11 +2557,6 @@ appUtilities.launchWithModelFile = function() {
}
});

$(document).one("sbgnvizLoadFileEnd", function(){
currentGeneralProperties.inferNestingOnLoad = currentInferNestingOnLoad;
appUtilities.mapTabGeneralPanel.render();
});

}

function loadFromURI(uri, chiseInstance, promptInvalidURIWarning){
Expand All @@ -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({
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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');
};

};

Expand Down
22 changes: 11 additions & 11 deletions app/samples/drosophila_cell_cycle.nwt
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
<start x="763.375" y="177.75"/>
<end x="745.2678571428571" y="177.75"/>
</arc>
<arc id="nwtE_1fcb9fb6-ba5a-4ccf-bd50-155ce657fedb" class="stimulation" source="89360553-bab4-532a-c6c7-624272c4e43b" target="nwtN_78d6cd14-2e5f-463f-9a30-27ce3baea7d9.2">
<arc id="nwtE_1fcb9fb6-ba5a-4ccf-bd50-155ce657fedb" class="stimulation" source="89360553-bab4-532a-c6c7-624272c4e43b" target="nwtN_78d6cd14-2e5f-463f-9a30-27ce3baea7d9">
<start x="875.5645730534169" y="135.5"/>
<next x="847.542424765152" y="213.7471460409822"/>
<next x="738.497886764629" y="214.7270119241452"/>
Expand Down Expand Up @@ -617,13 +617,13 @@
<start x="799" y="240.43456223215844"/>
<end x="799" y="260.00000000000006"/>
</arc>
<arc id="nwtE_b9e23793-a56e-4277-b278-6724f6a4d68a" class="stimulation" source="c3a94e68-cca7-3c6a-f546-33c23dc59923" target="9615ba87-e042-ef50-d78e-1ef00df34a6e.2">
<arc id="nwtE_b9e23793-a56e-4277-b278-6724f6a4d68a" class="stimulation" source="c3a94e68-cca7-3c6a-f546-33c23dc59923" target="9615ba87-e042-ef50-d78e-1ef00df34a6e">
<start x="875.7289709255696" y="326.21254896064926"/>
<next x="847.8464449746845" y="246.47997705747048"/>
<next x="737.9834983175773" y="247.1334840883929"/>
<end x="737.9947312772593" y="270.3571432226932"/>
</arc>
<arc id="nwtE_a567dc9c-c17b-4e41-89ad-947bed2f4fd3" class="catalysis" source="7626c6b6-b0e0-b4b7-e5f3-f803fe319ef8" target="93e171d7-e846-2f4e-b4af-cafdabb596dd.1">
<arc id="nwtE_a567dc9c-c17b-4e41-89ad-947bed2f4fd3" class="catalysis" source="7626c6b6-b0e0-b4b7-e5f3-f803fe319ef8" target="93e171d7-e846-2f4e-b4af-cafdabb596dd">
<start x="767.8264939279273" y="298.2980111331645"/>
<next x="702.9999999999995" y="333.74999999999943"/>
<next x="702.5266691532668" y="347.96471699095457"/>
Expand Down Expand Up @@ -653,12 +653,12 @@
<start x="804.7678571428571" y="538.75"/>
<end x="826.75" y="538.75"/>
</arc>
<arc id="nwtE_bd3e280f-efff-4d5b-868c-d834b3d6cad4" class="catalysis" source="a2ee1683-eb5f-030d-3bbe-46c0a02cb659" target="nwtN_e742f544-55df-4fda-a7ee-65473425b2b5.2">
<arc id="nwtE_bd3e280f-efff-4d5b-868c-d834b3d6cad4" class="catalysis" source="a2ee1683-eb5f-030d-3bbe-46c0a02cb659" target="nwtN_e742f544-55df-4fda-a7ee-65473425b2b5">
<start x="763.9884892268863" y="165.05526681360047"/>
<next x="702.4738258670972" y="142.75082404149953"/>
<end x="701.2673108079107" y="125.63512177066829"/>
</arc>
<arc id="nwtE_a8832f81-1169-4768-87f4-390a771f7fff" class="catalysis" source="35a3e0be-6e00-7a99-fca5-18ed65c2fac1" target="f82eccc1-2bc9-bf87-08ab-1f26c4ad1e5d.2">
<arc id="nwtE_a8832f81-1169-4768-87f4-390a771f7fff" class="catalysis" source="35a3e0be-6e00-7a99-fca5-18ed65c2fac1" target="f82eccc1-2bc9-bf87-08ab-1f26c4ad1e5d">
<start x="631.5622781050293" y="520.625"/>
<next x="701.7355091200076" y="464.8703837231595"/>
<end x="701.9129310851106" y="442.6740073154425"/>
Expand All @@ -679,7 +679,7 @@
<start x="1045.767857142857" y="481.75000000000006"/>
<end x="1070.75" y="481.75000000000006"/>
</arc>
<arc id="nwtE_68ee44c6-86ba-499b-a798-db1c00254138" class="stimulation" source="c3a94e68-cca7-3c6a-f546-33c23dc59923" target="nwtN_7ffe3be6-9a33-4696-a593-d5c0a8a45a4c.1">
<arc id="nwtE_68ee44c6-86ba-499b-a798-db1c00254138" class="stimulation" source="c3a94e68-cca7-3c6a-f546-33c23dc59923" target="nwtN_7ffe3be6-9a33-4696-a593-d5c0a8a45a4c">
<start x="898.4175879396985" y="445.53125000000006"/>
<end x="898.8248449738131" y="470.8575468090057"/>
</arc>
Expand All @@ -699,7 +699,7 @@
<start x="1114.267857142857" y="547.75"/>
<end x="1139.25" y="547.75"/>
</arc>
<arc id="nwtE_80c9d1c6-bab7-478d-b509-e6fe7b24b152" class="stimulation" source="nwtN_5a3ef454-8d2b-46de-b3a1-f9a0c2409ee4" target="46137b33-99be-2b1f-5a29-f38f55849a0b.1">
<arc id="nwtE_80c9d1c6-bab7-478d-b509-e6fe7b24b152" class="stimulation" source="nwtN_5a3ef454-8d2b-46de-b3a1-f9a0c2409ee4" target="46137b33-99be-2b1f-5a29-f38f55849a0b">
<start x="968" y="499.87500000000006"/>
<end x="968" y="536.8571428571429"/>
</arc>
Expand Down Expand Up @@ -743,15 +743,15 @@
<start x="733.25" y="596.5178571428571"/>
<end x="733.25" y="617.5"/>
</arc>
<arc id="nwtE_9f593961-7d71-49ac-8c9b-eb8e899665e4" class="stimulation" source="89360553-bab4-532a-c6c7-624272c4e43b" target="a8404458-8ee5-6465-5d2e-4be53abad9f9.2">
<arc id="nwtE_9f593961-7d71-49ac-8c9b-eb8e899665e4" class="stimulation" source="89360553-bab4-532a-c6c7-624272c4e43b" target="a8404458-8ee5-6465-5d2e-4be53abad9f9">
<start x="895.8985379750443" y="21.375"/>
<next x="895.8646325311395" y="2.306492411467092"/>
<next x="334.62761909656433" y="3.77560221892449"/>
<next x="332.9955347233823" y="668.6351180438446"/>
<next x="676.6188645851402" y="671.4050967869174"/>
<end x="676.4563459796519" y="649.642770006905"/>
</arc>
<arc id="nwtE_6ae825c1-a694-4326-9f5e-36e516db36f0" class="catalysis" source="2f567801-fc2c-e128-f352-1dfab2f0dbce" target="nwtN_713def92-298d-4eb9-bf64-35bfc38a4646.1">
<arc id="nwtE_6ae825c1-a694-4326-9f5e-36e516db36f0" class="catalysis" source="2f567801-fc2c-e128-f352-1dfab2f0dbce" target="nwtN_713def92-298d-4eb9-bf64-35bfc38a4646">
<start x="609.0574244085002" y="656.875"/>
<next x="609.1897360308067" y="664.67577341941"/>
<next x="344.83677141584394" y="660.6017836771279"/>
Expand All @@ -767,7 +767,7 @@
<start x="425.2791845941241" y="387.46875000000006"/>
<end x="401.2204117739146" y="387.46875000000006"/>
</arc>
<arc id="nwtE_85d06a5e-fd70-4ff6-99d8-ae053b4d75ea" class="catalysis" source="191857cc-7088-9f59-19c8-ad00bcf44b5e" target="nwtN_f14bd3e1-7c6d-49b6-ab82-2f69e2246853.1">
<arc id="nwtE_85d06a5e-fd70-4ff6-99d8-ae053b4d75ea" class="catalysis" source="191857cc-7088-9f59-19c8-ad00bcf44b5e" target="nwtN_f14bd3e1-7c6d-49b6-ab82-2f69e2246853">
<start x="433.04704173698127" y="334.58583432907056"/>
<end x="433.04704173698127" y="376.5758928571429"/>
</arc>
Expand All @@ -788,7 +788,7 @@
<start x="985.9921112946669" y="352.6317742742051"/>
<end x="948.25" y="367.9163358754463"/>
</arc>
<arc id="nwtE_a4ec4de6-fc5e-40a6-ba15-4a0a7de659ed" class="catalysis" source="f0a6c8f2-8384-fb32-c934-e51c7aa67e25" target="nwtN_11b88917-a429-4c8c-9ada-61c11265afb5.1">
<arc id="nwtE_a4ec4de6-fc5e-40a6-ba15-4a0a7de659ed" class="catalysis" source="f0a6c8f2-8384-fb32-c934-e51c7aa67e25" target="nwtN_11b88917-a429-4c8c-9ada-61c11265afb5">
<start x="993.759968437524" y="315.7909429932749"/>
<end x="993.759968437524" y="338.5931394592224"/>
</arc>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ <h2 class="sbgn-text">About</h2>
<table width="100%" height="100%" align="center" valign="center">
<tbody>
<tr><td>
<p id="about-newt-version" class="sbgn-text">Newt Editor version 3.0</p>
<p id="about-newt-version" class="sbgn-text">Newt Editor version 3.0.1</p>
</td></tr>

<tr><td>
Expand Down
Loading

0 comments on commit 2ae5159

Please sign in to comment.