Partially fix work with user color
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
||||||
|
{
|
||||||
|
public class FieldViewerViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
24
FieldVisualizer/ViewModels/ViewModelBase.cs
Normal file
24
FieldVisualizer/ViewModels/ViewModelBase.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace FieldVisualizer.ViewModels
|
||||||
|
{
|
||||||
|
public class ViewModelBase : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
protected virtual void OnPropertyChanged<T>(T value, T prop, [CallerMemberName] string propertyName = null)
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnPropertyChanged<T>(T value, ref T prop, [CallerMemberName] string propertyName = null)
|
||||||
|
{
|
||||||
|
prop = value;
|
||||||
|
OnPropertyChanged(propertyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||||
|
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,10 +36,11 @@
|
|||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel Grid.Column="2">
|
<StackPanel Grid.Column="2">
|
||||||
<CheckBox x:Name="cbMinValueEnabled" Margin="3" Content="Minimum Value"/>
|
<CheckBox x:Name="cbMinValueEnabled" Margin="3" Content="Minimum Value" IsChecked="{Binding Path=SetMinValue}"/>
|
||||||
<TextBox x:Name="tbMinValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMinValueEnabled}" Text="{Binding Path=UserValueRange.BottomValue}"/>
|
<TextBox x:Name="tbMinValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMinValueEnabled}" Text="{Binding Path=UserValueRange.BottomValue}"/>
|
||||||
<CheckBox x:Name="cbMaxValueEnabled" Margin="3" Content="Maximum Value"/>
|
<CheckBox x:Name="cbMaxValueEnabled" Margin="3" Content="Maximum Value" IsChecked="{Binding Path=SetMaxValue}"/>
|
||||||
<TextBox x:Name="tbMaxValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMaxValueEnabled}" Text="{Binding Path=UserValueRange.TopValue}"/>
|
<TextBox x:Name="tbMaxValue" Margin="20,3,3,3" IsEnabled="{Binding IsChecked, ElementName=cbMaxValueEnabled}" Text="{Binding Path=UserValueRange.TopValue}"/>
|
||||||
|
<Button Margin="3" Content="Set custom colors" Command="{Binding SetUserColorsCommand}"/>
|
||||||
<local:VerticalLegend x:Name="LegendViewer" Margin="3" Grid.Column="2"/>
|
<local:VerticalLegend x:Name="LegendViewer" Margin="3" Grid.Column="2"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -29,9 +29,12 @@ namespace FieldVisualizer.Windows.UserControls
|
|||||||
public ICommand ZoomInCommand { get; }
|
public ICommand ZoomInCommand { get; }
|
||||||
public ICommand ZoomOutCommand { get; }
|
public ICommand ZoomOutCommand { get; }
|
||||||
public ICommand ChangeColorMapCommand { get; }
|
public ICommand ChangeColorMapCommand { get; }
|
||||||
|
public ICommand SetUserColorsCommand { get; }
|
||||||
|
|
||||||
public IPrimitiveSet PrimitiveSet { get; set; }
|
public IPrimitiveSet PrimitiveSet { get; set; }
|
||||||
public IValueRange UserValueRange { get; set; }
|
public IValueRange UserValueRange { get; set; }
|
||||||
|
public bool SetMinValue { get; set; }
|
||||||
|
public bool SetMaxValue { get; set; }
|
||||||
|
|
||||||
private double dX, dY;
|
private double dX, dY;
|
||||||
private ColorMapsTypes _ColorMapType;
|
private ColorMapsTypes _ColorMapType;
|
||||||
@@ -50,9 +53,12 @@ namespace FieldVisualizer.Windows.UserControls
|
|||||||
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
|
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
|
||||||
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
|
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
|
||||||
ChangeColorMapCommand = new RelayCommand(o => ChangeColorMap(), o => PrimitiveValidation());
|
ChangeColorMapCommand = new RelayCommand(o => ChangeColorMap(), o => PrimitiveValidation());
|
||||||
|
SetUserColorsCommand = new RelayCommand(o => ColorRefresh(), o => (SetMinValue || SetMaxValue));
|
||||||
UserValueRange = new ValueRange() { BottomValue = 0, TopValue = 0 };
|
UserValueRange = new ValueRange() { BottomValue = 0, TopValue = 0 };
|
||||||
|
SetMinValue = false;
|
||||||
|
SetMaxValue = false;
|
||||||
}
|
}
|
||||||
public void Refresh()
|
public void ColorRefresh()
|
||||||
{
|
{
|
||||||
if (PrimitiveValidation() == false) { return; }
|
if (PrimitiveValidation() == false) { return; }
|
||||||
_ColorMap = ColorMapFactory.GetColorMap(_ColorMapType);
|
_ColorMap = ColorMapFactory.GetColorMap(_ColorMapType);
|
||||||
@@ -66,7 +72,6 @@ namespace FieldVisualizer.Windows.UserControls
|
|||||||
}
|
}
|
||||||
private void ProcessPrimitives()
|
private void ProcessPrimitives()
|
||||||
{
|
{
|
||||||
|
|
||||||
WorkPlaneCanvas.Children.Clear();
|
WorkPlaneCanvas.Children.Clear();
|
||||||
double sizeX = PrimitiveOperations.GetSizeX(PrimitiveSet.ValuePrimitives);
|
double sizeX = PrimitiveOperations.GetSizeX(PrimitiveSet.ValuePrimitives);
|
||||||
double sizeY = PrimitiveOperations.GetSizeY(PrimitiveSet.ValuePrimitives);
|
double sizeY = PrimitiveOperations.GetSizeY(PrimitiveSet.ValuePrimitives);
|
||||||
@@ -149,7 +154,7 @@ namespace FieldVisualizer.Windows.UserControls
|
|||||||
IColorMap colorMap = ColorMapFactory.GetColorMap(_ColorMapType);
|
IColorMap colorMap = ColorMapFactory.GetColorMap(_ColorMapType);
|
||||||
}
|
}
|
||||||
catch (Exception ex) { _ColorMapType = 0; }
|
catch (Exception ex) { _ColorMapType = 0; }
|
||||||
Refresh();
|
ColorRefresh();
|
||||||
}
|
}
|
||||||
private bool PrimitiveValidation()
|
private bool PrimitiveValidation()
|
||||||
{
|
{
|
||||||
@@ -159,10 +164,24 @@ namespace FieldVisualizer.Windows.UserControls
|
|||||||
private void SetColor()
|
private void SetColor()
|
||||||
{
|
{
|
||||||
valueRange = PrimitiveOperations.GetValueRange(PrimitiveSet.ValuePrimitives);
|
valueRange = PrimitiveOperations.GetValueRange(PrimitiveSet.ValuePrimitives);
|
||||||
if (cbMinValueEnabled.IsChecked == true) { valueRange.BottomValue = UserValueRange.BottomValue; } else { UserValueRange.BottomValue = valueRange.BottomValue; }
|
//if bottom value is greater than top value
|
||||||
if (cbMaxValueEnabled.IsChecked == true) { valueRange.TopValue = UserValueRange.TopValue; } else { UserValueRange.TopValue = valueRange.TopValue; }
|
if (SetMinValue
|
||||||
|
& SetMaxValue
|
||||||
|
& (UserValueRange.BottomValue > UserValueRange.TopValue))
|
||||||
|
{
|
||||||
|
UserValueRange.TopValue = UserValueRange.BottomValue;
|
||||||
|
}
|
||||||
|
if (SetMinValue) { valueRange.BottomValue = UserValueRange.BottomValue; } else { UserValueRange.BottomValue = valueRange.BottomValue; }
|
||||||
|
if (SetMaxValue) { valueRange.TopValue = UserValueRange.TopValue; } else { UserValueRange.TopValue = valueRange.TopValue; }
|
||||||
_ValueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
|
_ValueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
|
||||||
_ValueColorRanges = ColorOperations.GetValueColorRanges(valueRange, _ValueRanges, _ColorMap);
|
_ValueColorRanges = ColorOperations.GetValueColorRanges(valueRange, _ValueRanges, _ColorMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Refresh()
|
||||||
|
{
|
||||||
|
SetMinValue = false;
|
||||||
|
SetMaxValue = false;
|
||||||
|
ColorRefresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user