Simply3DScan
ConfigurationControl.Filter.cs
Go to the documentation of this file.
1 using System;
2 using System.Globalization;
3 using Configuration;
4 using SharedObjects;
5 
6 namespace Simple3DScan.UI
7 {
8  partial class ConfigurationControl
9  {
13  [LogException]
14  private void InitFilterValues()
15  {
16  this.checkBoxUseHSLFilter.Checked = this.configuration.Filter.UseHslFilter;
17  this.checkBoxUseHSLFilter.CheckedChanged += this.CheckBoxUseHslFilterOnCheckedChanged;
18 
19  this.numericHueMin.Value = this.configuration.Filter.HueMin;
20  this.numericHueMin.ValueChanged += this.NumericHueMinOnValueChanged;
21 
22  this.numericHueMax.Value = this.configuration.Filter.HueMax;
23  this.numericHueMax.ValueChanged += this.NumericHueMaxOnValueChanged;
24 
25  this.textBoxSaturationMin.Text =
26  this.configuration.Filter.SaturationMin.ToString(CultureInfo.InvariantCulture);
27  this.textBoxSaturationMin.TextChanged += this.TextBoxSaturationMinOnTextChanged;
28 
29  this.textBoxSaturationMax.Text =
30  this.configuration.Filter.SaturationMax.ToString(CultureInfo.InvariantCulture);
31  this.textBoxSaturationMax.TextChanged += this.TextBoxSaturationMaxOnTextChanged;
32 
33  this.textBoxLuminanceMin.Text = this.configuration.Filter.LuminanceMin.ToString(CultureInfo.InvariantCulture);
34  this.textBoxLuminanceMin.TextChanged += this.TextBoxLuminanceMinOnTextChanged;
35 
36  this.textBoxLuminanceMax.Text = this.configuration.Filter.LuminanceMax.ToString(CultureInfo.InvariantCulture);
37  this.textBoxLuminanceMax.TextChanged += this.TextBoxLuminanceMaxOnTextChanged;
38 
39  this.checkBoxUseColorFilter.Checked = this.configuration.Filter.UseColorFilter;
40  this.checkBoxUseColorFilter.CheckedChanged += this.CheckBoxUseColorFilterOnCheckedChanged;
41 
42  this.numericRedMin.Value = this.configuration.Filter.FilterRedMin;
43  this.numericRedMin.ValueChanged += this.NumericRedMinOnValueChanged;
44 
45  this.numericRedMax.Value = this.configuration.Filter.FilterRedMax;
46  this.numericRedMax.ValueChanged += this.NumericRedMaxOnValueChanged;
47 
48  this.numericGreenMin.Value = this.configuration.Filter.FilterGreenMin;
49  this.numericGreenMin.ValueChanged += this.NumericGreenMinOnValueChanged;
50 
51  this.numericGreenMax.Value = this.configuration.Filter.FilterGreenMax;
52  this.numericGreenMax.ValueChanged += this.NumericGreenMaxOnValueChanged;
53 
54  this.numericBlueMin.Value = this.configuration.Filter.FilterBlueMin;
55  this.numericBlueMin.ValueChanged += this.NumericBlueMinOnValueChanged;
56 
57  this.numericBlueMax.Value = this.configuration.Filter.FilterBlueMax;
58  this.numericBlueMax.ValueChanged += this.NumericBlueMaxOnValueChanged;
59 
60  string[] allowedGrayFilters = {"BT709", "RMY", "Y"};
61 
62  int i = 0;
63 
64  foreach (string grayFilter in allowedGrayFilters)
65  {
66  this.comboBoxGrayFilter.Items.Add(grayFilter);
67 
68  if (this.configuration.Filter.GrayFilter.ToString() == grayFilter)
69  this.comboBoxGrayFilter.SelectedIndex = i;
70  i++;
71  }
72 
73  this.comboBoxGrayFilter.SelectedIndexChanged += this.comboBoxGrayFilter_SelectedIndexChanged;
74 
75  this.checkBoxUseThresholdFilter.Checked = this.configuration.Filter.UseThresholdFilter;
76  this.checkBoxUseThresholdFilter.CheckStateChanged += this.CheckBoxUseThresholdFilterOnCheckStateChanged;
77 
78  this.numericThreshold.Value = this.configuration.Filter.Threshold;
79  this.numericThreshold.ValueChanged += this.NumericThresholdOnValueChanged;
80 
81  this.checkBoxUseErosionFilter.Checked = this.configuration.Filter.UseErosionFilter;
82  this.checkBoxUseErosionFilter.CheckedChanged += this.CheckBoxUseErosionFilterOnCheckedChanged;
83 
84  this.checkBoxUseDiletationFilter.Checked = this.configuration.Filter.UseDiletationFilter;
85  this.checkBoxUseDiletationFilter.CheckStateChanged += this.CheckBoxUseDiletationFilterOnCheckStateChanged;
86  }
87 
93  [Log]
94  [LogException]
95  private void CheckBoxUseHslFilterOnCheckedChanged(object sender, EventArgs eventArgs)
96  {
97  this.configuration.Filter.UseHslFilter = this.checkBoxUseHSLFilter.Checked;
98  }
99 
105  [Log]
106  [LogException]
107  private void NumericHueMinOnValueChanged(object sender, EventArgs eventArgs)
108  {
109  this.configuration.Filter.HueMin = (int) this.numericHueMin.Value;
110  }
111 
117  [Log]
118  [LogException]
119  private void NumericHueMaxOnValueChanged(object sender, EventArgs eventArgs)
120  {
121  this.configuration.Filter.HueMax = (int) this.numericHueMax.Value;
122  }
123 
129  [Log]
130  [LogException]
131  private void TextBoxSaturationMinOnTextChanged(object sender, EventArgs e)
132  {
133  this.configuration.Filter.SaturationMin = float.Parse(this.textBoxSaturationMin.Text);
134  }
135 
141  [Log]
142  [LogException]
143  private void TextBoxSaturationMaxOnTextChanged(object sender, EventArgs e)
144  {
145  this.configuration.Filter.SaturationMax = float.Parse(this.textBoxSaturationMax.Text);
146  }
147 
153  [Log]
154  [LogException]
155  private void TextBoxLuminanceMinOnTextChanged(object sender, EventArgs e)
156  {
157  this.configuration.Filter.LuminanceMin = float.Parse(this.textBoxLuminanceMin.Text);
158  }
159 
165  [Log]
166  [LogException]
167  private void TextBoxLuminanceMaxOnTextChanged(object sender, EventArgs eventArgs)
168  {
169  this.configuration.Filter.LuminanceMax = float.Parse(this.textBoxLuminanceMax.Text);
170  }
171 
177  [Log]
178  [LogException]
179  private void CheckBoxUseColorFilterOnCheckedChanged(object sender, EventArgs e)
180  {
181  this.configuration.Filter.UseColorFilter = this.checkBoxUseColorFilter.Checked;
182  }
183 
189  [Log]
190  [LogException]
191  private void NumericRedMinOnValueChanged(object sender, EventArgs eventArgs)
192  {
193  this.configuration.Filter.FilterRedMin = (int) this.numericRedMin.Value;
194  }
195 
201  [Log]
202  [LogException]
203  private void NumericRedMaxOnValueChanged(object sender, EventArgs eventArgs)
204  {
205  this.configuration.Filter.FilterRedMax = (int) this.numericRedMax.Value;
206  }
207 
213  [Log]
214  [LogException]
215  private void NumericGreenMinOnValueChanged(object sender, EventArgs eventArgs)
216  {
217  this.configuration.Filter.FilterGreenMin = (int) this.numericGreenMin.Value;
218  }
219 
225  [Log]
226  [LogException]
227  private void NumericGreenMaxOnValueChanged(object sender, EventArgs eventArgs)
228  {
229  this.configuration.Filter.FilterGreenMax = (int) this.numericGreenMax.Value;
230  }
231 
237  [Log]
238  [LogException]
239  private void NumericBlueMinOnValueChanged(object sender, EventArgs eventArgs)
240  {
241  this.configuration.Filter.FilterBlueMin = (int) this.numericBlueMin.Value;
242  }
243 
249  [Log]
250  [LogException]
251  private void NumericBlueMaxOnValueChanged(object sender, EventArgs eventArgs)
252  {
253  this.configuration.Filter.FilterBlueMax = (int) this.numericBlueMax.Value;
254  }
255 
261  [Log]
262  [LogException]
263  private void comboBoxGrayFilter_SelectedIndexChanged(object sender, EventArgs e)
264  {
265  this.configuration.Filter.GrayFilter = EnumHelper.ParseEnum<GrayFilter>(this.comboBoxGrayFilter.Text);
266  }
267 
273  [Log]
274  [LogException]
275  private void CheckBoxUseThresholdFilterOnCheckStateChanged(object sender, EventArgs eventArgs)
276  {
277  this.configuration.Filter.UseThresholdFilter = this.checkBoxUseThresholdFilter.Checked;
278  }
279 
285  [Log]
286  [LogException]
287  private void NumericThresholdOnValueChanged(object sender, EventArgs eventArgs)
288  {
289  this.configuration.Filter.Threshold = (int) this.numericThreshold.Value;
290  }
291 
297  [Log]
298  [LogException]
299  private void CheckBoxUseErosionFilterOnCheckedChanged(object sender, EventArgs eventArgs)
300  {
301  this.configuration.Filter.UseErosionFilter = this.checkBoxUseErosionFilter.Checked;
302  }
303 
309  [Log]
310  [LogException]
311  private void CheckBoxUseDiletationFilterOnCheckStateChanged(object sender, EventArgs eventArgs)
312  {
313  this.configuration.Filter.UseDiletationFilter = this.checkBoxUseDiletationFilter.Checked;
314  }
315 
316  [Log]
317  [LogException]
318  private void buttonLoadIDefaults_Click(object sender, EventArgs e)
319  {
320  this.DetachFilterEvents();
321  this.comboBoxGrayFilter.Items.Clear();
322  this.configuration.Filter = Config.CreateDefaultFilter();
323  this.InitFilterValues();
324  }
325 
326  private void DetachFilterEvents()
327  {
328  this.checkBoxUseHSLFilter.CheckedChanged -= this.CheckBoxUseHslFilterOnCheckedChanged;
329  this.numericHueMin.ValueChanged -= this.NumericHueMinOnValueChanged;
330  this.numericHueMax.ValueChanged -= this.NumericHueMaxOnValueChanged;
331  this.textBoxSaturationMin.TextChanged -= this.TextBoxSaturationMinOnTextChanged;
332  this.textBoxSaturationMax.TextChanged -= this.TextBoxSaturationMaxOnTextChanged;
333  this.textBoxLuminanceMin.TextChanged -= this.TextBoxLuminanceMinOnTextChanged;
334  this.textBoxLuminanceMax.TextChanged -= this.TextBoxLuminanceMaxOnTextChanged;
335  this.checkBoxUseColorFilter.CheckedChanged -= this.CheckBoxUseColorFilterOnCheckedChanged;
336  this.numericRedMin.ValueChanged -= this.NumericRedMinOnValueChanged;
337  this.numericRedMax.ValueChanged -= this.NumericRedMaxOnValueChanged;
338  this.numericGreenMin.ValueChanged -= this.NumericGreenMinOnValueChanged;
339  this.numericGreenMax.ValueChanged -= this.NumericGreenMaxOnValueChanged;
340  this.numericBlueMin.ValueChanged -= this.NumericBlueMinOnValueChanged;
341  this.numericBlueMax.ValueChanged -= this.NumericBlueMaxOnValueChanged;
342  this.comboBoxGrayFilter.SelectedIndexChanged -= this.comboBoxGrayFilter_SelectedIndexChanged;
343  this.checkBoxUseThresholdFilter.CheckStateChanged -= this.CheckBoxUseThresholdFilterOnCheckStateChanged;
344  this.numericThreshold.ValueChanged -= this.NumericThresholdOnValueChanged;
345  this.checkBoxUseErosionFilter.CheckedChanged -= this.CheckBoxUseErosionFilterOnCheckedChanged;
346  this.checkBoxUseDiletationFilter.CheckStateChanged -= this.CheckBoxUseDiletationFilterOnCheckStateChanged;
347  }
348 
349  #region startstop
350  [Log]
354  [LogException]
355  internal void Stop()
356  {
357  this.imagingControl.StopImaging();
358  }
359 
363  [Log]
364  [LogException]
365  internal void Start()
366  {
367  this.imagingControl.StartImaging(this.configuration.Camera.Name);
368  this.imagingControl.FilterLaser = true;
369  this.imagingControl.ShowLaserLine = true;
370  }
371  #endregion
372  }
373 }
static Filter CreateDefaultFilter()
Creates the default filter.
Definition: Config.cs:218
Class for accessing the configuration.
Definition: Config.cs:12