Logo ROOT   6.12/07
Reference Guide
TGLClipSetEditor.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel, Jun 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TGLClipSetEditor.h"
13 #include "TGLClip.h"
14 #include "TVirtualPad.h"
15 #include "TColor.h"
16 #include "TGLabel.h"
17 #include "TGButton.h"
18 #include "TGButtonGroup.h"
19 #include "TGNumberEntry.h"
20 
21 #include "TGLViewerEditor.h"
22 
23 /** \class TGLClipSetSubEditor
24 \ingroup opengl
25 GUI sub-editor for TGLClipSet.
26 */
27 
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Constructor.
32 
34  TGVerticalFrame(p),
35  fM(0),
36  fCurrentClip(TGLClip::kClipNone),
37  fTypeButtons(0),
38  fPlanePropFrame(0),
39  fPlaneProp(),
40  fBoxPropFrame(0),
41  fBoxProp(),
42  fClipInside(0),
43  fAutoUpdate(0),
44  fClipEdit(0),
45  fClipShow(0),
46  fApplyButton(0),
47  fResetButton(0)
48 {
49  fTypeButtons = new TGButtonGroup(this, "Clip Type", kChildFrame|kHorizontalFrame);
50  new TGRadioButton(fTypeButtons, "None ");
51  new TGRadioButton(fTypeButtons, "Plane ");
52  new TGRadioButton(fTypeButtons, "Box");
55  // Clip inside / edit
56  fClipInside = new TGCheckButton(this, "Clip away inside");
58  fAutoUpdate = new TGCheckButton(this, "Auto update clip");
60  fClipEdit = new TGCheckButton(this, "Edit In Viewer");
62  fClipShow = new TGCheckButton(this, "Show In Viewer");
64 
65  // Plane properties
68 
69  static const char * const planeStr[] = { "aX + ", "bY +", "cZ + ", "d = 0" };
70 
71  for (Int_t i = 0; i < 4; ++i)
73 
74  // Box properties
75  fBoxPropFrame = new TGCompositeFrame(this);
77 
78  static const char * const boxStr[] = {"Center X", "Center Y", "Center Z", "Length X", "Length Y", "Length Z" };
79 
80  for (Int_t i = 0; i < 6; ++i)
82 
83  // Apply button
84  fApplyButton = new TGTextButton(this, "Apply");
86 
87  fResetButton = new TGTextButton(this, "Reset");
89 
90  fTypeButtons->Connect("Clicked(Int_t)", "TGLClipSetSubEditor", this, "ClipTypeChanged(Int_t)");
91  fClipInside->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
92  fAutoUpdate->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
93  fClipEdit->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
94  fClipShow->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
95 
96  for (Int_t i = 0; i < 4; ++i)
97  fPlaneProp[i]->Connect("ValueSet(Long_t)", "TGLClipSetSubEditor", this, "ClipValueChanged()");
98 
99  for (Int_t i = 0; i < 6; ++i)
100  fBoxProp[i]->Connect("ValueSet(Long_t)", "TGLClipSetSubEditor", this, "ClipValueChanged()");
101 
102  fApplyButton->Connect("Pressed()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
103  fResetButton->Connect("Pressed()", "TGLClipSetSubEditor", this, "ResetViewerClip()");
104 }
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// Set model object.
108 
110 {
111  fM = m;
112 
115 
116  Double_t clip[6] = {0.};
117  fM->GetClipState(fCurrentClip, clip);
118 
120 
121  // Button ids run from 1
122  if (TGButton *btn = fTypeButtons->GetButton(fCurrentClip+1)) {
123  btn->SetDown();
125  }
126  Bool_t active = (fCurrentClip != TGLClip::kClipNone);
127  fClipInside->SetEnabled(active);
128  fAutoUpdate->SetEnabled(active);
129  fClipEdit ->SetEnabled(active);
130  fClipShow ->SetEnabled(active);
131  if (active) {
136 
140  for (Int_t i = 0; i < 4; ++i)
141  fPlaneProp[i]->SetNumber(clip[i]);
142  } else if (fCurrentClip == TGLClip::kClipBox) {
145  for (Int_t i = 0; i < 6; ++i)
146  fBoxProp[i]->SetNumber(clip[i]);
147  }
148 
150  } else {
153 
155  }
156 }
157 
158 ////////////////////////////////////////////////////////////////////////////////
159 /// Emit Changed signal.
160 
162 {
163  Emit("Changed()");
164 }
165 
166 ////////////////////////////////////////////////////////////////////////////////
167 /// One of number entries was changed.
168 
170 {
172 }
173 
174 ////////////////////////////////////////////////////////////////////////////////
175 /// Clip type radio button changed - update viewer.
176 
178 {
179  switch (id)
180  {
181  case 2: fCurrentClip = TGLClip::kClipPlane; break;
182  case 3: fCurrentClip = TGLClip::kClipBox; break;
183  default: fCurrentClip = TGLClip::kClipNone; break;
184  }
186  SetModel(fM);
188  Changed();
189 }
190 
191 ////////////////////////////////////////////////////////////////////////////////
192 /// Change clipping volume.
193 
195 {
196  Double_t data[6] = {0.};
197  // Fetch GUI state for clip if 'type' into 'data' vector
199  for (Int_t i = 0; i < 4; ++i)
200  data[i] = fPlaneProp[i]->GetNumber();
201  else if (fCurrentClip == TGLClip::kClipBox)
202  for (Int_t i = 0; i < 6; ++i)
203  data[i] = fBoxProp[i]->GetNumber();
204 
206 
207  fM->SetClipState(fCurrentClip, data);
213 
214  Changed();
215 }
216 
217 ////////////////////////////////////////////////////////////////////////////////
218 /// Reset transformation of the current clip.
219 
221 {
223  if (fM->GetClipType() == TGLClip::kClipPlane) {
224  TGLPlane plane(0.0, -1.0, 0.0, 0.0);
225  dynamic_cast<TGLClipPlane*>(fM->GetCurrentClip())->Set(plane);
226  } else if (fM->GetClipType() == TGLClip::kClipBox) {
228  }
229  Changed();
230  }
231 }
232 
233 
234 /** \class TGLClipSetEditor
235 \ingroup opengl
236 GUI editor for TGLClipSet.
237 */
238 
240 
241 ////////////////////////////////////////////////////////////////////////////////
242 /// Constructor.
243 
245  UInt_t options, Pixel_t back) :
246  TGedFrame(p, width, height, options | kVerticalFrame, back),
247  fM (0),
248  fSE (0)
249 {
250  MakeTitle("TGLClipSet");
251 
252  fSE = new TGLClipSetSubEditor(this);
253  AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
254  fSE->Connect("Changed()", "TGLClipSetEditor", this, "Update()");
255 }
256 
257 
258 ////////////////////////////////////////////////////////////////////////////////
259 /// Set model object.
260 
262 {
263  fM = dynamic_cast<TGLClipSet*>(obj);
264  fSE->SetModel(fM);
265 }
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
TGLClipSetSubEditor * fSE
TGLClip * GetCurrentClip() const
Definition: TGLClip.h:170
void SetShowManip(Bool_t show)
Definition: TGLClip.h:191
auto * m
Definition: textangle.C:8
void SetClipType(TGLClip::EType type)
Set current clip active in viewer - &#39;type&#39; is one of kClipNone kClipPlane or kClipBox.
Definition: TGLClip.cxx:580
void ClipValueChanged()
One of number entries was changed.
TGCheckButton * fAutoUpdate
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:596
virtual void SetButton(Int_t id, Bool_t down=kTRUE)
Sets the button with id to be on/down, and if this is an exclusive group, all other button in the gro...
void SetMode(EMode mode)
Definition: TGLClip.h:61
GUI editor for TGLClipSet.
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:31
TGLClipSetSubEditor(const TGLClipSetSubEditor &)
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1186
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetShowClip(Bool_t show)
Definition: TGLClip.h:193
Bool_t GetShowClip() const
Definition: TGLClip.h:192
TGCompositeFrame * fPlanePropFrame
TGLClip::EType fCurrentClip
TGCheckButton * fClipShow
GUI sub-editor for TGLClipSet.
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
virtual void SetModel(TObject *obj)
Set model object.
TGNumberEntry * fBoxProp[6]
TGNumberEntry * fPlaneProp[4]
ULong_t Pixel_t
Definition: GuiTypes.h:39
virtual Bool_t IsDown() const
Definition: TGButton.h:312
TGCompositeFrame(const TGCompositeFrame &)
TGCheckButton * fClipEdit
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
void Changed()
Emit Changed signal.
void UpdateViewerClip()
Change clipping volume.
EMode GetMode() const
Definition: TGLClip.h:60
Bool_t GetShowManip() const
Definition: TGLClip.h:190
void GetClipState(TGLClip::EType type, Double_t data[6]) const
Get state of clip object &#39;type&#39; into data vector:
Definition: TGLClip.cxx:477
void SetModel(TGLClipSet *m)
Set model object.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:867
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
Concrete clip plane object.
Definition: TGLClip.h:85
Bool_t GetAutoUpdate() const
Definition: TGLClip.h:188
unsigned int UInt_t
Definition: RtypesCore.h:42
A collection of concrete TGLClip objects to be selected from.
Definition: TGLClip.h:139
virtual TGButton * GetButton(Int_t id) const
Definition: TGButtonGroup.h:93
const Bool_t kFALSE
Definition: RtypesCore.h:88
void SetAutoUpdate(Bool_t aup)
Definition: TGLClip.h:189
void ClipTypeChanged(Int_t)
Clip type radio button changed - update viewer.
TGLClip::EType GetClipType() const
Get current type active in viewer - returns one of kClipNone kClipPlane or kClipBox.
Definition: TGLClip.cxx:560
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
void SetTransform(const TGLMatrix &transform)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
TGLClipSetEditor(const TGLClipSetEditor &)
static TGNumberEntry * MakeLabeledNEntry(TGCompositeFrame *p, const char *name, Int_t labelw, Int_t nd=7, Int_t s=5)
Helper function to create fixed width TGLabel and TGNumberEntry in same row.
void SetClipState(TGLClip::EType type, const Double_t data[6])
Set state of clip object &#39;type&#39; into data vector:
Definition: TGLClip.cxx:524
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:260
TGCheckButton * fClipInside
void ResetViewerClip()
Reset transformation of the current clip.
TGButtonGroup * fTypeButtons
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
TGCompositeFrame * fBoxPropFrame
3D plane class - of format Ax + By + Cz + D = 0
Definition: TGLUtil.h:525
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185