Exemplo n.º 1
0
        private void MenuItemClick(object sender, RoutedEventArgs e)
        {
            FrameworkElement menuItem = sender as FrameworkElement;

            if (menuItem.DataContext == null)
            {
                return;
            }

            IVisualization session = menuItem.DataContext as IVisualization;

            if (session == null)
            {
                return;
            }

            bool continueF = session.PrepareCreateComparisonFromSnapshot();

            if (continueF)
            {
                DateTime   currentDateTime = DateTime.Now;
                string     suggestedName   = "Comparison_" + currentDateTime.ToShortDateString() + "_" + currentDateTime.ToShortTimeString();
                ViewSaveAs saveAsControl   = new ViewSaveAs("Comparison name", session.CommandNewComparisonSuperSession, suggestedName);
                DllEntryPoint.ShowModalWindow("Save comparison as", saveAsControl, session, null);
            }
        }
Exemplo n.º 2
0
        private bool constructAxes()
        {
            // Setup Axes defined in XAML
            if (LineSeries != null && LineSeries.Count() > 0 && OxyPlotViewAxes.Count > 1)
            {
                IEnumerator <OxyPlot.Wpf.Axis> it = OxyPlotViewAxes.GetEnumerator();
                while (it.MoveNext())
                {
                    OxyPlotView.Axes.Add(it.Current);
                }
            }
            // Setup Axes defined in the ViewModel
            else if (ChartData != null && ChartData.LinesData.Count > 0 && ChartData.AxesConfigurations.Count > 1)
            {
                int i = 0;

                foreach (ChartAxisConf axisConf in ChartData.AxesConfigurations)
                {
                    OxyPlot.Wpf.Axis _axis = (OxyPlot.Wpf.Axis)Activator.CreateInstance(Type.GetType("OxyPlot.Wpf." + axisConf.AxisTypeName + ",OxyPlot.Wpf"));
                    _axis.SetCurrentValue(OxyPlot.Wpf.Axis.PositionProperty, MultifunctionalChartData.AxesPositions[i]);
                    // Set axis style
                    Style _axis_style = null;
                    switch (MultifunctionalChartData.AxesPositions[i])
                    {
                    case AxisPosition.Left:
                        _axis.Title = (ChartData.TitleY == null ? "" : ChartData.TitleY);
                        _axis_style = YAxisStyle;
                        break;

                    case AxisPosition.Bottom:
                        _axis.Title = (ChartData.TitleX == null ? "" : ChartData.TitleX);
                        _axis_style = XAxisStyle;
                        break;

                    // implement more cases if required
                    default:
                        DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Info, "Warning", $"{Name}.constructAxes: Axis # {(i + 1)}: Unhandled AxisPosition: {Convert.ToString(MultifunctionalChartData.AxesPositions[i])}");
                        break;
                    }
                    OxyPlotView.Axes.Add(_axis);
                    // Style DependencyProperty has to be defined always after adding the axis to the view
                    if (_axis_style == null)
                    {
                        _axis_style = TryFindResource("OxyPlotDefaultAxisStyle") as Style;
                    }
                    if (_axis_style != null)
                    {
                        _axis.SetCurrentValue(StyleProperty, _axis_style);
                    }

                    i++;
                }
            }

            return(OxyPlotView.Axes.Count() > 1);
        }
Exemplo n.º 3
0
        private static void LineSeriesChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            ViewOxyPlotChart control = null;

            try
            {
                control = source as ViewOxyPlotChart;
                control.ConstructPlot();
            }
            catch (Exception ex)
            {
                DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Warning, "Exception", $"{control.Name}: Exception updating line series: '{ex.Message}'.");
            }
        }
Exemplo n.º 4
0
 void OxyPlotViewAnnotations_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     try
     {
         OxyPlotView.Annotations.Clear();
         foreach (OxyPlot.Wpf.Annotation annotation in OxyPlotViewAnnotations)
         {
             OxyPlotView.Annotations.Add(annotation);
         }
         //System.Diagnostics.Debug.WriteLine($"{Name}: Annotations updated.");
     }
     catch (Exception ex)
     {
         DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Warning, "Exception", $"{Name}: Exception updating annotations: '{ex.Message}'.");
     }
 }
Exemplo n.º 5
0
        private static void OxyPlotViewAxesChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            ViewOxyPlotChart control = null;

            try
            {
                if (e.NewValue != null && e.NewValue != e.OldValue)
                {
                    control = source as ViewOxyPlotChart;
                    control.OxyPlotView.Axes.Clear();
                    control.ConstructPlot();
                }
            }
            catch (Exception ex)
            {
                DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Warning, "Exception", $"{control.Name}: Exception updating axes: '{ex.Message}'.");
            }
        }
Exemplo n.º 6
0
        private static void PlotViewStyleChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            ViewOxyPlotChart control = null;

            try
            {
                if (e.NewValue != e.OldValue)
                {
                    control = source as ViewOxyPlotChart;
                    control.OxyPlotView.Style = e.NewValue as Style;
                    //System.Diagnostics.Debug.WriteLine($"{control.Name}: PlotView Style updated.");
                }
            }
            catch (Exception ex)
            {
                DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Warning, "Exception", $"{control.Name}: Exception PlotView style: '{ex.Message}'.");
            }
        }
Exemplo n.º 7
0
        private void constructMultiSetAxes()
        {
            for (int k = 0; k < OxyPlotView.Axes.Count; k++)
            {
                Axis _axisModel = (Axis)Activator.CreateInstance((OxyPlotView.Axes[k].CreateModel()).GetType());
                System.Reflection.MethodInfo mi = _axisModel.GetType().GetMethod("ToDouble");
                switch (MultifunctionalChartData.AxesPositions[k])
                {
                case AxisPosition.Left:
                    if (ChartData.MaximumY != null)
                    {
                        AbsoluteMaximumY = Convert.ToDouble(mi == null ? ChartData.MaximumY : mi.Invoke(_axisModel, new object[] { ChartData.MaximumY }));
                    }
                    if (ChartData.MinimumY != null)
                    {
                        AbsoluteMinimumY = Convert.ToDouble(mi == null ? ChartData.MinimumY : mi.Invoke(_axisModel, new object[] { ChartData.MinimumY }));
                    }
                    break;

                case AxisPosition.Bottom:
                    if (ChartData.MaximumX != null)
                    {
                        AbsoluteMaximumX = Convert.ToDouble(mi == null ? ChartData.MaximumX : mi.Invoke(_axisModel, new object[] { ChartData.MaximumX }));
                    }
                    if (ChartData.MinimumX != null)
                    {
                        AbsoluteMinimumX = Convert.ToDouble(mi == null ? ChartData.MinimumX : mi.Invoke(_axisModel, new object[] { ChartData.MinimumX }));
                    }
                    break;

                default:
                    DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Info, "Warning", $"{Name}.contructMultipleLineSeries: Axis # {(k + 1)}: Unhandled AxisPosition: {Convert.ToString(MultifunctionalChartData.AxesPositions[k])}");
                    break;
                }
            }
        }
        void updatePosition()
        {
            try
            {
                prepareMinMax();
                updateTopLine();

                if (!double.IsNaN(_h1) && !double.IsNaN(_h2))
                {
                    double diff = prepareScalingLines();

                    double horizontalBorderWidth = 1;

                    if (viewbox.ActualHeight == 0)
                    {
                        viewbox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                        viewbox.Arrange(new Rect(0, 0, this.ActualWidth, this.ActualHeight / 2));
                    }

                    //calculate gauge zoom by viewbox control, so as to set border top/bottom width
                    if (viewbox.ActualHeight > 0)
                    {
                        horizontalBorderWidth = double.IsNaN(PART_gauge.Height / viewbox.ActualHeight) ? 1 : (PART_gauge.Height / viewbox.ActualHeight);
                    }

                    updateTrianglesPosition(horizontalBorderWidth, diff);
                    //border0Rect.StrokeDashArray = new DoubleCollection() { 1, 1 };
                    //border0Rect.StrokeThickness =  10;
                    //PART_image_values.BorderThickness = new Thickness(1, h1/100.0, 1, h1/100.0);

                    PART_scaling_values.Height = _h2;

                    if (UseLogarithmic)
                    {
                        _markers = LogarithmicMarkers;
                    }
                    else
                    {
                        _markers = NonLogarithmicMarkers;
                    }

                    updateScalingLines(horizontalBorderWidth);
                }
                //Scaling Range
                //this.tooltipInfo.Content
                //if (IsEnabled)
                //    this.viewbox.ToolTip = "Image Data: [" + minimumData.ToString("E3") + "]/[" + layerMax.ToString("E3") + "]" +
                //                           "\nScaling : [" + scaleMin.ToString("E3") + "]/[" + scaleMax.ToString("E3") + "]";
                //else
                //    this.viewbox.ToolTip = "Image Data: [" + minimumData.ToString("E3") + "]/[" + layerMax.ToString("E3") + "]";

                refreshViewBoxToolTip();

                //Xvue.MSOT.ViewModels.Log.ViewModelLog.MsotTrace(
                //    "ImageMax: " + ImageMax +
                //    ", ImageMin: "+ ImageMin +
                //    ", ScaleMax: " + ScaleMax +
                //    ", ScaleMin: "+ ScaleMin +
                //    ", Viewbox : "+ viewbox.ActualHeight +
                //    ", Gauge: " + PART_gauge.ActualHeight
                //, this.GetType().ToString());
            }
            catch (Exception ex)
            {
                DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Warning, "ViewScalingGaugeSimple:updatePosition", ex.Message);
            }
        }
Exemplo n.º 9
0
        private void setAxesLimits()
        {
            // Set Axes limits if not defined via styling
            for (int i = 0; i < OxyPlotView.Axes.Count; i++)
            {
                bool   isMajorStepStyled = false, isAbsoluteMinimumStyled = false, isAbsoluteMaximumStyled = false;
                double currentAbsoluteMaximum = 0, currentAbsoluteMinimum = 0, extremumOffset = 0;
                IEnumerable <Setter> axisStyleSetters = null;

                if (ShowGridLines)
                {
                    OxyPlotView.Axes[i].SetCurrentValue(OxyPlot.Wpf.Axis.MajorGridlineStyleProperty, LineStyle.Solid);
                    OxyPlotView.Axes[i].SetCurrentValue(OxyPlot.Wpf.Axis.MinorGridlineStyleProperty, LineStyle.Dot);
                }

                if (OxyPlotView.Axes[i].Style != null)
                {
                    axisStyleSetters = OxyPlotView.Axes[i].Style.Setters.OfType <Setter>();
                }

                if (axisStyleSetters != null)
                {
                    isMajorStepStyled       = axisStyleSetters.Where(X => X.Property.Name == "MajorStep").Any();
                    isAbsoluteMinimumStyled = axisStyleSetters.Where(X => X.Property.Name == "AbsoluteMinimum").Any();
                    isAbsoluteMaximumStyled = axisStyleSetters.Where(X => X.Property.Name == "AbsoluteMaximum").Any();
                }

                switch (OxyPlotView.Axes[i].Position)
                {
                case AxisPosition.Bottom:
                    currentAbsoluteMaximum = AbsoluteMaximumX;
                    currentAbsoluteMinimum = AbsoluteMinimumX;

                    if (currentAbsoluteMaximum == currentAbsoluteMinimum)
                    {
                        extremumOffset = 1;
                    }
                    else
                    {
                        extremumOffset = (currentAbsoluteMaximum - currentAbsoluteMinimum) * 0.05;
                    }
                    break;

                case AxisPosition.Left:
                    currentAbsoluteMaximum = AbsoluteMaximumY;
                    currentAbsoluteMinimum = AbsoluteMinimumY;

                    if (currentAbsoluteMaximum == currentAbsoluteMinimum)
                    {
                        extremumOffset = (currentAbsoluteMaximum == 0 ? 1 : currentAbsoluteMaximum * 0.05);
                        break;
                    }

                    if (!isMajorStepStyled)     // Y-Axis major step calculation based on the number of steps (nSteps defined below)
                    {
                        int    nSteps    = 10;
                        double step      = (currentAbsoluteMaximum - currentAbsoluteMinimum) / nSteps;
                        double logStep   = Math.Log10(step);
                        int    precision = (int)(logStep < 0 ? -logStep + 1 : 0);  // For rounding to first non-zero decimal ...
                        OxyPlotView.Axes[i].SetCurrentValue(OxyPlot.Wpf.Axis.MajorStepProperty, Math.Round(step, precision));
                    }

                    extremumOffset = OxyPlotView.Axes[i].MajorStep / 5;
                    break;

                default:
                    DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Info, "Warning", $"{Name}.setAxesLimits: Axis # {(i + 1)}: Unhandled AxisPosition: {Convert.ToString(MultifunctionalChartData.AxesPositions[i])}");
                    return;
                }

                if (!isAbsoluteMinimumStyled)
                {
                    OxyPlotView.Axes[i].SetCurrentValue(OxyPlot.Wpf.Axis.AbsoluteMinimumProperty, currentAbsoluteMinimum - extremumOffset);
                }

                OxyPlotView.Axes[i].SetCurrentValue(OxyPlot.Wpf.Axis.MinimumProperty, OxyPlotView.Axes[i].AbsoluteMinimum);

                if (!isAbsoluteMaximumStyled)
                {
                    OxyPlotView.Axes[i].SetCurrentValue(OxyPlot.Wpf.Axis.AbsoluteMaximumProperty, currentAbsoluteMaximum + extremumOffset);
                }

                OxyPlotView.Axes[i].SetCurrentValue(OxyPlot.Wpf.Axis.MaximumProperty, OxyPlotView.Axes[i].AbsoluteMaximum);
            }
        }
Exemplo n.º 10
0
        private void contructMultipleLineSeries(Style _series_style)
        {
            constructMultiSetAxes();

            bool initExtremes = true;

            // For each line series in the ViewModel
            foreach (MultifunctionalChartLineData line in ChartData.LinesData)
            {
                OxyPlot.Wpf.LineSeries _wpf_series = new OxyPlot.Wpf.LineSeries();
                LineSeries             _series     = (LineSeries)_wpf_series.CreateModel();

                foreach (ChartPoint cp in line.LinePoints)
                {
                    if (cp.X == null || cp.Y == null)
                    {
                        _series.Points.Add(DataPoint.Undefined);
                    }
                    else
                    {
                        DataPoint dp = new DataPoint();
                        for (int k = 0; k < OxyPlotView.Axes.Count; k++)
                        {
                            Axis _axisModel = (Axis)Activator.CreateInstance((OxyPlotView.Axes[k].CreateModel()).GetType());
                            System.Reflection.MethodInfo mi = _axisModel.GetType().GetMethod("ToDouble");
                            switch (MultifunctionalChartData.AxesPositions[k])
                            {
                            case AxisPosition.Left:
                                dp.Y = Convert.ToDouble(mi == null ? cp.Y : mi.Invoke(_axisModel, new object[] { cp.Y }));
                                break;

                            case AxisPosition.Bottom:
                                dp.X = Convert.ToDouble(mi == null ? cp.X : mi.Invoke(_axisModel, new object[] { cp.X }));
                                break;

                            default:
                                DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Info, "Warning", $"{Name}.contructMultipleLineSeries: Axis # {(k + 1)}: Unhandled AxisPosition: {Convert.ToString(MultifunctionalChartData.AxesPositions[k])}");
                                break;
                            }
                        }
                        _series.Points.Add(dp);
                        if (initExtremes)
                        {
                            if (ChartData.MinimumX == null)
                            {
                                AbsoluteMinimumX = dp.X;
                            }
                            if (ChartData.MaximumX == null)
                            {
                                AbsoluteMaximumX = dp.X;
                            }
                            if (ChartData.MinimumY == null)
                            {
                                AbsoluteMinimumY = dp.Y;
                            }
                            if (ChartData.MaximumY == null)
                            {
                                AbsoluteMaximumY = dp.Y;
                            }

                            /* Currently not implemented
                             * AbsoluteMinimumZ = dp.Z;
                             * AbsoluteMaximumZ = dp.Z;
                             */
                            initExtremes = false;
                        }
                        else
                        {
                            if (dp.X < AbsoluteMinimumX)
                            {
                                AbsoluteMinimumX = dp.X;
                            }
                            if (dp.X > AbsoluteMaximumX)
                            {
                                AbsoluteMaximumX = dp.X;
                            }
                            if (dp.Y < AbsoluteMinimumY)
                            {
                                AbsoluteMinimumY = dp.Y;
                            }
                            if (dp.Y > AbsoluteMaximumY)
                            {
                                AbsoluteMaximumY = dp.Y;
                            }

                            /* Currently not implemented
                             * if (_Z < AbsoluteMinimumZ) { AbsoluteMinimumY = _Z; }
                             * if (_Z > AbsoluteMaximumZ) { AbsoluteMaximumY = _Z; }
                             */
                        }
                    }
                }
                OxyPlotView.Series.Add(_wpf_series);
                // Style DependencyProperty has to be defined always after adding the series to the view
                if (_series_style != null)
                {
                    _wpf_series.SetCurrentValue(StyleProperty, _series_style);
                }
                _wpf_series.SetCurrentValue(OxyPlot.Wpf.LineSeries.MarkerStrokeProperty, line.Color);
                _wpf_series.SetCurrentValue(OxyPlot.Wpf.Series.ColorProperty, line.Color);
                _wpf_series.SetCurrentValue(OxyPlot.Wpf.LineSeries.MarkerFillProperty, line.Color);
                _wpf_series.SetCurrentValue(OxyPlot.Wpf.Series.TitleProperty, line.Name);
            }
        }