XYTransform.cxx

Go to the documentation of this file.
00001 
00012 #ifdef _MSC_VER
00013 #include "msdevstudio/MSconfig.h" // for CLONE_DEFECT
00014 #endif
00015 
00016 #include "XYTransform.h"
00017 
00018 #include "UnaryTransform.h"
00019 
00020 #include "graphics/Rectangle.h"
00021 
00022 using std::vector;
00023 
00024 using namespace hippodraw;
00025 
00026 XYTransform::XYTransform ( UnaryTransform * x,
00027                            UnaryTransform * y,
00028                            UnaryTransform * z )
00029   : BinaryTransform ( z )
00030 {
00031   m_x = x;
00032   m_y = y;
00033 // The following verboseness for VC++ in debug mode.
00034   const std::string xname = m_x->name ();
00035   const std::string yname = m_y->name ();
00036   const std::string zname = z->name ();
00037   m_name = xname;
00038   m_name += " ";
00039   m_name += yname;
00040   m_name += " ";
00041   m_name += zname;
00042 }
00043 
00044 XYTransform::~XYTransform ()
00045 {
00046   delete m_x;
00047   delete m_y;
00048 }
00049 
00050 XYTransform::XYTransform ( const XYTransform & t )
00051   : BinaryTransform ( t )
00052 {
00053 #ifdef CLONE_DEFECT
00054   m_x = dynamic_cast < UnaryTransform * > ( t.m_x->clone () );
00055   m_y = dynamic_cast < UnaryTransform * > ( t.m_y->clone () );
00056 #else
00057   m_x = t.m_x->clone ();
00058   m_y = t.m_y->clone ();
00059 #endif
00060 }
00061 
00062 #ifdef CLONE_DEFECT
00063 TransformBase * XYTransform::clone () const
00064 #else
00065 XYTransform   * XYTransform::clone () const
00066 #endif
00067 {
00068   return new XYTransform ( *this );
00069 }
00070 
00071 bool
00072 XYTransform::
00073 isLinearInXY ( ) const
00074 {
00075   return m_x -> isLinear () && m_y -> isLinear ();
00076 }
00077 
00078 /* virtual */
00079 void XYTransform::transform ( double & x,
00080                               double & y ) const
00081 {
00082   m_x->transform ( x );
00083   m_y->transform ( y );
00084 }
00085 
00086 bool
00087 XYTransform::
00088 inverseTransform ( double & x, double & y ) const
00089 {
00090   m_x->inverseTransform ( x );
00091   m_y->inverseTransform ( y );
00092 
00093   // Always return true because the return value only
00094   // make sense with WCSLIB.
00095   return true;
00096 }
00097 
00098 /* virtual */
00099 void
00100 XYTransform::
00101 transform ( std::vector< double > & x,
00102             std::vector< double > & y ) const
00103 {
00104   m_x->transform ( x );
00105   m_y->transform ( y );
00106 }
00107 
00108 double XYTransform::aspectRatio () const
00109 {
00110   return 0.0;
00111 }
00112 
00113 Rect XYTransform::calcRectangle ( const Range & x, 
00114                                             const Range & y ) 
00115 {
00116   double x_lo = x.low ();
00117   double x_hi = x.high ();
00118   double y_lo = y.low ();
00119   double y_hi = y.high ();
00120 
00121   transform ( x_lo, y_lo );
00122   transform ( x_hi, y_hi );
00123 
00124   return Rect ( x_lo, y_lo, x_hi - x_lo, y_hi - y_lo );
00125 }
00126 
00127 /* virtual */
00128 void XYTransform::validate ( Range & x, Range & y ) const
00129 {
00130   m_x->validate ( x );
00131   m_y->validate ( y );
00132 }
00133 
00134 /* virtual */
00135 const Range & XYTransform::limitX () const
00136 {
00137   return m_x->limits ();
00138 }
00139 
00140 const Range & XYTransform::limitY () const
00141 {
00142   return m_y->limits ();
00143 }
00144 
00145 TransformBase * XYTransform::xTransform () const
00146 {
00147   return m_x;
00148 }
00149 
00150 TransformBase * XYTransform::yTransform () const
00151 {
00152   return m_y;
00153 }
00154 
00155 const vector < AxisTick > &
00156 XYTransform::
00157 setTicks ( AxisModelBase & model, hippodraw::Axes::Type axis ) 
00158 {
00159   if ( axis == Axes::X ) {
00160     return m_x -> setTicks ( model );
00161   }
00162   else if ( axis == Axes::Y ) {
00163     return m_y -> setTicks ( model );
00164   }
00165   else {
00166     return m_z ->setTicks ( model );
00167   }
00168 }
00169 
00170 void
00171 XYTransform::
00172 adjustValues ( AxisModelBase & model,
00173                hippodraw::Axes::Type  axes,
00174                const Range & limit )
00175 {
00176   if ( axes == Axes::X )
00177     m_x -> adjustValues ( model, limit );
00178   else  if ( axes == Axes::Y )
00179     m_y -> adjustValues ( model, limit );
00180   else if ( axes == Axes::Z )
00181     m_z -> adjustValues ( model, limit );
00182 }

Generated for HippoDraw Class Library by doxygen