Commit a8c54fb9cffd46420e7ac77564903e33826f367f

Authored by Benjamin Renard
1 parent 829160b3

Add text object plot definition

js/app/models/PlotObjects/PlotObjectConfig.js
... ... @@ -148,6 +148,17 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
148 148 width : 1,
149 149 color : '#000000'
150 150 }
  151 + },
  152 + textObjs : {
  153 + yAxisId : 'y-left',
  154 + xRelative : true,
  155 + yRelative : true,
  156 + align : 'left',
  157 + color : '#000000',
  158 + font : {
  159 + name : 'sans-serif',
  160 + size: '12'
  161 + }
151 162 }
152 163 },
153 164  
... ... @@ -337,5 +348,11 @@ Ext.define('amdaPlotObj.PlotObjectConfig', {
337 348 {'key' : 'x', 'value' : 'X / Time / Epoch'},
338 349 {'key' : 'y-left', 'value' : 'Y Left'},
339 350 {'key' : 'y-right', 'value' : 'Y Right'}
  351 + ],
  352 +
  353 + availableTextAlignments : [
  354 + {'key' : 'left', 'value' : 'Left'},
  355 + {'key' : 'center', 'value' : 'Center'},
  356 + {'key' : 'right', 'value' : 'Right'}
340 357 ]
341 358 });
342 359 \ No newline at end of file
... ...
js/app/models/PlotObjects/PlotPanelObject.js
... ... @@ -26,7 +26,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
26 26 'amdaPlotObj.PlotParamObject',
27 27 'amdaPlotObj.PlotLegendSeriesObject',
28 28 'amdaPlotObj.PlotLegendTextObject',
29   - 'amdaPlotObj.PlotConstantObject'
  29 + 'amdaPlotObj.PlotConstantObject',
  30 + 'amdaPlotObj.PlotTextObject'
30 31 ],
31 32  
32 33 fields : [
... ... @@ -104,6 +105,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
104 105 name : 'constants'
105 106 },
106 107 {
  108 + type : 'hasMany',
  109 + model : 'amdaPlotObj.PlotTextObject',
  110 + name : 'textObjs'
  111 + },
  112 + {
107 113 type : 'belongsTo',
108 114 model : 'amdaPlotObj.PlotTabObject'
109 115 }
... ... @@ -122,6 +128,8 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
122 128 me.loadTextLegends(arguments[0].textLegends);
123 129 if (arguments[0].constants)
124 130 me.loadConstants(arguments[0].constants);
  131 + if (arguments[0].textObjs)
  132 + me.loadTextObjs(arguments[0].textObjs);
125 133 }
126 134 else
127 135 {
... ... @@ -150,6 +158,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
150 158 this.constants().loadData(constants);
151 159 },
152 160  
  161 + loadTextObjs: function(textObjs)
  162 + {
  163 + this.textObjs().loadData(textObjs);
  164 + },
  165 +
153 166 initAxes : function()
154 167 {
155 168 this.axes().removeAll();
... ... @@ -266,6 +279,22 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
266 279 return true;
267 280 },
268 281  
  282 + createNewTextObject: function() {
  283 + var recs = this.textObjs().add({id : this.get('id')+'-text-object-'+this.lastTextObjectId});
  284 + ++this.lastTextObjectId;
  285 + recs[0].setDefaultValues();
  286 + return recs[0];
  287 + },
  288 +
  289 + removeTextObjectById: function(textObjId) {
  290 + //Retrieve text object record
  291 + var textObjRecord = this.textObjs().getById(textObjId);
  292 + if (textObjRecord == null)
  293 + return false;
  294 + this.textObjs().remove(textObjRecord);
  295 + return true;
  296 + },
  297 +
269 298 updatePlotType: function(plotType, forceUpdate) {
270 299 forceUpdate = (typeof forceUpdate !== 'undefined') ? forceUpdate : false;
271 300  
... ... @@ -414,6 +443,12 @@ Ext.define('amdaPlotObj.PlotPanelObject', {
414 443 panelValues['constants'][index] = constant.getJsonValues();
415 444 });
416 445  
  446 + panelValues['textObjs'] = [];
  447 +
  448 + this.textObjs().each(function (textObj, index) {
  449 + panelValues['textObjs'][index] = textObj.getJsonValues();
  450 + });
  451 +
417 452 panelValues['axes'] = [];
418 453  
419 454 this.axes().each(function (axe, index) {
... ...
js/app/models/PlotObjects/PlotTextObject.js 0 โ†’ 100644
... ... @@ -0,0 +1,91 @@
  1 +/**
  2 + * Projectย  : AMDA-NG
  3 + * Name : PlotTextObject.js
  4 + * @class amdaPlotObj.PlotTextObject
  5 + * @extends Ext.data.Model
  6 + * @brief Plot Constant Business Object Definition
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotTextObject.js benjamin $
  9 + ******************************************************************************
  10 + * FT Id : Date : Name - Description
  11 + ******************************************************************************
  12 + * : :01/09/2015: BRE - file creation
  13 + */
  14 +
  15 +
  16 +Ext.define('amdaPlotObj.PlotTextObject', {
  17 + extend: 'Ext.data.Model',
  18 +
  19 + requires: [
  20 + 'amdaPlotObj.PlotObjectConfig'
  21 + ],
  22 +
  23 + fields : [
  24 + {name: 'text-value', type: 'string'},
  25 + {name: 'text-y-axis', type: 'string'},
  26 + {name: 'text-x-relative', type: 'boolean'},
  27 + {name: 'text-x-floatvalue', type: 'float'},
  28 + {name: 'text-x-timevalue', type: 'date',
  29 + defaultValue:Ext.Date.add(Ext.Date.clearTime(new Date()),Ext.Date.DAY,-1),
  30 + convert: function(value,rec) {
  31 + if (!Ext.isDate(value)) {
  32 + var valueString = new String(value);
  33 + var date = new Date(valueString.replace(/\-/g,'\/').replace(/[T|Z]/g,' '));
  34 + return date;
  35 + }
  36 + return value;
  37 + }
  38 + },
  39 + {name: 'text-y-relative', type: 'boolean'},
  40 + {name: 'text-y-value', type: 'float'},
  41 + {name: 'text-angle', type: 'float'},
  42 + {name: 'text-color', type: 'string'},
  43 + {name: 'text-align', type: 'string'},
  44 + {name: 'text-font-activated', type: 'boolean'},
  45 + {name: 'text-font-name', type: 'string'},
  46 + {name: 'text-font-size', type: 'int'},
  47 + {name: 'text-font-bold', type: 'boolean'},
  48 + {name: 'text-font-italic', type: 'boolean'}
  49 + ],
  50 +
  51 + setDefaultValues: function()
  52 + {
  53 + this.set('text-value', '');
  54 + this.set('text-y-axis', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.yAxisId);
  55 + this.set('text-x-relative', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.xRelative);
  56 + this.set('text-x-floatvalue', 0.);
  57 + this.set('text-y-relative', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.yRelative);
  58 + this.set('text-y-value', 0.);
  59 + this.set('text-angle', 0.);
  60 + this.set('text-color', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.color);
  61 + this.set('text-align', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.align);
  62 + this.set('text-font-activated', false);
  63 + this.set('text-font-name', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.font.name);
  64 + this.set('text-font-size', amdaPlotObj.PlotObjectConfig.defaultValues.textObjs.font.size);
  65 + this.set('text-font-bold', false);
  66 + this.set('text-font-italic', false);
  67 + },
  68 +
  69 + getJsonValues : function()
  70 + {
  71 + var textValues = new Object();
  72 +
  73 + textValues['text-value'] = this.get('text-value');
  74 + textValues['text-y-axis'] = this.get('text-y-axis');
  75 + textValues['text-x-relative'] = this.get('text-x-relative');
  76 + textValues['text-x-floatvalue'] = this.get('text-x-floatvalue');
  77 + textValues['text-x-timevalue'] = this.get('text-x-timevalue');
  78 + textValues['text-y-relative'] = this.get('text-y-relative');
  79 + textValues['text-y-value'] = this.get('text-y-value');
  80 + textValues['text-angle'] = this.get('text-angle');
  81 + textValues['text-color'] = this.get('text-color');
  82 + textValues['text-align'] = this.get('text-align');
  83 + textValues['text-font-activated'] = this.get('text-font-activated');
  84 + textValues['text-font-name'] = this.get('text-font-name');
  85 + textValues['text-font-size'] = this.get('text-font-size');
  86 + textValues['text-font-bold'] = this.get('text-font-bold');
  87 + textValues['text-font-italic'] = this.get('text-font-italic');
  88 +
  89 + return textValues;
  90 + }
  91 +});
0 92 \ No newline at end of file
... ...
js/app/models/PlotObjects/PlotTreeNode.js
... ... @@ -314,24 +314,16 @@ Ext.define('amdaPlotObj.PlotConstantTreeNode', {
314 314 removable: true
315 315 });
316 316  
317   -
318   -/*
319   - * .icon-plot-add-objs {
320   - background-image:url( ../images/16x16/plot_additional_objs.png ) !important;
321   -}
322   -
323   -.icon-plot-add-legends {
324   - background-image:url( ../images/16x16/plot_additional_legends.png ) !important;
325   -}
326   -
327   -.icon-plot-add-legend-series {
328   - background-image:url( ../images/16x16/plot_additional_series_legend.png ) !important;
329   -}
330   -
331   -.icon-plot-add-legends-text {
332   - background-image:url( ../images/16x16/plot_additional_text_legends.png ) !important;
333   -}
334   -
335   -.icon-plot-add-legend-text {
336   - background-image:url( ../images/16x16/plot_additional_text_legend.png ) !important;
337   -}*/
  317 +Ext.define('amdaPlotObj.PlotTextTreeNode', {
  318 + extend: 'amdaPlotObj.PlotTreeNode',
  319 +
  320 + leaf: true,
  321 +
  322 + iconCls: 'icon-plot-add-drawing-text',
  323 +
  324 + text: 'Text',
  325 +
  326 + type: 'text-obj',
  327 +
  328 + removable: true
  329 +});
... ...
js/app/views/PlotComponents/PlotDrawingObjectForm.js
... ... @@ -28,6 +28,15 @@ Ext.define('amdaPlotComp.PlotDrawingObjectForm', {
28 28 var constantObject = me.object.createNewConstant();
29 29 me.crtTree.buildPanelAdditionalObjectsNode(me.object, constantObject.get('id'));
30 30 }
  31 + },
  32 + {
  33 + xtype: 'button',
  34 + text: 'Add new text',
  35 + iconCls: 'icon-add',
  36 + handler : function() {
  37 + var textObject = me.object.createNewTextObject();
  38 + me.crtTree.buildPanelAdditionalObjectsNode(me.object, textObject.get('id'));
  39 + }
31 40 }
32 41 ];
33 42 }
... ...
js/app/views/PlotComponents/PlotElementPanel.js
... ... @@ -24,7 +24,8 @@ Ext.define('amdaPlotComp.PlotElementPanel', {
24 24 'amdaPlotComp.PlotLegendTextForm',
25 25 'amdaPlotComp.PlotLegendsTextForm',
26 26 'amdaPlotComp.PlotDrawingObjectForm',
27   - 'amdaPlotComp.PlotConstantForm'
  27 + 'amdaPlotComp.PlotConstantForm',
  28 + 'amdaPlotComp.PlotTextForm'
28 29 ],
29 30  
30 31 elementFormsManager : new Ext.AbstractManager(),
... ... @@ -106,6 +107,9 @@ Ext.define('amdaPlotComp.PlotElementPanel', {
106 107 case 'constant' :
107 108 this.elementFormsManager.register(new amdaPlotComp.PlotConstantForm({id : formId}));
108 109 break;
  110 + case 'text-obj' :
  111 + this.elementFormsManager.register(new amdaPlotComp.PlotTextForm({id : formId}));
  112 + break;
109 113 case '' :
110 114 this.elementFormsManager.register(new Ext.form.Label({id : formId, text: 'Select an element to the tree to show options'}));
111 115 break;
... ...
js/app/views/PlotComponents/PlotOutputForm.js
... ... @@ -50,11 +50,11 @@ Ext.define('amdaPlotComp.PlotOutputForm', {
50 50 var me = this;
51 51  
52 52 return [
53   - this.addStandardCombo('file-format', 'File format', amdaPlotObj.PlotObjectConfig.availableFileFormats, function(name, value) {
  53 + this.addStandardCombo('file-format', 'File format', amdaPlotObj.PlotObjectConfig.availableFileFormats, function(name, value, oldValue) {
54 54 me.updateOutputOption();
55 55 me.updateOneFilePerIntOption();
56 56 }),
57   - this.addStandardCombo('file-output', 'File output', amdaPlotObj.PlotObjectConfig.availableFileOutputs, function(name, value) {
  57 + this.addStandardCombo('file-output', 'File output', amdaPlotObj.PlotObjectConfig.availableFileOutputs, function(name, value, oldValue) {
58 58 me.updateFilePrefixOption();
59 59 }),
60 60 this.addStandardText('file-prefix', 'File prefix'),
... ...
js/app/views/PlotComponents/PlotPageForm.js
... ... @@ -28,13 +28,13 @@ Ext.define('amdaPlotComp.PlotPageForm', {
28 28 var me = this;
29 29 return [
30 30 //this.addStandardCombo('page-mode', 'Mode', amdaPlotObj.PlotObjectConfig.availablePageModes),
31   - this.addStandardCombo('page-orientation', 'Orientation', amdaPlotObj.PlotObjectConfig.availablePageOrientations, function(name, value) {
  31 + this.addStandardCombo('page-orientation', 'Orientation', amdaPlotObj.PlotObjectConfig.availablePageOrientations, function(name, value, oldValue) {
32 32 me.crtTree.getView().refresh();
33 33 }),
34   - this.addStandardCombo('page-dimension', 'Dimension', amdaPlotObj.PlotObjectConfig.availablePageDimensions, function(name, value) {
  34 + this.addStandardCombo('page-dimension', 'Dimension', amdaPlotObj.PlotObjectConfig.availablePageDimensions, function(name, value, oldValue) {
35 35 me.crtTree.getView().refresh();
36 36 }),
37   - this.addStandardCheck('page-superpose-mode', 'Epoch Superposed Mode', function(name, value) {
  37 + this.addStandardCheck('page-superpose-mode', 'Epoch Superposed Mode', function(name, value, oldValue) {
38 38 me.crtTree.getView().refresh();
39 39 }),
40 40 this.addStandardFieldSet('Title', '', titleItems),
... ...
js/app/views/PlotComponents/PlotStandardForm.js
... ... @@ -89,7 +89,7 @@ Ext.define('amdaPlotComp.PlotStandardForm', {
89 89 change: function(combo, newValue, oldValue, eOpts) {
90 90 this.object.set(name, newValue);
91 91 if (onChange != null)
92   - onChange(name, newValue);
  92 + onChange(name, newValue, oldValue);
93 93 },
94 94 scope: this
95 95 }
... ... @@ -105,7 +105,7 @@ Ext.define('amdaPlotComp.PlotStandardForm', {
105 105 change: function(combo, newValue, oldValue, eOpts) {
106 106 this.object.set(name, newValue);
107 107 if (onChange != null)
108   - onChange(name, newValue);
  108 + onChange(name, newValue, oldValue);
109 109 },
110 110 scope: this
111 111 }
... ... @@ -228,7 +228,7 @@ Ext.define('amdaPlotComp.PlotStandardForm', {
228 228 change: function(combo, newValue, oldValue, eOpts) {
229 229 this.object.set(name, newValue);
230 230 if (onChange != null)
231   - onChange(name, newValue);
  231 + onChange(name, newValue, oldValue);
232 232 },
233 233 scope: this
234 234 }
... ...
js/app/views/PlotComponents/PlotTextForm.js 0 โ†’ 100644
... ... @@ -0,0 +1,81 @@
  1 +/**
  2 + * Projectย  : AMDA-NG
  3 + * Name : PlotTextForm.js
  4 + * @class amdaPlotComp.PlotTextForm
  5 + * @extends amdaPlotComp.PlotStandardForm
  6 + * @brief Form to define specifics Text object options
  7 + * @author Benjamin Renard
  8 + * @version $Id: PlotTextForm.js benjamin $
  9 + */
  10 +
  11 +Ext.define('amdaPlotComp.PlotTextForm', {
  12 + extend: 'amdaPlotComp.PlotStandardForm',
  13 +
  14 + setObject : function(object) {
  15 + this.object = object;
  16 + if (this.object != null)
  17 + {
  18 + this.loadRecord(this.object);
  19 + this.updateOptions(this.crtTree.getSelectedPlotType());
  20 + }
  21 + },
  22 +
  23 + updateOptions: function(plotType) {
  24 + var xRelativeField = this.getForm().findField('text-x-relative');
  25 + var xFloatValueField = this.getForm().findField('text-x-floatvalue');
  26 + var xTimeValueField = this.getForm().findField('text-x-timevalue');
  27 + var yRelativeField = this.getForm().findField('text-y-relative');
  28 + var yValueField = this.getForm().findField('text-y-value');
  29 + var yAxisField = this.getForm().findField('text-y-axis');
  30 +
  31 + var isTimePlot = (plotType == 'timePlot');
  32 +
  33 + if (xRelativeField.getValue())
  34 + {
  35 + xFloatValueField.setMinValue(0);
  36 + xFloatValueField.setMaxValue(1);
  37 + }
  38 + else
  39 + {
  40 + xFloatValueField.setMinValue(-Number.MAX_VALUE);
  41 + xFloatValueField.setMaxValue(Number.MAX_VALUE);
  42 + }
  43 +
  44 + xFloatValueField.setVisible(!(isTimePlot && !xRelativeField.getValue()));
  45 + xTimeValueField.setVisible(isTimePlot && !xRelativeField.getValue());
  46 +
  47 + if (yRelativeField.getValue())
  48 + {
  49 + yAxisField.setVisible(false);
  50 + yValueField.setMinValue(0);
  51 + yValueField.setMaxValue(1);
  52 + }
  53 + else
  54 + {
  55 + yAxisField.setVisible(true);
  56 + yValueField.setMinValue(-Number.MAX_VALUE);
  57 + yValueField.setMaxValue(Number.MAX_VALUE);
  58 + }
  59 + },
  60 +
  61 + getFormItems: function() {
  62 + var me = this;
  63 + return [
  64 + this.addStandardText('text-value', 'Text'),
  65 + this.addStandardColor('text-color', 'Color', amdaPlotObj.PlotObjectConfig.availableColors),
  66 + this.addStandardCombo('text-align', 'Alignment', amdaPlotObj.PlotObjectConfig.availableTextAlignments),
  67 + this.addStandardCheck('text-x-relative', 'Relative X Position', function(name, value, oldValue) {
  68 + me.updateOptions(me.crtTree.getSelectedPlotType());
  69 + }),
  70 + this.addStandardFloat('text-x-floatvalue', 'X Position', 0, 1),
  71 + this.addStandardDate('text-x-timevalue', 'X Position', 0, 1),
  72 + this.addStandardCheck('text-y-relative', 'Relative Y Position', function(name, value, oldValue) {
  73 + me.updateOptions(me.crtTree.getSelectedPlotType());
  74 + }),
  75 + this.addStandardCombo('text-y-axis', 'Y Axis attachment', amdaPlotObj.PlotObjectConfig.availableYAxes),
  76 + this.addStandardFloat('text-y-value', 'Y Position', 0, 1),
  77 + this.addStandardFloat('text-angle', 'Rotation Angle', 0, 360),
  78 + this.addStandardFont('text-font')
  79 + ];
  80 + }
  81 +});
0 82 \ No newline at end of file
... ...
js/app/views/PlotComponents/PlotTree.js
... ... @@ -218,6 +218,7 @@ Ext.define('amdaPlotComp.PlotTree', {
218 218 buildDrawingObjectsNode: function(panelObject, objectsNode, selectedObjectId) {
219 219 var drawingObjectsNode = objectsNode.appendChild(new amdaPlotObj.PlotDrawingObjectsTreeNode({object : panelObject}));
220 220  
  221 + //Constants
221 222 var selectedConstantNode = null;
222 223 panelObject.constants().each(function (constantObject) {
223 224 var constantNode = drawingObjectsNode.appendChild(new amdaPlotObj.PlotConstantTreeNode({object : constantObject}));
... ... @@ -225,9 +226,21 @@ Ext.define('amdaPlotComp.PlotTree', {
225 226 selectedConstantNode = constantNode;
226 227 });
227 228  
  229 + //Texts
  230 + var selectedTextNode = null;
  231 + panelObject.textObjs().each(function (textObject) {
  232 + var textNode = drawingObjectsNode.appendChild(new amdaPlotObj.PlotTextTreeNode({object : textObject}));
  233 + if (textObject.get('id') == selectedObjectId)
  234 + selectedTextNode = textNode;
  235 + });
  236 +
  237 + //Refresh & selection
228 238 this.getView().refresh();
229 239 if (selectedConstantNode)
230 240 this.getSelectionModel().select(selectedConstantNode);
  241 +
  242 + if (selectedTextNode)
  243 + this.getSelectionModel().select(selectedTextNode);
231 244 },
232 245  
233 246 addPanelNode: function(panelObject) {
... ...