FEDRA emulsion software from the OPERA Collaboration
EGraphTool Class Reference

#include <EGraphTool.h>

Inheritance diagram for EGraphTool:
Collaboration diagram for EGraphTool:

Public Member Functions

 EGraphTool (const TGWindow *p, UInt_t w, UInt_t h)
 
void ExitApplication ()
 
void ProcessEvent ()
 
Bool_t ProcessMessage (Long_t msg, Long_t param, Long_t)
 
virtual ~EGraphTool ()
 

Private Member Functions

void AddMenuBar (TGVerticalFrame *frame)
 
void CloseInputFile ()
 
void DrawFrame ()
 
void InitDrawVariables ()
 
void InitInputFile (TString inputFileName)
 
void InitVariables ()
 

Private Attributes

EGraphRecfEmGraphRec
 
Int_t fEventId
 
Int_t fEvtNumber
 
TTree * fEvtTree
 
TFile * fInputTreeFile
 
TGLayoutHints * fLayout1
 
TGLayoutHints * fLayout2
 
TGLayoutHints * fLayout3
 
TGVerticalFrame * fMainFrame
 
TGPopupMenu * fMenuFile
 
TGToolBar * fToolBar
 

Constructor & Destructor Documentation

◆ EGraphTool()

EGraphTool::EGraphTool ( const TGWindow *  p,
UInt_t  w,
UInt_t  h 
)
46  : TGMainFrame(p, w, h)
47 {
48  InitVariables();
50 
51  fEmGraphRec = new EGraphRec(); // Init Graph Reconstruction Toolkit
52  DrawFrame(); // drawing main frame
53 
54  SetWindowName("Emulsion Graphical Tool");
55  MapSubwindows();
56  Resize(GetDefaultSize());
57  MapWindow();
58 }
Definition: EGraphRec.h:24
void InitVariables()
Definition: EGraphTool.cxx:241
void InitDrawVariables()
Definition: EGraphTool.cxx:250
void DrawFrame()
Definition: EGraphTool.cxx:77
EGraphRec * fEmGraphRec
Definition: EGraphTool.h:37
p
Definition: testBGReduction_AllMethods.C:8
void w(int rid=2, int nviews=2)
Definition: test.C:27

◆ ~EGraphTool()

EGraphTool::~EGraphTool ( )
virtual
63 {
64  delete fMainFrame;
65 }
TGVerticalFrame * fMainFrame
Definition: EGraphTool.h:33

Member Function Documentation

◆ AddMenuBar()

void EGraphTool::AddMenuBar ( TGVerticalFrame *  frame)
private
141 {
142  TGDockableFrame *MenuDock = new TGDockableFrame(workframe);
143 
144  // Section File
145 
146  fMenuFile = new TGPopupMenu(gClient->GetRoot());
147  fMenuFile->AddEntry("Open...", M_FILE_OPEN);
148  fMenuFile->AddEntry("Save picture...", M_FILE_SAVE_PICTURE);
149  fMenuFile->AddSeparator();
150  fMenuFile->AddEntry("Exit", M_FILE_EXIT);
151  fMenuFile->DisableEntry(M_FILE_SAVE_PICTURE);
152  fMenuFile->Associate(this);
153 
154  workframe->AddFrame(MenuDock, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
155  0, 0, 1, 0));
156 
157  TGMenuBar *MenuBar = new TGMenuBar(MenuDock, 1, 1, kHorizontalFrame);
158  MenuBar->AddPopup("File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
159  MenuDock->AddFrame(MenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
160 
161  // Toolbar
162 
163  Int_t spacing = 8;
164  fToolBar = new TGToolBar(workframe, 60, 20, kHorizontalFrame | kRaisedFrame);
165  for (Int_t i = 0; EGraphToolXpmNames[i]; i++) {
166  TString iconname = (TString)getenv("FEDRA_ROOT") +
167  "/src/appl/display/icons/" + EGraphToolXpmNames[i];
168  EGraphToolTbData[i].fPixmap = iconname.Data();
169  if (strlen(EGraphToolXpmNames[i]) == 0) {
170  spacing = 8;
171  continue;
172  }
173  fToolBar->AddButton(this, &EGraphToolTbData[i], spacing);
174  spacing = 0;
175  }
176 
177  fToolBar->GetButton(M_FILE_SAVE_PICTURE)->SetState(kButtonDisabled);
178  // fToolBar->GetButton(M_SHOW_3D)->SetState(kButtonDisabled);
179  // fToolBar->GetButton(M_ZOOM_IN)->SetState(kButtonDisabled);
180  // fToolBar->GetButton(M_ZOOM_OUT)->SetState(kButtonDisabled);
181 
182  workframe->AddFrame(fToolBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 0));
183 }
ToolBarData_t EGraphToolTbData[]
Definition: EGraphTool.cxx:32
const char * EGraphToolXpmNames[]
Definition: EGraphTool.cxx:19
TGPopupMenu * fMenuFile
Definition: EGraphTool.h:38
TGToolBar * fToolBar
Definition: EGraphTool.h:39

◆ CloseInputFile()

void EGraphTool::CloseInputFile ( )
private
285 {
286  fEventId = fEvtNumber = 0;
287  fEvtTree = NULL;
289  if (fInputTreeFile) {SafeDelete(fInputTreeFile); fInputTreeFile = NULL;}
290 }
void ClearEvent()
Definition: EGraphRec.cxx:754
TFile * fInputTreeFile
Definition: EGraphTool.h:30
Int_t fEvtNumber
Definition: EGraphTool.h:29
TTree * fEvtTree
Definition: EGraphTool.h:31
Int_t fEventId
Definition: EGraphTool.h:28
#define NULL
Definition: nidaqmx.h:84

◆ DrawFrame()

void EGraphTool::DrawFrame ( )
private
78 {
79  // Correct close window
80 
81  Connect("CloseWindow()", "EGraphTool", this, "ExitApplication()");
82 
83  SetCleanup(kDeepCleanup);
84 
85  // Create main frame
86 
87  fMainFrame = new TGVerticalFrame(this, 1000, 850);
88  fMainFrame->SetCleanup(kDeepCleanup);
89 
90  AddMenuBar(fMainFrame); // Create a menu bar
91  TGHorizontalFrame *workframe = new TGHorizontalFrame(fMainFrame);
92 
93  // buttons frame
94 
95  TGVerticalFrame *ButtonFrame = new TGVerticalFrame(workframe);
96 
97  // create Brick Id frame
98 
99  fEmGraphRec->AddProcBrickFrame(ButtonFrame);
100 
101  // create tab for options frame
102 
103  TGTab *OptTab = new TGTab(ButtonFrame);
104  // fEmGraphRec->AddRecOptFrame(OptTab); // Create a button frame
105  fEmGraphRec->AddScanBackFrame(OptTab); // Create scan back frame
106  fEmGraphRec->AddVertexRecFrame(OptTab); // Craete vertex reconstruction frame
107  ButtonFrame->AddFrame(OptTab, fLayout2);
108 
109  // create process list frame
110 
111  // fEmGraphRec->AddProcListFrame(ButtonFrame);
112 
113  // Process Event
114 
115 // TGTextButton *process = new TGTextButton(ButtonFrame, "Execute event");
116 // process->Connect("Clicked()", "EGraphTool", this, "ProcessEvent()");
117 // process->Associate(this);
118 // ButtonFrame->AddFrame(process, fLayout1);
119  workframe->AddFrame(ButtonFrame, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
120 
121  TGVerticalFrame *CanvasFrame = new TGVerticalFrame(workframe);
122 
123  // create tab for canvas frame
124 
125  TGTab *CanvasTab = new TGTab(CanvasFrame);
126  fEmGraphRec->AddCanvasFrame(CanvasTab); // Create a canvas frame
127  CanvasFrame->AddFrame(CanvasTab, fLayout3);
128 
129  // create text info frame
130 
131  fEmGraphRec->AddInfoFrame(CanvasFrame);
132 
133  workframe->AddFrame(CanvasFrame, fLayout3);
134  fMainFrame->AddFrame(workframe, fLayout3);
135  AddFrame(fMainFrame, fLayout3);
136 }
void AddScanBackFrame(TGTab *worktab)
Definition: EGraphRec.cxx:374
void AddInfoFrame(TGVerticalFrame *workframe)
Definition: EGraphRec.cxx:561
void AddVertexRecFrame(TGTab *worktab)
Definition: EGraphRec.cxx:455
void AddCanvasFrame(TGTab *worktab)
Definition: EGraphRec.cxx:539
void AddProcBrickFrame(TGVerticalFrame *workframe)
Definition: EGraphRec.cxx:191
TGLayoutHints * fLayout3
Definition: EGraphTool.h:36
void AddMenuBar(TGVerticalFrame *frame)
Definition: EGraphTool.cxx:140
TGLayoutHints * fLayout2
Definition: EGraphTool.h:35

◆ ExitApplication()

void EGraphTool::ExitApplication ( )
295 {
296  gApplication->Terminate(0);
297 }

◆ InitDrawVariables()

void EGraphTool::InitDrawVariables ( )
private
251 {
252  fLayout1 = new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2);
253  fLayout2 = new TGLayoutHints(kLHintsExpandY, 2, 2, 2, 2);
254  fLayout3 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2);
255 }
TGLayoutHints * fLayout1
Definition: EGraphTool.h:34

◆ InitInputFile()

void EGraphTool::InitInputFile ( TString  inputFileName)
private
260 {
261  CloseInputFile(); // close previously initalized files
262 
263  // Open the input file
264 
265  fInputTreeFile = new TFile(inputFileName, "read");
266 
267  if (!fInputTreeFile->IsOpen()) return;
268 
269  // get the input tree
270 
271  fEvtTree = (TTree*)fInputTreeFile->Get("Views");
272 
273  if (fEvtTree) {
275  fEvtNumber = fEvtTree->GetEntries() - 1;
276  cout << "number of events " << fEvtNumber << endl;
277  }
278  else
279  cout << "\"Views\" tree does not exist in this file" << endl;
280 }
void SetTree(TTree *tree)
Definition: EGraphRec.cxx:166
void CloseInputFile()
Definition: EGraphTool.cxx:284

◆ InitVariables()

void EGraphTool::InitVariables ( )
private
242 {
243  fEventId = 0;
244  fEvtTree = NULL;
246 }

◆ ProcessEvent()

void EGraphTool::ProcessEvent ( )
70 {
71  // if (fEvtTree) fEmGraphRec->ProcessEvent(fEvtNumber);
72  // fEmGraphRec->ProcessEvent(fEvtNumber);
73 }

◆ ProcessMessage()

Bool_t EGraphTool::ProcessMessage ( Long_t  msg,
Long_t  param,
Long_t   
)
187 {
188  // Handle messages send to the TDisplayMainFrame object.
189  // E.g. all menu button messages.
190 
191  const char *filetypes[] = {"ROOT files", "*.root", 0, 0};
192 
193  switch (GET_MSG(msg)) {
194  case kC_COMMAND:
195  switch (GET_SUBMSG(msg)) {
196  case kCM_BUTTON:
197  case kCM_MENU:
198  switch (param1)
199  {
200  case M_FILE_OPEN:
201  {
202  static TString dir(".");
203  TGFileInfo fi;
204  fi.fFileTypes = filetypes;
205  fi.fIniDir = StrDup(dir.Data());
206 
207  new TGFileDialog(gClient->GetRoot(), fMainFrame, kFDOpen, &fi);
208  dir = fi.fIniDir;
209 
210  // open new file
211 
212  if (fi.fFilename) InitInputFile((TString)fi.fFilename);
213  break;
214  }
215  case M_FILE_SAVE_PICTURE:
216  // save picture
217  break;
218  case M_FILE_EXIT:
219  ExitApplication(); // terminate the Application
220  break;
221  case M_SHOW_3D:
222  fEmGraphRec->Set3DViewer(); // GL viewer
223  break;
224  case M_ZOOM_IN:
225  fEmGraphRec->ZoomIn(); // zoom in
226  break;
227  case M_ZOOM_OUT:
228  fEmGraphRec->ZoomOut(); // zoom out
229  break;
230  }
231  break;
232  }
233  break;
234  }
235 
236  return kTRUE;
237 }
void Set3DViewer()
Definition: EGraphRec.cxx:596
void ZoomIn()
Definition: EGraphRec.cxx:603
void ZoomOut()
Definition: EGraphRec.cxx:613
void InitInputFile(TString inputFileName)
Definition: EGraphTool.cxx:259
void ExitApplication()
Definition: EGraphTool.cxx:294

Member Data Documentation

◆ fEmGraphRec

EGraphRec* EGraphTool::fEmGraphRec
private

◆ fEventId

Int_t EGraphTool::fEventId
private

◆ fEvtNumber

Int_t EGraphTool::fEvtNumber
private

◆ fEvtTree

TTree* EGraphTool::fEvtTree
private

◆ fInputTreeFile

TFile* EGraphTool::fInputTreeFile
private

◆ fLayout1

TGLayoutHints* EGraphTool::fLayout1
private

◆ fLayout2

TGLayoutHints* EGraphTool::fLayout2
private

◆ fLayout3

TGLayoutHints* EGraphTool::fLayout3
private

◆ fMainFrame

TGVerticalFrame* EGraphTool::fMainFrame
private

◆ fMenuFile

TGPopupMenu* EGraphTool::fMenuFile
private

◆ fToolBar

TGToolBar* EGraphTool::fToolBar
private

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