00001 00012 // for truncation warning in debug mode 00013 #ifdef _MSC_VER 00014 #include "msdevstudio/MSconfig.h" 00015 #endif 00016 00017 #include "VariableMesh.h" 00018 00019 #include "projectors/MeshProjector.h" 00020 #include "reps/ColorBoxPointRep.h" 00021 00022 using namespace hippodraw; 00023 00024 using std::string; 00025 using std::vector; 00026 00027 00028 VariableMesh::VariableMesh ( ) 00029 : DataRep () 00030 { 00031 m_name = "Variable Mesh"; 00032 00033 MeshProjector * projector = new MeshProjector(); 00034 projector->setXErrorOption ( false ); // method not in ProjectorBase 00035 projector->setYErrorOption ( false ); 00036 m_projector = projector; 00037 00038 m_rep = new ColorBoxPointRep ( ); 00039 } 00040 00041 DataRep * VariableMesh::clone () 00042 { 00043 return new VariableMesh( *this ); 00044 } 00045 00051 void 00052 VariableMesh:: 00053 setRepresentation ( RepBase * rep ) 00054 { 00055 DataRep::setPointRep ( rep ); 00056 00057 const vector < string > & bindings = m_projector -> getAxisBindings (); 00058 00059 bool yes = bindings[3] != "nil"; 00060 setErrorDisplay ( Axes::X, yes ); 00061 00062 yes = bindings[4] != "nil"; 00063 setErrorDisplay ( Axes::Y, yes ); 00064 } 00065 00066 bool VariableMesh::acceptFunction ( int num ) 00067 { 00068 return num == 2; 00069 } 00070 00071 bool 00072 VariableMesh:: 00073 hasErrorDisplay () const 00074 { 00075 bool yes = true; 00076 00077 const vector < string > & bindings = m_projector -> getAxisBindings (); 00078 00079 // Was 2 and 3, should be a bug 00080 yes = bindings[3] != "nil" || bindings[4] != "nil"; 00081 00082 return yes; 00083 } 00084 00085 00086 void 00087 VariableMesh:: 00088 setAxisBinding ( const std::string & axis, const std::string & label ) 00089 { 00090 DataRep::setAxisBinding ( axis, label ); 00091 00092 NTupleProjector * projector 00093 = dynamic_cast < NTupleProjector * > ( m_projector ); 00094 unsigned int index = projector -> indexOfBindingOption ( axis ); 00095 00096 bool yes = label != "nil"; 00097 if ( index == 3 ) { 00098 setErrorDisplay ( Axes::X, yes ); 00099 } 00100 00101 if ( index == 4 ) { 00102 setErrorDisplay ( Axes::Y, yes ); 00103 } 00104 } 00105 00106 void 00107 VariableMesh:: 00108 setAxisBindings ( const std::vector < std::string > & new_bindings ) 00109 { 00110 DataRep::setAxisBindings ( new_bindings ); 00111 00112 const vector < string > & bindings = m_projector ->getAxisBindings (); 00113 bool yes = bindings[3] != "nil"; 00114 setErrorDisplay ( Axes::X, yes ); 00115 00116 yes = bindings[4] != "nil"; 00117 setErrorDisplay ( Axes::Y, yes ); 00118 } 00119 00120 bool 00121 VariableMesh:: 00122 hasAxis ( hippodraw::Axes::Type axis ) const 00123 { 00124 return axis == Axes::X || axis == Axes::Y || axis == Axes::Z; 00125 }