Logo ROOT  
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 "TGButton.h"
15 #include "TGButtonGroup.h"
16 #include "TGNumberEntry.h"
17 
18 #include "TGLViewerEditor.h"
19 
20 /** \class TGLClipSetSubEditor
21 \ingroup opengl
22 GUI sub-editor for TGLClipSet.
23 */
24 
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// Constructor.
29 
31  TGVerticalFrame(p),
32  fM(0),
33  fCurrentClip(TGLClip::kClipNone),
34  fTypeButtons(0),
35  fPlanePropFrame(0),
36  fPlaneProp(),
37  fBoxPropFrame(0),
38  fBoxProp(),
39  fClipInside(0),
40  fAutoUpdate(0),
41  fClipEdit(0),
42  fClipShow(0),
43  fApplyButton(0),
44  fResetButton(0)
45 {
46  fTypeButtons = new TGButtonGroup(this, "Clip Type", kChildFrame|kHorizontalFrame);
47  new TGRadioButton(fTypeButtons, "None ");
48  new TGRadioButton(fTypeButtons, "Plane ");
49  new TGRadioButton(fTypeButtons, "Box");
52  // Clip inside / edit
53  fClipInside = new TGCheckButton(this, "Clip away inside");
55  fAutoUpdate = new TGCheckButton(this, "Auto update clip");
57  fClipEdit = new TGCheckButton(this, "Edit In Viewer");
59  fClipShow = new TGCheckButton(this, "Show In Viewer");
61 
62  // Plane properties
65 
66  static const char * const planeStr[] = { "aX + ", "bY +", "cZ + ", "d = 0" };
67 
68  for (Int_t i = 0; i < 4; ++i)
70 
71  // Box properties
72  fBoxPropFrame = new TGCompositeFrame(this);
74 
75  static const char * const boxStr[] = {"Center X", "Center Y", "Center Z", "Length X", "Length Y", "Length Z" };
76 
77  for (Int_t i = 0; i < 6; ++i)
79 
80  // Apply button
81  fApplyButton = new TGTextButton(this, "Apply");
83 
84  fResetButton = new TGTextButton(this, "Reset");
86 
87  fTypeButtons->Connect("Clicked(Int_t)", "TGLClipSetSubEditor", this, "ClipTypeChanged(Int_t)");
88  fClipInside->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
89  fAutoUpdate->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
90  fClipEdit->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
91  fClipShow->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
92 
93  for (Int_t i = 0; i < 4; ++i)
94  fPlaneProp[i]->Connect("ValueSet(Long_t)", "TGLClipSetSubEditor", this, "ClipValueChanged()");
95 
96  for (Int_t i = 0; i < 6; ++i)
97  fBoxProp[i]->Connect("ValueSet(Long_t)", "TGLClipSetSubEditor", this, "ClipValueChanged()");
98 
99  fApplyButton->Connect("Pressed()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
100  fResetButton->Connect("Pressed()", "TGLClipSetSubEditor", this, "ResetViewerClip()");
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Set model object.
105 
107 {
108  fM = m;
109 
112 
113  Double_t clip[6] = {0.};
114  fM->GetClipState(fCurrentClip, clip);
115 
117 
118  // Button ids run from 1
119  if (TGButton *btn = fTypeButtons->GetButton(fCurrentClip+1)) {
120  btn->SetDown();
122  }
123  Bool_t active = (fCurrentClip != TGLClip::kClipNone);
124  fClipInside->SetEnabled(active);
125  fAutoUpdate->SetEnabled(active);
126  fClipEdit ->SetEnabled(active);
127  fClipShow ->SetEnabled(active);
128  if (active) {
133 
137  for (Int_t i = 0; i < 4; ++i)
138  fPlaneProp[i]->SetNumber(clip[i]);
139  } else if (fCurrentClip == TGLClip::kClipBox) {
142  for (Int_t i = 0; i < 6; ++i)
143  fBoxProp[i]->SetNumber(clip[i]);
144  }
145 
147  } else {
150 
152  }
153 }
154 
155 ////////////////////////////////////////////////////////////////////////////////
156 /// Emit Changed signal.
157 
159 {
160  Emit("Changed()");
161 }
162 
163 ////////////////////////////////////////////////////////////////////////////////
164 /// One of number entries was changed.
165 
167 {
169 }
170 
171 ////////////////////////////////////////////////////////////////////////////////
172 /// Clip type radio button changed - update viewer.
173 
175 {
176  switch (id)
177  {
178  case 2: fCurrentClip = TGLClip::kClipPlane; break;
179  case 3: fCurrentClip = TGLClip::kClipBox; break;
180  default: fCurrentClip = TGLClip::kClipNone; break;
181  }
183  SetModel(fM);
185  Changed();
186 }
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Change clipping volume.
190 
192 {
193  Double_t data[6] = {0.};
194  // Fetch GUI state for clip if 'type' into 'data' vector
196  for (Int_t i = 0; i < 4; ++i)
197  data[i] = fPlaneProp[i]->GetNumber();
198  else if (fCurrentClip == TGLClip::kClipBox)
199  for (Int_t i = 0; i < 6; ++i)
200  data[i] = fBoxProp[i]->GetNumber();
201 
203 
204  fM->SetClipState(fCurrentClip, data);
210 
211  Changed();
212 }
213 
214 ////////////////////////////////////////////////////////////////////////////////
215 /// Reset transformation of the current clip.
216 
218 {
220  if (fM->GetClipType() == TGLClip::kClipPlane) {
221  TGLPlane plane(0.0, -1.0, 0.0, 0.0);
222  dynamic_cast<TGLClipPlane*>(fM->GetCurrentClip())->Set(plane);
223  } else if (fM->GetClipType() == TGLClip::kClipBox) {
225  }
226  Changed();
227  }
228 }
229 
230 
231 /** \class TGLClipSetEditor
232 \ingroup opengl
233 GUI editor for TGLClipSet.
234 */
235 
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 /// Constructor.
240 
242  UInt_t options, Pixel_t back) :
243  TGedFrame(p, width, height, options | kVerticalFrame, back),
244  fM (0),
245  fSE (0)
246 {
247  MakeTitle("TGLClipSet");
248 
249  fSE = new TGLClipSetSubEditor(this);
250  AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
251  fSE->Connect("Changed()", "TGLClipSetEditor", this, "Update()");
252 }
253 
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 /// Set model object.
257 
259 {
260  fM = dynamic_cast<TGLClipSet*>(obj);
261  fSE->SetModel(fM);
262 }
TGLClipSetSubEditor::fM
TGLClipSet * fM
Definition: TGLClipSetEditor.h:33
m
auto * m
Definition: textangle.C:8
TGButtonGroup::SetButton
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...
Definition: TGButtonGroup.cxx:334
TGButton::SetEnabled
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:412
TGLClipSet::GetClipState
void GetClipState(TGLClip::EType type, Double_t data[6]) const
Get state of clip object 'type' into data vector:
Definition: TGLClip.cxx:477
TGLClipSet::SetAutoUpdate
void SetAutoUpdate(Bool_t aup)
Definition: TGLClip.h:189
TGLClip::GetMode
EMode GetMode() const
Definition: TGLClip.h:60
TGWindow
Definition: TGWindow.h:31
kLHintsCenterX
@ kLHintsCenterX
Definition: TGLayout.h:32
TGLClipSetSubEditor::ClipValueChanged
void ClipValueChanged()
One of number entries was changed.
Definition: TGLClipSetEditor.cxx:166
TGMainFrame
Definition: TGFrame.h:444
TGLClip::kOutside
@ kOutside
Definition: TGLClip.h:36
TGLClipSet::GetAutoUpdate
Bool_t GetAutoUpdate() const
Definition: TGLClip.h:188
TGLClipSet
A collection of concrete TGLClip objects to be selected from.
Definition: TGLClip.h:140
TGButton::SetDown
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:263
TGLClipSet::GetShowManip
Bool_t GetShowManip() const
Definition: TGLClip.h:190
TGCompositeFrame::TGCompositeFrame
TGCompositeFrame(const TGCompositeFrame &)
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:34
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGLClipSet::GetClipType
TGLClip::EType GetClipType() const
Get current type active in viewer - returns one of kClipNone kClipPlane or kClipBox.
Definition: TGLClip.cxx:560
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:31
TGLClip::kClipBox
@ kClipBox
Definition: TGLClip.h:43
kButtonUp
@ kButtonUp
Definition: TGButton.h:53
TGLClipSetEditor::TGLClipSetEditor
TGLClipSetEditor(const TGLClipSetEditor &)
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGTextButton
Definition: TGButton.h:142
TGLClipSet::SetClipState
void SetClipState(TGLClip::EType type, const Double_t data[6])
Set state of clip object 'type' into data vector:
Definition: TGLClip.cxx:524
TGLClipSetSubEditor::ResetViewerClip
void ResetViewerClip()
Reset transformation of the current clip.
Definition: TGLClipSetEditor.cxx:217
TGLClipSetSubEditor::fPlaneProp
TGNumberEntry * fPlaneProp[4]
Definition: TGLClipSetEditor.h:39
TGLClipSetSubEditor::fTypeButtons
TGButtonGroup * fTypeButtons
Definition: TGLClipSetEditor.h:36
TGButtonGroup::SetLayoutHints
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
Definition: TGButtonGroup.cxx:585
TGLMatrix
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:598
TGButtonGroup
Definition: TGButtonGroup.h:31
TGLClipSetEditor
GUI editor for TGLClipSet.
Definition: TGLClipSetEditor.h:68
TGLClipSetSubEditor::fClipEdit
TGCheckButton * fClipEdit
Definition: TGLClipSetEditor.h:45
bool
TGLClipSetEditor::fM
TGLClipSet * fM
Definition: TGLClipSetEditor.h:75
TGLClipSetSubEditor::fCurrentClip
TGLClip::EType fCurrentClip
Definition: TGLClipSetEditor.h:35
TGLClipSet::GetCurrentClip
TGLClip * GetCurrentClip() const
Definition: TGLClip.h:170
kLHintsBottom
@ kLHintsBottom
Definition: TGLayout.h:36
TGCheckButton
Definition: TGButton.h:264
TGLClipSetSubEditor::SetModel
void SetModel(TGLClipSet *m)
Set model object.
Definition: TGLClipSetEditor.cxx:106
TGLPlane
3D plane class - of format Ax + By + Cz + D = 0
Definition: TGLUtil.h:525
TGLClipSetEditor::fSE
TGLClipSetSubEditor * fSE
Definition: TGLClipSetEditor.h:76
TGButtonGroup::GetButton
virtual TGButton * GetButton(Int_t id) const
Definition: TGButtonGroup.h:93
TGRadioButton
Definition: TGButton.h:322
TGVerticalFrame
Definition: TGFrame.h:412
TGLClipSet::SetShowManip
void SetShowManip(Bool_t show)
Definition: TGLClip.h:191
TGLClipSet::SetClipType
void SetClipType(TGLClip::EType type)
Set current clip active in viewer - 'type' is one of kClipNone kClipPlane or kClipBox.
Definition: TGLClip.cxx:580
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGLClipSetSubEditor::UpdateViewerClip
void UpdateViewerClip()
Change clipping volume.
Definition: TGLClipSetEditor.cxx:191
TGLClipSetSubEditor::fClipShow
TGCheckButton * fClipShow
Definition: TGLClipSetEditor.h:46
TGCompositeFrame::HideFrame
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1175
TGLayoutHints
Definition: TGLayout.h:57
TGLClipSetSubEditor::fPlanePropFrame
TGCompositeFrame * fPlanePropFrame
Definition: TGLClipSetEditor.h:38
TGButtonGroup.h
TGLClipSet::GetShowClip
Bool_t GetShowClip() const
Definition: TGLClip.h:192
TGLClip::SetMode
void SetMode(EMode mode)
Definition: TGLClip.h:61
TGLClipSetSubEditor::fBoxProp
TGNumberEntry * fBoxProp[6]
Definition: TGLClipSetEditor.h:42
TGedFrame::MakeTitle
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
TGLClipSetSubEditor::ClipTypeChanged
void ClipTypeChanged(Int_t)
Clip type radio button changed - update viewer.
Definition: TGLClipSetEditor.cxx:174
TGLClipSetSubEditor::fApplyButton
TGButton * fApplyButton
Definition: TGLClipSetEditor.h:47
TGLClipPlane
Concrete clip plane object.
Definition: TGLClip.h:86
unsigned int
TGButton::SetState
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:188
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGCheckButton::IsDown
virtual Bool_t IsDown() const
Definition: TGButton.h:312
TGLClipSetSubEditor::TGLClipSetSubEditor
TGLClipSetSubEditor(const TGLClipSetSubEditor &)
TGedFrame
Definition: TGedFrame.h:33
TGLViewerEditor::MakeLabeledNEntry
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.
Definition: TGLViewerEditor.cxx:437
TGLClipSetSubEditor::fClipInside
TGCheckButton * fClipInside
Definition: TGLClipSetEditor.h:43
TGLClipSetSubEditor::fResetButton
TGButton * fResetButton
Definition: TGLClipSetEditor.h:48
TGLClip
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:32
TGLViewerEditor.h
Double_t
double Double_t
Definition: RtypesCore.h:59
TQObject::Connect
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:866
TGLClipSetEditor::SetModel
virtual void SetModel(TObject *obj)
Set model object.
Definition: TGLClipSetEditor.cxx:258
TGLClip::kClipNone
@ kClipNone
Definition: TGLClip.h:41
TGWindow::GetMainFrame
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:151
TGLClipSet::SetShowClip
void SetShowClip(Bool_t show)
Definition: TGLClip.h:193
TGLClip.h
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TGButton.h
TGLClip::kInside
@ kInside
Definition: TGLClip.h:37
TGNumberEntry.h
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:37
TGLClipSetSubEditor::fAutoUpdate
TGCheckButton * fAutoUpdate
Definition: TGLClipSetEditor.h:44
TGButton
Definition: TGButton.h:68
TGLClipSetEditor.h
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TGLClipSetSubEditor::fBoxPropFrame
TGCompositeFrame * fBoxPropFrame
Definition: TGLClipSetEditor.h:41
TGCompositeFrame::Layout
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1242
TGLClipSetSubEditor::Changed
void Changed()
Emit Changed signal.
Definition: TGLClipSetEditor.cxx:158
TGCompositeFrame::ShowFrame
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1189
TGLClipSetSubEditor
GUI sub-editor for TGLClipSet.
Definition: TGLClipSetEditor.h:27
kButtonDisabled
@ kButtonDisabled
Definition: TGButton.h:56
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int
TGLPhysicalShape::SetTransform
void SetTransform(const TGLMatrix &transform)
Definition: TGLPhysicalShape.h:153
TGLClip::kClipPlane
@ kClipPlane
Definition: TGLClip.h:42