// $Id$ // // File: fcal11_fADCviewer.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_fADCviewer.h" #include "MyProcessor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include fcal11_fADCviewer *gfADCVIEWER=NULL; extern JApplication *japp; extern int GO; //--------------------------------- // fcal11_fADCviewer (Constructor) //--------------------------------- fcal11_fADCviewer::fcal11_fADCviewer(const TGWindow *p, UInt_t w, UInt_t h):TGMainFrame(NULL,w,h) { gfADCVIEWER = this; // Use the "color wheel" rather than the classic palette. TColor::CreateColorWheel(); 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"); displayopts->AddFrame(checkbuttons["sub_peds"], new TGLayoutHints(kLHintsNormal, 2,2,2,2)); displayopts->AddFrame(checkbuttons["autoscale"], 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 = 700; int height = 400; TGHorizontalFrame *canvasframe = new TGHorizontalFrame(midframe); midframe->AddFrame(canvasframe); canvas = new TRootEmbeddedCanvas("Main Canvas", canvasframe, width, height, kSunkenFrame, GetWhitePixel()); canvasframe->AddFrame(canvas); TGVerticalFrame *slotchanframe = new TGVerticalFrame(midframe); midframe->AddFrame(slotchanframe); //--------------- Slots TGVButtonGroup *slots = new TGVButtonGroup(slotchanframe,"Slot"); slotchanframe->AddFrame(slots); int active_slots[] = {5,7,9}; for(int i=0; i<3; i++){ char lab[256]; sprintf(lab, "slot %2d", active_slots[i]); TGRadioButton *b = new TGRadioButton(slots, lab, NULL, active_slots[i]); if(i==0){ b->SetState(kButtonDown,kTRUE); this->slot = active_slots[i]; } } //--------------- Channels TGVButtonGroup *channels = new TGVButtonGroup(slotchanframe,"Channel"); slotchanframe->AddFrame(channels); for(int i=0; i<16; i++){ char lab[256]; sprintf(lab, "chan%02d", i); TGRadioButton *b = new TGRadioButton(channels, lab, NULL, i); if(i==0){ b->SetState(kButtonDown,kTRUE); this->channel = i; } } //&&&&&&&&&&&&&&&& Connections close->Connect("Clicked()","fcal11_fADCviewer", this, "DoClose()"); next->Connect("Clicked()","fcal11_fADCviewer", this, "DoNext()"); //checkbuttons["continuous"]->Connect("Clicked()","fcal11_fADCviewer", this, "DoCont()"); //delay->Connect("Selected(Int_t)","fcal11_fADCviewer", this, "DoSetDelay(Int_t)"); slots->Connect("Clicked(Int_t)","fcal11_fADCviewer", this, "DoSetSlot(Int_t)"); slots->Connect("Clicked(Int_t)","fcal11_fADCviewer", this, "DoMyRedraw()"); channels->Connect("Clicked(Int_t)","fcal11_fADCviewer", this, "DoSetChannel(Int_t)"); channels->Connect("Clicked(Int_t)","fcal11_fADCviewer", this, "DoMyRedraw()"); checkbuttons["sub_peds"]->Connect("Clicked()","fcal11_fADCviewer", this, "DoMyRedraw()"); checkbuttons["autoscale"]->Connect("Clicked()","fcal11_fADCviewer", 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_fADCviewer::DoClose(void) { Hide(); } //------------------- // DoNext //------------------- void fcal11_fADCviewer::DoNext(void) { if(eventloop)eventloop->OneEvent(); //DoMyRedraw(); } //------------------- // DoSetSlot //------------------- void fcal11_fADCviewer::DoSetSlot(Int_t slot) { this->slot = slot; } //------------------- // DoSetChannel //------------------- void fcal11_fADCviewer::DoSetChannel(Int_t channel) { this->channel = channel; } //------------------- // DoMyRedraw //------------------- void fcal11_fADCviewer::DoMyRedraw(void) { gMYPROC->UpdateHisto(); } //------------------- // SetEvent //------------------- void fcal11_fADCviewer::SetEvent(int id) { if(!event)return; char str[256]; sprintf(str,"%5d", id); event->SetTitle(str); //event->Draw(); } //------------------- // SetSource //------------------- void fcal11_fADCviewer::SetSource(string source) { this->source->SetTitle(source.c_str()); //this->source->Draw(); } //------------------- // Show //------------------- void fcal11_fADCviewer::Show(void) { MapWindow(); RaiseWindow(); RequestFocus(); DoMyRedraw(); is_hidden = false; } //------------------- // Hide //------------------- void fcal11_fADCviewer::Hide(void) { UnmapWindow(); is_hidden = true; } //------------------- // IsHidden //------------------- bool fcal11_fADCviewer::IsHidden(void) { return is_hidden; } //------------------- // GetCheckButton //------------------- bool fcal11_fADCviewer::GetCheckButton(string who) { map::iterator iter = checkbuttons.find(who); if(iter==checkbuttons.end())return false; return iter->second->GetState()==kButtonDown; } //------------------- // AddCheckButtons //------------------- void fcal11_fADCviewer::AddCheckButtons(map &checkbuttons) { this->checkbuttons.insert(checkbuttons.begin(), checkbuttons.end()); } //--------------------------------- // ~fcal11_fADCviewer (Destructor) //--------------------------------- fcal11_fADCviewer::~fcal11_fADCviewer() { }