LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
Ortho3DView.cxx
Go to the documentation of this file.
1 //
6 #include <string>
7 #include <cmath>
8 #include "TCanvas.h"
9 #include "TGLabel.h"
10 #include "TGButton.h"
11 #include "TGNumberEntry.h"
12 #include "TVirtualX.h"
13 #include "TRootEmbeddedCanvas.h"
16 
17 #include "cetlib_except/exception.h"
19 
20 //......................................................................
21 // Consgtructor.
22 
24  evdb::Canvas(mf)
25 {
26  // Remove everything that's in the main frame by default.
27 
28  mf->RemoveFrame(fEmbCanvas);
29  mf->RemoveFrame(fFrame);
30 
31  // Make meta frame to hold graphics pad and our widgets.
32 
33  fMetaFrame = new TGHorizontalFrame(mf);
34 
35  // Refill main frame, replacing root canvas with meta frame.
36 
37  mf->AddFrame(fMetaFrame, fLayout);
38  mf->AddFrame(fFrame);
39 
40  // Add two frames inside the meta frame.
41  // Add a vertical frame on the left to hold our widgets.
42  // Add root canvas on the right.
43 
44  fWidgetFrame = new TGVerticalFrame(fMetaFrame);
45  fEmbCanvas->ReparentWindow(fMetaFrame);
46  fMetaFrame->AddFrame(fWidgetFrame, new TGLayoutHints(kLHintsTop |
47  kLHintsLeft |
48  kLHintsExpandY));
49  fMetaFrame->AddFrame(fEmbCanvas, fLayout);
50 
51  // Make vertically stacked subpads and widget subframes.
52 
53  int npad = 2;
54  for(int ipad = 0; ipad < npad; ++ipad) {
57  std::string projname;
58  switch (ipad) {
59  case 0:
60  proj = kXZ;
61  projname = "XZ";
62  break;
63  case 1:
64  proj = kYZ;
65  projname = "YZ";
66  break;
67  default:
68  throw cet::exception("Ortho3DView")
69  << __func__ << ": unknown projection pad " << ipad << "\n";
70  } // switch
71 
72  std::string padname = std::string("Ortho3DPad") + projname;
73  std::string padtitle = projname + std::string(" View");
74  double ylo = double(npad - ipad - 1) / double(npad);
75  double yhi = double(npad - ipad) / double(npad);
76  Ortho3DPad* pad = new Ortho3DPad(padname.c_str(), padtitle.c_str(),
77  proj, 0.0, ylo, 1.0, yhi);
78  fOrtho3DPads.push_back(pad);
79 
80  // Add subframe for this pad's widgets.
81 
82  TGCompositeFrame* wframe = new TGVerticalFrame(fWidgetFrame);
83  fWidgetSubFrames.push_back(wframe);
84  fWidgetFrame->AddFrame(wframe, new TGLayoutHints(kLHintsTop |
85  kLHintsLeft |
86  kLHintsExpandY));
87 
88  // Add widgets.
89 
90  // Label.
91 
92  TGLabel* label = new TGLabel(wframe, padtitle.c_str());
93  wframe->AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft,
94  5, 5, 5, 1));
95 
96  // Unzoom button.
97 
98  TGTextButton* unzoom = new TGTextButton(wframe, "&Unzoom");
99  wframe->AddFrame(unzoom, new TGLayoutHints(kLHintsTop | kLHintsLeft,
100  5, 5, 5, 1));
101  unzoom->Connect("Clicked()", "evd::Ortho3DPad", pad,
102  "UnZoom(=true)");
103 
104  // Marker size entry.
105 
106  TGCompositeFrame* msize_frame = new TGHorizontalFrame(wframe);
107  wframe->AddFrame(msize_frame, new TGLayoutHints(kLHintsTop | kLHintsLeft,
108  5, 5, 5, 1));
109  int val = pad->GetMarkerSize();
110  TGNumberEntry* msize_entry = new TGNumberEntry(msize_frame, val, 3, -1,
111  TGNumberFormat::kNESInteger,
112  TGNumberFormat::kNEANonNegative,
113  TGNumberFormat::kNELLimitMin, 1.);
114  msize_frame->AddFrame(msize_entry);
115  pad->SetMSizeEntry(msize_entry);
116 
117  TGLabel* msize_label = new TGLabel(msize_frame, "Marker Size");
118  msize_frame->AddFrame(msize_label,
119  new TGLayoutHints(kLHintsTop | kLHintsLeft,
120  5, 0, 0, 1));
121  msize_entry->Connect("ValueSet(Long_t)", "evd::Ortho3DPad", pad,
122  "SetMSize()");
123  }
124 
125  // Draw everything and update canvas.
126 
127  Draw();
128  evdb::Canvas::fCanvas->Update();
129 }
130 
131 //......................................................................
132 // Destructor.
134 {
135 }
136 
137 //......................................................................
138 // Draw object in graphics pads.
139 void evd::Ortho3DView::Draw(const char* /*opt*/)
140 {
142  i != fOrtho3DPads.end(); ++i) {
143  Ortho3DPad* pad = *i;
144  pad->Draw();
145  }
146 }
147 
const std::string label
TGCompositeFrame * fFrame
Graphics frame.
Definition: Canvas.h:39
void SetMSizeEntry(TGNumberEntry *p)
Definition: Ortho3DPad.cxx:351
virtual ~Ortho3DView()
A drawing pad showing an orthographic rendering of 3D objects.
Definition: Ortho3DPad.h:25
TCanvas * fCanvas
The ROOT drawing canvas.
Definition: Canvas.h:42
TGLayoutHints * fLayout
Layout hints for frame.
Definition: Canvas.h:40
OrthoProj_t
Definition: OrthoProj.h:12
Manage all things related to colors for the event display.
void Draw(const char *opt="")
intermediate_table::const_iterator const_iterator
TGCompositeFrame * fMetaFrame
Frame holding root canvas and widget frame.
Definition: Ortho3DView.h:46
Drawing pad showing an orthographic projection of 3D objects in the detector.
std::vector< TGCompositeFrame * > fWidgetSubFrames
Definition: Ortho3DView.h:48
A view showing an orthographic projection of 3D objects.
TGCompositeFrame * fWidgetFrame
Frame holding widgets.
Definition: Ortho3DView.h:47
double GetMarkerSize() const
Definition: Ortho3DPad.h:44
Float_t proj
Definition: plot.C:34
std::vector< Ortho3DPad * > fOrtho3DPads
Graphics pads.
Definition: Ortho3DView.h:42
TRootEmbeddedCanvas * fEmbCanvas
Embedded canvas.
Definition: Canvas.h:41
void Draw(const char *opt=0)
Definition: Ortho3DPad.cxx:222
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Ortho3DView(TGMainFrame *mf)
Definition: Ortho3DView.cxx:23