CMS 3D CMS Logo

VisRootModel.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisRoot/VisRootModel/interface/VisRootModel.h"
00004 #include "VisRoot/VisRootModel/interface/VisRootModelEvent.h"
00005 #include "VisRoot/VisRootModel/interface/VisRootRep.h"
00006 #include <TCanvas.h>
00007 #include <iostream>
00008 using namespace std;
00009 
00010 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00011 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00012 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00013 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00014 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00015 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00016 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00017 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00018 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00019 
00020 VisRootModel::VisRootModel (IgState *state)
00021     : m_state (state),
00022       m_canvas (0),
00023       m_modelChangedDispatcher (new Dispatcher)
00024 {
00025     m_currentPad = 0;
00026     
00027 }
00028 
00029 VisRootModel::~VisRootModel (void)
00030 {
00031     for (std::set<VisRootRep *>::iterator i = m_repSet.begin ();
00032          i != m_repSet.end ();
00033          i++)
00034     {
00035         untrackRep (*i);
00036         delete *i;      
00037     }    
00038 }
00039 
00040 
00041 TCanvas *
00042 VisRootModel::canvas (void)
00043 {
00044     return m_canvas;    
00045 }
00046 
00047 void
00048 VisRootModel::canvas (TCanvas *canvas)
00049 {
00050     m_canvas = canvas;
00051 }
00052 
00053 TVirtualPad *
00054 VisRootModel::pad (void)
00055 {
00056     return m_pad;    
00057 }
00058 
00059 void
00060 VisRootModel::pad (TVirtualPad *pad)
00061 {
00062     m_pad = pad;
00063 }
00064 
00065 IgState *
00066 VisRootModel::state (void)
00067 {
00068     return m_state;
00069 }
00070 
00071 
00072 VisRootModel::Dispatcher *
00073 VisRootModel::dispatcher (unsigned int /*eventType*/)
00074 {
00075     return m_modelChangedDispatcher;    
00076 }
00077 
00078 void
00079 VisRootModel::changed (void)
00080 {
00081     VisRootModelEvent event (this);    
00082     dispatcher (ModelChanged)->broadcast (event);    
00083 }
00084 
00085 void
00086 VisRootModel::setCanvasSubdivisions (unsigned int x, unsigned int y)
00087 {
00088     ASSERT (m_canvas);
00089     m_canvas->Clear ();    
00090     m_canvas->cd ();    
00091     m_canvas->Divide (x, y);
00092     m_maxPads = x * y;
00093     m_currentPad = 0;   
00094 }
00095 
00096 void
00097 VisRootModel::setPad (TVirtualPad * p, unsigned int nChildren)
00098 {
00099     m_vec.push_back (p);
00100     m_maxPads = nChildren;
00101 }
00102 
00103 TVirtualPad *
00104 VisRootModel::getCurrentVecElement (void)
00105 {
00106     m_currentPad %= (m_maxPads);
00107     m_currentPad++;
00108    
00109     return (m_vec.at (m_currentPad-1));
00110  }
00111 
00112 unsigned int
00113 VisRootModel::getNextPad (void)
00114 {
00115     m_currentPad++;
00116     m_currentPad %= (m_maxPads + 1);
00117     return m_currentPad;
00118 }
00119 
00120 void
00121 VisRootModel::trackRep (VisRootRep *rep)
00122 {
00123     m_repSet.insert (rep);    
00124 }
00125 
00126 void
00127 VisRootModel::resetVec ()
00128 {
00129     m_vec.clear ();    
00130 }
00131 
00132 void
00133 VisRootModel::untrackRep (VisRootRep *rep)
00134 {
00135     ASSERT (m_repSet.find (rep) != m_repSet.end ());    
00136     m_repSet.erase (rep);    
00137 }
00138 
00139 std::vector <TVirtualPad *>
00140 VisRootModel::getVec ()
00141 {
00142     return m_vec;    
00143 }
00144 

Generated on Tue Jun 9 17:50:29 2009 for CMSSW by  doxygen 1.5.4