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