Commit 06b9abc3 authored by maxchaza's avatar maxchaza
Browse files

Fix saving styles

parent ca513cb0
...@@ -220,6 +220,33 @@ Ext.define('metExploreViz.view.form.aStyleForm.AStyleFormController', { ...@@ -220,6 +220,33 @@ Ext.define('metExploreViz.view.form.aStyleForm.AStyleFormController', {
} }
}, },
updateDiscreteMapping : function(){
var me = this;
var view = me.getView();
var conditionName = view.lookupReference('selectConditionForm').lookupReference('selectCondition').getValue();
var selectConditionType = view.lookupReference('selectConditionForm').lookupReference('selectConditionType');
var dataType = selectConditionType.getValue();
var session = _metExploreViz.getSessionById("viz");
if(dataType==="Alias"){
session.setMappingDataType(dataType);
metExploreD3.GraphMapping.graphMappingDiscreteData(conditionName, view);
}
if(dataType==="Discrete"){
session.setMappingDataType(dataType);
metExploreD3.GraphMapping.graphMappingDiscreteData(conditionName, view);
}
if(dataType==="As selection"){
session.setMappingDataType(dataType);
metExploreD3.GraphMapping.graphMappingAsSelectionData(conditionName, view);
}
},
updateFormValues : function(){ updateFormValues : function(){
var me = this; var me = this;
var view = me.getView(); var view = me.getView();
...@@ -614,7 +641,6 @@ Ext.define('metExploreViz.view.form.aStyleForm.AStyleFormController', { ...@@ -614,7 +641,6 @@ Ext.define('metExploreViz.view.form.aStyleForm.AStyleFormController', {
}, },
addValueMapping : function(type, n, c){ addValueMapping : function(type, n, c){
var valueMappings = this.getValueMappingsByType(type); var valueMappings = this.getValueMappingsByType(type);
console.log(valueMappings);
var newVal = new ValueMapping(n,c); var newVal = new ValueMapping(n,c);
if(valueMappings.findIndex(function (valueMap) { return valueMap.getName()===n; })===-1) if(valueMappings.findIndex(function (valueMap) { return valueMap.getName()===n; })===-1)
valueMappings.push(newVal); valueMappings.push(newVal);
......
...@@ -43,8 +43,6 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', { ...@@ -43,8 +43,6 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
view.query("allStylesByTypeForm").forEach(function (allStylesByTypeForm) { view.query("allStylesByTypeForm").forEach(function (allStylesByTypeForm) {
console.log(aStyleForm);
var partOfAllScales = allStylesByTypeForm.query("aStyleForm") var partOfAllScales = allStylesByTypeForm.query("aStyleForm")
.map(function (aStyleForm) { .map(function (aStyleForm) {
return { return {
...@@ -120,9 +118,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', { ...@@ -120,9 +118,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
var dataType = selectConditionType.getValue(); var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue(); var selectedCondition = selectCondition.getValue();
if(dataType==="Continuous" && selectedCondition!==null){ if(dataType==="Discrete" && selectedCondition!==null){
theStyleForm.getController().updateContinuousCaption(); theStyleForm.getController().updateDiscreteMapping();
theStyleForm.getController().updateContinuousMapping();
} }
} }
} }
...@@ -141,9 +138,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', { ...@@ -141,9 +138,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
var dataType = selectConditionType.getValue(); var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue(); var selectedCondition = selectCondition.getValue();
if(dataType==="Continuous" && selectedCondition!==null){ if(dataType==="As selection" && selectedCondition!==null){
theStyleForm.getController().updateContinuousCaption(); theStyleForm.getController().updateDiscreteMapping();
theStyleForm.getController().updateContinuousMapping();
} }
} }
} }
...@@ -162,9 +158,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', { ...@@ -162,9 +158,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
var dataType = selectConditionType.getValue(); var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue(); var selectedCondition = selectCondition.getValue();
if(dataType==="Continuous" && selectedCondition!==null){ if(dataType==="Alias" && selectedCondition!==null){
theStyleForm.getController().updateContinuousCaption(); theStyleForm.getController().updateDiscreteMapping();
theStyleForm.getController().updateContinuousMapping();
} }
} }
} }
......
...@@ -118,20 +118,75 @@ Ext.define('metExploreViz.view.form.selectConditionForm.SelectConditionFormContr ...@@ -118,20 +118,75 @@ Ext.define('metExploreViz.view.form.selectConditionForm.SelectConditionFormContr
if(dataType==="Continuous"){ if(dataType==="Continuous"){
// Allows to reload the same file // Allows to reload the same file
var viewAStyleForm = me.getAStyleFormParent();
viewAStyleForm.scaleRange = metExploreD3.GraphUtils.decodeJSON(json); viewAStyleForm.scaleRange = metExploreD3.GraphUtils.decodeJSON(json);
viewAStyleForm.getController().updateContinuousCaption(); viewAStyleForm.getController().updateContinuousCaption();
viewAStyleForm.getController().updateContinuousMapping(); viewAStyleForm.getController().updateContinuousMapping();
} }
if(dataType==="Discrete" || dataType==="As selection" || dataType==="Alias"){ if (dataType==="Discrete"){
// Allows to reload the same file me.removeCaption();
var viewAStyleForm = me.getAStyleFormParent(); var newArray = metExploreD3.GraphUtils.decodeJSON(json).map(function (val) {
viewAStyleForm.scaleRange = metExploreD3.GraphUtils.decodeJSON(json); return new ValueMapping(val.name, val.value);
viewAStyleForm.getController().updateContinuousCaption(); });
viewAStyleForm.getController().updateContinuousMapping();
if(newArray!==viewAStyleForm.valueDiscreteMappings){
viewAStyleForm.valueDiscreteMappings=newArray;
var selectConditionForm = viewAStyleForm.lookupReference('selectConditionForm');
var selectCondition = selectConditionForm.lookupReference('selectCondition');
var selectConditionType = selectConditionForm.lookupReference('selectConditionType');
var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue();
if(dataType==="Discrete" && selectedCondition!==null){
viewAStyleForm.getController().updateDiscreteMapping();
}
}
} }
if (dataType==="As selection"){
me.removeCaption();
var newArray = metExploreD3.GraphUtils.decodeJSON(json).map(function (val) {
return new ValueMapping(val.name, val.value);
});
if(newArray!==viewAStyleForm.valueAsSelectionMappings){
viewAStyleForm.valueAsSelectionMappings=newArray;
var selectConditionForm = viewAStyleForm.lookupReference('selectConditionForm');
var selectCondition = selectConditionForm.lookupReference('selectCondition');
var selectConditionType = selectConditionForm.lookupReference('selectConditionType');
var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue();
if(dataType==="As selection" && selectedCondition!==null){
viewAStyleForm.getController().updateDiscreteMapping();
}
}
}
if (dataType==="Alias"){
me.removeCaption();
var newArray = metExploreD3.GraphUtils.decodeJSON(json).map(function (val) {
return new ValueMapping(val.name, val.value);
});
if(newArray!==viewAStyleForm.valueAliasMappings){
viewAStyleForm.valueAliasMappings=newArray;
var selectConditionForm = viewAStyleForm.lookupReference('selectConditionForm');
var selectCondition = selectConditionForm.lookupReference('selectCondition');
var selectConditionType = selectConditionForm.lookupReference('selectConditionType');
var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue();
if(dataType==="Alias" && selectedCondition!==null){
viewAStyleForm.getController().updateDiscreteMapping();
}
}
}
}); });
}, },
scope:me scope:me
...@@ -149,6 +204,27 @@ Ext.define('metExploreViz.view.form.selectConditionForm.SelectConditionFormContr ...@@ -149,6 +204,27 @@ Ext.define('metExploreViz.view.form.selectConditionForm.SelectConditionFormContr
}); });
}, },
/*******************************************
* Remove all mapping in visualisation and in side panel
*/
removeCaption:function(){
var me = this;
var view = me.getView();
var session = _metExploreViz.getSessionById('viz');
var aStyleFormParent = me.getAStyleFormParent();
var colorStore = aStyleFormParent.getController().getValueMappingsSet(session.getMappingDataType());
colorStore.forEach(function(color){
var newId = color.getName().toString().replace(me.regexpPanel, "_");
if(view.down("#mappingCaptionForm"+newId))
view.down("#mappingCaptionForm"+newId).close();
});
if(view.down("#undefined"))
view.down("#undefined").close();
},
/******************************************* /*******************************************
* Remove all mapping in visualisation and in side panel * Remove all mapping in visualisation and in side panel
*/ */
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
'-', '-',
{ {
xtype: 'button', xtype: 'button',
hidden : true,
iconCls:'edgesSelection', iconCls:'edgesSelection',
align:"right", align:"right",
scale : 'large', scale : 'large',
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
}, },
{ {
xtype: 'button', xtype: 'button',
hidden : true,
iconCls:'metaboliteSelection', iconCls:'metaboliteSelection',
align:"right", align:"right",
scale : 'large', scale : 'large',
...@@ -55,6 +57,7 @@ ...@@ -55,6 +57,7 @@
}, },
{ {
xtype: 'button', xtype: 'button',
hidden : true,
iconCls:'reactionSelection', iconCls:'reactionSelection',
align:"right", align:"right",
scale : 'large', scale : 'large',
......
...@@ -998,19 +998,19 @@ metExploreD3.GraphMapping = { ...@@ -998,19 +998,19 @@ metExploreD3.GraphMapping = {
.range([aStyleFormParent.min, aStyleFormParent.max]); .range([aStyleFormParent.min, aStyleFormParent.max]);
for (var i = 0; i < valuesParsed.length; i++) { for (var i = 0; i < valuesParsed.length; i++) {
aStyleFormParent.getController().addValueMapping("Discrete", values[i], linearScale(valuesParsed[i])); aStyleFormParent.getController().addValueMapping("Discrete", values[i], linearScale(valuesParsed[i]));
metExploreD3.GraphStyleEdition.setCollectionStyleDiscreteMapping(aStyleFormParent.target, aStyleFormParent.attrType, aStyleFormParent.attrName, aStyleFormParent.biologicalType, conditionName, mappingName, values[i], linearScale(valuesParsed[i]))
// metExploreD3.GraphMapping.fixMappingColorOnNodeData(color, values[i], conditionName, mappingName);
} }
var valueMapping = aStyleFormParent.getController().getValueMappingsSet(session.getMappingDataType());
valueMapping.forEach(function(valMapping){
metExploreD3.GraphStyleEdition.setCollectionStyleDiscreteMapping(aStyleFormParent.target, aStyleFormParent.attrType, aStyleFormParent.attrName, aStyleFormParent.biologicalType, conditionName, mappingName, valMapping.getName(), valMapping.getValue())
});
} }
if(aStyleFormParent.styleType==="color" ) { if(aStyleFormParent.styleType==="color" ) {
center = 128; center = 128;
width = 127; width = 127;
frequency = Math.PI * 2 * 0.95 / values.length; frequency = Math.PI * 2 * 0.95 / values.length;
var position = top; var position = top;
var colorStore = aStyleFormParent.getController().getValueMappingsSet(session.getMappingDataType());
for (var i = 0; i < values.length; i++) { for (var i = 0; i < values.length; i++) {
var red = Math.sin(frequency * i + 2 + values.length) * width + center; var red = Math.sin(frequency * i + 2 + values.length) * width + center;
...@@ -1020,9 +1020,15 @@ metExploreD3.GraphMapping = { ...@@ -1020,9 +1020,15 @@ metExploreD3.GraphMapping = {
color = metExploreD3.GraphUtils.RGB2Color(red, green, blue); color = metExploreD3.GraphUtils.RGB2Color(red, green, blue);
aStyleFormParent.getController().addValueMapping("Discrete", values[i], color); aStyleFormParent.getController().addValueMapping("Discrete", values[i], color);
metExploreD3.GraphStyleEdition.setCollectionStyleDiscreteMapping(aStyleFormParent.target, aStyleFormParent.attrType, aStyleFormParent.attrName, aStyleFormParent.biologicalType, conditionName, mappingName, values[i], color)
// metExploreD3.GraphMapping.fixMappingColorOnNodeData(color, values[i], conditionName, mappingName); // metExploreD3.GraphMapping.fixMappingColorOnNodeData(color, values[i], conditionName, mappingName);
} }
var colorStore = aStyleFormParent.getController().getValueMappingsSet(session.getMappingDataType());
colorStore.forEach(function(color){
console.log(color.getName());
console.log(color.getValue());
metExploreD3.GraphStyleEdition.setCollectionStyleDiscreteMapping(aStyleFormParent.target, aStyleFormParent.attrType, aStyleFormParent.attrName, aStyleFormParent.biologicalType, conditionName, mappingName, color.getName(), color.getValue())
});
} }
......
Supports Markdown
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