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

static EventDisplayInstance ()

Private Types

typedef std::vector
< Anp::EventTabPtr
TabVec

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

static EventDisplayfgInstance = 0

Detailed Description

Definition at line 17 of file EventDisplay.h.


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.

Referenced by Instance().

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 }

EventTabPtr Anp::EventDisplay::Add ( const std::string &  name  ) 
void Anp::EventDisplay::Add ( EventTabPtr  tab  ) 

Definition at line 54 of file EventDisplay.cxx.

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

Referenced by Anp::DrawSnarl::Config(), and Anp::DrawSnarl::Run().

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 390 of file EventDisplay.cxx.

References fMain.

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

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

Definition at line 118 of file EventDisplay.cxx.

References 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 ( void   ) 

Definition at line 148 of file EventDisplay.cxx.

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

Referenced by InitTab(), and Anp::DrawSnarl::~DrawSnarl().

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(bdata,  tloh);
00213    bframe -> AddFrame(bprint, tloh);
00214    bframe -> AddFrame(bclose, tloh);
00215 
00216    fMain -> AddFrame(bframe, lh);
00217 
00218    fMain -> SetWindowName("Event display");
00219 
00220    fMain -> MapSubwindows();
00221    fMain -> Resize(fMain -> GetDefaultSize());
00222    fMain -> MapWindow();
00223    fMain -> Layout();
00224    fMain -> Print();
00225    cout<<" Done with Event Display:: Init"<<endl;
00226 }

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

Definition at line 88 of file EventDisplay.cxx.

References fMain, 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 ( void   )  [static]

Definition at line 26 of file EventDisplay.cxx.

References EventDisplay(), and fgInstance.

Referenced by Anp::DrawSnarl::Config(), Anp::DrawSnarl::Run(), and Anp::DrawSnarl::~DrawSnarl().

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

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

Definition at line 283 of file EventDisplay.cxx.

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

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

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

void Anp::EventDisplay::NextEvent (  ) 

Definition at line 229 of file EventDisplay.cxx.

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

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

void Anp::EventDisplay::NextSnarl (  ) 

Definition at line 243 of file EventDisplay.cxx.

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

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

const EventDisplay& Anp::EventDisplay::operator= ( const EventDisplay  )  [private]
void Anp::EventDisplay::PrevEvent (  ) 

Definition at line 236 of file EventDisplay.cxx.

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

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

void Anp::EventDisplay::PrevSnarl (  ) 

Definition at line 250 of file EventDisplay.cxx.

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

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

void Anp::EventDisplay::PrintData (  ) 

Definition at line 320 of file EventDisplay.cxx.

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

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

void Anp::EventDisplay::PrintTab (  ) 

Definition at line 330 of file EventDisplay.cxx.

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

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

void Anp::EventDisplay::PrintTruth (  ) 

Definition at line 312 of file EventDisplay.cxx.

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

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

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 257 of file EventDisplay.cxx.

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

Referenced by NewEvent().

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

void Anp::EventDisplay::ZoomOut (  ) 

Definition at line 270 of file EventDisplay.cxx.

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

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


Member Data Documentation

Definition at line 65 of file EventDisplay.h.

Referenced by Instance().

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

Definition at line 67 of file EventDisplay.h.

Referenced by Add(), CloseWindow(), Init(), and InitTab().

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

Definition at line 68 of file EventDisplay.h.

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

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 NewEvent(), ZoomIn(), and ZoomOut().


The documentation for this class was generated from the following files:

Generated on 19 Jan 2018 for loon by  doxygen 1.6.1