Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Anp::EventDisplay Class Reference

#include <EventDisplay.h>

List of all members.

Public Member Functions

void Add (EventTabPtr tab)
EventTabPtr Add (const std::string &name)
void Add (const Record &record)
void Init ()
void Selected (int tab)
void NextEvent ()
void PrevEvent ()
void NextSnarl ()
void PrevSnarl ()
void ZoomIn ()
void ZoomOut ()
void PrintTruth ()
void PrintData ()
void PrintTab ()
void CloseWindow ()

Static Public Member Functions

EventDisplayInstance ()

Private Types

typedef std::vector< Anp::EventTabPtrTabVec

Private Member Functions

 EventDisplay (const EventDisplay &)
const EventDisplayoperator= (const EventDisplay &)
 EventDisplay ()
 ~EventDisplay ()
void NewEvent ()
void InitTab (EventTabPtr tab)
EventTabPtr GetCurrent ()

Private Attributes

TGMainFrame * fMain
TGTab * fTab
TabVec fTabs
RecordStore fStore
bool fZoom

Static Private Attributes

EventDisplayfgInstance = 0


Member Typedef Documentation

typedef std::vector<Anp::EventTabPtr> Anp::EventDisplay::TabVec [private]
 

Definition at line 61 of file EventDisplay.h.


Constructor & Destructor Documentation

Anp::EventDisplay::EventDisplay const EventDisplay  )  [private]
 

Anp::EventDisplay::EventDisplay  )  [private]
 

Definition at line 39 of file EventDisplay.cxx.

00040    :fMain(NULL),
00041     fTab(NULL),
00042     fStore(),
00043     fZoom(false)
00044 {
00045 }

Anp::EventDisplay::~EventDisplay  )  [inline, private]
 

Definition at line 51 of file EventDisplay.h.

00051 {}


Member Function Documentation

void Anp::EventDisplay::Add const Record record  ) 
 

Definition at line 48 of file EventDisplay.cxx.

References Anp::RecordStore::Add(), and fStore.

00049 {
00050    fStore.Add(record);
00051 }

Anp::EventTabPtr Anp::EventDisplay::Add const std::string &  name  ) 
 

Definition at line 70 of file EventDisplay.cxx.

References Add(), Anp::EventTabPtr, and Anp::Handle< T >::valid().

00071 {
00072    EventTabPtr tab = Factory<EventTab>::Instance().Create(name);
00073 
00074    if(!tab.valid())
00075    {
00076       cerr << "EventDisplay::Init() - failed to create tab:" << name << endl;
00077       return EventTabPtr(0);
00078    }      
00079    
00080    tab -> SetName(name);
00081 
00082    Add(tab);
00083 
00084    return tab;
00085 }

void Anp::EventDisplay::Add EventTabPtr  tab  ) 
 

Definition at line 54 of file EventDisplay.cxx.

References Anp::EventTabPtr, fTab, fTabs, InitTab(), and Anp::Handle< T >::valid().

Referenced by Add().

00055 {
00056    if(!tab.valid())
00057    {
00058       cerr << "EventDisplay::Add() - ignoring invalid tab" << endl;
00059    }
00060 
00061    fTabs.push_back(tab);
00062    
00063    if(fTab && fMain)
00064    {
00065       InitTab(tab);
00066    }
00067 }

void Anp::EventDisplay::CloseWindow  ) 
 

Definition at line 389 of file EventDisplay.cxx.

References fMain.

00390 {
00391    if(fMain)
00392    {
00393       fMain -> CloseWindow();
00394    }
00395 }

Anp::EventTabPtr Anp::EventDisplay::GetCurrent  )  [private]
 

Definition at line 118 of file EventDisplay.cxx.

References Anp::EventTabPtr, fTab, and fTabs.

Referenced by NewEvent(), PrintTab(), ZoomIn(), and ZoomOut().

00119 {
00120    const int current = fTab -> GetCurrent();
00121     
00122    if(current < static_cast<int>(fTabs.size()))
00123    {
00124       return fTabs[current];
00125    }
00126    else
00127    {
00128       cerr << "EventDisplay::GetCurrent() - requested tab does not exists" << endl;
00129    }
00130 
00131    return EventTabPtr(0);
00132 }

void Anp::EventDisplay::Init  ) 
 

Definition at line 148 of file EventDisplay.cxx.

References fMain, fTab, fTabs, InitTab(), main(), and Lit::Print().

Referenced by InitTab().

00149 {
00150   TGWindow* main = const_cast<TGWindow*> (gClient->GetRoot());
00151   fMain = new TGMainFrame(main, 1000, 900, kHorizontalFrame);
00152   fMain -> SetWMSize(900, 700);
00153   fMain -> SetCleanup(kDeepCleanup);
00154   fMain -> Connect("CloseWindow()", "Anp::EventDisplay", this, "CloseWindow()");  
00155 
00156    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00157    // add tab frame
00158    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00159 
00160    fTab = new TGTab(fMain, 900, 900);
00161    TGLayoutHints *thints = new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2);
00162    fTab -> Connect("Selected(Int_t)", "Anp::EventDisplay", this, "Selected(int)");
00163    fMain -> AddFrame(fTab, thints);
00164    cout<<"EventDisplay::Init() before for loop" <<endl;
00165    for(TabVec::const_iterator cit = fTabs.begin(); cit != fTabs.end(); ++cit) 
00166    {
00167       InitTab(*cit);
00168    }
00169    cout<<" EventDisplay::Init() Add Buttons"<<endl;
00170    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00171    // add buttons
00172    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00173 
00174    TGVerticalFrame *bframe = new TGVerticalFrame(fMain, 80, 1000);
00175    bframe -> SetHeight(1000);
00176    bframe -> SetWidth(80);
00177    TGLayoutHints *lh = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 2, 2);
00178 
00179    TGTextButton *bnevent = new TGTextButton(bframe, "Next event", 0);
00180    TGTextButton *bpevent = new TGTextButton(bframe, "Prev event", 0);
00181    TGTextButton *bnsnarl = new TGTextButton(bframe, "Next snarl", 0);
00182    TGTextButton *bpsnarl = new TGTextButton(bframe, "Prev snarl", 0);
00183 
00184    TGTextButton *bzoomi = new TGTextButton(bframe, "Zoom In", 0);
00185    TGTextButton *bzoomo = new TGTextButton(bframe, "Zoom Out", 0);
00186    TGTextButton *btruth = new TGTextButton(bframe, "Print truth", 0);
00187    TGTextButton *bdata  = new TGTextButton(bframe, "Print data", 0);
00188    TGTextButton *bprint = new TGTextButton(bframe, "Print tab", 0);
00189    TGTextButton *bclose = new TGTextButton(bframe, "Close", 0);
00190 
00191    TGLayoutHints *tloh = new TGLayoutHints(kLHintsTop);
00192 
00193    bnevent -> Connect("Clicked()", "Anp::EventDisplay", this, "NextEvent()");
00194    bpevent -> Connect("Clicked()", "Anp::EventDisplay", this, "PrevEvent()");
00195    bnsnarl -> Connect("Clicked()", "Anp::EventDisplay", this, "NextSnarl()");
00196    bpsnarl -> Connect("Clicked()", "Anp::EventDisplay", this, "PrevSnarl()");
00197 
00198    bzoomi -> Connect("Clicked()", "Anp::EventDisplay", this, "ZoomIn()");
00199    bzoomo -> Connect("Clicked()", "Anp::EventDisplay", this, "ZoomOut()");
00200    btruth -> Connect("Clicked()", "Anp::EventDisplay", this, "PrintTruth()");
00201    bdata  -> Connect("Clicked()", "Anp::EventDisplay", this, "PrintData()");
00202    bprint -> Connect("Clicked()", "Anp::EventDisplay", this, "PrintTab()");
00203    bclose -> Connect("Clicked()", "Anp::EventDisplay", this, "CloseWindow()");
00204  
00205    bframe -> AddFrame(bnevent, tloh);
00206    bframe -> AddFrame(bpevent, tloh);
00207    bframe -> AddFrame(bnsnarl, tloh);
00208    bframe -> AddFrame(bpsnarl, tloh);
00209    bframe -> AddFrame(bzoomi, tloh);
00210    bframe -> AddFrame(bzoomo, tloh);
00211    bframe -> AddFrame(btruth, tloh);
00212    bframe -> AddFrame(bprint, tloh);
00213    bframe -> AddFrame(bclose, tloh);
00214 
00215    fMain -> AddFrame(bframe, lh);
00216 
00217    fMain -> SetWindowName("Event display");
00218 
00219    fMain -> MapSubwindows();
00220    fMain -> Resize(fMain -> GetDefaultSize());
00221    fMain -> MapWindow();
00222    fMain -> Layout();
00223    fMain -> Print();
00224    cout<<" Done with Event Display:: Init"<<endl;
00225 }

void Anp::EventDisplay::InitTab EventTabPtr  tab  )  [private]
 

Definition at line 88 of file EventDisplay.cxx.

References Anp::EventTabPtr, fTab, GetCanvas(), Nav::GetName(), and Init().

Referenced by Add(), and Init().

00089 {   
00090    if(!fTab || !fMain)
00091    {
00092       return;
00093    }
00094 
00095    string label = tab -> GetLabel();
00096    if(label.empty())
00097    {
00098       label = tab -> GetName();
00099       tab -> SetLabel(label);      
00100    }
00101 
00102    TGCompositeFrame *tf = fTab -> AddTab(label.c_str());
00103 
00104    TGLayoutHints* lh = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY); 
00105    TRootEmbeddedCanvas *rec = new TRootEmbeddedCanvas(label.c_str(), tf, 700,700);
00106 
00107    tf -> AddFrame(rec, lh);
00108    
00109    tab -> Init(rec -> GetCanvas());
00110    tab -> SetEmbedded(rec);
00111    
00112    fTab -> MapSubwindows();
00113    fTab -> Resize(fTab -> GetDefaultSize());
00114    fTab -> Layout();
00115 }

Anp::EventDisplay & Anp::EventDisplay::Instance  )  [static]
 

Definition at line 26 of file EventDisplay.cxx.

References fgInstance.

00027 {
00028    if(!fgInstance)
00029    {
00030       fgInstance = new Anp::EventDisplay();
00031    }
00032 
00033   return *fgInstance;
00034 }

void Anp::EventDisplay::NewEvent  )  [private]
 

Definition at line 282 of file EventDisplay.cxx.

References Anp::RecordStore::CurrEvent(), Anp::RecordStore::CurrSnarl(), fStore, fTab, fTabs, GetCurrent(), Anp::RecordStore::IsValid(), Anp::Header::Run(), Selected(), Anp::Header::Snarl(), and ZoomIn().

Referenced by NextEvent(), NextSnarl(), PrevEvent(), and PrevSnarl().

00283 {
00284    if(!fStore.IsValid())
00285    {
00286       cerr << "EventDisplay::NewEvent() - bad RecordStore status..." << endl;
00287       return;
00288    }
00289    
00290    const Header &header = fStore.CurrSnarl() -> GetHeader();
00291 
00292    cout << "Run = " << setw(6) << header.Run()
00293         << " snarl = " << setw(6) << header.Snarl()
00294         << " event = " << setw(2) << fStore.CurrEvent() -> EventIndex() 
00295         << endl;
00296 
00297    for(TabVec::const_iterator cit = fTabs.begin(); cit != fTabs.end(); ++cit) 
00298    {
00299       (*cit) -> Set(*fStore.CurrEvent(), *fStore.CurrSnarl());
00300       
00301       if(fZoom)
00302       {
00303         (*cit) -> ZoomIn(); 
00304       }
00305    }
00306 
00307    Selected(fTab -> GetCurrent());
00308 }

void Anp::EventDisplay::NextEvent  ) 
 

Definition at line 228 of file EventDisplay.cxx.

References fStore, NewEvent(), and Anp::RecordStore::NextEvent().

00229 {
00230    fStore.NextEvent();
00231    NewEvent();
00232 }

void Anp::EventDisplay::NextSnarl  ) 
 

Definition at line 242 of file EventDisplay.cxx.

References fStore, NewEvent(), and Anp::RecordStore::NextSnarl().

00243 {
00244    fStore.NextSnarl();
00245    NewEvent();
00246 }

const EventDisplay& Anp::EventDisplay::operator= const EventDisplay  )  [private]
 

void Anp::EventDisplay::PrevEvent  ) 
 

Definition at line 235 of file EventDisplay.cxx.

References fStore, NewEvent(), and Anp::RecordStore::PrevEvent().

00236 {
00237    fStore.PrevEvent();
00238    NewEvent();
00239 }

void Anp::EventDisplay::PrevSnarl  ) 
 

Definition at line 249 of file EventDisplay.cxx.

References fStore, NewEvent(), and Anp::RecordStore::PrevSnarl().

00250 {
00251    fStore.PrevSnarl();
00252    NewEvent();
00253 }

void Anp::EventDisplay::PrintData  ) 
 

Definition at line 319 of file EventDisplay.cxx.

References fStore, Anp::RecordStore::IsValid(), and Anp::RecordStore::PrintData().

00320 {
00321   if(fStore.IsValid())
00322     {
00323       fStore.PrintData();
00324     }
00325 }

void Anp::EventDisplay::PrintTab  ) 
 

Definition at line 329 of file EventDisplay.cxx.

References Anp::RecordStore::CurrEvent(), Anp::RecordStore::CurrSnarl(), Anp::RecordStore::EventEnd(), Anp::EventTabPtr, fStore, GetCanvas(), GetCurrent(), Nav::GetName(), Anp::RecordStore::IsValid(), Lit::Print(), Anp::Header::Run(), Anp::Header::Snarl(), Anp::RecordStore::SnarlEnd(), and Anp::Handle< T >::valid().

00330 {
00331    if(!fTab)
00332    {
00333       cout << "PrintTab: no tabs exists" << endl;
00334       return;
00335    }
00336 
00337    if(!fStore.IsValid())
00338    {
00339       cout << "PrintTab:: bad RecordStore" << endl;
00340       return;
00341    }
00342 
00343    RecordStore::SnarlIter snarl = fStore.CurrSnarl();
00344    if(snarl == fStore.SnarlEnd())
00345    {
00346       cout << "PrintTab: no snarls found" << endl;
00347       return;
00348    }
00349 
00350    RecordStore::EventIter event = fStore.CurrEvent();
00351    if(event == fStore.EventEnd())
00352    {
00353       cout << "PrintTab: no events found" << endl;
00354       return;
00355    }
00356 
00357    EventTabPtr tab = GetCurrent();
00358    if(!tab.valid())
00359    {
00360       cout << "PrintTab: current tab is not valid" << endl;
00361       return;
00362    }
00363    
00364    TRootEmbeddedCanvas *emcan = tab -> GetEmbedded();
00365    if(!emcan)
00366    {
00367       cout << "PrintTab: invalid pointer to TRootEmbeddedCanvas" << endl;
00368       return;
00369    }
00370       
00371    TCanvas *canvas = emcan -> GetCanvas();
00372    if(!canvas)
00373    {
00374       cout << "PrintTab: TRootEmbeddedCanvas has invalid TCanvas" << endl;
00375       return;
00376    }
00377    
00378    const Header &header = snarl -> GetHeader();
00379    
00380    stringstream name;
00381    name << tab -> GetName() << "_run_" << header.Run()
00382         << "_snarl_" << header.Snarl() << "_event_" << event -> EventIndex() 
00383         << ".eps";
00384    
00385    canvas -> Print(name.str().c_str());
00386 }

void Anp::EventDisplay::PrintTruth  ) 
 

Definition at line 311 of file EventDisplay.cxx.

References fStore, Anp::RecordStore::IsValid(), and Anp::RecordStore::PrintTruth().

00312 {
00313    if(fStore.IsValid())
00314    {
00315       fStore.PrintTruth();
00316    }
00317 }

void Anp::EventDisplay::Selected int  tab  ) 
 

Definition at line 135 of file EventDisplay.cxx.

References fTabs.

Referenced by NewEvent(), ZoomIn(), and ZoomOut().

00136 {
00137    if(tab < static_cast<int>(fTabs.size()))
00138    {
00139       fTabs[tab] -> Expose();
00140    }
00141    else
00142    {
00143       cerr << "EventDisplay::Selected() - tab index is out of range" << endl;
00144    }
00145 }

void Anp::EventDisplay::ZoomIn  ) 
 

Definition at line 256 of file EventDisplay.cxx.

References fTab, fTabs, fZoom, GetCurrent(), and Selected().

Referenced by NewEvent().

00257 {
00258    fZoom = true;
00259 
00260    for(TabVec::const_iterator cit = fTabs.begin(); cit != fTabs.end(); ++cit) 
00261    {
00262       (*cit) -> ZoomIn();
00263    }
00264 
00265    Selected(fTab -> GetCurrent());
00266 }

void Anp::EventDisplay::ZoomOut  ) 
 

Definition at line 269 of file EventDisplay.cxx.

References fTab, fTabs, fZoom, GetCurrent(), and Selected().

00270 {
00271    fZoom = false;
00272 
00273    for(TabVec::const_iterator cit = fTabs.begin(); cit != fTabs.end(); ++cit) 
00274    {
00275       (*cit) -> ZoomOut();
00276    }
00277 
00278    Selected(fTab -> GetCurrent());
00279 }


Member Data Documentation

Anp::EventDisplay * Anp::EventDisplay::fgInstance = 0 [static, private]
 

Definition at line 21 of file EventDisplay.cxx.

Referenced by Instance().

TGMainFrame* Anp::EventDisplay::fMain [private]
 

Definition at line 67 of file EventDisplay.h.

Referenced by CloseWindow(), and Init().

RecordStore Anp::EventDisplay::fStore [private]
 

Definition at line 72 of file EventDisplay.h.

Referenced by Add(), NewEvent(), NextEvent(), NextSnarl(), PrevEvent(), PrevSnarl(), PrintData(), PrintTab(), and PrintTruth().

TGTab* Anp::EventDisplay::fTab [private]
 

Definition at line 68 of file EventDisplay.h.

Referenced by Add(), GetCurrent(), Init(), InitTab(), NewEvent(), ZoomIn(), and ZoomOut().

TabVec Anp::EventDisplay::fTabs [private]
 

Definition at line 70 of file EventDisplay.h.

Referenced by Add(), GetCurrent(), Init(), NewEvent(), Selected(), ZoomIn(), and ZoomOut().

bool Anp::EventDisplay::fZoom [private]
 

Definition at line 74 of file EventDisplay.h.

Referenced by ZoomIn(), and ZoomOut().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:10:31 2010 for loon by  doxygen 1.3.9.1