Logo ROOT  
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
26/** \class TGLManipSet
27\ingroup opengl
28
29Combine all available manipulators in a collection.
30
31At first I wanted to merge them back into TGLManip (to have a
32single class) but then it seemed somehow messy.
33Maybe next time.
34*/
35
37
39 TGLOverlayElement(kViewer),
40 fType (kTrans),
41 fDrawBBox (kFALSE)
42{
43 // Constructor.
44
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Destructor.
52
54{
55 for (Int_t i=kTrans; i<kEndType; ++i)
56 delete fManip[i];
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Set phys-shape, override of virtual from TGLPShapeRef.
61/// Forward to all managed manipulators.
62
64{
66 for (Int_t i=kTrans; i<kEndType; ++i)
67 fManip[i]->Attach(shape);
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Mouse has entered this element.
72/// Always accept.
73
75{
76 TGLManip* manip = GetCurrentManip();
77 manip->SetActive(kFALSE);
78 manip->SetSelectedWidget(0);
79 return kTRUE;
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Handle overlay event.
84/// Return TRUE if event was handled.
85
87 TGLOvlSelectRecord& selRec,
89{
90 TGLManip* manip = GetCurrentManip();
91
92 switch (event->fType)
93 {
94 case kButtonPress:
95 {
96 return manip->HandleButton(*event, rnrCtx.RefCamera());
97 }
98 case kButtonRelease:
99 {
100 manip->SetActive(kFALSE);
101 return kTRUE;
102 }
103 case kMotionNotify:
104 {
105 if (manip->GetActive())
106 return manip->HandleMotion(*event, rnrCtx.RefCamera());
107 if (selRec.GetCurrItem() != manip->GetSelectedWidget())
108 {
109 manip->SetSelectedWidget(selRec.GetCurrItem());
110 return kTRUE;
111 }
112 return kFALSE;
113 }
114 case kGKeyPress:
115 {
116 switch (rnrCtx.GetEventKeySym())
117 {
118 case kKey_V: case kKey_v:
120 return kTRUE;
121 case kKey_C: case kKey_c:
123 return kTRUE;
124 case kKey_X: case kKey_x:
126 return kTRUE;
127 default:
128 return kFALSE;
129 }
130 }
131 default:
132 {
133 return kFALSE;
134 }
135 }
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Mouse has left the element.
140
142{
143 TGLManip* manip = GetCurrentManip();
144 manip->SetActive(kFALSE);
145 manip->SetSelectedWidget(0);
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Render the manipulator and bounding-box.
150
152{
153 if (fPShape == 0)
154 return;
155
156 if (rnrCtx.Selection())
157 {
159 fManip[fType]->Draw(rnrCtx.RefCamera());
161 } else {
162 fManip[fType]->Draw(rnrCtx.RefCamera());
163 }
164
165 if (fDrawBBox && ! rnrCtx.Selection())
166 {
167 // TODO: This must be replaced by some color in rnrCtx,
168 // like def-overlay-color, background-color, foreground-color
169 // Or at least bkgcol ... i can then find high contrast.
170 TGLUtil::Color(rnrCtx.ColorSet().Markup());
171 glDisable(GL_LIGHTING);
173 glEnable(GL_LIGHTING);
174 }
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Set manipulator type, range checked.
179
181{
182 if (type < 0 || type >= kEndType)
183 return;
184 fType = (EManip) type;
185}
@ kGKeyPress
Definition: GuiTypes.h:60
@ kButtonRelease
Definition: GuiTypes.h:60
@ kButtonPress
Definition: GuiTypes.h:60
@ kMotionNotify
Definition: GuiTypes.h:61
@ 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
int Int_t
Definition: RtypesCore.h:45
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:364
int type
Definition: TGX11.cxx:121
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:854
Combine all available manipulators in a collection.
Definition: TGLManipSet.h:22
virtual Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event)
Handle overlay event.
Definition: TGLManipSet.cxx:86
TGLManip * fManip[3]
Definition: TGLManipSet.h:31
virtual ~TGLManipSet()
Destructor.
Definition: TGLManipSet.cxx:53
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
Mouse has entered this element.
Definition: TGLManipSet.cxx:74
EManip fType
manipulator store
Definition: TGLManipSet.h:32
void SetManipType(Int_t type)
Set manipulator type, range checked.
TGLManipSet()
also draw bounding-box around physical
Definition: TGLManipSet.cxx:38
Bool_t fDrawBBox
current manipulator
Definition: TGLManipSet.h:34
virtual void MouseLeave()
Mouse has left the element.
virtual void SetPShape(TGLPhysicalShape *shape)
Set phys-shape, override of virtual from TGLPShapeRef.
Definition: TGLManipSet.cxx:63
TGLManip * GetCurrentManip() const
Definition: TGLManipSet.h:49
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:115
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:142
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:276
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:1607
static void ResetDrawQuality()
static: reset draw quality
Definition: TGLUtil.cxx:1615
static void Color(const TGLColor &color)
Set color from TGLColor.
Definition: TGLUtil.cxx:1691
Event structure.
Definition: GuiTypes.h:174