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 "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
25GUI sub-editor for TGLClipSet.
26*/
27
29
30////////////////////////////////////////////////////////////////////////////////
31/// Constructor.
32
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{
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
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.};
118
120
121 // Button ids run from 1
123 btn->SetDown();
125 }
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();
202 for (Int_t i = 0; i < 6; ++i)
203 data[i] = fBoxProp[i]->GetNumber();
204
206
213
214 Changed();
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Reset transformation of the current clip.
219
221{
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
236GUI 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}
@ kChildFrame
Definition: GuiTypes.h:379
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
ULong_t Pixel_t
Definition: GuiTypes.h:39
const Bool_t kFALSE
Definition: RtypesCore.h:90
double Double_t
Definition: RtypesCore.h:57
#define ClassImp(name)
Definition: Rtypes.h:361
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:31
@ kLHintsCenterX
Definition: TGLayout.h:32
@ kLHintsBottom
Definition: TGLayout.h:36
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
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:93
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition: TGButton.cxx:262
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:411
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:187
virtual Bool_t IsDown() const
Definition: TGButton.h:312
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1241
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1188
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1174
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:597
void SetTransform(const TGLMatrix &transform)
3D plane class - of format Ax + By + Cz + D = 0
Definition: TGLUtil.h:524
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.
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:142
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
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:866
auto * m
Definition: textangle.C:8