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