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 }

Generated for HippoDraw Class Library by doxygen