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");
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
111
112 Double_t clip[6] = {0.};
114
116
117 // Button ids run from 1
119 btn->SetDown();
121 }
123 fClipInside->SetEnabled(active);
124 fAutoUpdate->SetEnabled(active);
125 fClipEdit ->SetEnabled(active);
126 fClipShow ->SetEnabled(active);
127 if (active) {
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
146 } else {
149
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 }
182 SetModel(fM);
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
202
209
210 Changed();
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Reset transformation of the current clip.
215
217{
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) {
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:379
@ kVerticalFrame
Definition GuiTypes.h:381
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ 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
winID h TVirtualViewer3D TVirtualGLPainter p
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
Organizes TGButton widgets in a group.
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=nullptr)
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
A button abstract base class.
Definition TGButton.h:68
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
Definition TGButton.cxx:304
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:453
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:229
Selects different options.
Definition TGButton.h:264
Bool_t IsDown() const override
Definition TGButton.h:311
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
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
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
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
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:473
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:520
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:576
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:556
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:399
Selects different options.
Definition TGButton.h:321
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:376
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
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:94
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:865
TMarker m
Definition textangle.C:8