Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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
25
26////////////////////////////////////////////////////////////////////////////////
27/// Constructor.
28
31 fM(nullptr),
32 fCurrentClip(TGLClip::kClipNone),
33 fTypeButtons(nullptr),
34 fPlanePropFrame(nullptr),
35 fPlaneProp(),
36 fBoxPropFrame(nullptr),
37 fBoxProp(),
38 fClipInside(nullptr),
39 fAutoUpdate(nullptr),
40 fClipEdit(nullptr),
41 fClipShow(nullptr),
42 fApplyButton(nullptr),
43 fResetButton(nullptr)
44{
46 new TGRadioButton(fTypeButtons, "None ");
47 new TGRadioButton(fTypeButtons, "Plane ");
48 new TGRadioButton(fTypeButtons, "Box");
49 fTypeButtons->SetLayoutHints(new TGLayoutHints(kLHintsLeft|kLHintsBottom, 0, 0, 2, -10));
51 // Clip inside / edit
52 fClipInside = new TGCheckButton(this, "Clip away inside");
54 fAutoUpdate = new TGCheckButton(this, "Auto update clip");
56 fClipEdit = new TGCheckButton(this, "Edit In Viewer");
58 fClipShow = new TGCheckButton(this, "Show In Viewer");
60
61 // Plane properties
64
65 static const char * const planeStr[] = { "aX + ", "bY +", "cZ + ", "d = 0" };
66
67 for (Int_t i = 0; i < 4; ++i)
69
70 // Box properties
73
74 static const char * const boxStr[] = {"Center X", "Center Y", "Center Z", "Length X", "Length Y", "Length Z" };
75
76 for (Int_t i = 0; i < 6; ++i)
78
79 // Apply button
80 fApplyButton = new TGTextButton(this, "Apply");
82
83 fResetButton = new TGTextButton(this, "Reset");
85
86 fTypeButtons->Connect("Clicked(Int_t)", "TGLClipSetSubEditor", this, "ClipTypeChanged(Int_t)");
87 fClipInside->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
88 fAutoUpdate->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
89 fClipEdit->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
90 fClipShow->Connect("Clicked()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
91
92 for (Int_t i = 0; i < 4; ++i)
93 fPlaneProp[i]->Connect("ValueSet(Long_t)", "TGLClipSetSubEditor", this, "ClipValueChanged()");
94
95 for (Int_t i = 0; i < 6; ++i)
96 fBoxProp[i]->Connect("ValueSet(Long_t)", "TGLClipSetSubEditor", this, "ClipValueChanged()");
97
98 fApplyButton->Connect("Pressed()", "TGLClipSetSubEditor", this, "UpdateViewerClip()");
99 fResetButton->Connect("Pressed()", "TGLClipSetSubEditor", this, "ResetViewerClip()");
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Set model object.
104
106{
107 fM = m;
108
109 fTypeButtons->GetButton(fCurrentClip+1)->SetDown(kFALSE);
110 fCurrentClip = fM->GetClipType();
111
112 Double_t clip[6] = {0.};
113 fM->GetClipState(fCurrentClip, clip);
114
115 fApplyButton->SetState(kButtonDisabled);
116
117 // Button ids run from 1
118 if (TGButton *btn = fTypeButtons->GetButton(fCurrentClip+1)) {
119 btn->SetDown();
120 fTypeButtons->SetButton(fCurrentClip+1);
121 }
123 fClipInside->SetEnabled(active);
124 fAutoUpdate->SetEnabled(active);
125 fClipEdit ->SetEnabled(active);
126 fClipShow ->SetEnabled(active);
127 if (active) {
128 fClipEdit->SetDown(fM->GetShowManip());
129 fClipShow->SetDown(fM->GetShowClip());
130 fClipInside->SetDown(fM->GetCurrentClip()->GetMode() == TGLClip::kInside);
131 fAutoUpdate->SetDown(fM->GetAutoUpdate());
132
136 for (Int_t i = 0; i < 4; ++i)
137 fPlaneProp[i]->SetNumber(clip[i]);
138 } else if (fCurrentClip == TGLClip::kClipBox) {
141 for (Int_t i = 0; i < 6; ++i)
142 fBoxProp[i]->SetNumber(clip[i]);
143 }
144
145 fResetButton->SetState(kButtonUp);
146 } else {
149
150 fResetButton->SetState(kButtonDisabled);
151 }
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Emit Changed signal.
156
158{
159 Emit("Changed()");
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// One of number entries was changed.
164
169
170////////////////////////////////////////////////////////////////////////////////
171/// Clip type radio button changed - update viewer.
172
174{
175 switch (id)
176 {
177 case 2: fCurrentClip = TGLClip::kClipPlane; break;
178 case 3: fCurrentClip = TGLClip::kClipBox; break;
179 default: fCurrentClip = TGLClip::kClipNone; break;
180 }
181 fM->SetClipType(fCurrentClip);
182 SetModel(fM);
183 ((TGMainFrame*)GetMainFrame())->Layout();
184 Changed();
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Change clipping volume.
189
191{
192 Double_t data[6] = {0.};
193 // Fetch GUI state for clip if 'type' into 'data' vector
195 for (Int_t i = 0; i < 4; ++i)
196 data[i] = fPlaneProp[i]->GetNumber();
198 for (Int_t i = 0; i < 6; ++i)
199 data[i] = fBoxProp[i]->GetNumber();
200
201 fApplyButton->SetState(kButtonDisabled);
202
203 fM->SetClipState(fCurrentClip, data);
204 fM->SetShowManip(fClipEdit->IsDown());
205 fM->SetShowClip (fClipShow->IsDown());
207 fM->GetCurrentClip()->SetMode(fClipInside->IsDown() ? TGLClip::kInside : TGLClip::kOutside);
208 fM->SetAutoUpdate(fAutoUpdate->IsDown());
209
210 Changed();
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Reset transformation of the current clip.
215
217{
219 if (fM->GetClipType() == TGLClip::kClipPlane) {
220 TGLPlane plane(0.0, -1.0, 0.0, 0.0);
221 dynamic_cast<TGLClipPlane*>(fM->GetCurrentClip())->Set(plane);
222 } else if (fM->GetClipType() == TGLClip::kClipBox) {
223 fM->GetCurrentClip()->SetTransform(TGLMatrix());
224 }
225 Changed();
226 }
227}
228
229
230/** \class TGLClipSetEditor
231\ingroup opengl
232GUI editor for TGLClipSet.
233*/
234
235
236////////////////////////////////////////////////////////////////////////////////
237/// Constructor.
238
240 UInt_t options, Pixel_t back) :
241 TGedFrame(p, width, height, options | kVerticalFrame, back),
242 fM (nullptr),
243 fSE (nullptr)
244{
245 MakeTitle("TGLClipSet");
246
247 fSE = new TGLClipSetSubEditor(this);
248 AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
249 fSE->Connect("Changed()", "TGLClipSetEditor", this, "Update()");
250}
251
252
253////////////////////////////////////////////////////////////////////////////////
254/// Set model object.
255
257{
258 fM = dynamic_cast<TGLClipSet*>(obj);
259 fSE->SetModel(fM);
260}
@ kChildFrame
Definition GuiTypes.h:380
@ kVerticalFrame
Definition GuiTypes.h:382
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
@ 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.
A button abstract base class.
Definition TGButton.h:68
Selects different options.
Definition TGButton.h:264
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1196
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1182
Concrete clip plane object.
Definition TGLClip.h:86
void Set(const TGLPlane &plane)
Update clip plane object to follow passed 'plane' equation.
Definition TGLClip.cxx:228
TGLClipSetSubEditor * fSE
TGLClipSetEditor(const TGLClipSetEditor &)=delete
void SetModel(TObject *obj) override
Set model object.
GUI sub-editor for TGLClipSet.
void ClipTypeChanged(Int_t)
Clip type radio button changed - update viewer.
TGLClipSetSubEditor(const TGLClipSetSubEditor &)=delete
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
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
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
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition TGLUtil.h:598
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:399
Selects different options.
Definition TGButton.h:321
Yield an action as soon as it is clicked.
Definition TGButton.h:142
TGVerticalFrame(const TGWindow *p=nullptr, UInt_t w=1, UInt_t h=1, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Definition TGFrame.h:378
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
TGedFrame(const TGedFrame &)=delete
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
Mother of all ROOT objects.
Definition TObject.h:42
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:865
TMarker m
Definition textangle.C:8