Simply3DScan
PrecisionControl.cs
Go to the documentation of this file.
1 using System;
2 using System.Globalization;
3 using System.Windows.Forms;
4 using Configuration;
5 using SharedObjects;
6 using Syncfusion.Windows.Forms.Tools;
7 
8 namespace Simple3DScan.UI
9 {
13  public partial class PrecisionControl : UserControl
14  {
15  private readonly Information configuration = Singleton<Config>.Instance.Information;
16  private Resolution resolution;
17 
21  [LogException]
23  {
24  this.InitializeComponent();
25  }
26 
31  [LogException]
32  internal void Init(Resolution res)
33  {
34  this.resolution = res;
35  this.radialSliderLaserSweepSteps.Value = this.resolution.SweepSteps;
36  this.RadialSliderPrecision.Value = this.resolution.Steps;
37  this.textBoxDegrees.Text = this.resolution.Degrees.ToString(CultureInfo.InvariantCulture);
38  }
39 
45  [Log]
46  [LogException]
47  private void RadialSliderPrecision_ValueChanged(object sender, RadialSlider.ValueChangedEventArgs args)
48  {
49 
50  this.resolution.Steps = (int)Math.Round(this.RadialSliderPrecision.Value);
51  this.RadialSliderPrecision.Value = this.resolution.Steps;
52 
53  float degreePerStep = this.configuration.Motor.MicroStepsEnabled
54  ? 360.0f / (float)(this.configuration.Motor.Steps*this.configuration.Motor.MicroSteps)
55  : 360.0f / (float)this.configuration.Motor.Steps;
56 
57  this.resolution.Degrees = degreePerStep * this.resolution.Steps;
58  this.textBoxDegrees.Text = this.resolution.Degrees.ToString(CultureInfo.InvariantCulture);
59  this.UpdateResolutionConfiguration();
60  }
61 
67  [Log]
68  [LogException]
69  private void radialSliderLaserSweepSteps_ValueChanged(object sender, RadialSlider.ValueChangedEventArgs args)
70  {
71  this.resolution.SweepSteps = (int)Math.Round(this.radialSliderLaserSweepSteps.Value);
72  this.radialSliderLaserSweepSteps.Value = this.resolution.SweepSteps;
73  this.UpdateResolutionConfiguration();
74  }
75 
76  [LogException]
77  private void UpdateResolutionConfiguration()
78  {
79  for (int i = 0; i < this.configuration.Resolutions.Count; i++)
80  {
81  if (this.configuration.Resolutions[i].Precision != this.resolution.Precision)
82  continue;
83 
84  this.configuration.Resolutions[i] = this.resolution;
85  break;
86  }
87  }
88  }
89 }
Configuration of a scan resulution
Definition: Resolution.cs:10
Class holding the configuration information
Definition: Information.cs:8
int Steps
Gets or sets the steps.
Definition: Resolution.cs:33
PrecisionControl()
Initializes a new instance of the PrecisionControl class.
Class for creating a singleton for a generic class
Definition: Singleton.cs:9
static T Instance
Gets the instance.
Definition: Singleton.cs:27
Control for setting a precision
void Init(Resolution res)
Initializes the specified resource.
int SweepSteps
Gets or sets the sweep steps.
Definition: Resolution.cs:41
float Degrees
Gets or sets the degrees.
Definition: Resolution.cs:25