Logo ROOT   6.18/05
Reference Guide
TGLManipSet.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 "TGLManipSet.h"
13
14#include "TGLTransManip.h"
15#include "TGLScaleManip.h"
16#include "TGLRotateManip.h"
17
18#include "TGLPhysicalShape.h"
19#include "TGLRnrCtx.h"
20#include "TGLSelectRecord.h"
21
22#include "TGLIncludes.h"
23
24#include <KeySymbols.h>
25#include <TVirtualX.h>
26
27/** \class TGLManipSet
28\ingroup opengl
29
30Combine all available manipulators in a collection.
31
32At first I wanted to merge them back into TGLManip (to have a
33single class) but then it seemed somehow messy.
34Maybe next time.
35*/
36
38
40 TGLOverlayElement(kViewer),
41 fType (kTrans),
42 fDrawBBox (kFALSE)
43{
44 // Constructor.
45
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Destructor.
53
55{
56 for (Int_t i=kTrans; i<kEndType; ++i)
57 delete fManip[i];
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Set phys-shape, override of virtual from TGLPShapeRef.
62/// Forward to all managed manipulators.
63
65{
67 for (Int_t i=kTrans; i<kEndType; ++i)
68 fManip[i]->Attach(shape);
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Mouse has entered this element.
73/// Always accept.
74
76{
77 TGLManip* manip = GetCurrentManip();
78 manip->SetActive(kFALSE);
79 manip->SetSelectedWidget(0);
80 return kTRUE;
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Handle overlay event.
85/// Return TRUE if event was handled.
86
88 TGLOvlSelectRecord& selRec,
89 Event_t* event)
90{
91 TGLManip* manip = GetCurrentManip();
92
93 switch (event->fType)
94 {
95 case kButtonPress:
96 {
97 return manip->HandleButton(*event, rnrCtx.RefCamera());
98 }
99 case kButtonRelease:
100 {
101 manip->SetActive(kFALSE);
102 return kTRUE;
103 }
104 case kMotionNotify:
105 {
106 if (manip->GetActive())
107 return manip->HandleMotion(*event, rnrCtx.RefCamera());
108 if (selRec.GetCurrItem() != manip->GetSelectedWidget())
109 {
110 manip->SetSelectedWidget(selRec.GetCurrItem());
111 return kTRUE;
112 }
113 return kFALSE;
114 }
115 case kGKeyPress:
116 {
117 switch (rnrCtx.GetEventKeySym())
118 {
119 case kKey_V: case kKey_v:
121 return kTRUE;
122 case kKey_C: case kKey_c:
124 return kTRUE;
125 case kKey_X: case kKey_x:
127 return kTRUE;
128 default:
129 return kFALSE;
130 }
131 }
132 default:
133 {
134 return kFALSE;
135 }
136 }
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Mouse has left the element.
141
143{
144 TGLManip* manip = GetCurrentManip();
145 manip->SetActive(kFALSE);
146 manip->SetSelectedWidget(0);
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Render the manipulator and bounding-box.
151
153{
154 if (fPShape == 0)
155 return;
156
157 if (rnrCtx.Selection())
158 {
160 fManip[fType]->Draw(rnrCtx.RefCamera());
162 } else {
163 fManip[fType]->Draw(rnrCtx.RefCamera());
164 }
165
166 if (fDrawBBox && ! rnrCtx.Selection())
167 {
168 // TODO: This must be replaced by some color in rnrCtx,
169 // like def-overlay-color, background-color, foreground-color
170 // Or at least bkgcol ... i can then find high contrast.
171 TGLUtil::Color(rnrCtx.ColorSet().Markup());
172 glDisable(GL_LIGHTING);
174 glEnable(GL_LIGHTING);
175 }
176}
177
178////////////////////////////////////////////////////////////////////////////////
179/// Set manipulator type, range checked.
180
182{
183 if (type < 0 || type >= kEndType)
184 return;
185 fType = (EManip) type;
186}
@ kGKeyPress
Definition: GuiTypes.h:59
@ kButtonRelease
Definition: GuiTypes.h:59
@ kButtonPress
Definition: GuiTypes.h:59
@ kMotionNotify
Definition: GuiTypes.h:60
@ kKey_v
Definition: KeySymbols.h:179
@ kKey_C
Definition: KeySymbols.h:128
@ kKey_x
Definition: KeySymbols.h:181
@ kKey_X
Definition: KeySymbols.h:149
@ kKey_c
Definition: KeySymbols.h:160
@ kKey_V
Definition: KeySymbols.h:147
PyObject * fType
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
int type
Definition: TGX11.cxx:120
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
TGLColor & Markup()
Definition: TGLUtil.h:853
Combine all available manipulators in a collection.
Definition: TGLManipSet.h:23
virtual Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event)
Handle overlay event.
Definition: TGLManipSet.cxx:87
TGLManip * fManip[3]
Definition: TGLManipSet.h:32
virtual ~TGLManipSet()
Destructor.
Definition: TGLManipSet.cxx:54
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
Mouse has entered this element.
Definition: TGLManipSet.cxx:75
EManip fType
manipulator store
Definition: TGLManipSet.h:33
void SetManipType(Int_t type)
Set manipulator type, range checked.
TGLManipSet()
also draw bounding-box around physical
Definition: TGLManipSet.cxx:39
Bool_t fDrawBBox
current manipulator
Definition: TGLManipSet.h:35
virtual void MouseLeave()
Mouse has left the element.
virtual void SetPShape(TGLPhysicalShape *shape)
Set phys-shape, override of virtual from TGLPShapeRef.
Definition: TGLManipSet.cxx:64
TGLManip * GetCurrentManip() const
Definition: TGLManipSet.h:50
virtual void Render(TGLRnrCtx &rnrCtx)
Render the manipulator and bounding-box.
Abstract base class for viewer manipulators, which allow direct in viewer manipulation of a (TGlPhysi...
Definition: TGLManip.h:29
void SetSelectedWidget(UInt_t s)
Definition: TGLManip.h:53
UInt_t GetSelectedWidget() const
Definition: TGLManip.h:52
virtual Bool_t HandleButton(const Event_t &event, const TGLCamera &camera)
Handle a mouse button event - return kTRUE if processed, kFALSE otherwise.
Definition: TGLManip.cxx:118
Bool_t GetActive() const
Definition: TGLManip.h:55
void SetActive(Bool_t a)
Definition: TGLManip.h:56
virtual Bool_t HandleMotion(const Event_t &event, const TGLCamera &camera)
Handle a mouse button event - return kTRUE if widget selection change kFALSE otherwise.
Definition: TGLManip.cxx:145
virtual void Draw(const TGLCamera &camera) const =0
An overlay element.
Definition: TGLOverlay.h:23
Selection record for overlay objects.
virtual void SetPShape(TGLPhysicalShape *shape)
Set the shape.
TGLPhysicalShape * fPShape
Definition: TGLPShapeRef.h:29
Concrete physical shape - a GL drawable.
const TGLBoundingBox & BoundingBox() const
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
UInt_t GetEventKeySym() const
Definition: TGLRnrCtx.h:247
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
TGLCamera & RefCamera()
Definition: TGLRnrCtx.h:157
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
Rotate manipulator - attaches to physical shape and draws local axes widgets - rings drawn from attac...
Scale manipulator - attaches to physical shape and draws local axes widgets with box heads.
Definition: TGLScaleManip.h:29
UInt_t GetCurrItem() const
Translation manipulator - attaches to physical shape and draws local axes widgets with arrow heads.
Definition: TGLTransManip.h:28
static void SetDrawQuality(UInt_t dq)
static: set draw quality
Definition: TGLUtil.cxx:1608
static void ResetDrawQuality()
static: reset draw quality
Definition: TGLUtil.cxx:1616
static void Color(const TGLColor &color)
Set color from TGLColor.
Definition: TGLUtil.cxx:1692
EGEventType fType
Definition: GuiTypes.h:174