XYTransform.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 #include "msdevstudio/MSconfig.h" // for CLONE_DEFECT
14 #endif
15 
16 #include "XYTransform.h"
17 
18 #include "UnaryTransform.h"
19 
20 #include "graphics/Rectangle.h"
21 
22 using std::vector;
23 
24 using namespace hippodraw;
25 
27  UnaryTransform * y,
28  UnaryTransform * z )
29  : BinaryTransform ( z )
30 {
31  m_x = x;
32  m_y = y;
33 // The following verboseness for VC++ in debug mode.
34  const std::string xname = m_x->name ();
35  const std::string yname = m_y->name ();
36  const std::string zname = z->name ();
37  m_name = xname;
38  m_name += " ";
39  m_name += yname;
40  m_name += " ";
41  m_name += zname;
42 }
43 
45 {
46  delete m_x;
47  delete m_y;
48 }
49 
51  : BinaryTransform ( t )
52 {
53 #ifdef CLONE_DEFECT
54  m_x = dynamic_cast < UnaryTransform * > ( t.m_x->clone () );
55  m_y = dynamic_cast < UnaryTransform * > ( t.m_y->clone () );
56 #else
57  m_x = t.m_x->clone ();
58  m_y = t.m_y->clone ();
59 #endif
60 }
61 
62 #ifdef CLONE_DEFECT
64 #else
66 #endif
67 {
68  return new XYTransform ( *this );
69 }
70 
71 bool
73 isLinearInXY ( ) const
74 {
75  return m_x -> isLinear () && m_y -> isLinear ();
76 }
77 
78 /* virtual */
79 void XYTransform::transform ( double & x,
80  double & y ) const
81 {
82  m_x->transform ( x );
83  m_y->transform ( y );
84 }
85 
86 bool
88 inverseTransform ( double & x, double & y ) const
89 {
90  m_x->inverseTransform ( x );
91  m_y->inverseTransform ( y );
92 
93  // Always return true because the return value only
94  // make sense with WCSLIB.
95  return true;
96 }
97 
98 /* virtual */
99 void
101 transform ( std::vector< double > & x,
102  std::vector< double > & y ) const
103 {
104  m_x->transform ( x );
105  m_y->transform ( y );
106 }
107 
109 {
110  return 0.0;
111 }
112 
114  const Range & y )
115 {
116  double x_lo = x.low ();
117  double x_hi = x.high ();
118  double y_lo = y.low ();
119  double y_hi = y.high ();
120 
121  transform ( x_lo, y_lo );
122  transform ( x_hi, y_hi );
123 
124  return Rect ( x_lo, y_lo, x_hi - x_lo, y_hi - y_lo );
125 }
126 
127 /* virtual */
128 void XYTransform::validate ( Range & x, Range & y ) const
129 {
130  m_x->validate ( x );
131  m_y->validate ( y );
132 }
133 
134 /* virtual */
135 const Range & XYTransform::limitX () const
136 {
137  return m_x->limits ();
138 }
139 
140 const Range & XYTransform::limitY () const
141 {
142  return m_y->limits ();
143 }
144 
146 {
147  return m_x;
148 }
149 
151 {
152  return m_y;
153 }
154 
155 const vector < AxisTick > &
158 {
159  if ( axis == Axes::X ) {
160  return m_x -> setTicks ( model );
161  }
162  else if ( axis == Axes::Y ) {
163  return m_y -> setTicks ( model );
164  }
165  else {
166  return m_z ->setTicks ( model );
167  }
168 }
169 
170 void
174  const Range & limit )
175 {
176  if ( axes == Axes::X )
177  m_x -> adjustValues ( model, limit );
178  else if ( axes == Axes::Y )
179  m_y -> adjustValues ( model, limit );
180  else if ( axes == Axes::Z )
181  m_z -> adjustValues ( model, limit );
182 }
double high() const
Returns the maximum of the range object.
Definition: Range.cxx:100
virtual const std::vector< AxisTick > & setTicks(AxisModelBase &axis_model, hippodraw::Axes::Type axis)
Sets and return the axis ticks on specified axis.
virtual void transform(double &x, double &y) const
Transform the coordinates on the X and Y axes.
Definition: XYTransform.cxx:79
TransformBase * yTransform() const
Returns the transform function on the Y axis.
A transform that transforms coordinates from one coordinate system to another.
Definition: TransformBase.h:35
UnaryTransform class interface.
XYTransform(UnaryTransform *x, UnaryTransform *y, UnaryTransform *z)
The following constructor takes three base constructors as arguments.
Definition: XYTransform.cxx:26
hippodrw::Rect class interface
virtual XYTransform * clone() const
Creates a new Transform object by copying an existing one.
Definition: XYTransform.cxx:65
hippodraw::XYTransform class interface
virtual UnaryTransform * clone() const =0
Function to make copy of object.
A transform that transforms the X and Y coordinates independently.
Definition: XYTransform.h:30
virtual const Range & limitY() const
Returns a Range whose values are the limits on the Y coordinate.
virtual Rect calcRectangle(const Range &x, const Range &y)
Returns a rectangle enclosing the transformed data space.
virtual const Range & limits() const
Returns a Range whose values are the limits on the coordinate.
TransformBase * xTransform() const
Returns the transform function on the X axis.
virtual void transform(double &x) const =0
virtual ~XYTransform()
The virtual destructor.
Definition: XYTransform.cxx:44
virtual void validate(Range &x, Range &y) const
Validates the Ranges.
UnaryTransform * m_y
The transform on the Y axis.
Definition: XYTransform.h:39
virtual const std::vector< AxisTick > & setTicks(AxisModelBase &axis)=0
Sets the vector of ticks along the axis to which this unary transform is applied. ...
virtual void inverseTransform(double &x) const =0
Inverse transforms the coordinate x.
UnaryTransform * m_x
The transform on the X axis.
Definition: XYTransform.h:36
virtual double aspectRatio() const
Returns the aspect ratio.
The AxisModelBase class maintains the Range and scaling of an axis.
Definition: AxisModelBase.h:33
Class representing a rectangle.
Definition: Rectangle.h:34
virtual void validate(Range &) const =0
Validates the Range.
const std::string & name() const
Returns the name of the Transform.
std::string m_name
Name of the Transform.
Definition: TransformBase.h:42
A transform that transforms coordinates from one 2D coordinate system to another. ...
A transform that transforms coordinates in one dimension from one coordinate system to another...
double low() const
Returns the minimum of the range object.
Definition: Range.cxx:87
virtual bool isLinearInXY() const
Returns true if the transform would be one to one on both the X and Y axes.
Definition: XYTransform.cxx:73
Expresses a range of values.
Definition: Range.h:33
virtual bool inverseTransform(double &x, double &y) const
Transform the transformed coordinates on X and Y axis back to the original true data space...
Definition: XYTransform.cxx:88
UnaryTransform * m_z
The transform on the Z axis.
virtual void adjustValues(AxisModelBase &model, hippodraw::Axes::Type axes, const Range &limit)
Sets the range of given axis to be a new &quot;nice&quot; within the limits given.
virtual const Range & limitX() const
Returns a Range whose values are the limits on the X coordinate.
Type
Axes constants.
Definition: AxesType.h:31

Generated for HippoDraw Class Library by doxygen