PlotSerieForm.js 3.68 KB
/**
 * Project   : AMDA-NG
 * Name      : PlotSerieForm.js
 * @class   amdaPlotComp.PlotSerieForm
 * @extends amdaPlotComp.PlotBaseSerieForm
 * @brief   Form to define specifics serie options
 * @author  Benjamin Renard
 * @version $Id: PlotSerieForm.js benjamin $
 */

Ext.define('amdaPlotComp.PlotSerieForm', {
	extend: 'amdaPlotComp.PlotBaseSerieForm',
	
	updateOptions: function(plotType) {
		var isScatter = (plotType == 'xyPlot');
		
		var xParamField = this.getForm().findField('serie-xaxis-param');
		var xValueMinField = this.getForm().findField('serie-xvalue-min');
		var xValueFieldSet = xValueMinField.findParentByType('fieldset');
		var resamplingModeField = this.getForm().findField('serie-resampling-mode');
		
		xParamField.setVisible(isScatter);
		xValueFieldSet.setVisible(isScatter);
		resamplingModeField.setVisible(isScatter);
		
		var errorBarTypeField = this.getForm().findField('serie-errorbar-type');
		var errorBarFieldSet = errorBarTypeField.findParentByType('fieldset');
		
		errorBarFieldSet.setVisible(!isScatter);
		
		if (!isScatter)
		{
			var errorMinField = this.getForm().findField('serie-errorbar-minparam');
			var errorMaxField = this.getForm().findField('serie-errorbar-maxparam');
			var errorDeltaField = this.getForm().findField('serie-errorbar-deltaparam');
			
			errorMinField.setVisible(errorBarTypeField.getValue() == 'min-max');
			errorMaxField.setVisible(errorBarTypeField.getValue() == 'min-max');
			errorDeltaField.setVisible(errorBarTypeField.getValue() == 'delta');
		}
		
		this.callParent(arguments);
	},
	
	getErrorBarItems: function() {
		var me = this;
		
		return [
			this.addStandardCombo('serie-errorbar-type', 'Type', amdaPlotObj.PlotObjectConfig.availableErrorBarTypes, function(name, value, oldValue) {
		    	me.updateOptions(me.crtTree.getSelectedPlotType());
			}),
			this.addStandardParamDropTarget('serie-errorbar-minparam', 'Min. Parameter'),
			this.addStandardParamDropTarget('serie-errorbar-maxparam', 'Max. Parameter'),
			this.addStandardParamDropTarget('serie-errorbar-deltaparam', 'Delta Parameter'),
			this.addStandardFieldSet('Bar Lines', '', this.addStandardLineItems('serie-errorbar-lines'))
		];
	},
	
	getXValuesRangeItems: function() {
		return [
		        this.addStandardFloat2('serie-xvalue-min', 'Min value', -Number.MAX_VALUE, Number.MAX_VALUE, true),
		        this.addStandardFloat2('serie-xvalue-max', 'Max value', -Number.MAX_VALUE, Number.MAX_VALUE, true)
		];
	},
	
	getFormItems: function() {
		var me = this;
		
		var baseSerieItems = this.callParent(arguments);
		
		var serieItems = [
			this.addStandardParamDropTarget('serie-xaxis-param', 'X Parameter', function(name, value, oldValue) {
				me.object.set('serie-xaxis-param', value);
        		me.crtTree.refresh();
			}),
			this.addStandardFieldSet('X Values range', '', this.getXValuesRangeItems()),
			this.addStandardCombo('serie-resampling-mode', 'Reference parameter for resampling', amdaPlotObj.PlotObjectConfig.availableResamplingModes)
		];
		
		Ext.each(baseSerieItems, function(item) {
			serieItems.push(item);
		});
		
		serieItems.push(this.addStandardFieldSet('Error Bar', 'serie-errorbar-activated', this.getErrorBarItems()));
                                   /**
                var colorPicker = Ext.create('Ext.menu.ColorPicker', {
                                                    value: '000000'
                            });
                var colorMenu =Ext.create('Ext.menu.Menu', {
                                items: [{
                                    text: 'Choose a color',
                                    menu: colorPicker
                                }]
                            }).show();
		serieItems.push(colorMenu); */
		return serieItems;
	}
});