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
26
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor.
29
32 fM(nullptr),
33 fCurrentClip(TGLClip::kClipNone),
34 fTypeButtons(nullptr),
35 fPlanePropFrame(nullptr),
36 fPlaneProp(),
37 fBoxPropFrame(nullptr),
38 fBoxProp(),
39 fClipInside(nullptr),
40 fAutoUpdate(nullptr),
41 fClipEdit(nullptr),
42 fClipShow(nullptr),
43 fApplyButton(nullptr),
44 fResetButton(nullptr)
45{
47 new TGRadioButton(fTypeButtons, "None ");
48 new TGRadioButton(fTypeButtons, "Plane ");
49 new TGRadioButton(fTypeButtons, "Box");
50 fTypeButtons->SetLayoutHints(new TGLayoutHints(kLHintsLeft|kLHintsBottom, 0, 0, 2, -10));
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
110 fTypeButtons->GetButton(fCurrentClip+1)->SetDown(kFALSE);
111 fCurrentClip = fM->GetClipType();
112
113 Double_t clip[6] = {0.};
114 fM->GetClipState(fCurrentClip, clip);
115
116 fApplyButton->SetState(kButtonDisabled);
117
118 // Button ids run from 1
119 if (TGButton *btn = fTypeButtons->GetButton(fCurrentClip+1)) {
120 btn->SetDown();
121 fTypeButtons->SetButton(fCurrentClip+1);
122 }
124 fClipInside->SetEnabled(active);
125 fAutoUpdate->SetEnabled(active);
126 fClipEdit ->SetEnabled(active);
127 fClipShow ->SetEnabled(active);
128 if (active) {
129 fClipEdit->SetDown(fM->GetShowManip());
130 fClipShow->SetDown(fM->GetShowClip());
131 fClipInside->SetDown(fM->GetCurrentClip()->GetMode() == TGLClip::kInside);
132 fAutoUpdate->SetDown(fM->GetAutoUpdate());
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
146 fResetButton->SetState(kButtonUp);
147 } else {
150
151 fResetButton->SetState(kButtonDisabled);
152 }
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Emit Changed signal.
157
159{
160 Emit("Changed()");
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// One of number entries was changed.
165
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 }
182 fM->SetClipType(fCurrentClip);
183 SetModel(fM);
184 ((TGMainFrame*)GetMainFrame())->Layout();
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
202 fApplyButton->SetState(kButtonDisabled);
203
204 fM->SetClipState(fCurrentClip, data);
205 fM->SetShowManip(fClipEdit->IsDown());
206 fM->SetShowClip (fClipShow->IsDown());
208 fM->GetCurrentClip()->SetMode(fClipInside->IsDown() ? TGLClip::kInside : TGLClip::kOutside);
209 fM->SetAutoUpdate(fAutoUpdate->IsDown());
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) {
224 fM->GetCurrentClip()->SetTransform(TGLMatrix());
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 (nullptr),
245 fSE (nullptr)
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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
#define ClassImp(name)
Definition Rtypes.h:377
@ 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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Int_t i
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:1117
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
void Set(const TGLPlane &plane)
Update clip plane object to follow passed 'plane' equation.
Definition TGLClip.cxx:230
GUI editor for TGLClipSet.
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:397
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:376
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:152
TGedFrame(const TGedFrame &)=delete
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:95
Mother of all ROOT objects.
Definition TObject.h:41
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
TMarker m
Definition textangle.C:8