public ContourPlotLegendViewModel(ColormapBrush colormap, double min, double max) { _MinVelocity = min; _MaxVelocity = max; _Colormap = colormap; ScaleLabel = DEFAULT_SCALE_LABEL; // Update the legend Update(); }
/// <summary> /// Create a scatter plot. /// </summary> public ScatterPlot3D() { _colormap = new ColormapBrush(); _colormap.ColormapBrushType = ColormapBrush.ColormapBrushEnum.Jet; _isProcessingBuffer = false; _buffer = new ConcurrentQueue <Point3D>(); Points = new List <Point3D>(); SphereSize = 1.0; }
/// <summary> /// Create a plot to represent the a bin's magnitude and direction. /// This plot will be made up of arrows pointing in the direction /// with its length and color representing its magnitude. The arrows /// will be in a column representing the bin location. /// </summary> public BinPlot3D() { // Initialize values SelectedBin = DEFAULT_SELECTED_BIN; _minVelocity = DEFAULT_MIN_VELOCITY; _maxVelocity = DEFAULT_MAX_VELOCITY; _colormap = new ColormapBrush(); _colormap.ColormapBrushType = ColormapBrush.ColormapBrushEnum.Jet; _cylinderRadius = DEFAULT_CYLINDER_RADIUS; YAxis = true; _prevNumBins = 0; }
/// <summary> /// Convert the given enum value to a colormap brush. /// </summary> /// <param name="value">.</param> /// <param name="targetType">.</param> /// <param name="parameter">.</param> /// <param name="culture">.</param> /// <returns>Colormap brush with the correct brush type.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ColormapBrush brush = new ColormapBrush(); if (targetType != typeof(Brush)) { return(null); } if (!(value is ColormapBrush.ColormapBrushEnum)) { return(null); } Brush scb = ColormapBrush.GetBrush((ColormapBrush.ColormapBrushEnum)value); return(scb); }
/// <summary> /// Initialize the values. /// </summary> private void InitializeValues() { // Set values SelectedProject = null; // Set previous BT good values _prevGoodBtEast = DataSet.Ensemble.BAD_VELOCITY; _prevGoodBtNorth = DataSet.Ensemble.BAD_VELOCITY; _prevGoodBtVert = DataSet.Ensemble.BAD_VELOCITY; // Initialize the value _numEnsembles = 0; MinVelocity = DEFAULT_MIN_VELOCITY; MaxVelocity = DEFAULT_MAX_VELOCITY; // Set the color map to use _colormap = new ColormapBrush(); _colormap.ColormapBrushType = DEFAULT_COLORMAP; }
///// <summary> ///// Bitmap to store the scale based off ///// the current options. ///// </summary> //private SimpleBitmap _scaleBitmap; ///// <summary> ///// Use this as the image source for the ///// view. This will be the base of the ///// _scaleBitmap SimpleBitmap. ///// </summary> //public WriteableBitmap ScaleImage //{ // get // { // if (_scaleBitmap != null) // { // return _scaleBitmap.BaseBitmap; // } // else // { // // Create the legend // CreateLegend(); // return _scaleBitmap.BaseBitmap; // } // } //} ///// <summary> ///// Used for scale to display the minimum velocity. ///// </summary> //public string MinVelocityScale //{ // get { return _minVelocity.ToString("0.00") + ScaleLabel; } //} ///// <summary> ///// Used for scale to display the velocity between center and minimum. ///// </summary> //public string HalfMinVelocityScale //{ // get { return (_minVelocity + ((_maxVelocity - _minVelocity) * 0.25)).ToString("0.00") + ScaleLabel; } //} ///// <summary> ///// Used for scale to display the center velocity. ///// </summary> //public string HalfVelocityScale //{ // get { return (_minVelocity + ((_maxVelocity - _minVelocity) * 0.50)).ToString("0.00") + ScaleLabel; } //} ///// <summary> ///// Used for scale to display the velocity between center and maximum. ///// </summary> //public string HalfMaxVelocityScale //{ // get { return (_minVelocity + ((_maxVelocity - _minVelocity) * 0.75)).ToString("0.00") + ScaleLabel; } //} ///// <summary> ///// Used for scale to display the velocity the maximum velocity. ///// </summary> //public string MaxVelocityScale //{ // get { return _maxVelocity.ToString("0.00") + ScaleLabel; } //} #endregion #endregion /// <summary> /// Initialize the values. /// </summary> public VelocityPlotSurface() { // Intialize values MaxEnsembles = DEFAULT_MAX_ENSEMBLES; _minBin = 0; _maxBin = -1; // Set the color brush _colormap = new ColormapBrush(); _colormapBrushSelection = DEFAULT_BRUSH; _surfaceBrush = ColormapBrush.GetBrush(_colormapBrushSelection); _colormap.ColormapBrushType = _colormapBrushSelection; _emptyColor = DEFAULT_EMPTY_COLOR; ResetMinMaxVelocity(); ScaleLabel = DEFAULT_SCALE_LABEL; // Create a list to hold the vectors _vectors = new List <DataSet.EnsembleVelocityVectors>(); }
/// <summary> /// Initialize the values. /// </summary> public VelocityPlotSpectrum() { // Intialize values _maxEnsembles = 10; _vectors = new List <DataSet.EnsembleVelocityVectors>(); _colormap = new ColormapBrush(); _colormap.ColormapBrushType = ColormapBrush.ColormapBrushEnum.Winter; Distance = 1.0; //ShowIntensity = false; //ScaleHeightOnly = true; _minVelocity = -1; _maxVelocity = 2; _emptyColor = DEFAULT_EMPTY_COLOR; //FrequencyColumns = _maxEnsembles; //TimeColumns = 16; Geometry = GetDefaultGeometry(); _ens = 0; _isNewPlot = true; }
/// <summary> /// Create a brush based off the value given. /// The value will be based against the min and max velocity value. /// This will check if the value given is good. If it is not good, it will /// give a color for a bad value. /// </summary> /// <param name="colormap">Colormap to use to determine the color.</param> /// <param name="value">Value to convert to a color brush.</param> /// <param name="minVel">Minimum velocity.</param> /// <param name="maxVel">Maximum Velocity.</param> /// <param name="emptyColor">Color to use if the color is bad.</param> /// <returns>Color brush with the color based off the value, min and max velocity.</returns> public static SolidColorBrush GenerateColor(ColormapBrush colormap, double value, double minVel, double maxVel, SolidColorBrush emptyColor = null) { // Ensure the colormap was given if (colormap == null) { return(DEFAULT_EMPTY_COLOR); } // Bad Values get an empty color if (value == DataSet.Ensemble.BAD_VELOCITY) { // If the user did not give a empty color, use the default if (emptyColor == null) { return(DEFAULT_EMPTY_COLOR); } else { return(emptyColor); } } return(colormap.GetColormapColor(value, minVel, maxVel)); }
/// <summary> /// Create a brush based off the value given. /// The value will be based against the min and max velocity value. /// This will check if the value given is good. If it is not good, it will /// give a color for a bad value. /// </summary> /// <param name="colormap">Colormap to use to determine the color.</param> /// <param name="value">Value to convert to a color brush.</param> /// <param name="minVel">Minimum velocity.</param> /// <param name="maxVel">Maximum Velocity.</param> /// <param name="emptyColor">Color to use if the color is bad.</param> /// <returns>Color brush with the color based off the value, min and max velocity.</returns> public static SolidColorBrush GenerateColor(ColormapBrush colormap, double value, double minVel, double maxVel, SolidColorBrush emptyColor = null) { // Ensure the colormap was given if (colormap == null) { return DEFAULT_EMPTY_COLOR; } // Bad Values get an empty color if (value == DataSet.Ensemble.BAD_VELOCITY) { // If the user did not give a empty color, use the default if (emptyColor == null) { return DEFAULT_EMPTY_COLOR; } else { return emptyColor; } } return colormap.GetColormapColor(value, minVel, maxVel); }
/// <summary> /// Create the a brush based off the enum given and the minimum and maximum value. /// The brush will be created, then frozen and returned. /// Spectrum of the color is 0.0 to 1.0. /// /// I added black to the begining of some some, ranging from 0.0-0.01 to 0.0 - 0.1 /// to display black for bad velocity with a velocity of 0. /// </summary> /// <param name="brushEnum">Brush chosen.</param> /// <param name="alphaValue">The transparency of the display.</param> /// <returns>Brush for the given enum.</returns> public static Brush GetBrush(ColormapBrush.ColormapBrushEnum brushEnum, byte alphaValue = 255) { // Determine which brush is being selected // Then create the brush and return switch (brushEnum) { case ColormapBrush.ColormapBrushEnum.Spring: LinearGradientBrush springBrush = new LinearGradientBrush(); springBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal springBrush.EndPoint = new Point(1, 0.5); springBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) springBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 0, 255), 0.1)); // R = 255 G = 255*0 = 0 B = 255-G = 255 springBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 0), 1.0)); // R = 255 G = 255*1 = 255 B = 255-G = 0 springBrush.Freeze(); return springBrush; case ColormapBrush.ColormapBrushEnum.Summer: LinearGradientBrush summerBrush = new LinearGradientBrush(); summerBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal summerBrush.EndPoint = new Point(1, 0.5); summerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) summerBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 128, 102), 0.01)); // R = 255*0 = 0 G = 255 * 0.5 * (1 + 0) = 127.5 B = 255*0.4 = 102 summerBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 102), 1.0)); // R = 255*1 = 255 G = 255 * 0.5 * (1 + 1) = 255 B = 255*0.4 = 102 summerBrush.Freeze(); return summerBrush; case ColormapBrush.ColormapBrushEnum.Autumn: LinearGradientBrush autumnBrush = new LinearGradientBrush(); autumnBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal autumnBrush.EndPoint = new Point(1, 0.5); autumnBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) autumnBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 0, 0), 0.1)); // R = 255 G = 255*0 = 0 B = 0 autumnBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 0), 1.0)); // R = 255 G = 255*1 = 255 B = 0 autumnBrush.Freeze(); return autumnBrush; case ColormapBrush.ColormapBrushEnum.Winter: LinearGradientBrush winterBrush = new LinearGradientBrush(); winterBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal winterBrush.EndPoint = new Point(1, 0.5); winterBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) winterBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 0, 255), 0.01)); // R = 0 G = 255*0 = 0 B = 255 * (1.0 - (0.5 * 0)) = 255 winterBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 255, 128), 1.0)); // R = 0 G = 255*1 = 255 B = 255 * (1.0 - (0.5 * 1)) = 128 winterBrush.Freeze(); return winterBrush; case ColormapBrush.ColormapBrushEnum.Gray: LinearGradientBrush grayBrush = new LinearGradientBrush(); grayBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 0, 0), 0.0)); // R = 255*0 = 0 G = 255*0 = 0 B = 255*0 = 0 grayBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 255), 1.0)); // R = 255*1 = 255 G = 255*1 = 255 B = 255*1 = 255 grayBrush.Freeze(); return grayBrush; case ColormapBrush.ColormapBrushEnum.Hot: LinearGradientBrush hotBrush = new LinearGradientBrush(); hotBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal hotBrush.EndPoint = new Point(1, 0.5); hotBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); hotBrush.GradientStops.Add(new GradientStop(Colors.Red, 0.25)); hotBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.50)); hotBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.75)); hotBrush.GradientStops.Add(new GradientStop(Colors.White, 1.0)); hotBrush.Freeze(); return hotBrush; case ColormapBrush.ColormapBrushEnum.Cool: LinearGradientBrush coolBrush = new LinearGradientBrush(); coolBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal coolBrush.EndPoint = new Point(1, 0.5); coolBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) coolBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 255, 255), 0.1)); // R = 255*0 = 0 G = 255 * (1.0 - 0) = 255 B = 255 coolBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 0, 255), 1.0)); // R = 255*1 = 255 G = 255 * (1.0 - 1) = 0 B = 255 coolBrush.Freeze(); return coolBrush; case ColormapBrush.ColormapBrushEnum.Jet: LinearGradientBrush jetBrush = new LinearGradientBrush(); jetBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal jetBrush.EndPoint = new Point(1, 0.5); jetBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) jetBrush.GradientStops.Add(new GradientStop(Colors.DarkBlue, 0.01)); jetBrush.GradientStops.Add(new GradientStop(Colors.Blue, 0.125)); jetBrush.GradientStops.Add(new GradientStop(Colors.Cyan, 0.375)); jetBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.625)); jetBrush.GradientStops.Add(new GradientStop(Colors.Red, 0.875)); jetBrush.GradientStops.Add(new GradientStop(Colors.DarkRed, 1.0)); jetBrush.Freeze(); return jetBrush; default: SolidColorBrush defaultBrush = new SolidColorBrush(Colors.YellowGreen); defaultBrush.Freeze(); return defaultBrush; } }
/// <summary> /// Update the color for the legend. /// </summary> /// <param name="colormap">Color for the legend.</param> public void UpdateColor(ColormapBrush.ColormapBrushEnum colormap) { _Colormap.ColormapBrushType = colormap; // Update the legend Update(); }
/// <summary> /// Constructor /// Initalize all the values. /// <param name="colormap">Colormap for the legend.</param> /// <param name="min">Minimum Velocity.</param> /// <param name="max">Maximum Velocity.</param> /// </summary> public ContourPlotLegendViewModel(ColormapBrush.ColormapBrushEnum colormap, double min, double max) { _MinVelocity = min; _MaxVelocity = max; _Colormap = new ColormapBrush(); _Colormap.ColormapBrushType = colormap; ScaleLabel = DEFAULT_SCALE_LABEL; // Update the legend Update(); }