/**
 * Project      : AMDA-NG
 * Name         : PlotObjectConfig.js
 * @class   amdaPlotObj.PlotObjectConfig
 * @extends Ext.data.Model
 * @brief   Plot Request object configuration 
 * @author  Benjamin Renard
 * @version $Id: PlotObjectConfig.js benjamin $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :21/07/2015: BRE  - file creation
 */


Ext.define('amdaPlotObj.PlotObjectConfig', {
	singleton: true,

	defaultValues: {
		file: {
			format: 'PNG',
			output: 'INTERACTIVE',
			oneFilePerInterval: false
		},
		tree: {
			fullView: false
		},
		page: {
			xMargin: 5.,
			yMargin: 5.,
			mode: 'color',
			orientation: 'landscape',
			dimension: 'ISO A4',
			title: {
				position: 'top',
				alignment: ' center',
				color: '#000000'
			},
			font: {
				name: 'sans-serif',
				size: '8'
			},
			layout: {
				type: 'vertical',
				panelHeight: 0.5,
				panelSpacing: 0.,
				expand: false,
				timeAxesLegend: true
			}
		},
		panel: {
			plotType: 'timePlot',
			isotropic: false,
			title: {
				position: 'top',
				alignment: ' center',
				color: '#000000'
			},
			font: {
				name: 'sans-serif',
				size: '8'
			},
			backgroundColor: 'none',
			status: {
				position: 'top',
				colorMap: 0
			}
		},
		axis: {
			scale: 'linear',
			tickPosition: 'outwards',
			color: '#000000',
			thickness: '1',
			legend: {
				color: '#000000',
				font: {
					name: 'sans-serif',
					size: '8'
				}
			},
			timeFormat: 'dd/mm/yy',
			colorMap: '1'
		},
		serie: {
			yAxis: 'y-left',
			resolution: 3000,
			lines: {
				style: 'plain',
				width: 1,
				color: 'auto'
			},
			symbols: {
				type: 'dot',
				size: 3,
				color: 'auto'
			},
			resamplingMode: 'xparam',
			timetick: {
				type: 'auto',
				step: 3600,
				nbmajor: 5,
				nbminor: 5,
				color: '#FF0000',
				symbols: {
					type: 'full-circle',
					size: 10,
					color: '#FF0000'
				},
				firstsymbols: {
					type: 'triangle',
					size: 4,
					color: '#00FF00'
				},
				font: {
					name: 'sans-serif',
					size: '8'
				}
			},
			intervaltick: {
				mode: 'start-time',
				color: '#FF0000',
				symbols: {
					type: 'full-circle',
					size: 10,
					color: '#FF0000'
				},
				font: {
					name: 'sans-serif',
					size: '8'
				}
			},
			errorbar: {
				type: 'min-max',
				lines: {
					style: 'plain',
					width: 1,
					color: 'auto'
				}
			},
			projection: 'XY',
		},
		spectro: {
			yAxis: 'y-left',
			resolution: 3000
		},
		sauvaud: {
			yAxis: 'y-right',
			resolution: 3000
		},
		intervals: {
			color: "#FF0000"
		},
		statusbar: {
			color: "#FF0000"
		},
		legends: {
			series: {
				type: 'text-only',
				position: 'outside',
				text: {
					color: '#000000'
				},
				border: {
					color: '#000000'
				},
				intervalinfo: {
					type: 'start-stop'
				},
				font: {
					name: 'sans-serif',
					size: '8'
				}
			},
			text: {
				position: 'left',
				color: '#000000',
				font: {
					name: 'sans-serif',
					size: '8'
				}
			}
		},
		constants: {
			axisId: 'y-left',
			line: {
				style: 'plain',
				width: 1,
				color: '#000000'
			}
		},
		textObjs: {
			yAxisId: 'y-left',
			xRelative: true,
			yRelative: true,
			align: 'left',
			color: '#000000',
			font: {
				name: 'sans-serif',
				size: '8'
			}
		},
		curves: {
			line: {
				style: 'plain',
				width: 1,
				color: '#000000'
			}
		},
		fills: {
			type: 'serie-constant',
			greaterColor: 'none',
			lessColor: 'none'
		},
		filtering: {
			level: 1
		}
	},

	getValueByKey: function (dataList, key) {
		var value = '';
		Ext.each(dataList, function (data) {
			if (data.key == key) {
				value = data.value;
				return;
			}
		});
		return value;
	},

	availableFileFormats: [
		{ 'key': 'PNG', 'value': 'PNG' },
		{ 'key': 'PDF', 'value': 'PDF' },
		{ 'key': 'PS', 'value': 'PS' },
		{ 'key': 'SVG', 'value': 'SVG' }
	],

	availableFileOutputsForPng: [
		{ 'key': 'INTERACTIVE', 'value': 'screen' },
		{ 'key': 'TGZ', 'value': 'tar+gzip archive' },
		{ 'key': 'ZIP', 'value': 'zip archive' }
	],

	availableFileOutputsForOtherFormats: [
		{ 'key': 'TGZ', 'value': 'tar+gzip archive' },
		{ 'key': 'ZIP', 'value': 'zip archive' }
	],

	availablePageModes: [
		{ 'key': 'color', 'value': 'Color' },
		{ 'key': 'grayscale', 'value': 'Grayscale' }
	],

	availablePageOrientations: [
		{ 'key': 'landscape', 'value': 'Landscape' },
		{ 'key': 'portrait', 'value': 'Portrait' }
	],

	availablePageDimensions: [
		{ 'key': 'ISO A4', 'value': 'ISO A4' },
		{ 'key': 'US letter', 'value': 'US letter' }
	],

	availablePlotTypes: [
		{ 'key': 'timePlot', value: 'Time Plot' },
		{ 'key': 'xyPlot', value: 'Scatter Plot' },
		{ 'key': 'epochPlot', value: 'Epoch Plot' },
		{ 'key': 'instantPlot', value: 'Instant Plot' },
		{ 'key': 'statusPlot', value: 'Status Plot' },
		{ 'key': 'tickPlot', value: 'Tick Plot' }
	],

	availableFontNames: [
		{ 'key': 'sans-serif', 'value': 'sans-serif' },
		{ 'key': 'serif', 'value': 'serif' },
		{ 'key': 'monospace', 'value': 'monospace' },
		{ 'key': 'script', 'value': 'script' }
	],

	availableTitlePositions: [
		{ 'key': 'top', 'value': 'Top' },
		{ 'key': 'bottom', 'value': 'Bottom' }
	],

	availableTitleAlignments: [
		{ 'key': 'center', 'value': 'Center' },
		{ 'key': 'left', 'value': 'Left' },
		{ 'key': 'right', 'value': 'Right' }
	],

	availableAxisScales: [
		{ 'key': 'linear', 'value': 'Linear' },
		{ 'key': 'logarithmic', 'value': 'Logarithmic' }
	],

	availableTicksPositions: [
		{ 'key': 'inwards', 'value': 'Inwards' },
		{ 'key': 'outwards', 'value': 'Outwards' }
	],

	availableTimeAxisFormats: [
		{ 'key': 'dd/mm/yy', 'value': 'dd/mm/yy' },
		{ 'key': 'ddd/yy', 'value': 'ddd/yy' },
		{ 'key': 'DD/MM/YYYY', 'value': 'dd/mm/yyyy' },
		{ 'key': 'yyyy/dd/mm', 'value': 'yyyy/dd/mm' },
		{ 'key': 'yyyy-dd-mm', 'value': 'yyyy-dd-mm' }
	],

	availableYAxes: [
		{ 'key': 'y-left', 'value': 'Left' },
		{ 'key': 'y-right', 'value': 'Right' }
	],

	availableResolutions: [
		{ 'key': 3000, 'value': '3000' },
		{ 'key': 10000, 'value': '10000' },
		{ 'key': 50000, 'value': '50000' },
		{ 'key': 100000, 'value': '100000' }
	],

	availableLinesStyles: [
		{ 'key': 'plain', 'value': 'Plain' },
		{ 'key': 'dot', 'value': 'Dot' },
		{ 'key': 'long-spaced-dot', 'value': 'Long spaced dot' },
		{ 'key': 'long-short-dot', 'value': 'Long short dot' }
	],

	availableSymbolsTypes: [
		{ 'key': 'dot', 'value': 'Dot' },
		{ 'key': 'plus', 'value': 'Plus' },
		{ 'key': 'wildcard', 'value': 'Wildcard' },
		{ 'key': 'circle', 'value': 'Circle' },
		{ 'key': 'crux', 'value': 'Crux' },
		{ 'key': 'square', 'value': 'Square' },
		{ 'key': 'triangle', 'value': 'Triangle' },
		{ 'key': 'crux-in-circle', 'value': 'Crux in circle' },
		{ 'key': 'dot-in-circle', 'value': 'Dot in circle' },
		{ 'key': 'diamond', 'value': 'Diamond' },
		{ 'key': 'star', 'value': 'Star' },
		{ 'key': 'david-star', 'value': 'David star' },
		{ 'key': 'full-square', 'value': 'Full square' },
		{ 'key': 'full-circle', 'value': 'Full circle' },
		{ 'key': 'full-star', 'value': 'Full star' }
	],

	availableColorMaps: [
		{ 'key': '0', 'value': 'Blue Red' },
		{ 'key': '1', 'value': 'Default' },
		{ 'key': '2', 'value': 'Blue Yellow' },
		{ 'key': '3', 'value': 'Grayscale' },
		{ 'key': '4', 'value': 'AMDA Default' },
		{ 'key': '5', 'value': 'GeoWhite' },
		{ 'key': '6', 'value': 'GeoBlack' },
		{ 'key': '7', 'value': 'Violet Yellow' },
		{ 'key': '8', 'value': 'Red Blue 4' }
	],

	availableColors: [
		{ 'key': 'auto', 'color': 'auto', 'value': 'auto' },
		{ 'key': '[0,0,0]', 'color': '#000000', 'value': 'Black' },
		{ 'key': '[0,0,255]', 'color': '#0000ff', 'value': 'Blue' },
		{ 'key': '[255,0,0]', 'color': '#ff0000', 'value': 'Red' },
		{ 'key': '[0,255,255]', 'color': '#00ffff', 'value': 'Cyan' },
		{ 'key': '[255,0,255]', 'color': '#ff00ff', 'value': 'Magenta' },
		{ 'key': '[0,128,0]', 'color': '#008000', 'value': 'Green' },
		{ 'key': '[128,128,128]', 'color': '#808080', 'value': 'Gray' },
		{ 'key': '[0,255,0]', 'color': '#00ff00', 'value': 'Lime' },
		{ 'key': '[128,0,0]', 'color': '#800000', 'value': 'Maroon' },
		{ 'key': '[0,0,128]', 'color': '#000080', 'value': 'Navy' },
		{ 'key': '[128,128,0]', 'color': '#808000', 'value': 'Olive' },
		{ 'key': '[128,0,128]', 'color': '#800080', 'value': 'Purple' },
		{ 'key': '[192,192,192]', 'color': '#c0c0c0', 'value': 'Silver' },
		{ 'key': '[0,128,128]', 'color': '#008080', 'value': 'Teal' },
		{ 'key': '[255,255,0]', 'color': '#ffff00', 'value': 'Yellow' },
		{ 'key': '[0,64,64]', 'color': '#004040', 'value': 'Cyprus' }
	],

	availableColorsNew: [
		"#000000", "#0000ff", "#ff0000", "#00ffff", "#ff00ff", "#008000", "#800000",
		"#000080", "#808000", "#800080", "#c0c0c0", "#008080", "#ffff00", "#004040",
		"#29d8d7", "#6b9842", "#73a9b4", "#1c883d", "#808080", "#4342dd", "#e84130",
		"#dee2e6", "#ced4da", "#adb5bd", "#868e96", "#495057", "#343a40", "#212529",
		"#ffa8a8", "#ff8787", "#ff6b6b", "#fa5252", "#f03e3e", "#e03131", "#c92a2a",
		"#faa2c1", "#f783ac", "#f06595", "#e64980", "#d6336c", "#c2255c", "#a61e4d",
		"#e599f7", "#da77f2", "#cc5de8", "#be4bdb", "#ae3ec9", "#9c36b5", "#862e9c",
		"#b197fc", "#9775fa", "#845ef7", "#7950f2", "#7048e8", "#6741d9", "#5f3dc4",
		"#91a7ff", "#748ffc", "#5c7cfa", "#4c6ef5", "#4263eb", "#3b5bdb", "#364fc7",
		"#74c0fc", "#4dabf7", "#339af0", "#228be6", "#1c7ed6", "#1971c2", "#1864ab",
		"#66d9e8", "#3bc9db", "#22b8cf", "#15aabf", "#1098ad", "#0c8599", "#0b7285",
		"#63e6be", "#38d9a9", "#20c997", "#12b886", "#0ca678", "#099268", "#087f5b",
		"#8ce99a", "#69db7c", "#51cf66", "#40c057", "#37b24d", "#2f9e44", "#2b8a3e",
		"#c0eb75", "#a9e34b", "#94d82d", "#82c91e", "#74b816", "#66a80f", "#5c940d",
		"#ffe066", "#ffd43b", "#fcc419", "#fab005", "#f59f00", "#f08c00", "#e67700",
		"#ffc078", "#ffa94d", "#ff922b", "#fd7e14", "#f76707", "#e8590c", "#d9480f"
	],

	availableBackgroundColors: [
		{ 'color': 'none', 'value': 'None' },
		{ 'key': '[0,0,0]', 'color': '#000000', 'value': 'Black' },
		{ 'key': '[0,0,255]', 'color': '#0000FF', 'value': 'Blue' },
		{ 'key': '[255,0,0]', 'color': '#FF0000', 'value': 'Red' },
		{ 'key': '[0,255,255]', 'color': '#00FFFF', 'value': 'Cyan' },
		{ 'key': '[255,0,255]', 'color': '#FF00FF', 'value': 'Magenta' },
		{ 'key': '[0,128,0]', 'color': '#008000', 'value': 'Green' },
		{ 'key': '[128,128,128]', 'color': '#808080', 'value': 'Gray' },
		{ 'key': '[0,255,0]', 'color': '#00FF00', 'value': 'Lime' },
		{ 'key': '[128,0,0]', 'color': '#800000', 'value': 'Maroon' },
		{ 'key': '[0,0,128]', 'color': '#000080', 'value': 'Navy' },
		{ 'key': '[128,128,0]', 'color': '#808000', 'value': 'Olive' },
		{ 'key': '[128,0,128]', 'color': '#800080', 'value': 'Purple' },
		{ 'key': '[192,192,192]', 'color': '#C0C0C0', 'value': 'Silver' },
		{ 'key': '[0,128,128]', 'color': '#008080', 'value': 'Teal' },
		{ 'key': '[255,255,0]', 'color': '#FFFF00', 'value': 'Yellow' },
		{ 'key': '[0,64,64]', 'color': '#004040', 'value': 'Cyprus' }
	],

	availableStatusBarPositions: [
		{ 'key': 'top', 'value': 'Top' },
		{ 'key': 'bottom', 'value': 'Bottom' }
	],

	availableStatusBarColorMaps: [
		{ 'key': '0', 'value': '0' },
		{ 'key': '1', 'value': '1' },
		{ 'key': '2', 'value': '2' }
	],

	availablePageLayouts: [
		{ 'key': 'vertical', 'value': 'Vertical' },
		{ 'key': 'auto', 'value': 'Auto' },
		{ 'key': 'manual', 'value': 'Manual' }
	],

	availableResamplingModes: [
		{ 'key': 'xparam', 'value': 'X Parameter' },
		{ 'key': 'yparam', 'value': 'Y Parameter' }
	],

	availableOrbitSerieProjections: [
		{ 'key': 'XY', 'value': 'XY' },
		{ 'key': 'XZ', 'value': 'XZ' },
		{ 'key': 'YZ', 'value': 'YZ' },
		{ 'key': 'XR', 'value': 'XR' },
		{ 'key': 'YR', 'value': 'YR' },
		{ 'key': 'ZR', 'value': 'ZR' }
	],

	availableDimsOnXAxis: [
		{ 'key': '0', 'value': 'First dimension' },
		{ 'key': '1', 'value': 'Second dimension' }
	],

	availableTimeTickTypes: [
		{ 'key': 'auto', 'value': 'Auto' },
		{ 'key': 'time-step', 'value': 'Time step' },
		{ 'key': 'nb-major', 'value': 'Num. of major symb.' }
	],

	availableIntervalTickModes: [
		{ 'key': 'symbol-only', 'value': 'Symbol only' },
		{ 'key': 'interval-index', 'value': 'Interval index' },
		{ 'key': 'start-time', 'value': 'Start time' },
		{ 'key': 'start-stop-time', 'value': 'Start/Stop times' }
	],

	availableErrorBarTypes: [
		{ 'key': 'min-max', 'value': 'Min./Max. Parameters' },
		{ 'key': 'delta', 'value': 'Delta parameter' }
	],

	availableLegendSeriesTypes: [
		{ 'key': 'text-line-symbol', 'value': 'Text, Line & Symbols' },
		{ 'key': 'text-only', 'value': 'Text only' }
	],

	availableLegendSeriesPositions: [
		{ 'key': 'inside', 'value': 'Inside' },
		{ 'key': 'outside', 'value': 'Outside' }
	],

	availableLegendSeriesIntervalInfoTypes: [
		{ 'key': 'index', 'value': 'Interval Index' },
		{ 'key': 'start-stop', 'value': 'Interval Start/Stop' }
	],

	availableLegendTextPositions: [
		{ 'key': 'right', 'value': 'Right' },
		{ 'key': 'left', 'value': 'Left' },
		{ 'key': 'top', 'value': 'Top' },
		{ 'key': 'bottom', 'value': 'Bottom' }
	],

	availableConstantAxes: [
		{ 'key': 'x', 'value': 'X / Time / Epoch' },
		{ 'key': 'y-left', 'value': 'Y Left' },
		{ 'key': 'y-right', 'value': 'Y Right' }
	],

	availableTextAlignments: [
		{ 'key': 'left', 'value': 'Left' },
		{ 'key': 'center', 'value': 'Center' },
		{ 'key': 'right', 'value': 'Right' }
	],

	availableFillTypes: [
		{ 'key': 'serie-constant', 'value': 'Serie / Constant' },
		{ 'key': 'serie-serie', 'value': 'Serie / Serie' }
	],
	availableSpectroNormalization: [
		{ 'key': 'none', 'value': 'None' },
		{ 'key': 'linear', 'value': 'Linear' },
		{ 'key': 'log', 'value': 'Logarithmic' }
	],

	availableFilteringLevel: [
		{ 'key': 1, 'value': 'Weak' },
		{ 'key': 2, 'value': 'Intermediate/moderated' },
		{ 'key': 3, 'value': 'Strong' }
	],

	fieldComboBox: {
		key: 'key',
		value: 'value'
	},

	bgSubstraction: {
		tableName: "channels-param-info",
		tableChannels: "channels",
		tableRelatedDim: 'relatedDim',
		name: 'Background Substraction',
		type: {
			label: "Type ",
			key: "background_sub_type",
			values: {
				bychannel: "By Channel",
				fixedvalue: "Fixed Value"
			}
		},
		value: {
			textinputlabel: "Fixed value ",
			key: "background_sub_value",
			textinputkey: "background_sub_by_value",
			dimlabel: 'Dim ',
			dimkey: 'background_sub_dim',
			dimNullValue: "-1"
		}
	},
	getParamConfig: function (paramId, onParamConfigLoaded) {
		AmdaAction.getParamPlotInit({ "paramId": paramId }, function (result, e) {
			onParamConfigLoaded(result.success, result.data);
		});
	}
});