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

Ext.define('amdaPlotComp.PlotSerieForm', {
	extend: 'amdaPlotComp.PlotStandardForm',
	
	setObject : function(object) {
		this.object = object.get('param-drawing-object');
		this.loadRecord(this.object);
		this.updateOptions(this.crtTree.getSelectedPlotType());
	},
	
	updateOptions: function(plotType) {
		var isScatter = (plotType == 'xyPlot');
		
		var xParamField = this.getForm().findField('serie-xaxis-param');
		var resamplingModeField = this.getForm().findField('serie-resampling-mode');
		var timeTickTypeField = this.getForm().findField('serie-timetick-type');
		var timeTickFieldSet = timeTickTypeField.findParentByType('fieldset');
		
		xParamField.setVisible(isScatter);
		resamplingModeField.setVisible(isScatter);
		timeTickFieldSet.setVisible(isScatter);
		
		if (isScatter)
		{
			//Update Time Tick field
			var timeTickStepField = this.getForm().findField('serie-timetick-step');
			var timeTickNbMajorField = this.getForm().findField('serie-timetick-nbmajor');
			switch (timeTickTypeField.getValue())
			{
			case 'time-step' :
				timeTickStepField.setVisible(true);
				timeTickNbMajorField.setVisible(false);
				break;
			case 'nb-major' :
				timeTickStepField.setVisible(false);
				timeTickNbMajorField.setVisible(true);
				break;
			case 'auto' :
			default :
				timeTickStepField.setVisible(false);
				timeTickNbMajorField.setVisible(false);
			}
		}
	},
	
	getTimeTickItems: function() {
		var me = this;
		return [
			this.addStandardCombo('serie-timetick-type', 'Type', amdaPlotObj.PlotObjectConfig.availableTimeTickTypes, function(name, value, oldValue) {
				me.updateOptions(me.crtTree.getSelectedPlotType());
			}),
		    this.addStandardFloat('serie-timetick-step', 'Time step (sec.)'),
			this.addStandardFloat('serie-timetick-nbmajor', 'Number of major ticks'),
			this.addStandardFloat('serie-timetick-nbminor', 'Number of minor ticks'),
			this.addStandardColor('serie-timetick-color', 'Color', amdaPlotObj.PlotObjectConfig.availableColors),
			this.addStandardFieldSet('Symbols', '', this.addStandardSymbolsItems('serie-timetick-symbols')),
			this.addStandardFieldSet('First symbol', 'serie-timetick-firstsymbols-activated', this.addStandardSymbolsItems('serie-timetick-firstsymbols')),
			this.addStandardFont('serie-timetick-font')
		];
	},
	
	getFormItems: function() {
		return [
		    this.addStandardParamDropTarget('serie-xaxis-param', 'X Parameter'),
		    this.addStandardCombo('serie-resampling-mode', 'Reference parameter for resampling', amdaPlotObj.PlotObjectConfig.availableResamplingModes),
		    this.addStandardCombo('serie-yaxis', 'Y axis', amdaPlotObj.PlotObjectConfig.availableYAxes),
		    this.addStandardParamDropTarget('serie-colored-param', 'Colored Parameter'),
		    this.addStandardFieldSet('Lines', 'serie-lines-activated', this.addStandardLineItems('serie-lines')),
		    this.addStandardFieldSet('Symbols', 'serie-symbols-activated', this.addStandardSymbolsItems('serie-symbols')),
		    this.addStandardFieldSet('Time ticks', 'serie-timetick-activated', this.getTimeTickItems())
		];
	}
});