cs.pro.DecimatePanel = Ext.extend(Ext.FormPanel, {

	initComponent: function()
	{
		this.decimateOptions = new cs.pro.DecimateOptions();

		Ext.apply(this, {
			title: 'Decimater',
			frame: true,
			autoHeight: true,
			items:[
				this.decimateOptions
			]
		});

		cs.pro.ResurfacePanel.superclass.initComponent.apply(this, arguments);
	}
});

cs.pro.DecimateOptions = Ext.extend(Ext.form.FieldSet, {

	getDecimate: function()
	{
		var file;
		if((file = cs.pro.viewport.getSelectedFile()) == false) return;
		Ext.Ajax.request({
			url: 'json/pro_job_decimate',
			params: {
				file: file.get('id'),
				angle: this.angle.getValue(),
				dec: this.dec.getValue()
			},
			callback: this.gotDecimate,
			scope: this
		});
	},
	
	gotDecimate: function(options, success, response)
	{
		if(response = cs.common.lib.errorFilter(success, response, this.getDecimate))
		{
			cs.pro.viewport.addTab(response.filename, 'prodecimate', response.job);
		}
	},

	initComponent: function()
	{
		this.dec = new cs.common.SliderPanel({
			label: 'Decimation',
			startValue: 8,
			maxValue: 10
		});

		this.angle = new cs.common.SliderPanel({
			label: 'Angle',
			startValue: 5,
			maxValue: 10
		});
		
		this.begin = new Ext.Button({
			text: 'Process Selected File',
			handler: this.getDecimate,
			scope: this
		});

		Ext.apply(this, {
			title: 'Processing Options',
			autoHeight: true,
			style: 'padding-left: 10px; padding-right: 10px;',
			items: [
				this.dec,
				this.angle
			],
			buttons: [
				this.begin
			]
		});

		cs.pro.DecimateOptions.superclass.initComponent.apply(this, arguments);
	}
});
