private void CouplingButton_Click(object sender, RoutedEventArgs e) { if (!this.coupling_isEnabled) { //exit g mode if (g_isPicking) { g_isPicking = false; this.gButton.Foreground = Brushes.Black; } this.coupling_isEnabled = true; this.mdiTabMenu.BorderBrush = Brushes.OrangeRed; this.CouplingButton.Foreground = Brushes.OrangeRed; this.getActivePlotView().Model.Annotations.Clear(); this.getActivePlotView().Model.InvalidatePlot(false); } else { this.coupling_isEnabled = false; this.coupling_isMeasure = false; this.mdiTabMenu.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 63, 81, 181)); EPRPlotView pw = this.getActivePlotView(); this.CouplingButton.Foreground = Brushes.Black; pw.Model.Annotations.Clear(); //refresh couplings && g this.RefreshData(); } }
public void pm_MouseUp(object sender, OxyMouseEventArgs e) { if (this.coupling_isEnabled && this.coupling_isMeasure) { coupling_end = new DataPoint(this.getActivePlotView().Model.Axes[0].InverseTransform(e.Position.X), this.getActivePlotView().Model.Axes[1].InverseTransform(e.Position.Y)); coupling_isEnabled = false; coupling_isMeasure = false; this.mdiTabMenu.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 63, 81, 181)); EPRPlotView pw = this.getActivePlotView(); this.CouplingButton.Foreground = Brushes.Black; pw.Model.Annotations.Clear(); pw.spc.A.Add(new Tuple <DataPoint, DataPoint>(coupling_start, coupling_end)); this.RefreshData(); } if (this.g_isPicking) { this.getActiveSpectrum().g.Add(this.getActiveSpectrum().calcG(this.getActivePlotView().Model.Axes[0].InverseTransform(e.Position.X))); this.g_isPicking = false; this.mdiTabMenu.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 63, 81, 181)); this.gButton.Foreground = Brushes.Black; //refresh couplings && g this.RefreshData(); } }
public void plotDeriv(EPRPlotView pw) { LineSeries se = new LineSeries { ItemsSource = BPUtil.getDataPoints(this.getX(), this.getDerivative()), Title = "Derivative" }; pw.Model.Series.Add(se); pw.InvalidatePlot(); pw.rescale(); }
public SimWindow(EPRPlotView plotView) { InitializeComponent(); //garlic mode is default spiceImg.Source = BluEPRint2.Properties.Resources.garlic.ToBitmapImage(); this.plotView = plotView; this.spc = plotView.spc; //setup exp params this.exp = new Exp(spc.freq, spc.getX().Length, spc.getX().First(), spc.getX().Last()); Load(); this.ExpTBlock.Text = "Experimental Data: \nFrequency: " + exp.frequency + " GHz \nRange: " + spc.getX().First() + " - " + spc.getX().Last() + " mT\nResolution: " + spc.getX().Length + " Points"; }
public List <PlottableEPRSpectrum> getAllSpectra() { List <PlottableEPRSpectrum> EPRSpectra = new List <PlottableEPRSpectrum>(); if (mdiTabMenu.Items.Count != 0) { foreach (TabItem tab in mdiTabMenu.Items) { StackPanel sp = (StackPanel)tab.Content; EPRPlotView plotView = (EPRPlotView)sp.Children[0]; PlottableEPRSpectrum spc = plotView.spc; EPRSpectra.Add(spc); } } return(EPRSpectra); }
public void pm_MouseMove(object sender, OxyMouseEventArgs e) { if (this.coupling_isEnabled && this.coupling_isMeasure) { EPRPlotView pw = this.getActivePlotView(); pw.HideTracker(); ArrowAnnotation Line = new ArrowAnnotation() { StrokeThickness = 1, Color = OxyColors.Black, HeadWidth = 1, StartPoint = coupling_start, EndPoint = new DataPoint(pw.Model.Axes[0].InverseTransform(e.Position.X), coupling_start.Y) }; pw.Model.Annotations.Add(Line); pw.Model.InvalidatePlot(false); mousePosition = new DataPoint(pw.Model.Axes[0].InverseTransform(e.Position.X), pw.Model.Axes[1].InverseTransform(e.Position.Y)); } }
private void DerivButton_Click(object sender, RoutedEventArgs e) { EPRPlotView pw = this.getActivePlotView(); if (!this.getActiveSpectrum().showDeriv) { this.getActiveSpectrum().showDeriv = true; this.DerivButton.Foreground = Brushes.SaddleBrown; this.getActiveSpectrum().plotDeriv(pw); } else { var test = pw.Model.Series.Where(s => s.Title.Contains("Derivative")); if (test.Count() != 0) { pw.Model.Series.Remove(test.First()); } this.getActiveSpectrum().showDeriv = false; pw.InvalidatePlot(); pw.rescale(); this.DerivButton.Foreground = Brushes.Black; } }
private void IntButton_Click(object sender, RoutedEventArgs e) { EPRPlotView pw = this.getActivePlotView(); if (!this.getActiveSpectrum().showInt) { this.getActiveSpectrum().showInt = true; this.IntButton.Foreground = Brushes.Magenta; this.getActiveSpectrum().plotInt(pw); } else { var test = pw.Model.Series.Where(s => s.Title.Contains("Integral")); if (test.Count() != 0) { pw.Model.Series.Remove(test.First()); } this.getActiveSpectrum().showInt = false; pw.InvalidatePlot(); pw.rescale(); this.IntButton.Foreground = Brushes.Black; } }
public PlottableEPRSpectrum plotEPR(EPRPlotView plotView) { PlotModel pm = new PlotModel(); pm.IsLegendVisible = true; pm.LegendPosition = LegendPosition.RightTop; pm.DefaultFontSize = 14; pm.LegendFontSize = 14; LineSeries se = new LineSeries { ItemsSource = BPUtil.getDataPoints(getX(), getY()), Title = this.getTitle() }; LinearAxis x = new LinearAxis { Position = AxisPosition.Bottom, Title = "B/" + unit }; pm.PlotAreaBorderThickness = new OxyThickness(1.5); x.MajorGridlineThickness = 1.5; x.MinorGridlineThickness = 1.5; x.AbsoluteMaximum = getX().Last(); x.AbsoluteMinimum = getX().First(); LinearAxis y = new LinearAxis { Position = AxisPosition.Left }; y.IsAxisVisible = false; LinkedAxis g = new LinkedAxis(x, calcG, calcB); g.Position = AxisPosition.Top; g.Title = "g"; g.MajorGridlineThickness = 1.5; g.MinorGridlineThickness = 1.5; pm.Series.Add(se); pm.Axes.Add(x); pm.Axes.Add(y); pm.Axes.Add(g); //rescale y.AbsoluteMaximum = getY().Max() + getY().Max() * 0.1; y.AbsoluteMinimum = getY().Min() + getY().Min() * 0.1; //full zoom out on y scale y.Zoom(y.AbsoluteMinimum, y.AbsoluteMaximum); plotView.InvalidatePlot(); //sync bool isc = false; x.AxisChanged += (s, e) => { if (isc) { return; } isc = true; g.Zoom(calcG(x.ActualMinimum), calcG(x.ActualMaximum)); pm.InvalidatePlot(false); isc = false; }; g.AxisChanged += (s, e) => { if (isc) { return; } isc = true; x.Zoom(calcB(g.ActualMinimum), calcB(g.ActualMaximum)); pm.InvalidatePlot(false); isc = false; }; pm.MouseDown += (s, e) => Application.Current.Windows.OfType <MainWindow>().First().pm_MouseDown(s, e); pm.MouseMove += (s, e) => Application.Current.Windows.OfType <MainWindow>().First().pm_MouseMove(s, e); pm.MouseUp += (s, e) => Application.Current.Windows.OfType <MainWindow>().First().pm_MouseUp(s, e); plotView.Model = pm; plotView.spc = this; return(this); }
private void createMDIChild(PlottableEPRSpectrum spc) { //create inner stackpanel StackPanel side = new StackPanel(); side.Orientation = Orientation.Vertical; //create textbox TextBlock tb = new TextBlock(); tb.Padding = new Thickness(5); tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; tb.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; tb.MinHeight = 200; tb.Inlines.Add(new Bold(new Run(spc.getTitle()))); tb.Inlines.Add("\nFrequency: " + spc.freq.ToString() + " GHz"); tb.Inlines.Add("\nResolution: " + spc.getX().Length); tb.Inlines.Add("\nField: " + spc.getX().First() + " - " + spc.getX().Last() + " " + spc.unit); tb.Inlines.Add("\nMicrowave Power: " + spc.power + " mW"); tb.Inlines.Add("\nModulation Amplitude: " + (spc.modAmp / 10) + " mT"); tb.Inlines.Add("\nReceiver Gain: " + spc.gain.ToString("E")); tb.Inlines.Add("\nConversion Time: " + spc.convTime + " msec"); tb.Inlines.Add("\nTimeConversion: " + spc.timeConv + " msec"); tb.Inlines.Add("\nNumber of Scans: " + spc.scans); tb.Inlines.Add("\n\nOperator: " + spc.operator_); tb.Inlines.Add("\nDate: " + spc.date); tb.Inlines.Add("\nComment: " + spc.comment); tb.Inlines.Add("\n\nDouble Integral: " + spc.doubleIntegral().ToString("E")); tb.TextWrapping = TextWrapping.Wrap; side.Children.Add(tb); //create plotview EPRPlotView plotView = new EPRPlotView(); plotView.Padding = new Thickness(5); plotView.Width = this.ActualWidth * 0.80; plotView.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; spc.plotEPR(plotView); if (File.Exists(spc.getFileName() + ".bp2")) { spc.loadBP2(); } //stack items StackPanel sp = new StackPanel(); sp.Background = Brushes.White; sp.Orientation = Orientation.Horizontal; sp.Children.Add(plotView); sp.Children.Add(side); //add all together TabItem eprItem = new TabItem(); eprItem.Header = spc.getTitle(); eprItem.Content = sp; mdiTabMenu.Items.Add(eprItem); mdiTabMenu.SelectedItem = eprItem; this.RefreshData(); }
private PlottableEPRSpectrum getActiveSpectrum() { EPRPlotView plotView = this.getActivePlotView(); return(plotView.spc); }