PlotFillForm.js 3.12 KB
/**
 * Project   : AMDA-NG
 * Name      : PlotFillForm.js
 * @class   amdaPlotComp.PlotFillForm
 * @extends amdaPlotComp.PlotStandardForm
 * @brief   Form to define specifics fill options
 * @author  Benjamin Renard
 * @version $Id: PlotFillForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotFillForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
	
	requires: [
	           'amdaPlotObj.PlotCurveDef'
	],
	
	setObject : function(object) {
		this.object = object;
		if (this.object != null)
		{
			this.updateSerieIdLists();
			this.updateConstantIdList();
			this.loadRecord(this.object);
			this.updateOptions();
		}
	},
	
	updateOptions : function() {
		var typeField = this.getForm().findField('fill-type');
		var secondSerieField = this.getForm().findField('fill-secondserie-id');
		var constantField = this.getForm().findField('fill-constant-id');
		
		var isSerieSerie = (typeField.getValue() == 'serie-serie');
		
		secondSerieField.setVisible(isSerieSerie);
		constantField.setVisible(!isSerieSerie);
	},
	
	updateSerieIdLists: function() {
		var firstSerieField = this.getForm().findField('fill-firstserie-id');
		var secondSerieField = this.getForm().findField('fill-secondserie-id');
		
		firstSerieField.getStore().removeAll();
		secondSerieField.getStore().removeAll();
		
		var panelObject = this.crtTree.getSelectedPanelObject();
		if (panelObject == null)
			return;
		
		panelObject.params().each(function(paramObject) {
			var drawingType = paramObject.get('param-drawing-type');
			if ((drawingType == 'serie') || (drawingType == 'orbit-serie'))
			{
				firstSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
				secondSerieField.getStore().add({key : paramObject.get('id'), value : paramObject.getShortInfo(panelObject.get('panel-plot-type'))});
			}
		});
	},
	
	updateConstantIdList: function() {
		var constantField = this.getForm().findField('fill-constant-id');
		
		constantField.getStore().removeAll();
		
		var panelObject = this.crtTree.getSelectedPanelObject();
		if (panelObject == null)
			return;
		
		panelObject.constants().each(function(constantObject) {
			constantField.getStore().add({key : constantObject.get('id'), value : constantObject.getShortInfo()});
		});
	},
	
	getFormItems: function() {
		var me = this;
		
		return [
		        
		        this.addStandardCombo('fill-type', 'Fill type', amdaPlotObj.PlotObjectConfig.availableFillTypes, function(name, value, oldValue) {
		        	if (me.object.get('fill-type') != value)
		        	{
		        		me.updateOptions();
		        		me.object.set('fill-type', value);
		        		me.crtTree.refresh();
		        	}
		        }),
		        this.addStandardCombo('fill-firstserie-id', 'First serie Id', []),
		        this.addStandardCombo('fill-secondserie-id', 'Second serie Id', []),
		        this.addStandardCombo('fill-constant-id', 'Constant Id', []),
			this.addColorsPicker('fill-greater-color', 'Greater Color', amdaPlotObj.PlotObjectConfig.availableColorsNew, 'none'),
		        this.addColorsPicker('fill-less-color', 'Less Color', amdaPlotObj.PlotObjectConfig.availableColorsNew, 'none')
        ];
	}
});