CheezyPage Class Reference

#include <CheezyPage.h>

Inheritance diagram for CheezyPage:

CanvasPage PageABC List of all members.

Public Member Functions

 CheezyPage ()
 ~CheezyPage ()
virtual TObject * Init (Mint *mint, PageDisplay *pd, GuiBox &box)
void Clear ()
void Update ()
 Implement to respond to a change in the data.
void Configure (const Registry &reg)

Private Member Functions

void BuildMenus (PageDisplay *pd)
void InitConfig ()
void ApplyConfig ()
void SpawnConfigurator (void)

Private Attributes

CheezyDisplayfDisplay
MintfMint
std::string fListPlex
std::string fListTruth
bool fDrawEmpty
Registry fConfig
Registry fConfigPossibles

Detailed Description

Id
CheezyPage.h,v 1.2 2003/03/26 18:48:33 bv Exp

Definition at line 30 of file CheezyPage.h.


Constructor & Destructor Documentation

CheezyPage::CheezyPage (  ) 

Definition at line 45 of file CheezyPage.cxx.

References InitConfig().

00046     : fDisplay(0)
00047     , fMint(0)
00048     , fListPlex("canddigitlist")
00049     , fListTruth("candmcdigitlist")
00050     , fDrawEmpty(false)
00051 {
00052     this->InitConfig();
00053 }

CheezyPage::~CheezyPage (  ) 

Definition at line 54 of file CheezyPage.cxx.

References fDisplay.

00055 {
00056     if (fDisplay) delete fDisplay; fDisplay=0;
00057 }


Member Function Documentation

void CheezyPage::ApplyConfig (  )  [private]

Definition at line 220 of file CheezyPage.cxx.

References fConfig, fDisplay, fDrawEmpty, fListPlex, fListTruth, Registry::Get(), CheezyDisplay::SetDrawOnlyBest(), CheezyDisplay::SetDrawTruth(), and CheezyDisplay::SetWgtThresh().

Referenced by Update().

00221 {
00222     const char* str = 0;
00223     int num = 0;
00224     double real = 0.0;
00225 
00226     if (fConfig.Get("ListPlex",str)) fListPlex = str;
00227     if (fConfig.Get("ListTruth",str)) fListTruth = str;
00228     if (fConfig.Get("DrawEmpty",num)) fDrawEmpty = num != 0;
00229 
00230     // The rest need fDisplay already, just quietly return.
00231     if (!fDisplay) return;
00232     
00233     if (fConfig.Get("DrawTruth",num)) fDisplay->SetDrawTruth(num != 0);
00234     if (fConfig.Get("OnlyBest",num))  fDisplay->SetDrawOnlyBest(num != 0);
00235     if (fConfig.Get("WgtThresh",real))  fDisplay->SetWgtThresh(real);
00236 }

void CheezyPage::BuildMenus ( PageDisplay pd  )  [private]

Definition at line 153 of file CheezyPage.cxx.

References GuiMenu::Add(), GuiMenuBar::GetMenu(), PageDisplay::GetMenuBar(), and SpawnConfigurator().

Referenced by Init().

00154 {
00155     // There are two ways to add menus:
00156     // 1) just add a top level one for this CLASS of page
00157     // 2) add one for each INSTANCE in the "Pages" menu
00158     // we will do the latter.
00159 
00160     // Get the menu:
00161     GuiMenuBar& mb = pd->GetMenuBar();
00162     GuiMenu* pm = mb.GetMenu("Pages");
00163     assert(pm);                 // this should always exist.
00164 
00165     // manage() tells the system to do memory management
00166     GuiMenu* mymenu = manage(new GuiMenu);
00167     pm->Add("Cheezy",*mymenu);
00168 
00169     
00170     // for configuring this we will rely on a registry and the
00171     // RegistryGui to set it.  To do this, we will add a single entry
00172     // in our menu with a suitable method to get called with the menu
00173     // entry is selected:
00174     mymenu->Add("Configure",slot_class(*this,&CheezyPage::SpawnConfigurator));
00175 
00176 }

void CheezyPage::Clear ( void   )  [virtual]

Implement to respond to a new record read in, the actual record is accessible in the subsequent Update() call.

Reimplemented from PageABC.

Definition at line 83 of file CheezyPage.cxx.

References CheezyDisplay::ClearLists(), and fDisplay.

00084 {
00085     fDisplay->ClearLists();
00086 }

void CheezyPage::Configure ( const Registry reg  ) 

Definition at line 178 of file CheezyPage.cxx.

References fConfig, and reg.

Referenced by apply_reg_gui().

00179 {
00180     fConfig = reg;
00181 }

TObject * CheezyPage::Init ( Mint mint,
PageDisplay pd,
GuiBox box 
) [virtual]

Implement to fill box with whatever your page displays. If the page wishes to return a class to the initializer, then return an object which inherits from TObject, o.w. just return 0.

Reimplemented from CanvasPage.

Definition at line 60 of file CheezyPage.cxx.

References BuildMenus(), fDisplay, fMint, CanvasPage::GetCanvas(), and CanvasPage::Init().

00061 {
00062     // Must call parent to build blank canvas
00063     this->CanvasPage::Init(mint,pd,box);
00064 
00065     // Save for future use below.
00066     fMint = mint;
00067 
00068     // Now can get the canvas
00069     TCanvas& canvas = this->GetCanvas();
00070     
00071     // Create the object that actually displays stuff.
00072     fDisplay = new CheezyDisplay("CheezyPage","CheezyPage display", &canvas);
00073 
00074     // Allow configurations through Midad menus.
00075     this->BuildMenus(pd);
00076 
00077     // Whatever we return gets returned by the caller of
00078     // PageDisplay::AddPage() or SpawnSinglePage().
00079     // We don't need to comunicate with anyone so just return 0.
00080     return 0;
00081 }

void CheezyPage::InitConfig (  )  [private]

Definition at line 184 of file CheezyPage.cxx.

References fConfig, fConfigPossibles, fListPlex, fListTruth, and Registry::Set().

Referenced by CheezyPage().

00185 {
00186     Registry r;
00187     r.Set("ListPlex",fListPlex.c_str());
00188     r.Set("ListTruth",fListTruth.c_str());
00189     r.Set("DrawEmpty",0);
00190     r.Set("DrawTruth",1);
00191     r.Set("OnlyBest",0);
00192     r.Set("WgtThresh",-1);
00193     fConfig = r;
00194 
00195     Registry possibles;
00196 
00197     Registry list_possibles;
00198     list_possibles.Set("MC list","candmcdigitlist");
00199     list_possibles.Set("Data list","canddigitlist");
00200 
00201     list_possibles.SetName("Possible ListPlex types");
00202     possibles.Set("ListPlex",list_possibles);
00203     list_possibles.SetName("Possible ListTruth types");
00204     possibles.Set("ListTruth",list_possibles);    
00205 
00206     Registry tf_possibles;
00207     tf_possibles.Set("true",1);
00208     tf_possibles.Set("false",0);
00209 
00210     tf_possibles.SetName("Possible DrawEmpty values");
00211     possibles.Set("DrawEmpty",tf_possibles);
00212     tf_possibles.SetName("Possible DrawTruth values");
00213     possibles.Set("DrawTruth",tf_possibles);
00214     tf_possibles.SetName("Possible OnlyBest values");
00215     possibles.Set("OnlyBest",tf_possibles);
00216     
00217     fConfigPossibles = possibles;
00218 }

void CheezyPage::SpawnConfigurator ( void   )  [private]

Definition at line 245 of file CheezyPage.cxx.

References apply_reg_gui(), GuiButtonBase::clicked, fConfig, fConfigPossibles, GuiBase::SetLayoutHints(), RegistryGui::SetPossibles(), and RegistryGui::SetRegistry().

Referenced by BuildMenus().

00246 {
00247     GuiMainWindow* mw = new GuiMainWindow(100,300);
00248     RegistryGui* rg = manage(new RegistryGui(*mw));
00249     mw->Add(*rg);
00250 
00251     GuiBox* box = manage(new GuiBox(*mw,kHorizontalFrame));
00252     box->SetLayoutHints(kLHintsExpandX);
00253     mw->Add(*box);
00254  
00255     GuiTextButton* apply = manage(new GuiTextButton(*box,"Apply"));
00256     box->Add(*apply);
00257     apply->clicked.connect(bind(slot(apply_reg_gui),this,rg));
00258  
00259     GuiTextButton* okay = manage(new GuiTextButton(*box,"Okay"));
00260     box->Add(*okay);
00261     okay->clicked.connect(bind(slot(apply_reg_gui),this,rg));
00262     okay->clicked.connect(slot(*mw,&GuiMainWindow::SendCloseMessage));
00263  
00264     GuiTextButton* cancel = manage(new GuiTextButton(*box,"Cancel"));
00265     box->Add(*cancel);
00266     cancel->clicked.connect(slot(*mw,&GuiMainWindow::SendCloseMessage));
00267  
00268     rg->SetRegistry(fConfig);
00269     rg->SetPossibles(fConfigPossibles);
00270  
00271     mw->ShowAll();
00272     mw->ConnectClose(true);
00273     mw->Resize(mw->GetDefaultWidth(),mw->GetDefaultHeight());
00274     
00275 }

void CheezyPage::Update ( void   )  [virtual]

Implement to respond to a change in the data.

Reimplemented from PageABC.

Definition at line 88 of file CheezyPage.cxx.

References CheezyDisplay::AddSEIdAltL(), ApplyConfig(), CheezyDisplay::Draw(), fDisplay, fDrawEmpty, fListPlex, fListTruth, fMint, CanvasPage::GetCanvas(), MomNavigator::GetFragment(), RecMinos::GetHeader(), Mint::GetJint(), Jint::GetMom(), RecMinosHdr::GetVldContext(), Msg::kWarning, MSG, and CheezyDisplay::SetVldContext().

Referenced by apply_reg_gui().

00089 {
00090     TCanvas& canvas = this->GetCanvas();
00091     canvas.cd();
00092 
00093     const MomNavigator* mom = fMint->GetJint().GetMom();
00094 
00095     // The below is ripped from RerootExodus/CheezyDisplayModule::Ana().
00096 
00097     // Get either RawRecord or CandRecord from Mom
00098     RecMinos *rec = dynamic_cast<RecMinos *>(mom->GetFragment("RecMinos"));
00099     if ( ! rec ) {
00100         MSG("Cheezy", Msg::kWarning) << "CheezyPage: No RecMinos\n";
00101         return;
00102     }
00103 
00104     this->ApplyConfig();
00105 
00106     VldContext vldc = rec->GetHeader()->GetVldContext();
00107     fDisplay->SetVldContext(vldc);
00108 
00109     // This stanza tries to find the MC and data digitlists and if
00110     // successful, goes through and fills the CheezyDisplay with the
00111     // digits.
00112 
00113     // Draw TRUTH first so other digits won't be obscured
00114     // Find MC version of CandDigitList fragment in MOM.
00115 
00116     int ndigits = 0;
00117     const char* names[2] = {
00118         fListTruth.c_str(),
00119         fListPlex.c_str(),
00120     };
00121     bool is_mc[2] = { true, false }; // Is MC, Isn't MC
00122     for (int n=0; n<2; ++n) {
00123         const CandDigitListHandle *cdlh =
00124             DataUtil::GetCandidate<CandDigitListHandle>
00125             (mom,"CandDigitListHandle",names[n]);
00126         if (!cdlh) {
00127             MSG("Cheezy", Msg::kWarning)
00128                 << "CheezyPage: No CandDigitListHandle named "
00129                 << names[n]
00130                 << endl;
00131             continue;
00132         }
00133 
00134         vector<const CandDigitHandle*> dv = 
00135             DataUtil::CDL2STLvector<const CandDigitHandle>(*cdlh);
00136         int siz = dv.size();
00137         ndigits += siz;
00138         for (int ind = 0; ind < siz; ++ind) {
00139             // Register each digit with CheezyDisplay
00140             PlexSEIdAltL altlist = dv[ind]->GetPlexSEIdAltL();
00141             fDisplay->AddSEIdAltL(altlist,is_mc[n]);
00142         }
00143     }  
00144 
00145 
00146     // Now actually draw these things
00147     if (ndigits || fDrawEmpty) fDisplay->Draw();
00148 
00149     return;
00150 }


Member Data Documentation

Registry CheezyPage::fConfig [private]

Definition at line 59 of file CheezyPage.h.

Referenced by ApplyConfig(), Configure(), InitConfig(), and SpawnConfigurator().

Registry CheezyPage::fConfigPossibles [private]

Definition at line 59 of file CheezyPage.h.

Referenced by InitConfig(), and SpawnConfigurator().

CheezyDisplay* CheezyPage::fDisplay [private]

Definition at line 54 of file CheezyPage.h.

Referenced by ApplyConfig(), Clear(), Init(), Update(), and ~CheezyPage().

bool CheezyPage::fDrawEmpty [private]

Definition at line 58 of file CheezyPage.h.

Referenced by ApplyConfig(), and Update().

std::string CheezyPage::fListPlex [private]

Definition at line 56 of file CheezyPage.h.

Referenced by ApplyConfig(), InitConfig(), and Update().

std::string CheezyPage::fListTruth [private]

Definition at line 57 of file CheezyPage.h.

Referenced by ApplyConfig(), InitConfig(), and Update().

Mint* CheezyPage::fMint [private]

Definition at line 55 of file CheezyPage.h.

Referenced by Init(), and Update().


The documentation for this class was generated from the following files:
Generated on Mon Nov 10 00:55:19 2014 for loon by  doxygen 1.4.7