diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-06-22 01:38:35 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-06-22 01:38:35 +0300 |
| commit | 69a5fa82c4633e1c9afa3e0164ff215a8d54c1ed (patch) | |
| tree | ac00f961f9921e5f07be90142fdfeeca0e9cea70 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML | |
| parent | eb1ceefef381a36a752558af89acd1bafb51bc26 (diff) | |
| parent | 37672b35159b7a1ce7b669dc11edcf583b9f7840 (diff) | |
| download | Tango-69a5fa82c4633e1c9afa3e0164ff215a8d54c1ed.tar.gz Tango-69a5fa82c4633e1c9afa3e0164ff215a8d54c1ed.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML')
7 files changed, 592 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs new file mode 100644 index 000000000..87eba8ba2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/CalibrationMeasurementModel.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.BL.Enumerations; +using Tango.PMR.Printing; + +namespace Tango.MachineStudio.RML.Models +{ + public static class ColorCalibrationExt + { + public static Dictionary<LiquidTypes, LAB> TargetLiquidTypeToLAB = new Dictionary<LiquidTypes, LAB> + { + {LiquidTypes.Cyan, new LAB(51.94591,-18.3438,-39.0577)}, + {LiquidTypes.Magenta, new LAB(47.46248, 65.84478, 3.922838)}, + {LiquidTypes.Yellow, new LAB(84.41956,-0.27005, 94.05445)}, + {LiquidTypes.Black, new LAB(26.57986, -0.13567, 0.948574)}, + }; + public static Dictionary<LiquidTypes, string> DisplayLiquidTypeToLABType = new Dictionary<LiquidTypes, string> + { + {LiquidTypes.Cyan, "L"}, + {LiquidTypes.Magenta, "L"}, + {LiquidTypes.Yellow, "B"}, + {LiquidTypes.Black, "L"}, + }; + }; + + public class LAB + { + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + + public LAB( double l, double a, double b) + { + L = l; B = b; A = a; + } + }; + + public class CalibrationMeasurementModel : ExtendedObject + { + #region properties + private double _l; + + public double L + { + get { return _l; } + set { _l = value; RaisePropertyChangedAuto(); } + } + + private double _a; + + public double A + { + get { return _a; } + set { _a = value; RaisePropertyChangedAuto(); } + } + + private double _b; + + public double B + { + get { return _b; } + set { _b = value; RaisePropertyChangedAuto(); } + } + + private double _ink; + + public double Ink + { + get { return _ink; } + set { _ink = value; RaisePropertyChangedAuto(); } + } + #endregion + + public CalibrationMeasurementModel() + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index a413223c3..1f9d56f07 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -49,6 +49,12 @@ <Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> </Reference> + <Reference Include="OxyPlot"> + <HintPath>..\..\..\packages\OxyPlot.Core.2.0.0\lib\net45\OxyPlot.dll</HintPath> + </Reference> + <Reference Include="OxyPlot.Wpf"> + <HintPath>..\..\..\packages\OxyPlot.Wpf.2.0.0\lib\net45\OxyPlot.Wpf.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Data" /> @@ -73,6 +79,7 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="Contracts\IMainView.cs" /> + <Compile Include="Models\CalibrationMeasurementModel.cs" /> <Compile Include="Models\CctModel.cs" /> <Compile Include="RMLModule.cs" /> <Compile Include="Properties\AssemblyInfo.cs"> @@ -93,6 +100,7 @@ <Compile Include="ViewModels\CalibrationDataPointVM.cs" /> <Compile Include="ViewModels\CalibrationDataViewVM.cs" /> <Compile Include="ViewModels\CalibrationDataVM.cs" /> + <Compile Include="ViewModels\ColorCalibrationViewVM.cs" /> <Compile Include="ViewModels\ColorConversionViewVM.cs" /> <Compile Include="ViewModels\LiquidVolumeVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> @@ -103,6 +111,9 @@ <Compile Include="Views\CalibrationDataView.xaml.cs"> <DependentUpon>CalibrationDataView.xaml</DependentUpon> </Compile> + <Compile Include="Views\ColorCalibrationView.xaml.cs"> + <DependentUpon>ColorCalibrationView.xaml</DependentUpon> + </Compile> <Compile Include="Views\ColorConversionView.xaml.cs"> <DependentUpon>ColorConversionView.xaml</DependentUpon> </Compile> @@ -151,6 +162,10 @@ <Project>{40085232-aced-4cbe-945b-90ba8153c151}</Project> <Name>Tango.BrushPicker</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.ColorCalibration\Tango.ColorCalibration.csproj"> + <Project>{b60c695c-61e8-4091-b506-4c45349c04aa}</Project> + <Name>Tango.ColorCalibration</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.ColorConversion\Tango.ColorConversion.csproj"> <Project>{b4fe6485-4161-4b36-bc08-67e0b53d01b7}</Project> <Name>Tango.ColorConversion</Name> @@ -212,6 +227,10 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\ColorCalibrationView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\ColorConversionView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs new file mode 100644 index 000000000..dd0c66c58 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorCalibrationViewVM.cs @@ -0,0 +1,313 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core; +using Tango.Core.Commands; +using Tango.MachineStudio.RML.Models; +using Tango.SharedUI; +using OxyPlot; +using OxyPlot.Wpf; +using OxyPlot.Annotations; +using Tango.ColorCalibration; +using Tango.PMR.ColorLab; +using Tango.Logging; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.RML.ViewModels +{ + public class ColorCalibrationViewVM : ExtendedObject + { + private IColorCalibrator _calibrator; + private INotificationProvider _notification; + + #region Properties + + private Rml _rml; + public Rml RML + { + get { return _rml; } + set { _rml = value; RaisePropertyChangedAuto(); } + } + + private BL.Entities.LiquidType _liquidType; + + public BL.Entities.LiquidType LiquidType + { + get { return _liquidType; } + set { _liquidType = value; RaisePropertyChangedAuto(); } + } + + private List<BL.Entities.LiquidType> _liquidTypes; + + public List<BL.Entities.LiquidType> LiquidTypes + { + get { return _liquidTypes; } + set { _liquidTypes = value; } + } + + + private ObservableCollection<CalibrationMeasurementModel> _measurements; + public ObservableCollection<CalibrationMeasurementModel> Measurements + { + get + { + return _measurements; + } + set + { + _measurements = value; RaisePropertyChangedAuto(); + } + } + + + private double _factor; + + public double Factor + { + get { return _factor; } + set { _factor = value; } + } + + public RelayCommand CreateGraphCommand { get; set; } + + + public string CalibrationType + { + get { return LiquidType == null ?"" : LiquidType.Name; } + } + + public Plot PlotControl { get; set; } + private IList<DataPoint> _points; + /// <summary> + /// Binding to ItemsSource of line chart. + /// </summary> + public IList<DataPoint> Points + { + get { return _points; } + set + { + _points = value; + RaisePropertyChangedAuto(); + } + } + private IList<DataPoint> _targetPoints; + /// <summary> + /// Binding to ItemsSource of line chart. + /// </summary> + public IList<DataPoint> TargetPoints + { + get { return _targetPoints; } + set + { + _targetPoints = value; + RaisePropertyChangedAuto(); + } + } + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } + + private double _from; + /// <summary> + /// From use to binding to bottom axis min value + /// </summary> + public double From + { + get { return _from; } + set + { + _from = value; RaisePropertyChangedAuto(); + } + } + + private double _to; + /// <summary> + /// To use to binding to bottom axis max value + /// </summary> + public double To + { + get { return _to; } + set + { + _to = value; RaisePropertyChangedAuto(); + } + } + + #endregion + + public ColorCalibrationViewVM(INotificationProvider notification) + { + _notification = notification; + Measurements = new ObservableCollection<CalibrationMeasurementModel>() + { + new CalibrationMeasurementModel(), + new CalibrationMeasurementModel(), + new CalibrationMeasurementModel(), + }; + Factor = 0; + CreateGraphCommand = new RelayCommand(CreateGraph); + this.Points = new List<DataPoint>(); + TargetPoints = new List<DataPoint>(); + } + + public void Loading() + { + LiquidType = LiquidTypes.Count > 0 ? LiquidTypes[0] : null; + _calibrator = new DefaultColorCalibrator(); + + } + + private double GetLiquidFactor() + { + try{ + CalibrationInput conversionInput = new CalibrationInput(); + Measurements.ToList().ForEach(x => conversionInput.Measurements.Add(new CalibrationMeasurement{ L = x.L, A = x.A, B = x.B, NanoliterPerCentimeter = x.Ink })); + conversionInput.LiquidType = PMR.ColorLab.LiquidType.TryParse(_liquidType.Type.ToString(), out PMR.ColorLab.LiquidType outValue) ? outValue : PMR.ColorLab.LiquidType.Black; + + + LAB lab; + if (ColorCalibrationExt.TargetLiquidTypeToLAB.TryGetValue(_liquidType.Type, out lab)) + { + conversionInput.TargetL = lab.L; + conversionInput.TargetA = lab.A; + conversionInput.TargetB = lab.B; + } + CalibrationOutput result = _calibrator.GetLiquidFactor(conversionInput); + return result.LiquidFactor; + } + catch (Exception ex ) + { + LogManager.Log(ex, "Error occurred while trying to call GetLiquidFactor."); + } + return 0.0; + } + + #region CreateGraph + + private async void CreateGraph(object obj) + { + if (_liquidType == null) + return; + + LAB lab; + string labType = ColorCalibrationExt.DisplayLiquidTypeToLABType[_liquidType.Type]; + await Task.Factory.StartNew(() => + { + Factor = GetLiquidFactor(); + }); + + Points.Clear(); + TargetPoints.Clear(); + + To = 0; + From = 0; + + Measurements.ToList().ForEach(x =>{ + Points.Add(new DataPoint(x.Ink, x.L)); + TargetPoints.Add(new DataPoint(x.Ink,Factor)); }); + + _to = labType == "L"? 100 : 128; + _from = labType == "L" ? 0 : -127; + + RaisePropertyChanged("To"); + RaisePropertyChanged("From"); + XStep = (int)(Points.Count / 6); + RaisePropertyChanged("CalibrationType"); + PlotControl.InvalidatePlot(true); + + //await Task.Factory.StartNew(() => + //{ + // DataPoint ? intersectionpoints = FindIntersection(Points.ToArray(), TargetPoints.ToArray()); + // if(intersectionpoints == null) + // { + // InvokeUI(() => + // { + // _notification.ShowWarning(LogManager.Log($"No intersect target value with input values", LogCategory.Warning)); + // }); + // } + //}); + + } + + #endregion + + #region Intersect + + public DataPoint? FindIntersection(DataPoint[] line1, DataPoint[] line2) + { + for (int i = 0; i < line1.Length; i++) + { + int nextI = i; + nextI++; + if (nextI == line1.Length) break; + + for (int j = 0; j < line2.Length; j++) + { + int nextJ = j; + nextJ++; + if (nextJ == line2.Length) break; + DataPoint? d = CheckIntersecting(line1[i], line1[nextI], line2[j], line2[nextJ]); + return d; + + } + } + return null; + } + + public DataPoint? CheckIntersecting(DataPoint A, DataPoint B, DataPoint C, DataPoint D) + { + // Line AB represented as a1x + b1y = c1 + double a1 = B.Y - A.Y; + double b1 = A.X - B.X; + double c1 = a1 * (A.X) + b1 * (A.Y); + + // Line CD represented as a2x + b2y = c2 + double a2 = D.Y - C.Y; + double b2 = C.X - D.X; + double c2 = a2 * (C.X) + b2 * (C.Y); + + double determinant = a1 * b2 - a2 * b1; + + if (determinant == 0) + { + // The lines are parallel. This is simplified + } + else + { + double x = (b2 * c1 - b1 * c2) / determinant; + double y = (a1 * c2 - a2 * c1) / determinant; + + // check if the point lies on given line segment + /* To check if "x" is between "a" and "b"; + int m = (a+b)/2; + if(Math.abs(x-m) <= (Math.abs(a-m))) + { + } + */ + double mx1 = (A.X + B.X) / 2; + double mx2 = (C.X + D.X) / 2; + double my1 = (A.Y + B.Y) / 2; + double my2 = (C.Y + D.Y) / 2; + if (Math.Abs(x - mx1) <= Math.Abs(A.X - mx1) + && Math.Abs(x - mx2) <= Math.Abs(C.X - mx2) + && Math.Abs(y - my1) <= Math.Abs(A.Y - my1) + && Math.Abs(y - my2) <= Math.Abs(C.Y - my2)) + { + return new DataPoint(x, y); + } + + } + return null; + } + + #endregion + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index 1ceaf07df..36398a593 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -164,6 +164,12 @@ namespace Tango.MachineStudio.RML.ViewModels set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private ColorCalibrationViewVM _colorCalibrationVM; + public ColorCalibrationViewVM ColorCalibrationVM + { + get { return _colorCalibrationVM; } + set { _colorCalibrationVM = value; RaisePropertyChangedAuto(); } + } /// <summary> /// Gets or sets the manage RML command. @@ -374,6 +380,12 @@ namespace Tango.MachineStudio.RML.ViewModels LiquidTypesRmls = LiquidTypesRmls, }; + ColorCalibrationVM = new ColorCalibrationViewVM(_notification) + { + RML = ActiveRML, + LiquidTypes = LiquidTypesRmls.Where(x => x.LiquidType.HasPigment).ToList().Select(y => y.LiquidType).ToList(), + }; + _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML); View.NavigateTo(RmlNavigationView.RmlView); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml new file mode 100644 index 000000000..02cef3c0d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml @@ -0,0 +1,121 @@ +<UserControl x:Class="Tango.MachineStudio.RML.Views.ColorCalibrationView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:vm="clr-namespace:Tango.MachineStudio.RML.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.RML" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:oxy="http://oxyplot.org/wpf" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + <converters:EmptyStringToNullConverter x:Key="EmptyStringToNullConverter" /> + <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> + </UserControl.Resources> + + <Grid> + <DockPanel> + <Border DockPanel.Dock="Top" Background="{StaticResource TransparentBackgroundBrush200}" Margin="20 0" Padding="5" CornerRadius="5"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16" Padding="2">Color Calibrations</TextBlock> + </Grid> + </Border> + + <Grid Margin="25"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + <Grid Grid.Column="0" Margin="20 0 0 0"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + <RowDefinition Height="1"/> + </Grid.RowDefinitions> + <Border Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="Auto" Height="80" Margin="0 0 0 20" > + <StackPanel Orientation="Vertical"> + <TextBlock FontSize="16" HorizontalAlignment="Left" >Liquid Type</TextBlock> + <ComboBox Margin="0 20 0 0" MinWidth="140" HorizontalAlignment="Left" ItemsSource="{Binding LiquidTypes}" + SelectedItem="{Binding LiquidType}" DisplayMemberPath="Name" + Style="{StaticResource TransparentComboBoxStyle}" FontSize="16"></ComboBox> + </StackPanel> + </Border> + <Grid Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Stretch"> + <Grid.RowDefinitions> + <RowDefinition Height="1*"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <DataGrid HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" Margin="0 0 0 10" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="False" ItemsSource="{Binding Measurements}" > + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Resources> + <Style x:Key="CellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsHitTestVisible" Value="false"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="HideUpDownButtons" Value="true"/> + </Style> + <Style x:Key="EditableCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + </Style> + </DataGrid.Resources> + <DataGrid.Columns> + <mahapps:DataGridNumericUpDownColumn Header="Ink nl/cm" Minimum="0" Maximum="100000" Binding="{Binding Ink}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + <Button Grid.Row="1" Background="{StaticResource TransparentBackgroundBrush200}" MinWidth="160" Height="50" BorderBrush="{StaticResource TransparentBackgroundBrush200}" Command="{Binding CreateGraphCommand}" > + <TextBlock FontSize="16" Foreground="{StaticResource MainWindow.Foreground}">CREATE GRAPH</TextBlock> + </Button> + </Grid> + </Grid> + <Grid Grid.Column="1"> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="20 20 0 0"> + <oxy:Plot Title="{Binding CalibrationType}" x:Name="CalibrationPlot"> + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding Points}" Color="#73B6EC" MarkerFill="SteelBlue" MarkerType="Circle" /> + <oxy:LineSeries ItemsSource="{Binding TargetPoints}" Color="#E14141" MarkerFill="#E14141" MarkerType="Circle" /> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "nl/cm" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True"/> + <oxy:LinearAxis Position="Left" Title = "Lab" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding From}" Maximum="{Binding To}"/> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + </Grid> + </Grid> + </DockPanel> + </Grid> + </UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs new file mode 100644 index 000000000..4c456c12d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ColorCalibrationView.xaml.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.RML.ViewModels; + +namespace Tango.MachineStudio.RML.Views +{ + /// <summary> + /// Interaction logic for ColorCalibrationView.xaml + /// </summary> + public partial class ColorCalibrationView : UserControl + { + public ColorCalibrationView() + { + InitializeComponent(); + this.Loaded += ColorCalibrationView_Loaded; + } + + private void ColorCalibrationView_Loaded(object sender, RoutedEventArgs e) + { + if(DataContext is ColorCalibrationViewVM) + { + ColorCalibrationViewVM vm = (ColorCalibrationViewVM)DataContext; + vm.PlotControl = CalibrationPlot; + vm.Loading(); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index cd3ed2fe4..7d050a29a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -30,7 +30,7 @@ <Button Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" Command="{Binding BackToRmlsCommand}"> <materialDesign:PackIcon Kind="ArrowLeft" Width="50" Height="50" Foreground="{StaticResource DarkGrayBrush200}" ToolTip="Back to RML list" /> </Button> - <TextBlock Text="{Binding ActiveRML.Name}" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="34"></TextBlock> + <TextBlock MaxWidth="350" Text="{Binding ActiveRML.Name}" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="30" TextWrapping="Wrap"></TextBlock> </StackPanel> <Button HorizontalAlignment="Right" Width="170" Height="45" Margin="0 0 20 0" VerticalAlignment="Center" Command="{Binding SaveCommand}"> @@ -226,6 +226,9 @@ <TabItem Header="SPOOLS" Margin="-100 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> <local:SpoolsView/> </TabItem> + <TabItem Header="Color Calibration" Margin="-100 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:ColorCalibrationView DataContext="{Binding ColorCalibrationVM}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/> + </TabItem> </TabControl> </Grid> <Grid Grid.Row="1"> |
