Logo ROOT   6.10/09
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 
30 Combine all available manipulators in a collection.
31 
32 At first I wanted to merge them back into TGLManip (to have a
33 single class) but then it seemed somehow messy.
34 Maybe 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);
173  fPShape->BoundingBox().Draw();
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 }
Abstract base class for viewer manipulators, which allow direct in viewer manipulation of a (TGlPhysi...
Definition: TGLManip.h:28
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
virtual void Draw(const TGLCamera &camera) const =0
static void Color(const TGLColor &color)
Set color from TGLColor.
Definition: TGLUtil.cxx:1658
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
TGLCamera & RefCamera()
Definition: TGLRnrCtx.h:157
virtual void SetPShape(TGLPhysicalShape *shape)
Set phys-shape, override of virtual from TGLPShapeRef.
Definition: TGLManipSet.cxx:64
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
virtual void MouseLeave()
Mouse has left the element.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGLColor & Markup()
Definition: TGLUtil.h:852
void SetSelectedWidget(UInt_t s)
Definition: TGLManip.h:53
Combine all available manipulators in a collection.
Definition: TGLManipSet.h:21
Scale manipulator - attaches to physical shape and draws local axes widgets with box heads...
Definition: TGLScaleManip.h:28
An overlay element.
Definition: TGLOverlay.h:22
Concrete physical shape - a GL drawable.
UInt_t GetSelectedWidget() const
Definition: TGLManip.h:52
Bool_t fDrawBBox
current manipulator
Definition: TGLManipSet.h:35
const TGLBoundingBox & BoundingBox() const
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
Mouse has entered this element.
Definition: TGLManipSet.cxx:75
Rotate manipulator - attaches to physical shape and draws local axes widgets - rings drawn from attac...
virtual Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event)
Handle overlay event.
Definition: TGLManipSet.cxx:87
TGLManip * GetCurrentManip() const
Definition: TGLManipSet.h:50
UInt_t GetCurrItem() const
EGEventType fType
Definition: GuiTypes.h:174
void SetActive(Bool_t a)
Definition: TGLManip.h:56
const Bool_t kFALSE
Definition: RtypesCore.h:92
PyObject * fType
virtual void SetPShape(TGLPhysicalShape *shape)
Set the shape.
#define ClassImp(name)
Definition: Rtypes.h:336
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
Bool_t GetActive() const
Definition: TGLManip.h:55
int type
Definition: TGX11.cxx:120
virtual void Render(TGLRnrCtx &rnrCtx)
Render the manipulator and bounding-box.
void SetManipType(Int_t type)
Set manipulator type, range checked.
TGLPhysicalShape * fPShape
Definition: TGLPShapeRef.h:29
static void ResetDrawQuality()
static: reset draw quality
Definition: TGLUtil.cxx:1582
TGLManipSet()
also draw bounding-box around physical
Definition: TGLManipSet.cxx:39
static void SetDrawQuality(UInt_t dq)
static: set draw quality
Definition: TGLUtil.cxx:1574
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
TGLManip * fManip[3]
Definition: TGLManipSet.h:32
Selection record for overlay objects.
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
const Bool_t kTRUE
Definition: RtypesCore.h:91
EManip fType
manipulator store
Definition: TGLManipSet.h:33
virtual ~TGLManipSet()
Destructor.
Definition: TGLManipSet.cxx:54
UInt_t GetEventKeySym() const
Definition: TGLRnrCtx.h:247
Translation manipulator - attaches to physical shape and draws local axes widgets with arrow heads...
Definition: TGLTransManip.h:27