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
22GUI sub-editor for TGLClipSet.
23*/
24
26
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor.
29
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{
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
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.};
115
117
118 // Button ids run from 1
120 btn->SetDown();
122 }
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();
199 for (Int_t i = 0; i < 6; ++i)
200 data[i] = fBoxProp[i]->GetNumber();
201
203
210
211 Changed();
212}
213
214////////////////////////////////////////////////////////////////////////////////
215/// Reset transformation of the current clip.
216
218{
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
233GUI 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}
@ kChildFrame
Definition: GuiTypes.h:379
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
#define ClassImp(name)
Definition: Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDisabled
Definition: TGButton.h:56
@ kButtonUp
Definition: TGButton.h:53
@ kLHintsLeft
Definition: TGLayout.h:24
@ kLHintsCenterX
Definition: TGLayout.h:25
@ kLHintsBottom
Definition: TGLayout.h:29
@ kLHintsTop
Definition: TGLayout.h:27
@ kLHintsExpandX
Definition: TGLayout.h:30
Organizes TGButton widgets in a group.
Definition: TGButtonGroup.h:21
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
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...
virtual TGButton * GetButton(Int_t id) const
Definition: TGButtonGroup.h:83
A button abstract base class.
Definition: TGButton.h:68
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:310
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:459
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:235
Selects different options.
Definition: TGButton.h:264
virtual Bool_t IsDown() const
Definition: TGButton.h:312
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1117
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1257
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1204
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1190
Concrete clip plane object.
Definition: TGLClip.h:86
GUI editor for TGLClipSet.
TGLClipSetSubEditor * fSE
TGLClipSetEditor(const TGLClipSetEditor &)
virtual void SetModel(TObject *obj)
Set model object.
GUI sub-editor for TGLClipSet.
void ClipTypeChanged(Int_t)
Clip type radio button changed - update viewer.
TGCheckButton * fClipInside
TGCheckButton * fAutoUpdate
TGNumberEntry * fPlaneProp[4]
void UpdateViewerClip()
Change clipping volume.
TGCompositeFrame * fBoxPropFrame
void SetModel(TGLClipSet *m)
Set model object.
void ClipValueChanged()
One of number entries was changed.
TGCheckButton * fClipShow
TGNumberEntry * fBoxProp[6]
TGLClip::EType fCurrentClip
TGLClipSetSubEditor(const TGLClipSetSubEditor &)
TGCompositeFrame * fPlanePropFrame
TGButtonGroup * fTypeButtons
void Changed()
Emit Changed signal.
TGCheckButton * fClipEdit
void ResetViewerClip()
Reset transformation of the current clip.
A collection of concrete TGLClip objects to be selected from.
Definition: TGLClip.h:140
TGLClip * GetCurrentClip() const
Definition: TGLClip.h:170
void GetClipState(TGLClip::EType type, Double_t data[6]) const
Get state of clip object 'type' into data vector:
Definition: TGLClip.cxx:477
void SetAutoUpdate(Bool_t aup)
Definition: TGLClip.h:189
void SetClipState(TGLClip::EType type, const Double_t data[6])
Set state of clip object 'type' into data vector:
Definition: TGLClip.cxx:524
void SetShowClip(Bool_t show)
Definition: TGLClip.h:193
void SetClipType(TGLClip::EType type)
Set current clip active in viewer - 'type' is one of kClipNone kClipPlane or kClipBox.
Definition: TGLClip.cxx:580
void SetShowManip(Bool_t show)
Definition: TGLClip.h:191
Bool_t GetAutoUpdate() const
Definition: TGLClip.h:188
Bool_t GetShowManip() const
Definition: TGLClip.h:190
TGLClip::EType GetClipType() const
Get current type active in viewer - returns one of kClipNone kClipPlane or kClipBox.
Definition: TGLClip.cxx:560
Bool_t GetShowClip() const
Definition: TGLClip.h:192
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:32
@ kClipBox
Definition: TGLClip.h:43
@ kClipPlane
Definition: TGLClip.h:42
@ kClipNone
Definition: TGLClip.h:41
@ kOutside
Definition: TGLClip.h:36
@ kInside
Definition: TGLClip.h:37
void SetMode(EMode mode)
Definition: TGLClip.h:61
EMode GetMode() const
Definition: TGLClip.h:60
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:598
void SetTransform(const TGLMatrix &transform)
3D plane class - of format Ax + By + Cz + D = 0
Definition: TGLUtil.h:525
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.
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition: TGFrame.h:398
Selects different options.
Definition: TGButton.h:322
Yield an action as soon as it is clicked.
Definition: TGButton.h:142
A composite frame that layout their children in vertical way.
Definition: TGFrame.h:375
ROOT GUI Window base class.
Definition: TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:152
Base frame for implementing GUI - a service class.
Definition: TGedFrame.h:27
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:95
Mother of all ROOT objects.
Definition: TObject.h:37
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
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:869
auto * m
Definition: textangle.C:8