forked from oxyplot/oxyplot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlotManipulator.cs
More file actions
91 lines (81 loc) · 2.86 KB
/
PlotManipulator.cs
File metadata and controls
91 lines (81 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PlotManipulator.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Provides an abstract base class for plot manipulators.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace OxyPlot
{
using OxyPlot.Axes;
/// <summary>
/// Provides an abstract base class for plot manipulators.
/// </summary>
/// <typeparam name="T">The type of the event arguments.</typeparam>
public abstract class PlotManipulator<T> : ManipulatorBase<T> where T : OxyInputEventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="PlotManipulator{T}" /> class.
/// </summary>
/// <param name="view">The plot view.</param>
protected PlotManipulator(IPlotView view)
: base(view)
{
this.PlotView = view;
}
/// <summary>
/// Gets the plot view where the event was raised.
/// </summary>
/// <value>The plot view.</value>
public IPlotView PlotView { get; private set; }
/// <summary>
/// Gets or sets the X axis.
/// </summary>
/// <value>The X axis.</value>
public Axis XAxis { get; set; }
/// <summary>
/// Gets or sets the Y axis.
/// </summary>
/// <value>The Y axis.</value>
public Axis YAxis { get; set; }
/// <summary>
/// Transforms a point from screen coordinates to data coordinates.
/// </summary>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <returns>A data point.</returns>
protected DataPoint InverseTransform(double x, double y)
{
if (this.XAxis != null)
{
return this.XAxis.InverseTransform(x, y, this.YAxis);
}
if (this.YAxis != null)
{
return new DataPoint(0, this.YAxis.InverseTransform(y));
}
return new DataPoint();
}
/// <summary>
/// Assigns the axes to this manipulator by the specified position.
/// </summary>
/// <param name="position">The position.</param>
protected void AssignAxes(ScreenPoint position)
{
Axis xaxis;
Axis yaxis;
if (this.PlotView.ActualModel != null)
{
this.PlotView.ActualModel.GetAxesFromPoint(position, out xaxis, out yaxis);
}
else
{
xaxis = null;
yaxis = null;
}
this.XAxis = xaxis;
this.YAxis = yaxis;
}
}
}