// $Id$ // // File: fcal11_SignalViewer.cc // Created: Wed Nov 30 07:42:06 EST 2011 // Creator: davidl (on Linux ifarm1101 2.6.18-128.7.1.el5 x86_64) // #include #include #include #include #include using namespace std; #include "fcal11view.h" #include "fcal11_SignalViewer.h" #include "MyProcessor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include fcal11_SignalViewer *gSIGNALVIEWER=NULL; extern JApplication *japp; extern int GO; //--------------------------------- // fcal11_SignalViewer (Constructor) //--------------------------------- fcal11_SignalViewer::fcal11_SignalViewer(const TGWindow *p, UInt_t w, UInt_t h):TGMainFrame(NULL,w,h) { gSIGNALVIEWER = this; TGHorizontalFrame *sourceframe = new TGHorizontalFrame(this,w,20); TGHorizontalFrame *topframe = new TGHorizontalFrame(this, w, h); TGHorizontalFrame *midframe = new TGHorizontalFrame(this, w, h); TGHorizontalFrame *botframe = new TGHorizontalFrame(this, w, h); AddFrame(sourceframe, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 2,2,0,0)); AddFrame(topframe, new TGLayoutHints(kLHintsNormal, 2,2,2,2)); AddFrame(midframe, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY, 5,5,5,5)); AddFrame(botframe, new TGLayoutHints(kLHintsNormal, 2,2,2,2)); //========== Source =========== TGLabel *sourcelab = new TGLabel(sourceframe, "Source:"); sourceframe->AddFrame(sourcelab,new TGLayoutHints(kLHintsNormal, 2,2,0,0)); source = new TGLabel(sourceframe, "--"); sourceframe->AddFrame(source, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 2,2,0,0)); source->SetTextJustify(1); //========== TOP FRAME ============ TGGroupFrame *eventcontrols = new TGGroupFrame(topframe, "Event Controls", kHorizontalFrame); TGGroupFrame *eventinfo = new TGGroupFrame(topframe, "Info", kHorizontalFrame); TGGroupFrame *displaycontrols = new TGGroupFrame(topframe, "Display Controls", kHorizontalFrame); TGHorizontalFrame *programcontrols = new TGHorizontalFrame(topframe); topframe->AddFrame(eventcontrols, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY, 5,5,5,5)); topframe->AddFrame(eventinfo, new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 2,2,2,2)); topframe->AddFrame(displaycontrols, new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 2,2,2,2)); topframe->AddFrame(programcontrols, new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 2,2,2,2)); //-------------- Next, Previous next = new TGTextButton(eventcontrols, "Next -->"); eventcontrols->AddFrame(next, new TGLayoutHints(kLHintsNormal, 2,2,2,2)); //----------------- Event Info TGVerticalFrame *eventlabs = new TGVerticalFrame(eventinfo); TGVerticalFrame *eventvals = new TGVerticalFrame(eventinfo); eventinfo->AddFrame(eventlabs, new TGLayoutHints(kLHintsNormal, 2,2,2,2)); eventinfo->AddFrame(eventvals, new TGLayoutHints(kLHintsNormal, 2,2,2,2)); TGLabel *runlab = new TGLabel(eventlabs, "Run:"); TGLabel *eventlab = new TGLabel(eventlabs, "Event:"); run = new TGLabel(eventvals, "----------"); event = new TGLabel(eventvals, "----------"); eventlabs->AddFrame(runlab, new TGLayoutHints(kLHintsCenterY|kLHintsRight, 2,2,2,2)); eventlabs->AddFrame(eventlab,new TGLayoutHints(kLHintsCenterY|kLHintsRight, 2,2,2,2)); eventvals->AddFrame(run, new TGLayoutHints(kLHintsNormal, 2,2,2,2)); eventvals->AddFrame(event, new TGLayoutHints(kLHintsNormal, 2,2,2,2)); //-------------- Display Controls TGVerticalFrame *displayopts = new TGVerticalFrame(displaycontrols); displaycontrols->AddFrame(displayopts, new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY, 5,5,5,5)); checkbuttons["sub_peds"] = new TGCheckButton(displayopts, "Subtract Pedestal"); checkbuttons["autoscale"] = new TGCheckButton(displayopts, "Autoscale y-axis"); checkbuttons["sum_labels"] = new TGCheckButton(displayopts, "Show sums"); displayopts->AddFrame(checkbuttons["sub_peds"], new TGLayoutHints(kLHintsNormal, 2,2,2,2)); displayopts->AddFrame(checkbuttons["autoscale"], new TGLayoutHints(kLHintsNormal, 2,2,2,2)); displayopts->AddFrame(checkbuttons["sum_labels"], new TGLayoutHints(kLHintsNormal, 2,2,2,2)); //-------------- Program Controls TGTextButton *close = new TGTextButton(programcontrols, "&Close"); programcontrols->AddFrame(close, new TGLayoutHints(kLHintsTop|kLHintsRight|kLHintsExpandX, 2,2,2,2)); //========== MID FRAME ============ int width = 800; int height = 800; TGHorizontalFrame *canvasframe = new TGHorizontalFrame(midframe); midframe->AddFrame(canvasframe); canvas = new TRootEmbeddedCanvas("Main Canvas", canvasframe, width, height, kSunkenFrame, GetWhitePixel()); canvasframe->AddFrame(canvas); TCanvas *c1 = canvas->GetCanvas(); c1->SetMargin((float)0.0, (float)0.0, (float)0.0, (float)0.0); c1->Divide(5, 5); c1->SetMargin((float)0.0, (float)0.0, (float)0.0, (float)0.0); for(int i=1; i<=5; i++){ for(int j=1; j<=5; j++){ c1->cd(i + 5*(j-1)); gPad->SetTicks(); gPad->SetGrid(); gPad->SetMargin((float)0.0, (float)0.0, (float)0.0, (float)0.0); } } //&&&&&&&&&&&&&&&& Connections close->Connect("Clicked()","fcal11_SignalViewer", this, "DoClose()"); next->Connect("Clicked()","fcal11_SignalViewer", this, "DoNext()"); checkbuttons["sub_peds"]->Connect("Clicked()","fcal11_SignalViewer", this, "DoMyRedraw()"); checkbuttons["autoscale"]->Connect("Clicked()","fcal11_SignalViewer", this, "DoMyRedraw()"); checkbuttons["sum_labels"]->Connect("Clicked()","fcal11_SignalViewer", this, "DoMyRedraw()"); checkbuttons["sub_peds"]->SetState(kButtonDown); // Finish up and map the window SetWindowName("FCAL 2011 Beam Test Event Viewer"); SetIconName("FCAL11View"); MapSubwindows(); Resize(GetDefaultSize()); //MapWindow(); is_hidden = true; // Call Resize method of some group frames to get them to shrink down to smallest size eventinfo->Resize(); eventcontrols->Resize(); } //------------------- // DoClose //------------------- void fcal11_SignalViewer::DoClose(void) { Hide(); } //------------------- // DoNext //------------------- void fcal11_SignalViewer::DoNext(void) { if(eventloop)eventloop->OneEvent(); //DoMyRedraw(); } //------------------- // DoMyRedraw //------------------- void fcal11_SignalViewer::DoMyRedraw(void) { gMYPROC->UpdateSignals(); } //------------------- // SetEvent //------------------- void fcal11_SignalViewer::SetEvent(int id) { if(!event)return; char str[256]; sprintf(str,"%5d", id); event->SetTitle(str); //event->Draw(); } //------------------- // SetSource //------------------- void fcal11_SignalViewer::SetSource(string source) { this->source->SetTitle(source.c_str()); //this->source->Draw(); } //------------------- // SetPad //------------------- void fcal11_SignalViewer::SetPad(int col, int row) { if(row<0 || row>4 || col<0 || col>4)return; int id = 1 + col + 5*row; TCanvas *c1 = canvas->GetCanvas(); c1->cd(id); } //------------------- // Show //------------------- void fcal11_SignalViewer::Show(void) { MapWindow(); RaiseWindow(); RequestFocus(); DoMyRedraw(); is_hidden = false; } //------------------- // Hide //------------------- void fcal11_SignalViewer::Hide(void) { UnmapWindow(); is_hidden = true; } //------------------- // IsHidden //------------------- bool fcal11_SignalViewer::IsHidden(void) { return is_hidden; } //------------------- // GetCheckButton //------------------- bool fcal11_SignalViewer::GetCheckButton(string who) { map::iterator iter = checkbuttons.find(who); if(iter==checkbuttons.end())return false; return iter->second->GetState()==kButtonDown; } //------------------- // AddCheckButtons //------------------- void fcal11_SignalViewer::AddCheckButtons(map &checkbuttons) { this->checkbuttons.insert(checkbuttons.begin(), checkbuttons.end()); } //--------------------------------- // ~fcal11_SignalViewer (Destructor) //--------------------------------- fcal11_SignalViewer::~fcal11_SignalViewer() { }