Commit 2b9a0222 authored by Jean-Clement Gallardo's avatar Jean-Clement Gallardo
Browse files

fix some bugs :

1- fix invisible button bug under firefox
2- block extract & quit if 0 node is visited
3- fix starting node style if start with 2 or more nodes
4- block load new score file uf GIR is used
parent 09bad00b
......@@ -39,6 +39,7 @@ Ext.define('metExploreViz.view.form.girForm.GirFormController', {
if (metExploreD3.GraphRank.launchGIR === false) {
view.lookupReference('launchGIR').setText("quit GIR");
view.lookupReference('extractNQuit').enable();
view.lookupReference('loadRankFile').disable();
var listMi = []
var nbMi = view.lookupReference('miBox').items.items.length;
for (var i = 1; i < nbMi+1; i++){
......@@ -52,6 +53,7 @@ Ext.define('metExploreViz.view.form.girForm.GirFormController', {
else {
view.lookupReference('launchGIR').setText("launch GIR");
view.lookupReference('extractNQuit').disable();
view.lookupReference('loadRankFile').enable();
metExploreD3.GraphRank.launchGIR = false;
metExploreD3.GraphRank.quitGir();
......@@ -68,12 +70,14 @@ Ext.define('metExploreViz.view.form.girForm.GirFormController', {
view.lookupReference('extractNQuit').on({
click: function() {
metExploreD3.GraphRank.quitAndExtract();
var extract = metExploreD3.GraphRank.quitAndExtract();
view.lookupReference('launchGIR').setText("launch GIR");
view.lookupReference('extractNQuit').disable();
if (extract){
view.lookupReference('launchGIR').setText("launch GIR");
view.lookupReference('extractNQuit').disable();
metExploreD3.GraphRank.launchGIR = false;
metExploreD3.GraphRank.launchGIR = false;
}
}
});
......
......@@ -15,7 +15,6 @@ metExploreD3.GraphRank = {
/**
* @property {Boolean} [launchGIR=false]
* @property {Boolean} [metaboRankMode=false]
* @property {String} [girMode="classic"]
*/
launchGIR: false,
metaboRankMode: false,
......@@ -45,6 +44,7 @@ metExploreD3.GraphRank = {
nodes.each(function(node){
if (listMiCmpt.includes(node.dbIdentifier)){
metExploreD3.GraphRank.startNode(node);
node.markAsStarter();
}
if (!(listMiCmpt.includes(node.dbIdentifier))) {
node.hide()
......@@ -109,6 +109,9 @@ metExploreD3.GraphRank = {
node.setLocked(false);
metExploreD3.GraphNode.unfixNode(node);
}
if (node.getAsStarter() === true){
node.removeAsStarter();
}
});
metExploreD3.GraphRank.removeGirStyle();
......@@ -117,6 +120,7 @@ metExploreD3.GraphRank = {
},100);
}
metExploreD3.GraphCaption.drawCaption();
networkData.updateNbVisited(-(networkData.getNbVisited()));
},
/*******************************************
......@@ -185,28 +189,42 @@ metExploreD3.GraphRank = {
var networkData = session.getD3Data();
var allNodes = d3.select("#viz").select("#D3viz").select("#graphComponent").selectAll("g.node");
var nodes = networkData.getNodes();
var nbVisited = networkData.getNbVisited();
allNodes.each(function(node){
if (node.duplicated === true){
networkData.removeNode(node);
}
});
if (nbVisited > 0){
allNodes.each(function(node){
if (node.duplicated === true){
networkData.removeNode(node);
}
});
allNodes.remove();
allNodes.remove();
nodes.map(function(node){
if (node.isVisited() === false){
node.hide();
}
if (node.isVisited() === true){
node.show();
node.unvisit();
}
});
nodes.map(function(node){
if (node.isVisited() === false){
node.hide();
}
if (node.isVisited() === true){
node.show();
node.unvisit();
}
if (node.getAsStarter() === true){
node.removeAsStarter();
}
});
metExploreD3.GraphRank.removeGirStyle();
metExploreD3.GraphNetwork.updateNetwork("viz", _metExploreViz.getSessionById("viz"));
metExploreD3.GraphCaption.drawCaption();
metExploreD3.GraphRank.removeGirStyle();
metExploreD3.GraphNetwork.updateNetwork("viz", _metExploreViz.getSessionById("viz"));
metExploreD3.GraphCaption.drawCaption();
networkData.updateNbVisited(-(networkData.getNbVisited()));
return true;
}
else {
metExploreD3.displayWarning("Warning",
'You try to extract empty subnetwork'
);
}
},
// save network function
......@@ -697,7 +715,7 @@ metExploreD3.GraphRank = {
var rankOut = parseInt(nodeScore[1]);
nodes.each(function(thisNode){
if (thisNode === node) {
if (thisNode === node && thisNode.getAsStarter() !== true) {
if (rankIn < 25 && rankOut < 25) {
d3.select(this).selectAll("rect")
.style("stroke-width",3)
......@@ -728,6 +746,8 @@ metExploreD3.GraphRank = {
* @param {Object} node node object
*/
visit: function(node) {
var session = _metExploreViz.getSessionById("viz");
var networkData = session.getD3Data();
var nodes = d3.select("#viz").select("#D3viz").select("#graphComponent").selectAll("g.node");
nodes.each(function(thisNode){
......@@ -737,6 +757,7 @@ metExploreD3.GraphRank = {
}
});
networkData.updateNbVisited(1);
metExploreD3.GraphRank.visitLink();
},
......@@ -745,6 +766,8 @@ metExploreD3.GraphRank = {
* @param {Object} node node object
*/
unvisit: function(node) {
var session = _metExploreViz.getSessionById("viz");
var networkData = session.getD3Data();
var nodes = d3.select("#viz").select("#D3viz").select("#graphComponent").selectAll("g.node");
var metaboliteStyle = metExploreD3.getMetaboliteStyle();
......@@ -755,6 +778,7 @@ metExploreD3.GraphRank = {
}
});
networkData.updateNbVisited(-1);
metExploreD3.GraphRank.unvisitLink();
metExploreD3.GraphRank.visitLink();
},
......@@ -934,10 +958,9 @@ metExploreD3.GraphRank = {
boxExpand.append("svg:path")
.attr("class", "backgroundExpand")
.attr("d", "M 0 0, L 0 " + (metaboliteStyle.getHeight()) +
"L " + (metaboliteStyle.getWidth()) + " " + (metaboliteStyle.getHeight()) +
" Q " + (metaboliteStyle.getWidth()) + " 0, " +
"0 0")
.attr("d", "M 0 0 L 0 " + metaboliteStyle.getHeight() +
"L " + metaboliteStyle.getWidth() + " " + metaboliteStyle.getHeight() +
"Q " + metaboliteStyle.getWidth() + " 0, 0 0")
.attr("fill", "#00aa00");
boxExpand.append("image")
......@@ -992,7 +1015,7 @@ metExploreD3.GraphRank = {
boxCollaspe.append("svg:path")
.attr("class", "backgroundCollapse")
.attr("d", "M 0 0, L " + (metaboliteStyle.getWidth()) + " 0" +
.attr("d", "M 0 0 L " + (metaboliteStyle.getWidth()) + " 0" +
"Q " + (metaboliteStyle.getWidth()) + " " + (metaboliteStyle.getHeight()) +
" ,0 " + (metaboliteStyle.getHeight()) +
"L 0 0")
......@@ -1043,7 +1066,7 @@ metExploreD3.GraphRank = {
boxVisit.append("svg:path")
.attr("class", "backgroundVisit")
.attr("d", "M 0 0, Q 0 " + (metaboliteStyle.getHeight()) + ", " +
.attr("d", "M 0 0 Q 0 " + (metaboliteStyle.getHeight()) + ", " +
(metaboliteStyle.getWidth()) + " " + (metaboliteStyle.getHeight()) +
"L" + (metaboliteStyle.getWidth()) + " 0" +
"L 0 0")
......
......@@ -14,9 +14,18 @@ var NetworkData = function(id){
this.links = [];
this.compartments = [];
this.pathways = [];
this.nbVisited = 0;
};
NetworkData.prototype = {
updateNbVisited : function(value){
this.nbVisited += value;
},
getNbVisited : function(){
return this.nbVisited;
},
resetMapping : function(){
this.nodes.forEach(function(node){
node.resetMapping();
......@@ -41,16 +50,16 @@ NetworkData.prototype = {
{
return this.nodes;
},
setId:function(newId)
{
this.id = newId;
},
},
getId:function()
{
return this.id;
},
},
copyData:function(aData)
{
......@@ -76,7 +85,7 @@ NetworkData.prototype = {
{
return this.compartments.length;
},
getCompartmentByName: function(name){
var allCompartments=[];
allCompartments=this.compartments;
......@@ -91,7 +100,7 @@ NetworkData.prototype = {
}
}
return null;
},
getCompartmentById: function(id){
......@@ -108,7 +117,7 @@ NetworkData.prototype = {
}
}
return null;
},
sortCompartments:function()
......@@ -140,7 +149,7 @@ NetworkData.prototype = {
{
return this.pathways.length;
},
getPathwayByName: function(name){
var allPathways=[];
allPathways=this.pathways;
......@@ -171,7 +180,7 @@ NetworkData.prototype = {
}
}
return null;
},
removePathway : function (path){
for(k=0;k<this.pathways.length;k++)
......@@ -291,7 +300,7 @@ NetworkData.prototype = {
var nodes = allNodes.filter(function(node){
return node.mappedInchi==(inchi);
});
if(nodes.length==0)
nodes = undefined;
......@@ -372,11 +381,11 @@ NetworkData.prototype = {
svgHeight,
isSideCompound,
ec,
isDuplicated,
identifier,
pathway,
locked,
alias,
isDuplicated,
identifier,
pathway,
locked,
alias,
label,
labelFont,
hidden
......@@ -385,25 +394,25 @@ NetworkData.prototype = {
this.nodes = [];
var object = new NodeData(
name,
compartment,
dbIdentifier,
ec,
id,
reactionReversibility,
isSideCompound,
biologicalType,
selected,
labelVisible,
svg,
svgWidth,
svgHeight,
undefined,
isDuplicated,
identifier,
pathway,
locked,
alias,
name,
compartment,
dbIdentifier,
ec,
id,
reactionReversibility,
isSideCompound,
biologicalType,
selected,
labelVisible,
svg,
svgWidth,
svgHeight,
undefined,
isDuplicated,
identifier,
pathway,
locked,
alias,
label,
labelFont,
hidden);
......@@ -412,7 +421,7 @@ NetworkData.prototype = {
this.nodes.push(object);
return object;
},
//get the array of link adjacent to a node
getAdjLink : function (node)
{
......@@ -432,12 +441,12 @@ NetworkData.prototype = {
if(node.id==target.id)
{
adjLink.push(link);
}
}
}
}
}
return adjLink;
return adjLink;
},
//remove link function
removeLink : function (link){
for(k=0;k<this.links.length;k++)
......@@ -620,4 +629,4 @@ NetworkData.prototype = {
}
};
\ No newline at end of file
};
......@@ -66,6 +66,7 @@ var NodeData = function(
this.visited = false;
this.nbHidden = 0;
this.asSideCompounds = false;
this.starter = false;
};
......@@ -82,6 +83,15 @@ NodeData.prototype = {
setNbHidden: function(x){
this.nbHidden = x;
},
markAsStarter: function(){
this.starter = true;
},
removeAsStarter: function(){
this.starter = false;
},
getAsStarter: function(){
return this.starter;
},
equals : function(x){
var equal=true;
if(this.id!=x.id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment