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

Ext.define('amdaPlotComp.PlotPanelForm', {
	extend: 'amdaPlotComp.PlotStandardForm',

	setObject : function(object) {
		this.object = object;
		this.loadRecord(this.object);
		this.updateOptions(this.object.get('panel-plot-type'));
	},
	
	updateOptions: function(plotType) {
		var plotTypeField = this.getForm().findField('panel-plot-type');
		
		//Scatter field set visibility
		var isotropicField = this.getForm().findField('panel-scatter-isotropic');
		
		isotropicField.setVisible(plotType == 'xyPlot');
		
		//Status field set visibility
		var statusBarAvailable = ((plotType == 'timePlot') || (plotType == 'statusPlot'));
		
		var statusPositionField = this.getForm().findField('panel-status-position');
		var statusFieldSet = statusPositionField.findParentByType('fieldset');
		
		statusFieldSet.setVisible(statusBarAvailable);
		
		//Tick field set visibility
		var tickBarAvailable = ((plotType == 'timePlot') || (plotType == 'tickPlot'));
		
		var tickFormatField = this.getForm().findField('panel-tick-format');
		var tickFieldSet = tickFormatField.findParentByType('fieldset');
		
		tickFieldSet.setVisible(tickBarAvailable);
		
		//Epoch center time id visibility
		var centerTimeIdField = this.getForm().findField('panel-epoch-centertimeid');
		
		centerTimeIdField.setVisible(plotType == 'epochPlot');
		
		//Instant time visibility
		var instantTimeField = this.getForm().findField('panel-instant-time');
		
		instantTimeField.setVisible(plotType == 'instantPlot');
		
		//Options in relation with the layout
		this.updateLayoutOptions(plotType);
	},
	
	updateLayoutOptions: function(plotType) {
		//Margins and Bounds visibility in relation with the layout type
		var isManualLayout = this.crtTree.tabObject && (this.crtTree.tabObject.get('page-layout-type') == 'manual');
		var isVerticalLayout = this.crtTree.tabObject && (this.crtTree.tabObject.get('page-layout-type') == 'vertical');
		
		var xBoundsField = this.getForm().findField('panel-bounds-x');
		var boundFieldSet = xBoundsField.findParentByType('fieldset');
		boundFieldSet.setVisible(isManualLayout);
		
		var marginLeftField = this.getForm().findField('panel-margin-left');
		var marginsFieldSet = marginLeftField.findParentByType('fieldset');
		marginsFieldSet.setVisible(isManualLayout);
		
		var preferedWidthField = this.getForm().findField('panel-prefered-width');
		var preferedDimFieldSet = preferedWidthField.findParentByType('fieldset');
		preferedDimFieldSet.setVisible(isVerticalLayout);
		preferedWidthField.setVisible((plotType == 'xyPlot') || (plotType == 'instantPlot'));
	},
	
	getFormItems: function() {
		
		
		var boundsItems = [
		        this.addStandardFloat('panel-bounds-x', 'X Position', 0, 1),
		        this.addStandardFloat('panel-bounds-y', 'Y Position', 0, 1),
		        this.addStandardFloat('panel-bounds-width', 'Width', 0, 1),
		        this.addStandardFloat('panel-bounds-height', 'Height', 0, 1)
		];
		
		var marginItems = [
		        this.addStandardFloat('panel-margin-left', 'Left Margin', 0, 100, true),
		        this.addStandardFloat('panel-margin-right', 'Right Margin', 0, 100, true)
		];
		
		var preferedDimItems = [
                this.addStandardFloat('panel-prefered-width', 'Prefered Width', 0, 1, true),
                this.addStandardFloat('panel-prefered-height', 'Prefered Height', 0, 1, true)
		];
		
		var titleItems = [
		  		this.addStandardText('panel-title-text', 'Text'),
		  		this.addStandardColor('panel-title-color', 'Color', amdaPlotObj.PlotObjectConfig.availableColors),
		  		this.addStandardCombo('panel-title-position', 'Position', amdaPlotObj.PlotObjectConfig.availableTitlePositions),
		  		this.addStandardCombo('panel-title-alignment', 'Alignment', amdaPlotObj.PlotObjectConfig.availableTitleAlignments),
		  		this.addStandardFont('panel-title-font')
		];
		
		var statusItems = [
		   		this.addStandardCombo('panel-status-position', 'Position', amdaPlotObj.PlotObjectConfig.availableStatusBarPositions),
				this.addStandardCombo('panel-status-colormap', 'Color Map', amdaPlotObj.PlotObjectConfig.availableStatusBarColorMaps)
        ];
		
		var tickItems = [
                this.addStandardText('panel-tick-format', 'Format')
		];
		
		
		
		var me = this;
		return [
		        this.addStandardCombo('panel-plot-type', 'Plot type', amdaPlotObj.PlotObjectConfig.availablePlotTypes, function(name, value, oldValue) {
		        	if (value != oldValue)
		        	{
		        		me.object.updatePlotType(value, true);
		        		if (!me.crtTree.isSimplifiedView)
		        			me.crtTree.buildPanelAxesNode(me.object);
		        		me.crtTree.getView().refresh();
		        		me.updateOptions(value);
		        	}
		        }),
		        this.addStandardCheck('panel-scatter-isotropic', 'Isotropic'), 
		        this.addStandardText('panel-epoch-centertimeid', 'Epoch Center Time Id'),
		        this.addStandardDate('panel-instant-time', 'Instant time'),
		        this.addStandardColor('panel-background-color', 'Background Color', amdaPlotObj.PlotObjectConfig.availableBackgroundColors),
		        this.addStandardFieldSet('Manual Bounds', '', boundsItems),
		        this.addStandardFieldSet('Manual Margins', '', marginItems),
		        this.addStandardFieldSet('Prefered Dimensions', '', preferedDimItems),
    	        this.addStandardFieldSet('Title', '', titleItems),
		        this.addStandardFont('panel-font'),
		        this.addStandardFieldSet('Status Bars', '', statusItems),
		        this.addStandardFieldSet('Ticks Bars', '', tickItems)
		];
	}
});