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