Commit 829160b34b53923a85a2db521e6a11095a9de73b

Authored by Benjamin Renard
1 parent 339866c4

Add constants definition

js/app/models/PlotObjects/PlotConstantObject.js 0 → 100644
... ... @@ -0,0 +1,64 @@
  1 +/**
  2 + * Project  : AMDA-NG
  3 + * Name : PlotConstantObject.js
  4 + * @class amdaPlotObj.PlotConstantObject
  5 + * @extends Ext.data.Model
  6 + * @brief Plot Constant Business Object Definition
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotConstantObject.js benjamin $
  9 + ******************************************************************************
  10 + * FT Id : Date : Name - Description
  11 + ******************************************************************************
  12 + * : :01/09/2015: BRE - file creation
  13 + */
  14 +
  15 +
  16 +Ext.define('amdaPlotObj.PlotConstantObject', {
  17 + extend: 'Ext.data.Model',
  18 +
  19 + requires: [
  20 + 'amdaPlotObj.PlotObjectConfig'
  21 + ],
  22 +
  23 + fields : [
  24 + {name: 'constant-axis-id', type: 'string'},
  25 + {name: 'constant-time-value', type: 'date',
  26 + defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1),
  27 + convert: function(value,rec) {
  28 + if (!Ext.isDate(value)) {
  29 + var valueString = new String(value);
  30 + var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' '));
  31 + return date;
  32 + }
  33 + return value;
  34 + }
  35 + },
  36 + {name: 'constant-float-value', type: 'float'},
  37 + {name: 'constant-line-style', type: 'string'},
  38 + {name: 'constant-line-width', type: 'float'},
  39 + {name: 'constant-line-color', type: 'string'}
  40 + ],
  41 +
  42 + setDefaultValues: function()
  43 + {
  44 + this.set('constant-axis-id', amdaPlotObj.PlotObjectConfig.defaultValues.constants.axisId);
  45 + this.set('constant-float-value', 0.);
  46 + this.set('constant-line-style', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.style);
  47 + this.set('constant-line-width', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.width);
  48 + this.set('constant-line-color', amdaPlotObj.PlotObjectConfig.defaultValues.constants.line.color);
  49 + },
  50 +
  51 + getJsonValues : function()
  52 + {
  53 + var constantValues = new Object();
  54 +
  55 + constantValues['constant-axis-id'] = this.get('constant-axis-id');
  56 + constantValues['constant-time-value'] = this.get('constant-time-value');
  57 + constantValues['constant-float-value'] = this.get('constant-float-value');
  58 + constantValues['constant-line-style'] = this.get('constant-line-style');
  59 + constantValues['constant-line-width'] = this.get('constant-line-width');
  60 + constantValues['constant-line-color'] = this.get('constant-line-color');
  61 +
  62 + return constantValues;
  63 + }
  64 +});
0 65 \ No newline at end of file
... ...
js/app/models/PlotObjects/PlotObjectConfig.js
... ... @@ -140,6 +140,14 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
140 140 size: '12'
141 141 }
142 142 }
  143 + },
  144 + constants : {
  145 + axisId : 'y-left',
  146 + line : {
  147 + style : 'plain',
  148 + width : 1,
  149 + color : '#000000'
  150 + }
143 151 }
144 152 },
145 153  
... ... @@ -323,5 +331,11 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
323 331 {'key' : 'left', 'value' : 'Left'},
324 332 {'key' : 'top', 'value' : 'Top'},
325 333 {'key' : 'bottom', 'value' : 'Bottom'}
326   - ]
  334 + ],
  335 +
  336 + availableConstantAxes : [
  337 + {'key' : 'x', 'value' : 'X / Time / Epoch'},
  338 + {'key' : 'y-left', 'value' : 'Y Left'},
  339 + {'key' : 'y-right', 'value' : 'Y Right'}
  340 + ]
327 341 });
328 342 \ No newline at end of file
... ...
js/app/models/PlotObjects/PlotPanelObject.js
... ... @@ -16,15 +16,17 @@
16 16 Ext.define('amdaPlotObj.PlotPanelObject', {
17 17 extend: 'Ext.data.Model',
18 18  
19   - lastParamId : 0,
  19 + lastParamId : 0,
20 20 lastTextLegendId : 0,
  21 + lastConstantId : 0,
21 22  
22 23 requires: [
23 24 'amdaPlotObj.PlotObjectConfig',
24 25 'amdaPlotObj.PlotAxisObject',
25 26 'amdaPlotObj.PlotParamObject',
26 27 'amdaPlotObj.PlotLegendSeriesObject',
27   - 'amdaPlotObj.PlotLegendTextObject'
  28 + 'amdaPlotObj.PlotLegendTextObject',
  29 + 'amdaPlotObj.PlotConstantObject'
28 30 ],
29 31  
30 32 fields : [
... ... @@ -97,6 +99,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
97 99 name : 'textLegends'
98 100 },
99 101 {
  102 + type : 'hasMany',
  103 + model : 'amdaPlotObj.PlotConstantObject',
  104 + name : 'constants'
  105 + },
  106 + {
100 107 type : 'belongsTo',
101 108 model : 'amdaPlotObj.PlotTabObject'
102 109 }
... ... @@ -113,6 +120,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
113 120 me.loadParams(arguments[0].params);
114 121 if (arguments[0].textLegends)
115 122 me.loadTextLegends(arguments[0].textLegends);
  123 + if (arguments[0].constants)
  124 + me.loadConstants(arguments[0].constants);
116 125 }
117 126 else
118 127 {
... ... @@ -136,6 +145,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
136 145 this.textLegends().loadData(textLegends);
137 146 },
138 147  
  148 + loadConstants: function(constants)
  149 + {
  150 + this.constants().loadData(constants);
  151 + },
  152 +
139 153 initAxes : function()
140 154 {
141 155 this.axes().removeAll();
... ... @@ -236,6 +250,22 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
236 250 return true;
237 251 },
238 252  
  253 + createNewConstant: function() {
  254 + var recs = this.constants().add({id : this.get('id')+'-constant-'+this.lastConstantId});
  255 + ++this.lastConstantId;
  256 + recs[0].setDefaultValues();
  257 + return recs[0];
  258 + },
  259 +
  260 + removeConstantById: function(constantId) {
  261 + //Retrieve constant record
  262 + var constantRecord = this.constants().getById(constantId);
  263 + if (constantRecord == null)
  264 + return false;
  265 + this.constants().remove(constantRecord);
  266 + return true;
  267 + },
  268 +
239 269 updatePlotType: function(plotType, forceUpdate) {
240 270 forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false;
241 271  
... ... @@ -378,6 +408,12 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
378 408 panelValues['text-legends'][index] = legend.getJsonValues();
379 409 });
380 410  
  411 + panelValues['constants'] = [];
  412 +
  413 + this.constants().each(function (constant, index) {
  414 + panelValues['constants'][index] = constant.getJsonValues();
  415 + });
  416 +
381 417 panelValues['axes'] = [];
382 418  
383 419 this.axes().each(function (axe, index) {
... ...
js/app/models/PlotObjects/PlotTreeNode.js
... ... @@ -290,6 +290,31 @@ Ext.define('amdaPlotObj.PlotTextLegendTreeNode', {
290 290 removable: true
291 291 });
292 292  
  293 +Ext.define('amdaPlotObj.PlotDrawingObjectsTreeNode', {
  294 + extend: 'amdaPlotObj.PlotTreeNode',
  295 +
  296 + iconCls: 'icon-plot-add-drawing-objs',
  297 +
  298 + text: 'Drawing objects',
  299 +
  300 + type: 'drawing-objects'
  301 +});
  302 +
  303 +Ext.define('amdaPlotObj.PlotConstantTreeNode', {
  304 + extend: 'amdaPlotObj.PlotTreeNode',
  305 +
  306 + leaf: true,
  307 +
  308 + iconCls: 'icon-plot-add-drawing-constant',
  309 +
  310 + text: 'Constant',
  311 +
  312 + type: 'constant',
  313 +
  314 + removable: true
  315 +});
  316 +
  317 +
293 318 /*
294 319 * .icon-plot-add-objs {
295 320 background-image:url( ../images/16x16/plot_additional_objs.png ) !important;
... ...
js/app/views/PlotComponents/PlotConstantForm.js 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +/**
  2 + * Project  : AMDA-NG
  3 + * Name : PlotConstantForm.js
  4 + * @class amdaPlotComp.PlotConstantForm
  5 + * @extends amdaPlotComp.PlotStandardForm
  6 + * @brief Form to define specifics Text legend options
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotConstantForm.js benjamin $
  9 + */
  10 +
  11 +Ext.define('amdaPlotComp.PlotConstantForm', {
  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 + updateOptions: function(axisId, plotType) {
  21 + var timeValueField = this.getForm().findField('constant-time-value');
  22 + var floatValueField = this.getForm().findField('constant-float-value');
  23 + var isTimePlot = (plotType == 'timePlot');
  24 + timeValueField.setVisible(isTimePlot && (axisId == "x"));
  25 + floatValueField.setVisible(!(isTimePlot && (axisId == "x")));
  26 + },
  27 +
  28 + getFormItems: function() {
  29 + var me = this;
  30 + return [
  31 + this.addStandardCombo('constant-axis-id', 'Axis attachment', amdaPlotObj.PlotObjectConfig.availableConstantAxes, function (name, value, oldValue) {
  32 + me.updateOptions(value, me.crtTree.getSelectedPlotType());
  33 + }),
  34 + this.addStandardDate('constant-time-value', 'Value'),
  35 + this.addStandardText('constant-float-value', 'Value'),
  36 + this.addStandardFieldSet('Line', '', this.addStandardLineItems('constant-line'))
  37 + ];
  38 + }
  39 +});
0 40 \ No newline at end of file
... ...
js/app/views/PlotComponents/PlotDrawingObjectForm.js 0 → 100644
... ... @@ -0,0 +1,34 @@
  1 +/**
  2 + * Project  : AMDA-NG
  3 + * Name : PlotDrawingObjectForm.js
  4 + * @class amdaPlotComp.PlotDrawingObjectForm
  5 + * @extends amdaPlotComp.PlotStandardForm
  6 + * @brief Form to define a list of text legends
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotDrawingObjectForm.js benjamin $
  9 + */
  10 +
  11 +Ext.define('amdaPlotComp.PlotDrawingObjectForm', {
  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 constant',
  26 + iconCls: 'icon-add',
  27 + handler : function() {
  28 + var constantObject = me.object.createNewConstant();
  29 + me.crtTree.buildPanelAdditionalObjectsNode(me.object, constantObject.get('id'));
  30 + }
  31 + }
  32 + ];
  33 + }
  34 +});
0 35 \ No newline at end of file
... ...
js/app/views/PlotComponents/PlotElementPanel.js
... ... @@ -22,7 +22,9 @@ Ext.define('amdaPlotComp.PlotElementPanel', {
22 22 'amdaPlotComp.PlotLayoutForm',
23 23 'amdaPlotComp.PlotLegendSeriesForm',
24 24 'amdaPlotComp.PlotLegendTextForm',
25   - 'amdaPlotComp.PlotLegendsTextForm'
  25 + 'amdaPlotComp.PlotLegendsTextForm',
  26 + 'amdaPlotComp.PlotDrawingObjectForm',
  27 + 'amdaPlotComp.PlotConstantForm'
26 28 ],
27 29  
28 30 elementFormsManager : new Ext.AbstractManager(),
... ... @@ -98,6 +100,12 @@ Ext.define('amdaPlotComp.PlotElementPanel', {
98 100 case 'text-legends' :
99 101 this.elementFormsManager.register(new amdaPlotComp.PlotLegendsTextForm({id : formId}));
100 102 break;
  103 + case 'drawing-objects' :
  104 + this.elementFormsManager.register(new amdaPlotComp.PlotDrawingObjectForm({id : formId}));
  105 + break;
  106 + case 'constant' :
  107 + this.elementFormsManager.register(new amdaPlotComp.PlotConstantForm({id : formId}));
  108 + break;
101 109 case '' :
102 110 this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'Select an element to the tree to show options'}));
103 111 break;
... ...
js/app/views/PlotComponents/PlotTree.js
... ... @@ -191,6 +191,9 @@ Ext.define('amdaPlotComp.PlotTree', {
191 191  
192 192 //create legends node
193 193 this.buildPanelLegendsNode(panelObject, objectsNode, selectedObjectId);
  194 +
  195 + //create drawing objects node
  196 + this.buildDrawingObjectsNode(panelObject, objectsNode, selectedObjectId);
194 197 },
195 198  
196 199 buildPanelLegendsNode: function(panelObject, objectsNode, selectedObjectId) {
... ... @@ -212,6 +215,21 @@ Ext.define('amdaPlotComp.PlotTree', {
212 215 this.getSelectionModel().select(selectedTextLegendNode);
213 216 },
214 217  
  218 + buildDrawingObjectsNode: function(panelObject, objectsNode, selectedObjectId) {
  219 + var drawingObjectsNode = objectsNode.appendChild(new amdaPlotObj.PlotDrawingObjectsTreeNode({object : panelObject}));
  220 +
  221 + var selectedConstantNode = null;
  222 + panelObject.constants().each(function (constantObject) {
  223 + var constantNode = drawingObjectsNode.appendChild(new amdaPlotObj.PlotConstantTreeNode({object : constantObject}));
  224 + if (constantObject.get('id') == selectedObjectId)
  225 + selectedConstantNode = constantNode;
  226 + });
  227 +
  228 + this.getView().refresh();
  229 + if (selectedConstantNode)
  230 + this.getSelectionModel().select(selectedConstantNode);
  231 + },
  232 +
215 233 addPanelNode: function(panelObject) {
216 234 var panelNode = this.panelsNode.appendChild(new amdaPlotObj.PlotPanelTreeNode({object : panelObject}));
217 235 if (!this.isSimplifiedView)
... ...
js/resources/css/amda.css
... ... @@ -458,6 +458,22 @@ p + p {
458 458 background-image:url( ../images/16x16/plot_additional_text_legend.png ) !important;
459 459 }
460 460  
  461 +.icon-plot-add-drawing-objs {
  462 + background-image:url( ../images/16x16/plot_additional_drawing_objs.png ) !important;
  463 +}
  464 +
  465 +.icon-plot-add-drawing-constant {
  466 + background-image:url( ../images/16x16/plot_additional_drawing_constant.png ) !important;
  467 +}
  468 +
  469 +.icon-plot-add-drawing-curve {
  470 + background-image:url( ../images/16x16/plot_additional_drawing_curve.png ) !important;
  471 +}
  472 +
  473 +.icon-plot-add-drawing-text {
  474 + background-image:url( ../images/16x16/plot_additional_drawing_text.png ) !important;
  475 +}
  476 +
461 477 .x-item-disabled .x-form-item-label {
462 478 filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100) !important;
463 479 opacity: 1.0 !important;
... ...
js/resources/images/16x16/plot_additional_drawing_constant.png 0 → 100644

156 Bytes

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

175 Bytes

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

217 Bytes

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

186 Bytes