Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hdv_endviewBframe.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <iomanip>
4 #include <sstream>
5 #include <cmath>
6 #include <fstream>
7 using namespace std;
8 
9 #include <pthread.h>
10 
11 #include <TRACKING/DMCThrown.h>
12 #include "hdv_endviewBframe.h"
13 #include "hdview2.h"
14 #include "MyProcessor.h"
15 #include "FDC/DFDCGeometry.h"
16 #include "FCAL/DFCALGeometry.h"
17 #include "DVector2.h"
18 #include "HDGEOMETRY/DGeometry.h"
19 #include <PID/DNeutralParticle.h>
20 
21 #include <TPolyMarker.h>
22 #include <TLine.h>
23 #include <TMarker.h>
24 #include <TBox.h>
25 #include <TVector3.h>
26 #include <TGeoVolume.h>
27 #include <TGeoManager.h>
28 #include <TGLabel.h>
29 #include <TGComboBox.h>
30 #include <TGButton.h>
31 #include <TGButtonGroup.h>
32 #include <TGTextEntry.h>
33 #include <TArrow.h>
34 #include <TLatex.h>
35 #include <TColor.h>
36 #include <TG3DLine.h>
37 
38 extern JApplication *japp;
39 //TGeoVolume *MOTHER = NULL;
40 //TGeoCombiTrans *MotherRotTrans = NULL;
41 
42 extern int GO;
43 
44 
45 //-------------------
46 // Constructor
47 //-------------------
48 hdv_endviewBframe::hdv_endviewBframe(hdv_mainframe *hdvmf, const TGWindow *p, UInt_t w, UInt_t h):TGMainFrame(p,w,h)
49 {
50  this->hdvmf = hdvmf;
51 
52  // First, define all of the of the graphics objects. Below that, make all
53  // of the connections to the methods so these things will work!
54 
55  // The main GUI window is divided into three sections, top, middle, and bottom.
56  // Create those frames here.
57  TGLayoutHints *lhints = new TGLayoutHints(kLHintsNormal, 2,2,2,2);
58  TGLayoutHints *chints = new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2);
59  TGLayoutHints *xhints = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 2,2,2,2);
60  TGLayoutHints *yhints = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsCenterY, 2,2,2,2);
61  TGLayoutHints *thints = new TGLayoutHints(kLHintsTop|kLHintsCenterX|kLHintsExpandX, 2,2,0,0);
62  TGHorizontalFrame *topframe = new TGHorizontalFrame(this, w, h);
63  TGHorizontalFrame *botframe = new TGHorizontalFrame(this, w, h);
64  AddFrame(topframe, lhints);
65  AddFrame(botframe, chints);
66 
67  TGGroupFrame *canvasframe = new TGGroupFrame(topframe, "FCAL", kVerticalFrame);
68  TGGroupFrame *controls = new TGGroupFrame(topframe, "", kVerticalFrame);
69  topframe->AddFrame(canvasframe, lhints);
70  topframe->AddFrame(controls, lhints);
71 
72  TGGroupFrame *viewcontrols = new TGGroupFrame(controls, "Controls", kVerticalFrame);
73  controls->AddFrame(viewcontrols, lhints);
74  TGGroupFrame *fcalColorCodes = new TGGroupFrame(controls, "Color code", kVerticalFrame);
75  controls->AddFrame(fcalColorCodes, lhints);
76 
77  //------------- View canvas
78  ecanvas = new TRootEmbeddedCanvas("endviewB Large Canvas", canvasframe, w, h, kSunkenFrame, GetWhitePixel());
79  canvasframe->AddFrame(ecanvas, chints);
80 
81  //------------- Pan buttons
82  TGGroupFrame *panframe = new TGGroupFrame(viewcontrols, "Pan", kHorizontalFrame);
83  TGTextButton *panxneg = new TGTextButton(panframe, "-X");
84  TGVerticalFrame *panupdn = new TGVerticalFrame(panframe);
85  TGTextButton *panypos = new TGTextButton(panupdn, "+Y");
86  TGTextButton *panyneg = new TGTextButton(panupdn, "-Y");
87  TGTextButton *panxpos = new TGTextButton(panframe, "X+");
88 
89  viewcontrols->AddFrame(panframe, yhints);
90  panframe->AddFrame(panxneg, chints);
91  panframe->AddFrame(panupdn, chints);
92  panupdn->AddFrame(panypos, chints);
93  panupdn->AddFrame(panyneg, chints);
94  panframe->AddFrame(panxpos, chints);
95 
96  panxneg->Connect("Clicked()","hdv_mainframe",hdvmf,"DoPanXneg()");
97  panyneg->Connect("Clicked()","hdv_mainframe",hdvmf,"DoPanYneg()");
98  panxpos->Connect("Clicked()","hdv_mainframe",hdvmf,"DoPanXpos()");
99  panypos->Connect("Clicked()","hdv_mainframe",hdvmf,"DoPanYpos()");
100 
101  //------------- Zoom buttons
102  TGGroupFrame *zoomframe = new TGGroupFrame(viewcontrols, "ZOOM", kHorizontalFrame);
103  viewcontrols->AddFrame(zoomframe, thints);
104  TGTextButton *zoomout = new TGTextButton(zoomframe, " - ");
105  TGTextButton *zoomin = new TGTextButton(zoomframe, " + ");
106  zoomframe->AddFrame(zoomout, xhints);
107  zoomframe->AddFrame(zoomin, xhints);
108 
109  zoomout->Connect("Clicked()","hdv_mainframe",hdvmf,"DoZoomOut()");
110  zoomin->Connect("Clicked()","hdv_mainframe",hdvmf,"DoZoomIn()");
111 
112  //------------- Reset button
113  TGTextButton *reset = new TGTextButton(viewcontrols, "Reset");
114  viewcontrols->AddFrame(reset, chints);
115  reset->Connect("Clicked()","hdv_mainframe", hdvmf, "DoReset()");
116 
117  //------------- SaveAs message
118  stringstream ss;
119  ss<<"To save the canvas to\n";
120  ss<<"a file, right click\n";
121  ss<<"and select \"SaveAs\"\n";
122  ss<<"from the menu. File type\n";
123  ss<<"will be determined by\n";
124  ss<<"the suffix of the file\n";
125  ss<<"name.\n";
126  TGLabel *saveas = new TGLabel(viewcontrols, ss.str().c_str());
127  viewcontrols->AddFrame(saveas, chints);
128 
129  TGLabel* FCCLables[9];
130  unsigned int FCccodes[9] = {0x0000FF,0x7700FF,0xFF00FF,0xFF0077,0xFF0000,0xFF7700,0xFFFF00,0xFFFF77,0xFFFFFF};
131  for (int i=0;i<9;i++) {
132  double e = pow(10,((8-(double)i)/2.0));
133  char str1[128];
134  if (e >= 1000) {
135  sprintf(str1,"%7.2f GeV",e/1000.);
136  } else {
137  sprintf(str1,"%7.1f MeV",e);
138  }
139  FCCLables[i] = new TGLabel(fcalColorCodes, (const char*)str1);
140  FCCLables[i]->SetBackgroundColor(FCccodes[i]);
141  fcalColorCodes->AddFrame(FCCLables[i],lhints);
142  }
143 
144 
145  //========== Dismiss Button ===========
146  TGTextButton *dismiss = new TGTextButton(botframe, "dismiss");
147  botframe->AddFrame(dismiss, chints);
148 
149  //&&&&&&&&&&&&&&&& Connections
150  dismiss->Connect("Clicked()","hdv_endviewBframe", this, "DoDismiss()");
151  this->Connect("CloseWindow()", "hdv_endviewBframe", this, "DoDismiss()");
152  this->DontCallClose();
153 
154  // Finish up and map the window
155  SetWindowName("Hall-D Event Viewer FCAL and TOF View");
156  SetIconName("HDView");
157 
158 
159  MapSubwindows();
160  Resize(GetDefaultSize());
161  panframe->Resize();
162  saveas->Resize();
163  viewcontrols->Resize();
164 }
165 
166 //-------------------
167 // DoDismiss
168 //-------------------
170 {
171  UnmapWindow();
172 }
173 
174 //-------------------
175 // SetRange
176 //-------------------
177 void hdv_endviewBframe::SetRange(double xlo, double ylo, double xhi, double yhi)
178 {
179  ecanvas->GetCanvas()->cd();
180  ecanvas->GetCanvas()->Range(xlo, ylo, xhi, yhi);
181 }
182 
183 //-------------------
184 // DrawObjects
185 //-------------------
186 void hdv_endviewBframe::DrawObjects(vector<TObject*> &graphics_endB)
187 {
188  if(!IsMapped())return;
189 
190  ecanvas->GetCanvas()->cd(0);
191  for(unsigned int i=0; i<graphics_endB.size(); i++)graphics_endB[i]->Draw("f");
192  for(unsigned int i=0; i<graphics_endB.size(); i++)graphics_endB[i]->Draw();
193  ecanvas->GetCanvas()->Update();
194 }
195 
sprintf(text,"Post KinFit Cut")
void SetRange(double xlo, double ylo, double xhi, double yhi)
JApplication * japp
TEllipse * e
hdv_mainframe * hdvmf
void DrawObjects(vector< TObject * > &graphics_endB)
TRootEmbeddedCanvas * ecanvas
hdv_endviewBframe(hdv_mainframe *hdvmf, const TGWindow *p, UInt_t w, UInt_t h)
int GO
Definition: hdview2.cc:10
hdv_mainframe * hdvmf
locHist_NumHighLevel Draw("COLZ")