aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-05-19 12:07:38 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-05-19 12:07:38 +0300
commit5ed1e236bc0db0f1480344d0934cbb42df20df7b (patch)
treed242fecf6d74a1af7b00760c1fd23a62fddda1c0 /Software/Visual_Studio/MachineStudio/Modules
parentdb94be7a673886297f5a6dfe4331793452a9f609 (diff)
parent1d2d515c91a78a8a3e373e05ae925ba6af1f32fd (diff)
downloadTango-5ed1e236bc0db0f1480344d0934cbb42df20df7b.tar.gz
Tango-5ed1e236bc0db0f1480344d0934cbb42df20df7b.zip
merge, no change
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs7
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/Emulated3DModel.cs61
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/LightingModes.cs16
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs16
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml73
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs63
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml9
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs2
9 files changed, 231 insertions, 18 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs
index 0b74f2b3f..730665263 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs
@@ -110,6 +110,13 @@ namespace Tango.MachineStudio.ColorCapture.Models
set { _enforceBarcodeDetection = value; RaisePropertyChangedAuto(); }
}
+ private bool _performCLAHE;
+ public bool PerformCLAHE
+ {
+ get { return _performCLAHE; }
+ set { _performCLAHE = value; RaisePropertyChangedAuto(); }
+ }
+
public CaptureConfig()
{
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/Emulated3DModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/Emulated3DModel.cs
new file mode 100644
index 000000000..5153277ce
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/Emulated3DModel.cs
@@ -0,0 +1,61 @@
+using HelixToolkit.Wpf;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+
+namespace Tango.MachineStudio.ColorCapture.Models
+{
+ public class Emulated3DModel : ExtendedObject
+ {
+ private DefaultLights _defaultLights;
+ private ThreePointLights _threePointLights;
+ private DirectionalHeadLight _directionalHeadLights;
+ private SpotHeadLight _spotHeadLight;
+
+ public Emulated3DModel()
+ {
+ _defaultLights = new DefaultLights();
+ _threePointLights = new ThreePointLights();
+ _directionalHeadLights = new DirectionalHeadLight();
+ _spotHeadLight = new SpotHeadLight();
+
+ CurrentMode = LightingModes.Default;
+ }
+
+ private LightSetup _currentLight;
+ public LightSetup CurrentLight
+ {
+ get { return _currentLight; }
+ set { _currentLight = value; RaisePropertyChangedAuto(); }
+ }
+
+ private LightingModes _currentMode;
+ public LightingModes CurrentMode
+ {
+ get { return _currentMode; }
+ set { _currentMode = value; RaisePropertyChangedAuto(); OnCurrentModeChanged(); }
+ }
+
+ private void OnCurrentModeChanged()
+ {
+ switch (CurrentMode)
+ {
+ case LightingModes.Default:
+ CurrentLight = _defaultLights;
+ break;
+ case LightingModes.DirectionalHeadLight:
+ CurrentLight = _directionalHeadLights;
+ break;
+ case LightingModes.SpotHeadLight:
+ CurrentLight = _spotHeadLight;
+ break;
+ case LightingModes.ThreePointLights:
+ CurrentLight = _threePointLights;
+ break;
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/LightingModes.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/LightingModes.cs
new file mode 100644
index 000000000..84369f90c
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/LightingModes.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.ColorCapture.Models
+{
+ public enum LightingModes
+ {
+ Default,
+ ThreePointLights,
+ DirectionalHeadLight,
+ SpotHeadLight,
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj
index 1c04917c0..4825f1812 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Tango.MachineStudio.ColorCapture.csproj
@@ -125,6 +125,8 @@
<Compile Include="Models\CaptureConfig.cs" />
<Compile Include="Models\CaptureItem.cs" />
<Compile Include="Models\DeltaEComparisons.cs" />
+ <Compile Include="Models\Emulated3DModel.cs" />
+ <Compile Include="Models\LightingModes.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs
index 38c86c297..2cf3ed63f 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs
@@ -244,6 +244,13 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels
set { _emulatedImage = value; RaisePropertyChangedAuto(); }
}
+ private Emulated3DModel _emulated3DModel;
+ public Emulated3DModel Emulated3DModel
+ {
+ get { return _emulated3DModel; }
+ set { _emulated3DModel = value; RaisePropertyChangedAuto(); }
+ }
+
public RelayCommand ImportBenchmarksCommand { get; set; }
public RelayCommand ExportBenchmarksCommand { get; set; }
@@ -285,6 +292,8 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels
CaptureModeCommand = new RelayCommand<CaptureMode>((mode) => CaptureMode = mode);
_emulatedActionTimer = new ActionTimer(TimeSpan.FromMilliseconds(100));
+ Emulated3DModel = new Emulated3DModel();
+
_timer3D = new DispatcherTimer();
_timer3D.Interval = TimeSpan.FromSeconds(1);
_timer3D.Tick += _timer3D_Tick;
@@ -539,6 +548,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels
HistogramMethod = Config.HistogramComparison,
EnableDoubleChecking = Config.EnableDoubleChecking,
EnforceBarcodeDetection = Config.EnforceBarcodeDetection,
+ PerformCLAHE = Config.PerformCLAHE,
});
if (result.Similarity > 0)
@@ -775,7 +785,11 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels
if (EmulatedColors != null)
{
var source = View.GetViewportImage();
- PerformDetection(source);
+
+ if (source != null)
+ {
+ PerformDetection(source);
+ }
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml
index e11ae3fa3..96e5fc488 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml
@@ -48,7 +48,7 @@
</UserControl.Resources>
<Grid Margin="20">
- <TabControl Background="{StaticResource Background}" Foreground="{StaticResource Foreground}">
+ <TabControl x:Name="tabControl" Background="{StaticResource Background}" Foreground="{StaticResource Foreground}">
<TabControl.Resources>
<Style TargetType="TabPanel">
<Setter Property="HorizontalAlignment" Value="Center"/>
@@ -237,6 +237,7 @@
</Grid>
</Grid>
+ <!--{Binding CaptureMode,Converter={StaticResource CaptureModeToVisibilityConverter},ConverterParameter={x:Static global:CaptureMode.Emulated3D}}-->
<Grid Visibility="{Binding CaptureMode,Converter={StaticResource CaptureModeToVisibilityConverter},ConverterParameter={x:Static global:CaptureMode.Emulated3D}}">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
@@ -249,10 +250,15 @@
<Grid Grid.Row="1" Background="{StaticResource Background}" Margin="1">
<helix:HelixViewport3D x:Name="viewport" ShowCoordinateSystem="True" ShowViewCube="False">
- <helix:DefaultLights ShowLights="True" />
+ <ModelVisual3D x:Name="lightsContainer">
+ <helix:DefaultLights ShowLights="True" />
+ </ModelVisual3D>
<helix:RectangleVisual3D DivWidth="30" DivLength="30">
<helix:RectangleVisual3D.BackMaterial>
- <DiffuseMaterial Brush="Gray"></DiffuseMaterial>
+ <MaterialGroup>
+ <DiffuseMaterial Brush="Silver" />
+ <SpecularMaterial Brush="White" SpecularPower="30"></SpecularMaterial>
+ </MaterialGroup>
</helix:RectangleVisual3D.BackMaterial>
<helix:RectangleVisual3D.Material>
<MaterialGroup x:Name="material">
@@ -267,24 +273,65 @@
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
- <SpecularMaterial Brush="White" SpecularPower="30"></SpecularMaterial>
+ <SpecularMaterial x:Name="specularMaterial" Brush="White" SpecularPower="30"></SpecularMaterial>
</MaterialGroup>
</helix:RectangleVisual3D.Material>
</helix:RectangleVisual3D>
</helix:HelixViewport3D>
<Grid>
- <UniformGrid Rows="4" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="20">
+
+ <StackPanel Orientation="Horizontal" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel>
- <visuals:Knob Minimum="-100" Maximum="100" Width="40" TicksHeight="2" TicksHighlightBrush="{StaticResource Accent}" />
- <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Light</TextBlock>
+ <TextBlock FontSize="10">Lighting</TextBlock>
+ <ComboBox x:Name="comboLights" SelectionChanged="ComboBox_SelectionChanged" ItemsSource="{Binding Source={x:Type models:LightingModes},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding Emulated3DModel.CurrentMode}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" Margin="0 5 0 0" HorizontalAlignment="Left" BorderThickness="1" BorderBrush="{StaticResource LightBackground}" VerticalAlignment="Top" Width="200"></ComboBox>
</StackPanel>
- <StackPanel Margin="0 10 0 0">
- <visuals:Knob Minimum="0" Maximum="100" Width="40" TicksHeight="2" TicksHighlightBrush="{StaticResource Accent}" />
- <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Spectural</TextBlock>
+ <StackPanel Margin="20 0 0 0">
+ <visuals:Knob Minimum="0" Maximum="1" Width="40" TicksHeight="2" TicksHighlightBrush="{StaticResource Accent}" />
+ <TextBlock FontSize="10" HorizontalAlignment="Center" Margin="0 5 0 0">Specular Brightness</TextBlock>
</StackPanel>
- </UniformGrid>
+
+ <StackPanel Margin="20 0 0 0">
+ <visuals:Knob Minimum="0" Maximum="200" Value="{Binding ElementName=specularMaterial,Path=SpecularPower,Mode=TwoWay}" Width="40" TicksHeight="2" TicksHighlightBrush="{StaticResource Accent}" />
+ <TextBlock FontSize="10" HorizontalAlignment="Center" Margin="0 5 0 0">Specular Power</TextBlock>
+ </StackPanel>
+
+ <ContentControl Content="{Binding Emulated3DModel}" Margin="20 0 0 0">
+ <ContentControl.Style>
+ <Style TargetType="ContentControl">
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate/>
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding CurrentMode}" Value="Default">
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate/>
+ </Setter.Value>
+ </Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding CurrentMode}" Value="SpotHeadLight">
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal">
+ <StackPanel>
+ <visuals:Knob Minimum="0" Maximum="1" Value="{Binding CurrentLight.Brightness,Mode=TwoWay}" Width="40" TicksHeight="2" TicksHighlightBrush="{StaticResource Accent}" />
+ <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0">Light</TextBlock>
+ </StackPanel>
+ </StackPanel>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ContentControl.Style>
+ </ContentControl>
+ </StackPanel>
</Grid>
</Grid>
</Grid>
@@ -767,6 +814,7 @@
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
+ <RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Bottom" Height="27">Columns</TextBlock>
@@ -825,6 +873,9 @@
<TextBlock Grid.Row="13" Grid.Column="0" VerticalAlignment="Bottom" Height="27">Enforce Barcode Detection</TextBlock>
<ToggleButton IsChecked="{Binding Config.EnforceBarcodeDetection}" Grid.Row="13" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom"></ToggleButton>
+
+ <TextBlock Grid.Row="14" Grid.Column="0" VerticalAlignment="Bottom" Height="27">Perform CLAHE</TextBlock>
+ <ToggleButton IsChecked="{Binding Config.PerformCLAHE}" Grid.Row="14" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom"></ToggleButton>
</Grid>
</Border>
</TabItem>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs
index 0bd0efe31..2759b44dc 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml.cs
@@ -17,6 +17,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.Core.DI;
using Tango.MachineStudio.ColorCapture.Contracts;
+using Tango.MachineStudio.ColorCapture.Models;
using Tango.MachineStudio.ColorCapture.ViewModels;
namespace Tango.MachineStudio.ColorCapture.Views
@@ -87,12 +88,62 @@ namespace Tango.MachineStudio.ColorCapture.Views
public BitmapSource GetViewportImage()
{
- MemoryStream ms = new MemoryStream();
- Viewport3DHelper.SaveBitmap(viewport.Viewport, ms, null, 1, BitmapExporter.OutputFormat.Bmp);
- ms.Position = 0;
- var source = ms.ToArray().ToBitmapSource();
- ms.Dispose();
- return source;
+ try
+ {
+ if (_vm.CaptureMode == CaptureMode.Emulated3D && tabControl.SelectedIndex == 0)
+ {
+ var location = viewport.Viewport.PointToScreen(new Point(0, 0));
+ var size = new Size(viewport.Viewport.ActualWidth, viewport.Viewport.ActualHeight);
+
+ using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap((int)size.Width, (int)size.Height))
+ {
+ using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
+ {
+ g.CopyFromScreen((int)location.X, (int)location.Y, 0, 0, bmp.Size);
+ }
+
+ bmp.Save("D:\\Test\\ttt.bmp");
+
+ using (MemoryStream ms = new MemoryStream())
+ {
+ bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
+ ms.Position = 0;
+ var source = ms.ToArray().ToBitmapSource();
+ return source;
+ }
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch (Exception ex)
+ {
+ System.Diagnostics.Debug.WriteLine(ex.Message);
+ return null;
+ }
+ //MemoryStream ms = new MemoryStream();
+ //Viewport3DHelper.SaveBitmap(viewport.Viewport, ms, null, 1, BitmapExporter.OutputFormat.Bmp);
+ //ms.Position = 0;
+ //var source = ms.ToArray().ToBitmapSource();
+ //ms.Dispose();
+ //return source;
+ }
+
+ private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ ReplaceLight();
+ }
+
+ private async void ReplaceLight()
+ {
+ if (_vm != null)
+ {
+ await Task.Delay(100);
+ lightsContainer.Children.Clear();
+ lightsContainer.Children.Add(_vm.Emulated3DModel.CurrentLight);
+ }
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml
index eb3eea5ab..ba2a022a1 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml
@@ -64,6 +64,9 @@
<TextBlock FontWeight="SemiBold">OS Key</TextBlock>
<TextBox Text="{Binding ActiveMachine.OsKey}"></TextBox>
+
+ <TextBlock FontWeight="SemiBold">Device COM Port</TextBlock>
+ <TextBox Text="{Binding ActiveMachine.DeviceComPort}"></TextBox>
</controls:TableGrid>
<Rectangle Grid.Column="1" StrokeThickness="1" Stroke="Silver" HorizontalAlignment="Center" Margin="50 50" />
<controls:TableGrid RowHeight="50" Margin="10" Grid.Column="2">
@@ -90,6 +93,12 @@
<TextBlock FontWeight="SemiBold">Is Demo Machine</TextBlock>
<ToggleButton HorizontalAlignment="Left" IsChecked="{Binding ActiveMachine.IsDemo}"></ToggleButton>
+
+ <TextBlock FontWeight="SemiBold">Suspend Version Update</TextBlock>
+ <ToggleButton HorizontalAlignment="Left" IsChecked="{Binding ActiveMachine.SuspendVersionUpdate}"></ToggleButton>
+
+ <TextBlock FontWeight="SemiBold">Update Schema on Update</TextBlock>
+ <ToggleButton HorizontalAlignment="Left" IsChecked="{Binding ActiveMachine.PerformSchemaUpdateOnDataUpdate}"></ToggleButton>
</controls:TableGrid>
</Grid>
</Border>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
index 72e43d7b0..ab5d2ebb1 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
@@ -405,6 +405,8 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// <param name="data">The data.</param>
private void PopulateDiagnosticsData(StartDiagnosticsResponse data)
{
+ if (data.Monitors == null) return;
+
TimeSpan delta_base = DateTime.Now - _start_time;
TimeSpan delta = (DateTime.Now - _last_time);
double delta_mili = delta.TotalMilliseconds;