00001 00012 #include "BinaryTransform.h" 00013 00014 #include "UnaryTransform.h" 00015 00016 #include <cassert> 00017 00018 namespace hippodraw { 00019 00024 BinaryTransform::BinaryTransform () 00025 { 00026 m_name = "nil"; 00027 00028 m_needs_grid = false; 00029 m_needs_x_ticks = true; 00030 m_needs_y_ticks = true; 00031 m_is_periodic = false; 00032 00033 m_z = 0; 00034 } 00035 00036 BinaryTransform::BinaryTransform ( UnaryTransform * z, 00037 bool is_periodic, 00038 bool needs_grid, 00039 bool needs_x_ticks, 00040 bool needs_y_ticks ) 00041 { 00042 m_z = z; 00043 m_name = m_z->name(); 00044 00045 m_needs_grid = needs_grid; 00046 m_needs_x_ticks = needs_x_ticks; 00047 m_needs_y_ticks = needs_y_ticks; 00048 m_is_periodic = is_periodic; 00049 00050 } 00051 00052 BinaryTransform::BinaryTransform ( const BinaryTransform & t ) 00053 : TransformBase ( t ) 00054 { 00055 00056 if ( t.m_z == 0 ){ 00057 m_z = 0; 00058 return; 00059 } 00060 00061 assert ( t.m_z ); 00062 00063 #ifdef CLONE_DEFECT 00064 m_z = dynamic_cast < UnaryTransform * > ( t.m_z->clone () ); 00065 #else 00066 m_z = t.m_z->clone (); 00067 #endif 00068 00069 m_needs_grid = t.needsGrid(); 00070 m_needs_x_ticks = t.needsXTicks(); 00071 m_needs_y_ticks = t.needsYTicks(); 00072 m_is_periodic = t.isPeriodic(); 00073 00074 } 00075 00076 BinaryTransform::~BinaryTransform () 00077 { 00078 delete m_z; 00079 } 00080 00081 double BinaryTransform::aspectRatio () const 00082 { 00083 return 0.0; 00084 } 00085 00086 TransformBase * BinaryTransform::zTransform () const 00087 { 00088 return m_z; 00089 } 00090 00091 void 00092 BinaryTransform:: 00093 setZTransform ( TransformBase * transform ) 00094 { 00095 UnaryTransform * t = dynamic_cast < UnaryTransform * > ( transform ); 00096 00097 m_z = t; 00098 } 00099 00100 void BinaryTransform::transformZ ( double & z ) const 00101 { 00102 assert ( m_z ); 00103 m_z->transform ( z ); 00104 } 00105 00106 void BinaryTransform::inverseTransformZ ( double & z ) const 00107 { 00108 assert ( m_z ); 00109 m_z->inverseTransform ( z ); 00110 } 00111 00112 const Range & BinaryTransform::limitZ () const 00113 { 00114 assert ( m_z ); 00115 return m_z->limits(); 00116 } 00117 00118 bool BinaryTransform::needsGrid() const 00119 { 00120 return m_needs_grid; 00121 } 00122 00123 void BinaryTransform::setNeedsGrid( bool needs_grid ) 00124 { 00125 m_needs_grid = needs_grid; 00126 } 00127 00128 bool BinaryTransform::needsXTicks() const 00129 { 00130 return m_needs_x_ticks; 00131 } 00132 00133 void BinaryTransform::setNeedsXTicks( bool needs_x_ticks ) 00134 { 00135 m_needs_x_ticks = needs_x_ticks; 00136 } 00137 00138 bool BinaryTransform::needsYTicks() const 00139 { 00140 return m_needs_y_ticks; 00141 } 00142 00143 void BinaryTransform::setNeedsYTicks( bool needs_y_ticks ) 00144 { 00145 m_needs_y_ticks = needs_y_ticks; 00146 } 00147 00148 bool BinaryTransform::isPeriodic() const 00149 { 00150 return m_is_periodic; 00151 } 00152 00153 bool BinaryTransform::isLinearInZ() const 00154 { 00155 return m_z->isLinear(); 00156 } 00157 00158 00159 } // namespace hippodraw