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', {
}
},
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(){
var me = this;
var view = me.getView();
......@@ -614,7 +641,6 @@ Ext.define('metExploreViz.view.form.aStyleForm.AStyleFormController', {
},
addValueMapping : function(type, n, c){
var valueMappings = this.getValueMappingsByType(type);
console.log(valueMappings);
var newVal = new ValueMapping(n,c);
if(valueMappings.findIndex(function (valueMap) { return valueMap.getName()===n; })===-1)
valueMappings.push(newVal);
......
......@@ -43,8 +43,6 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
view.query("allStylesByTypeForm").forEach(function (allStylesByTypeForm) {
console.log(aStyleForm);
var partOfAllScales = allStylesByTypeForm.query("aStyleForm")
.map(function (aStyleForm) {
return {
......@@ -120,9 +118,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue();
if(dataType==="Continuous" && selectedCondition!==null){
theStyleForm.getController().updateContinuousCaption();
theStyleForm.getController().updateContinuousMapping();
if(dataType==="Discrete" && selectedCondition!==null){
theStyleForm.getController().updateDiscreteMapping();
}
}
}
......@@ -141,9 +138,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue();
if(dataType==="Continuous" && selectedCondition!==null){
theStyleForm.getController().updateContinuousCaption();
theStyleForm.getController().updateContinuousMapping();
if(dataType==="As selection" && selectedCondition!==null){
theStyleForm.getController().updateDiscreteMapping();
}
}
}
......@@ -162,9 +158,8 @@ Ext.define('metExploreViz.view.form.allStylesForm.AllStylesFormController', {
var dataType = selectConditionType.getValue();
var selectedCondition = selectCondition.getValue();
if(dataType==="Continuous" && selectedCondition!==null){
theStyleForm.getController().updateContinuousCaption();
theStyleForm.getController().updateContinuousMapping();
if(dataType==="Alias" && selectedCondition!==null){
theStyleForm.getController().updateDiscreteMapping();
}
}
}
......
......@@ -118,20 +118,75 @@ Ext.define('metExploreViz.view.form.selectConditionForm.SelectConditionFormContr
if(dataType==="Continuous"){
// Allows to reload the same file
var viewAStyleForm = me.getAStyleFormParent();
viewAStyleForm.scaleRange = metExploreD3.GraphUtils.decodeJSON(json);
viewAStyleForm.getController().updateContinuousCaption();
viewAStyleForm.getController().updateContinuousMapping();
}
if(dataType==="Discrete" || dataType==="As selection" || dataType==="Alias"){
// Allows to reload the same file
var viewAStyleForm = me.getAStyleFormParent();
viewAStyleForm.scaleRange = metExploreD3.GraphUtils.decodeJSON(json);
viewAStyleForm.getController().updateContinuousCaption();
viewAStyleForm.getController().updateContinuousMapping();
if (dataType==="Discrete"){
me.removeCaption();
var newArray = metExploreD3.GraphUtils.decodeJSON(json).map(function (val) {
return new ValueMapping(val.name, val.value);
});
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
......@@ -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
*/
......
......@@ -35,6 +35,7 @@
'-',
{
xtype: 'button',
hidden : true,
iconCls:'edgesSelection',
align:"right",
scale : 'large',
......@@ -45,6 +46,7 @@
},
{
xtype: 'button',
hidden : true,
iconCls:'metaboliteSelection',
align:"right",
scale : 'large',
......@@ -55,6 +57,7 @@
},
{
xtype: 'button',
hidden : true,
iconCls:'reactionSelection',
align:"right",
scale : 'large',
......
......@@ -998,19 +998,19 @@ metExploreD3.GraphMapping = {
.range([aStyleFormParent.min, aStyleFormParent.max]);
for (var i = 0; i < valuesParsed.length; 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" ) {
center = 128;
width = 127;
frequency = Math.PI * 2 * 0.95 / values.length;
var position = top;
var colorStore = aStyleFormParent.getController().getValueMappingsSet(session.getMappingDataType());
for (var i = 0; i < values.length; i++) {
var red = Math.sin(frequency * i + 2 + values.length) * width + center;
......@@ -1020,9 +1020,15 @@ metExploreD3.GraphMapping = {
color = metExploreD3.GraphUtils.RGB2Color(red, green, blue);
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);
}
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