Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Recon.cxx

Go to the documentation of this file.
00001 // $Id: Recon.cxx,v 1.5 2001/01/26 02:09:31 burnett Exp $
00002 
00003 #include "reconstruction/Recon.h"
00004 
00005 
00006 #include "reconstruction/ReconVisitor.h"
00007 #include "gui/DisplayRep.h"
00008 
00009 int Recon::s_mode=1; // global mode (interpret at will)
00010 
00011 Recon::Recon () : _title(0), _parent(0) {}
00012 
00013 Recon::Recon (Recon* prnt) : _title(0), _parent(prnt) {}
00014 
00015 Recon::~Recon ()
00016 {
00017   deleteRecons();
00018   if(_parent) {
00019     _parent->removeRecon(this);
00020   }
00021 }
00022 
00023 
00024 Recon& Recon::addRecon (Recon* nextRecon)
00025 {
00026   _reconList.push_back(nextRecon);
00027   nextRecon->setParent(this);
00028   return *nextRecon;
00029 }
00030 
00031 
00032 Recon& Recon::removeRecon (Recon* oldRecon)
00033 {
00034      _reconList.remove(oldRecon);
00035      return *oldRecon;
00036 }
00037 
00038 
00039 void Recon::deleteRecons ()
00040 {
00041   if(_title) delete [] _title;
00042   ReconListIterator it = _reconList.begin();
00043   while (it != _reconList.end() ) {
00044         delete *it;
00045         it = _reconList.erase(it);
00046   }
00047 }
00048 
00049 
00050 Recon& Recon::setTitle (const char* newTitle)
00051 {
00052    if( _title) delete [] _title;
00053    strcpy(_title = new char[strlen(newTitle)+1], newTitle);
00054    return *this;
00055 }
00056 
00057 
00058 void Recon::clear ()
00059 {
00060   setState(RESET);
00061   ReconListIterator it = _reconList.begin();
00062   for ( ; it != _reconList.end(); it++ ) {
00063     (*it)->clear();
00064   }
00065 }
00066 
00067 
00068 void Recon::accept (ReconVisitor& a)
00069 {
00070     ReconListIterator it = _reconList.begin();
00071     for ( ; it != _reconList.end(); it++ ) {
00072         (*it)->accept(a); 
00073         if( (*it)->state()==FAIL) break;
00074     }
00075 }
00076 
00077 
00078 void Recon::readData (std::istream& is)
00079 {
00080   Recon::readData(is);
00081   ReconListIterator it = _reconList.begin();
00082   for ( ; it != _reconList.end(); it++ ) {
00083     (*it)->readData(is);
00084   }
00085 }
00086 
00087 
00088 void Recon::writeData (std::ostream& os)
00089 {
00090   Recon::writeData(os);
00091   ReconListIterator it = _reconList.begin();
00092   for ( ; it != _reconList.end(); it++ ) {
00093     (*it)->writeData(os);
00094   }
00095 }
00096 
00097 
00098 void Recon::printOn (std::ostream& os) const
00099 {
00100   ReconListConstIterator it = _reconList.begin();
00101   int i=0;
00102   for ( ; it != _reconList.end(); it++ ) {
00103     os << "\n" << title() <<" inner Recon# "<< ++i ;
00104     (*it)->printOn(os);
00105   }
00106 }
00107 
00108 class Recon::Rep : public gui::DisplayRep {
00109     friend class Recon;
00110         Rep( Recon* reco):m_reco(reco){}
00111         void update(){m_reco->draw(*this);}
00112         Recon * m_reco;
00113     };
00114 
00115 
00116 
00117 gui::DisplayRep* Recon::displayRep()
00118 {
00119     
00120     return new Rep(this);
00121 }
00122 
00123 void Recon::draw (gui::DisplayRep& v)
00124 {
00125   ReconListIterator it = _reconList.begin();
00126   for ( ; it != _reconList.end(); it++ ) {
00127     (*it)->draw(v);
00128   }
00129 }

Generated at Wed Nov 21 12:20:45 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000