| 1 | #include "MGDisplayAdc.h"
|
|---|
| 2 |
|
|---|
| 3 | MGDisplayAdc::MGDisplayAdc ( MHistosAdc *Histos,
|
|---|
| 4 | const TGWindow *p, const TGWindow *main,
|
|---|
| 5 | UInt_t w, UInt_t h,
|
|---|
| 6 | UInt_t options)
|
|---|
| 7 | : TGTransientFrame(p, main, w, h, options )
|
|---|
| 8 | {
|
|---|
| 9 | // default constructor
|
|---|
| 10 |
|
|---|
| 11 | fHists = Histos ;
|
|---|
| 12 |
|
|---|
| 13 | // the top frame for the list and some buttons and the Canvas
|
|---|
| 14 |
|
|---|
| 15 | fFrameTop = new TGHorizontalFrame (this, 60,20, kFitWidth ) ;
|
|---|
| 16 |
|
|---|
| 17 | // left part of top frame
|
|---|
| 18 | fFT1 = new TGVerticalFrame (fFrameTop, 80,300, kFitWidth ) ;
|
|---|
| 19 |
|
|---|
| 20 | fHistoList = new TGListBox ( fFT1, M_LIST_HISTO ) ;
|
|---|
| 21 | fHistoList->Associate( this ) ;
|
|---|
| 22 | fFT1->AddFrame ( fHistoList, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 10 ) ) ;
|
|---|
| 23 | fHistoList->Resize(80, 300 ) ;
|
|---|
| 24 |
|
|---|
| 25 | fFrameTop->AddFrame (fFT1, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | // middle part of top frame
|
|---|
| 29 |
|
|---|
| 30 | fFT2 = new TGVerticalFrame (fFrameTop, 80,20, kFitWidth ) ;
|
|---|
| 31 |
|
|---|
| 32 | fButtonPrev = new TGTextButton ( fFT2, "Prev Histo", M_BUTTON_PREV ) ;
|
|---|
| 33 | fButtonPrev->Associate (this) ;
|
|---|
| 34 | fFT2->AddFrame ( fButtonPrev, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 50, 10 ) ) ;
|
|---|
| 35 |
|
|---|
| 36 | fButtonNext = new TGTextButton ( fFT2, "Next Histo", M_BUTTON_NEXT ) ;
|
|---|
| 37 | fButtonNext->Associate (this) ;
|
|---|
| 38 | fFT2->AddFrame ( fButtonNext, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 10, 5 ) ) ;
|
|---|
| 39 |
|
|---|
| 40 | fFrameTop->AddFrame (fFT2, new TGLayoutHints ( kLHintsTop , 10, 10, 10, 10 ) ) ;
|
|---|
| 41 |
|
|---|
| 42 | // right part of top frame
|
|---|
| 43 |
|
|---|
| 44 | fFT3 = new TGVerticalFrame (fFrameTop, 60, 60, kFitWidth ) ;
|
|---|
| 45 |
|
|---|
| 46 | fECanv = new TRootEmbeddedCanvas("fECanv", fFT3, 400, 400 ) ;
|
|---|
| 47 | fFT3->AddFrame( fECanv, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
|
|---|
| 48 |
|
|---|
| 49 | fCanv = fECanv->GetCanvas() ;
|
|---|
| 50 |
|
|---|
| 51 | fFrameTop->AddFrame (fFT3, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY , 10, 10, 10, 10 ) ) ;
|
|---|
| 52 |
|
|---|
| 53 | AddFrame ( fFrameTop, new TGLayoutHints ( kLHintsTop | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
|
|---|
| 54 |
|
|---|
| 55 | //
|
|---|
| 56 | // the low frame for the control buttons
|
|---|
| 57 | //
|
|---|
| 58 | fFrameLow = new TGHorizontalFrame (this, 60,20, kFixedWidth ) ;
|
|---|
| 59 |
|
|---|
| 60 | fButtonSave = new TGTextButton ( fFrameLow, "Save", M_BUTTON_SAVE ) ;
|
|---|
| 61 | fButtonSave->Associate (this) ;
|
|---|
| 62 | fFrameLow->AddFrame ( fButtonSave, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
|
|---|
| 63 |
|
|---|
| 64 | fButtonPrint = new TGTextButton ( fFrameLow, "Print", M_BUTTON_PRINT ) ;
|
|---|
| 65 | fButtonPrint->Associate (this) ;
|
|---|
| 66 | fFrameLow->AddFrame ( fButtonPrint, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
|
|---|
| 67 |
|
|---|
| 68 | fButtonPrintAll = new TGTextButton ( fFrameLow, "PrintAll", M_BUTTON_PRINTALL ) ;
|
|---|
| 69 | fButtonPrintAll->Associate (this) ;
|
|---|
| 70 | fFrameLow->AddFrame ( fButtonPrintAll, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
|
|---|
| 71 |
|
|---|
| 72 | fButtonClose = new TGTextButton ( fFrameLow, "Close", M_BUTTON_CLOSE ) ;
|
|---|
| 73 | fButtonClose->Associate (this) ;
|
|---|
| 74 | fFrameLow->AddFrame ( fButtonClose, new TGLayoutHints (kLHintsLeft | kLHintsTop, 10, 10, 5, 5 ) ) ;
|
|---|
| 75 | AddFrame ( fFrameLow, new TGLayoutHints ( kLHintsBottom | kLHintsExpandX , 10, 10, 10, 10 ) ) ;
|
|---|
| 76 |
|
|---|
| 77 | //
|
|---|
| 78 | //
|
|---|
| 79 | //
|
|---|
| 80 | BuildHistoList() ;
|
|---|
| 81 |
|
|---|
| 82 | MapSubwindows();
|
|---|
| 83 |
|
|---|
| 84 | Layout();
|
|---|
| 85 |
|
|---|
| 86 | SetWindowName("ADC Spectra");
|
|---|
| 87 | SetIconName("ADC Spectra");
|
|---|
| 88 |
|
|---|
| 89 | MapWindow();
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | // ======================================================================
|
|---|
| 93 | // ======================================================================
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | MGDisplayAdc::~MGDisplayAdc ()
|
|---|
| 98 | {
|
|---|
| 99 | delete fButtonSave ;
|
|---|
| 100 | delete fButtonPrint ;
|
|---|
| 101 | delete fButtonPrintAll ;
|
|---|
| 102 | delete fButtonClose ;
|
|---|
| 103 |
|
|---|
| 104 | delete fButtonPrev;
|
|---|
| 105 | delete fButtonNext ;
|
|---|
| 106 |
|
|---|
| 107 | delete fECanv ;
|
|---|
| 108 | delete fHistoList ;
|
|---|
| 109 | delete fFT1 ;
|
|---|
| 110 | delete fFT2 ;
|
|---|
| 111 | delete fFT3 ;
|
|---|
| 112 | delete fFrameLow ;
|
|---|
| 113 | delete fFrameTop ;
|
|---|
| 114 |
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // ======================================================================
|
|---|
| 118 | // ======================================================================
|
|---|
| 119 |
|
|---|
| 120 | void MGDisplayAdc::CloseWindow()
|
|---|
| 121 | {
|
|---|
| 122 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
|---|
| 123 | // (which destroys the window) and terminate the application.
|
|---|
| 124 | // The close message is generated by the window manager when its close
|
|---|
| 125 | // window menu item is selected.
|
|---|
| 126 |
|
|---|
| 127 | delete this ;
|
|---|
| 128 | // TGTransientFrame::CloseWindow();
|
|---|
| 129 | // TGMainFrame::CloseWindow();
|
|---|
| 130 | // gROOT->GetApplication()->Terminate(0) ;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | // ======================================================================
|
|---|
| 135 | // ======================================================================
|
|---|
| 136 |
|
|---|
| 137 | Bool_t MGDisplayAdc::BuildHistoList()
|
|---|
| 138 | {
|
|---|
| 139 | // looks in the container of the AdcSpectra and reads in the
|
|---|
| 140 | // Histogramms in there.
|
|---|
| 141 | //
|
|---|
| 142 | // In the class MHistosAdc are in fact two lists. One for the high and
|
|---|
| 143 | // one for the low gain. Here we will use only the high gain list!!!
|
|---|
| 144 | // With some special options (settings in the gui) we will also be able
|
|---|
| 145 | // to plot the low gain
|
|---|
| 146 |
|
|---|
| 147 | for ( Int_t i=0 ; i < fHists->GetHighEntries(); i++ ) {
|
|---|
| 148 |
|
|---|
| 149 | fHistoList->AddEntry(fHists->GetHighList()->At(i)->GetName(), i+1) ;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | fHistoList->MapSubwindows() ;
|
|---|
| 153 | fHistoList->Layout() ;
|
|---|
| 154 |
|
|---|
| 155 | return (kTRUE) ;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | // ======================================================================
|
|---|
| 159 | // ======================================================================
|
|---|
| 160 |
|
|---|
| 161 | Bool_t MGDisplayAdc::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
|
|---|
| 162 | {
|
|---|
| 163 | // Process events generated by the buttons in the frame.
|
|---|
| 164 |
|
|---|
| 165 | Int_t buttons = 4, retval = 0 ;
|
|---|
| 166 | Char_t wort[100] ;
|
|---|
| 167 | Char_t extens[5] ;
|
|---|
| 168 | Char_t command[110] ;
|
|---|
| 169 |
|
|---|
| 170 | TGFileItem *item ; // to process items in the file view container
|
|---|
| 171 | void *np = NULL ; // null pointer
|
|---|
| 172 |
|
|---|
| 173 | switch (GET_MSG(msg))
|
|---|
| 174 | {
|
|---|
| 175 | case kC_COMMAND:
|
|---|
| 176 | switch (GET_SUBMSG(msg))
|
|---|
| 177 | {
|
|---|
| 178 | case kCM_BUTTON:
|
|---|
| 179 |
|
|---|
| 180 | switch (parm1)
|
|---|
| 181 | {
|
|---|
| 182 |
|
|---|
| 183 | case M_BUTTON_SAVE:
|
|---|
| 184 | break ;
|
|---|
| 185 |
|
|---|
| 186 | case M_BUTTON_CLOSE:
|
|---|
| 187 | CloseWindow() ;
|
|---|
| 188 | break ;
|
|---|
| 189 |
|
|---|
| 190 | default:
|
|---|
| 191 | break ;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | case kCM_MENU:
|
|---|
| 195 | switch (parm1) {
|
|---|
| 196 | }
|
|---|
| 197 | break ;
|
|---|
| 198 |
|
|---|
| 199 | default:
|
|---|
| 200 | break ;
|
|---|
| 201 |
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | case kCM_LISTBOX:
|
|---|
| 205 | switch (GET_SUBMSG(msg))
|
|---|
| 206 | {
|
|---|
| 207 | case M_LIST_HISTO:
|
|---|
| 208 | fCanv->cd() ;
|
|---|
| 209 |
|
|---|
| 210 | fHists->GetHighList()->At( fHistoList->GetSelected()-1)->Draw() ;
|
|---|
| 211 |
|
|---|
| 212 | fCanv->Modified() ;
|
|---|
| 213 | fCanv->Update() ;
|
|---|
| 214 |
|
|---|
| 215 | break;
|
|---|
| 216 |
|
|---|
| 217 | default:
|
|---|
| 218 | break ;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | case kC_CONTAINER:
|
|---|
| 222 | switch (GET_SUBMSG(msg)) {
|
|---|
| 223 |
|
|---|
| 224 | case kCT_ITEMDBLCLICK:
|
|---|
| 225 |
|
|---|
| 226 | break;
|
|---|
| 227 |
|
|---|
| 228 | default:
|
|---|
| 229 | break ;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 | default:
|
|---|
| 235 | break;
|
|---|
| 236 | }
|
|---|
| 237 | return kTRUE;
|
|---|
| 238 | }
|
|---|