ROOT  6.06/09
Reference Guide
TGLLightSetEditor.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel, Feb 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 "TGLLightSetEditor.h"
13 #include <TGLLightSet.h>
14 
15 #include <TVirtualPad.h>
16 #include <TColor.h>
17 
18 #include <TGLabel.h>
19 #include <TGButton.h>
20 #include <TGNumberEntry.h>
21 #include <TGColorSelect.h>
22 #include <TGDoubleSlider.h>
23 
24 /** \class TGLLightSetSubEditor
25 \ingroup opengl
26 Sub-editor for TGLLightSet.
27 */
28 
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 
34  TGVerticalFrame(p),
35  fM (0),
36 
37  fLightFrame (0),
38  fTopLight (0),
39  fRightLight (0),
40  fBottomLight (0),
41  fLeftLight (0),
42  fFrontLight (0),
43  fSpecularLight (0)
44 {
45  // Constructor.
46 
47  fLightFrame = new TGGroupFrame(this, "Light sources:", kVerticalFrame);//, kLHintsTop | kLHintsCenterX);
48  fLightFrame->SetTitlePos(TGGroupFrame::kLeft);
49  AddFrame(fLightFrame, new TGLayoutHints(kLHintsTop| kLHintsExpandX, 1, 1, 1, 1));//-
50  TGCompositeFrame* hf =0;
51 
52  hf = new TGHorizontalFrame(fLightFrame);
53  fTopLight = MakeLampButton("Top", TGLLightSet::kLightTop, hf);
54  fBottomLight = MakeLampButton("Bottom", TGLLightSet::kLightBottom, hf);
55  fLightFrame->AddFrame(hf, new TGLayoutHints(kLHintsTop|kLHintsExpandX, 0, 0, 2, 2));
56 
57  hf = new TGHorizontalFrame(fLightFrame);
58  fLeftLight = MakeLampButton("Left", TGLLightSet::kLightLeft, hf);
59  fRightLight = MakeLampButton("Right", TGLLightSet::kLightRight, hf);
60  fLightFrame->AddFrame(hf, new TGLayoutHints(kLHintsTop|kLHintsExpandX , 0, 0, 0, 2));
61 
62  hf = new TGHorizontalFrame(fLightFrame);
63  fFrontLight = MakeLampButton("Front", TGLLightSet::kLightFront, hf);
64  fSpecularLight = MakeLampButton("Specular", TGLLightSet::kLightSpecular, hf);
65 
66  fLightFrame->AddFrame(hf, new TGLayoutHints(kLHintsTop|kLHintsExpandX, 0, 0, 0, 2));
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Create a button for given lamp and set it up.
71 
73  TGCompositeFrame* parent)
74 {
75  TGButton* b = new TGCheckButton(parent, name, wid);
76  parent->AddFrame(b, new TGLayoutHints(kLHintsNormal|kLHintsExpandX, -2, 0, 0, 2));
77  b->Connect("Clicked()", "TGLLightSetSubEditor", this, "DoButton()");
78  return b;
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// New model was set, refresh data.
83 
85 {
86  fM = m;
87  UInt_t als = fM->GetLightState();
88 
92  fLeftLight ->SetState((als & TGLLightSet::kLightLeft) ? kButtonDown : kButtonUp);
94 
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Data in sub-editor has been changed, emit "Changed()" signal.
100 
102 {
103  Emit("Changed()");
104 }
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// Lights radio button was clicked.
108 
110 {
111  TGButton* b = (TGButton*) gTQSender;
113  Changed();
114 }
115 
116 
117 //______________________________________________________________________________
118 // TGLLightSetEditor
119 //
120 // Editor for TGLLightSet.
121 
123 
124 ////////////////////////////////////////////////////////////////////////////////
125 /// Constructor.
126 
128  Int_t width, Int_t height,
129  UInt_t options, Pixel_t back) :
130  TGedFrame(p, width, height, options | kVerticalFrame, back),
131  fM (0),
132  fSE (0)
133 {
134  MakeTitle("TGLLightSet");
135 
136  fSE = new TGLLightSetSubEditor(this);
137  AddFrame(fSE, new TGLayoutHints(kLHintsTop, 2, 0, 2, 2));
138  fSE->Connect("Changed()", "TGLLightSetEditor", this, "Update()");
139 }
140 
141 ////////////////////////////////////////////////////////////////////////////////
142 /// Destructor.
143 
145 {
146 }
147 
148 ////////////////////////////////////////////////////////////////////////////////
149 /// SetModel ... forward to sub-editor.
150 
152 {
153  fM = dynamic_cast<TGLLightSet*>(obj);
154  fSE->SetModel(fM);
155 }
void DoButton()
Lights radio button was clicked.
void SetLight(ELight light, Bool_t on)
Set a light on/off.
Definition: TGLLightSet.cxx:55
R__EXTERN void * gTQSender
Definition: TQObject.h:49
int Int_t
Definition: RtypesCore.h:41
Encapsulates a set of lights for OpenGL.
Definition: TGLLightSet.h:21
TGButton * MakeLampButton(const char *name, Int_t wid, TGCompositeFrame *parent)
Create a button for given lamp and set it up.
void Changed()
Data in sub-editor has been changed, emit "Changed()" signal.
Bool_t GetUseSpecular() const
Definition: TGLLightSet.h:51
ULong_t Pixel_t
Definition: GuiTypes.h:41
Sub-editor for TGLLightSet.
UInt_t GetLightState()
Definition: TGLLightSet.h:49
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
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:1135
unsigned int UInt_t
Definition: RtypesCore.h:42
TMarker * m
Definition: textangle.C:8
virtual Bool_t IsOn() const
Definition: TGButton.h:123
virtual void SetModel(TObject *obj)
SetModel ... forward to sub-editor.
Int_t WidgetId() const
Definition: TGWidget.h:86
void SetModel(TGLLightSet *m)
New model was set, refresh data.
virtual ~TGLLightSetEditor()
Destructor.
TGLLightSetSubEditor * fSE
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
ClassImp(TGLLightSetSubEditor) TGLLightSetSubEditor
TObject * obj
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185