Commit 486cc3c79546a6e1a91b43fd4b74cf886e433c28

Authored by Benjamin Renard
1 parent fd5552a4

Add fill elements for plot

js/app/models/DownloadNode.js
... ... @@ -68,7 +68,6 @@ Ext.define('amdaModel.DownloadNode', {
68 68 },
69 69  
70 70 decodeObject: function(obj) {
71   - console.log(obj);
72 71 var myValues = new Object();
73 72 myValues.list=[];
74 73  
... ...
js/app/models/PlotObjects/PlotFillObject.js 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +/**
  2 + * Project  : AMDA-NG
  3 + * Name : PlotFillObject.js
  4 + * @class amdaPlotObj.PlotFillObject
  5 + * @extends Ext.data.Model
  6 + * @brief Plot Fill Business Object Definition
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotFillObject.js benjamin $
  9 + ******************************************************************************
  10 + * FT Id : Date : Name - Description
  11 + ******************************************************************************
  12 + * : :04/09/2015: BRE - file creation
  13 + */
  14 +
  15 +
  16 +Ext.define('amdaPlotObj.PlotFillObject', {
  17 + extend: 'Ext.data.Model',
  18 + idProperty: 'id',
  19 +
  20 + requires: [
  21 + 'amdaPlotObj.PlotObjectConfig'
  22 + ],
  23 +
  24 + fields : [
  25 + {name: 'id', type: 'int'},
  26 + {name: 'fill-type', type: 'string'},
  27 + {name: 'fill-firstserie-id', type: 'int', useNull:true},
  28 + {name: 'fill-secondserie-id', type: 'int', useNull:true},
  29 + {name: 'fill-constant-id', type: 'int', useNull:true},
  30 + {name: 'fill-greater-color', type: 'string'},
  31 + {name: 'fill-less-color', type: 'string'}
  32 + ],
  33 +
  34 + setDefaultValues: function()
  35 + {
  36 + this.set('fill-type', amdaPlotObj.PlotObjectConfig.defaultValues.fills.type);
  37 + this.set('fill-firstserie-id', null);
  38 + this.set('fill-secondserie-id', null);
  39 + this.set('fill-constant-id', null);
  40 + this.set('fill-greater-color', amdaPlotObj.PlotObjectConfig.defaultValues.fills.greaterColor);
  41 + this.set('fill-less-color', amdaPlotObj.PlotObjectConfig.defaultValues.fills.lessColor);
  42 + },
  43 +
  44 + getShortInfo : function()
  45 + {
  46 + var type = amdaPlotObj.PlotObjectConfig.getValueByKey(amdaPlotObj.PlotObjectConfig.availableFillTypes, this.get('fill-type'));
  47 + return type;
  48 + },
  49 +
  50 + getJsonValues : function()
  51 + {
  52 + var fillValues = new Object();
  53 +
  54 + fillValues['id'] = this.get('id');
  55 +
  56 + fillValues['fill-type'] = this.get('fill-type');
  57 + fillValues['fill-firstserie-id'] = this.get('fill-firstserie-id');
  58 + fillValues['fill-secondserie-id'] = this.get('fill-secondserie-id');
  59 + fillValues['fill-constant-id'] = this.get('fill-constant-id');
  60 + fillValues['fill-greater-color'] = this.get('fill-greater-color');
  61 + fillValues['fill-less-color'] = this.get('fill-less-color');
  62 +
  63 + return fillValues;
  64 + }
  65 +});
0 66 \ No newline at end of file
... ...
js/app/models/PlotObjects/PlotObjectConfig.js
... ... @@ -166,6 +166,11 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
166 166 width : 1,
167 167 color : '#000000'
168 168 }
  169 + },
  170 + fills : {
  171 + type : 'serie-constant',
  172 + greaterColor : 'none',
  173 + lessColor : 'none'
169 174 }
170 175 },
171 176  
... ... @@ -374,5 +379,10 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
374 379 {'key' : 'left', 'value' : 'Left'},
375 380 {'key' : 'center', 'value' : 'Center'},
376 381 {'key' : 'right', 'value' : 'Right'}
377   - ]
  382 + ],
  383 +
  384 + availableFillTypes : [
  385 + {'key' : 'serie-constant', 'value' : 'Serie / Constant'},
  386 + {'key' : 'serie-serie', 'value' : 'Serie / Serie'}
  387 + ]
378 388 });
379 389 \ No newline at end of file
... ...
js/app/models/PlotObjects/PlotPanelObject.js
... ... @@ -25,7 +25,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
25 25 'amdaPlotObj.PlotLegendTextObject',
26 26 'amdaPlotObj.PlotConstantObject',
27 27 'amdaPlotObj.PlotTextObject',
28   - 'amdaPlotObj.PlotCurveObject'
  28 + 'amdaPlotObj.PlotCurveObject',
  29 + 'amdaPlotObj.PlotFillObject'
29 30 ],
30 31  
31 32 fields : [
... ... @@ -84,7 +85,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
84 85 {name: 'last-textlegend-id', type: 'int', defaultValue:0},
85 86 {name: 'last-constant-id', type: 'int', defaultValue:0},
86 87 {name: 'last-textobj-id', type: 'int', defaultValue:0},
87   - {name: 'last-curve-id', type: 'int', defaultValue:0}
  88 + {name: 'last-curve-id', type: 'int', defaultValue:0},
  89 + {name: 'last-fill-id', type: 'int', defaultValue:0}
88 90 ],
89 91  
90 92 associations : [
... ... @@ -119,6 +121,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
119 121 name : 'curves'
120 122 },
121 123 {
  124 + type : 'hasMany',
  125 + model : 'amdaPlotObj.PlotFillObject',
  126 + name : 'fills'
  127 + },
  128 + {
122 129 type : 'belongsTo',
123 130 model : 'amdaPlotObj.PlotTabObject'
124 131 }
... ... @@ -141,6 +148,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
141 148 me.loadTextObjs(arguments[0].textObjs);
142 149 if (arguments[0].curves)
143 150 me.loadCurves(arguments[0].curves);
  151 + if (arguments[0].fills)
  152 + me.loadFills(arguments[0].fills);
144 153 }
145 154 else
146 155 {
... ... @@ -179,6 +188,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
179 188 this.curves().loadData(curves);
180 189 },
181 190  
  191 + loadFills: function(fills)
  192 + {
  193 + this.fills().loadData(fills);
  194 + },
  195 +
182 196 initAxes : function()
183 197 {
184 198 this.axes().removeAll();
... ... @@ -327,6 +341,22 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
327 341 return true;
328 342 },
329 343  
  344 + createNewFill: function() {
  345 + this.set('last-fill-id', this.get('last-fill-id') + 1);
  346 + var recs = this.fills().add({id : this.get('last-fill-id')});
  347 + recs[0].setDefaultValues();
  348 + return recs[0];
  349 + },
  350 +
  351 + removeFillById: function(fillId) {
  352 + //Retrieve fill record
  353 + var fillRecord = this.fills().getById(fillId);
  354 + if (fillRecord == null)
  355 + return false;
  356 + this.fills().remove(fillRecord);
  357 + return true;
  358 + },
  359 +
330 360 updatePlotType: function(plotType, forceUpdate) {
331 361 forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false;
332 362  
... ... @@ -369,6 +399,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
369 399 this.textObjs().removeAll();
370 400 this.constants().removeAll();
371 401 this.curves().removeAll();
  402 + this.fills().removeAll();
372 403 }
373 404 else if (plotType != 'xyPlot')
374 405 this.curves().removeAll();
... ... @@ -518,6 +549,12 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
518 549 panelValues['curves'][index] = curve.getJsonValues();
519 550 });
520 551  
  552 + panelValues['fills'] = [];
  553 +
  554 + this.fills().each(function (fill, index) {
  555 + panelValues['fills'][index] = fill.getJsonValues();
  556 + });
  557 +
521 558 panelValues['axes'] = [];
522 559  
523 560 this.axes().each(function (axe, index) {
... ... @@ -535,6 +572,7 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
535 572 panelValues['last-constant-id'] = this.get('last-constant-id');
536 573 panelValues['last-textobj-id'] = this.get('last-textobj-id');
537 574 panelValues['last-curve-id'] = this.get('last-curve-id');
  575 + panelValues['last-fill-id'] = this.get('last-fill-id');
538 576  
539 577 return panelValues;
540 578 }
... ...
js/app/models/PlotObjects/PlotTreeNode.js
... ... @@ -359,3 +359,32 @@ Ext.define('amdaPlotObj.PlotCurveTreeNode', {
359 359  
360 360 removable: true
361 361 });
  362 +
  363 +Ext.define('amdaPlotObj.PlotFillsTreeNode', {
  364 + extend: 'amdaPlotObj.PlotTreeNode',
  365 +
  366 + iconCls: 'icon-plot-add-fills',
  367 +
  368 + text: 'Fills',
  369 +
  370 + type: 'fills'
  371 +});
  372 +
  373 +Ext.define('amdaPlotObj.PlotFillTreeNode', {
  374 + extend: 'amdaPlotObj.PlotTreeNode',
  375 +
  376 + leaf: true,
  377 +
  378 + iconCls: 'icon-plot-add-fill',
  379 +
  380 + text: 'Fill',
  381 +
  382 + type: 'fill',
  383 +
  384 + removable: true,
  385 +
  386 + getAdditionalText: function()
  387 + {
  388 + return ' ('+this.object.getShortInfo()+')';
  389 + }
  390 +});
... ...
js/app/views/PlotComponents/PlotCurveForm.js
... ... @@ -109,8 +109,6 @@ Ext.define('amdaPlotComp.PlotCurveForm', {
109 109 attachedSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
110 110 }
111 111 });
112   -
113   - console.log(attachedSerieField.getStore());
114 112 },
115 113  
116 114 getFormItems: function() {
... ...
js/app/views/PlotComponents/PlotElementPanel.js
... ... @@ -26,7 +26,9 @@ Ext.define('amdaPlotComp.PlotElementPanel', {
26 26 'amdaPlotComp.PlotDrawingObjectForm',
27 27 'amdaPlotComp.PlotConstantForm',
28 28 'amdaPlotComp.PlotTextForm',
29   - 'amdaPlotComp.PlotCurveForm'
  29 + 'amdaPlotComp.PlotCurveForm',
  30 + 'amdaPlotComp.PlotFillsForm',
  31 + 'amdaPlotComp.PlotFillForm'
30 32 ],
31 33  
32 34 elementFormsManager : new Ext.AbstractManager(),
... ... @@ -182,6 +184,20 @@ Ext.define('amdaPlotComp.PlotElementPanel', {
182 184 me.getEl().unmask();
183 185 });
184 186 break;
  187 + case 'fills' :
  188 + this.elementFormsManager.register(new amdaPlotComp.PlotFillsForm({id : formId}));
  189 + if (onFormReady != null)
  190 + onFormReady(this.elementFormsManager.get(formId));
  191 + if (this.rendered)
  192 + this.getEl().unmask();
  193 + break;
  194 + case 'fill' :
  195 + this.elementFormsManager.register(new amdaPlotComp.PlotFillForm({id : formId}));
  196 + if (onFormReady != null)
  197 + onFormReady(this.elementFormsManager.get(formId));
  198 + if (this.rendered)
  199 + this.getEl().unmask();
  200 + break;
185 201 case '' :
186 202 this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'Select an element to the tree to show options'}));
187 203 if (onFormReady != null)
... ...
js/app/views/PlotComponents/PlotFillForm.js 0 → 100644
... ... @@ -0,0 +1,90 @@
  1 +/**
  2 + * Project  : AMDA-NG
  3 + * Name : PlotFillForm.js
  4 + * @class amdaPlotComp.PlotFillForm
  5 + * @extends amdaPlotComp.PlotStandardForm
  6 + * @brief Form to define specifics fill options
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotFillForm.js benjamin $
  9 + */
  10 +
  11 +Ext.define('amdaPlotComp.PlotFillForm', {
  12 + extend: 'amdaPlotComp.PlotStandardForm',
  13 +
  14 + requires: [
  15 + 'amdaPlotObj.PlotCurveDef'
  16 + ],
  17 +
  18 + setObject : function(object) {
  19 + this.object = object;
  20 + if (this.object != null)
  21 + {
  22 + this.updateSerieIdLists();
  23 + this.updateConstantIdList();
  24 + this.loadRecord(this.object);
  25 + }
  26 + },
  27 +
  28 + updateOptions : function() {
  29 + var typeField = this.getForm().findField('fill-type');
  30 + var secondSerieField = this.getForm().findField('fill-secondserie-id');
  31 + var constantField = this.getForm().findField('fill-constant-id');
  32 +
  33 + var isSerieSerie = (typeField.getValue() == 'serie-serie');
  34 +
  35 + secondSerieField.setVisible(isSerieSerie);
  36 + constantField.setVisible(!isSerieSerie);
  37 + },
  38 +
  39 + updateSerieIdLists: function() {
  40 + var firstSerieField = this.getForm().findField('fill-firstserie-id');
  41 + var secondSerieField = this.getForm().findField('fill-secondserie-id');
  42 +
  43 + firstSerieField.getStore().removeAll();
  44 + secondSerieField.getStore().removeAll();
  45 +
  46 + var panelObject = this.crtTree.getSelectedPanelObject();
  47 + if (panelObject == null)
  48 + return;
  49 +
  50 + panelObject.params().each(function(paramObject) {
  51 + var drawingType = paramObject.get('param-drawing-type');
  52 + if ((drawingType == 'serie') || (drawingType == 'orbit-serie'))
  53 + {
  54 + firstSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
  55 + secondSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
  56 + }
  57 + });
  58 + },
  59 +
  60 + updateConstantIdList: function() {
  61 + var constantField = this.getForm().findField('fill-constant-id');
  62 +
  63 + constantField.getStore().removeAll();
  64 +
  65 + var panelObject = this.crtTree.getSelectedPanelObject();
  66 + if (panelObject == null)
  67 + return;
  68 +
  69 + panelObject.constants().each(function(constantObject) {
  70 + constantField.getStore().add({key : constantObject.get('id'), value : constantObject.getShortInfo()});
  71 + });
  72 + },
  73 +
  74 + getFormItems: function() {
  75 + var me = this;
  76 +
  77 + return [
  78 +
  79 + this.addStandardCombo('fill-type', 'Fill type', amdaPlotObj.PlotObjectConfig.availableFillTypes, function(name, value, oldValue) {
  80 + me.updateOptions();
  81 + me.crtTree.getView().refresh();
  82 + }),
  83 + this.addStandardCombo('fill-firstserie-id', 'First serie Id', []),
  84 + this.addStandardCombo('fill-secondserie-id', 'Second serie Id', []),
  85 + this.addStandardCombo('fill-constant-id', 'Constant Id', []),
  86 + this.addStandardColor('fill-greater-color', 'Greater Color', amdaPlotObj.PlotObjectConfig.availableBackgroundColors),
  87 + this.addStandardColor('fill-less-color', 'Less Color', amdaPlotObj.PlotObjectConfig.availableBackgroundColors)
  88 + ];
  89 + }
  90 +});
0 91 \ No newline at end of file
... ...
js/app/views/PlotComponents/PlotFillsForm.js 0 → 100644
... ... @@ -0,0 +1,34 @@
  1 +/**
  2 + * Project  : AMDA-NG
  3 + * Name : PlotFillsForm.js
  4 + * @class amdaPlotComp.PlotFillsForm
  5 + * @extends amdaPlotComp.PlotStandardForm
  6 + * @brief Form to define a list of fill
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotFillsForm.js benjamin $
  9 + */
  10 +
  11 +Ext.define('amdaPlotComp.PlotFillsForm', {
  12 + extend: 'amdaPlotComp.PlotStandardForm',
  13 +
  14 + setObject : function(object) {
  15 + this.object = object;
  16 + if (this.object != null)
  17 + this.loadRecord(this.object);
  18 + },
  19 +
  20 + getFormItems: function() {
  21 + var me = this;
  22 + return [
  23 + {
  24 + xtype: 'button',
  25 + text: 'Add new fill',
  26 + iconCls: 'icon-add',
  27 + handler : function() {
  28 + var fillObject = me.object.createNewFill();
  29 + me.crtTree.buildPanelAdditionalObjectsNode(me.object, fillObject);
  30 + }
  31 + }
  32 + ];
  33 + }
  34 +});
0 35 \ No newline at end of file
... ...
js/app/views/PlotComponents/PlotTree.js
... ... @@ -194,6 +194,9 @@ Ext.define('amdaPlotComp.PlotTree', {
194 194  
195 195 //create drawing objects node
196 196 this.buildDrawingObjectsNode(panelObject, objectsNode, selectedObject);
  197 +
  198 + //create fills node
  199 + this.buildFillsNode(panelObject, objectsNode, selectedObject);
197 200 },
198 201  
199 202 buildPanelLegendsNode: function(panelObject, objectsNode, selectedObject) {
... ... @@ -255,6 +258,21 @@ Ext.define('amdaPlotComp.PlotTree', {
255 258 this.getSelectionModel().select(selectedCurveNode);
256 259 },
257 260  
  261 + buildFillsNode: function(panelObject, objectsNode, selectedObject) {
  262 + var fillsNode = objectsNode.appendChild(new amdaPlotObj.PlotFillsTreeNode({object : panelObject}));
  263 +
  264 + var selectedFillNode = null;
  265 + panelObject.fills().each(function (fillObject) {
  266 + var fillNode = fillsNode.appendChild(new amdaPlotObj.PlotFillTreeNode({object : fillObject}));
  267 + if (fillObject == selectedObject)
  268 + selectedFillNode = fillNode;
  269 + });
  270 +
  271 + this.getView().refresh();
  272 + if (selectedFillNode)
  273 + this.getSelectionModel().select(selectedFillNode);
  274 + },
  275 +
258 276 addPanelNode: function(panelObject) {
259 277 var panelNode = this.panelsNode.appendChild(new amdaPlotObj.PlotPanelTreeNode({object : panelObject}));
260 278 if (!this.isSimplifiedView)
... ... @@ -378,7 +396,43 @@ Ext.define('amdaPlotComp.PlotTree', {
378 396 if (panelObject.removeTextLegendById(record.object.get('id')))
379 397 this.buildPanelAdditionalObjectsNode(panelObject);
380 398 break;
381   - }
  399 + case 'constant' :
  400 + var panelObject = null;
  401 + if (!this.isSimplifiedView)
  402 + panelObject = record.parentNode.parentNode.object;
  403 + else
  404 + panelObject = record.parentNode.object;
  405 + if (panelObject.removeConstantById(record.object.get('id')))
  406 + this.buildPanelAdditionalObjectsNode(panelObject);
  407 + break;
  408 + case 'text-obj' :
  409 + var panelObject = null;
  410 + if (!this.isSimplifiedView)
  411 + panelObject = record.parentNode.parentNode.object;
  412 + else
  413 + panelObject = record.parentNode.object;
  414 + if (panelObject.removeTextObjectById(record.object.get('id')))
  415 + this.buildPanelAdditionalObjectsNode(panelObject);
  416 + break;
  417 + case 'curve' :
  418 + var panelObject = null;
  419 + if (!this.isSimplifiedView)
  420 + panelObject = record.parentNode.parentNode.object;
  421 + else
  422 + panelObject = record.parentNode.object;
  423 + if (panelObject.removeCurveById(record.object.get('id')))
  424 + this.buildPanelAdditionalObjectsNode(panelObject);
  425 + break;
  426 + case 'fill' :
  427 + var panelObject = null;
  428 + if (!this.isSimplifiedView)
  429 + panelObject = record.parentNode.parentNode.object;
  430 + else
  431 + panelObject = record.parentNode.object;
  432 + if (panelObject.removeFillById(record.object.get('id')))
  433 + this.buildPanelAdditionalObjectsNode(panelObject);
  434 + break;
  435 + }
382 436 }
383 437 },
384 438  
... ...
js/app/views/PlotUI.js
... ... @@ -49,7 +49,6 @@ Ext.define('amdaUI.PlotUI', {
49 49 */
50 50 saveProcess : function(){
51 51 var plotModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id);
52   - console.log(plotModule.linkedNode);
53 52 if (plotModule)
54 53 plotModule.linkedNode.create();
55 54 },
... ...
js/resources/css/amda.css
... ... @@ -474,6 +474,14 @@ p + p {
474 474 background-image:url( ../images/16x16/plot_additional_drawing_text.png ) !important;
475 475 }
476 476  
  477 +.icon-plot-add-fills {
  478 + background-image:url( ../images/16x16/plot_additional_fills.png ) !important;
  479 +}
  480 +
  481 +.icon-plot-add-fill {
  482 + background-image:url( ../images/16x16/plot_additional_fill.png ) !important;
  483 +}
  484 +
477 485 .x-item-disabled .x-form-item-label {
478 486 filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100) !important;
479 487 opacity: 1.0 !important;
... ...
js/resources/images/16x16/plot_additional_fill.png 0 → 100644

180 Bytes

js/resources/images/16x16/plot_additional_fills.png 0 → 100644

207 Bytes