Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
36
38 TGLOverlayElement(kViewer),
39 fType (kTrans),
40 fDrawBBox (kFALSE)
41{
42 // Constructor.
43
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// Destructor.
51
53{
54 for (Int_t i=kTrans; i<kEndType; ++i)
55 delete fManip[i];
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Set phys-shape, override of virtual from TGLPShapeRef.
60/// Forward to all managed manipulators.
61
63{
65 for (Int_t i=kTrans; i<kEndType; ++i)
66 fManip[i]->Attach(shape);
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Mouse has entered this element.
71/// Always accept.
72
74{
76 manip->SetActive(kFALSE);
77 manip->SetSelectedWidget(0);
78 return kTRUE;
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Handle overlay event.
83/// Return TRUE if event was handled.
84
87 Event_t* event)
88{
90
91 switch (event->fType)
92 {
93 case kButtonPress:
94 {
95 return manip->HandleButton(*event, rnrCtx.RefCamera());
96 }
97 case kButtonRelease:
98 {
99 manip->SetActive(kFALSE);
100 return kTRUE;
101 }
102 case kMotionNotify:
103 {
104 if (manip->GetActive())
105 return manip->HandleMotion(*event, rnrCtx.RefCamera());
106 if (selRec.GetCurrItem() != manip->GetSelectedWidget())
107 {
108 manip->SetSelectedWidget(selRec.GetCurrItem());
109 return kTRUE;
110 }
111 return kFALSE;
112 }
113 case kGKeyPress:
114 {
115 switch (rnrCtx.GetEventKeySym())
116 {
117 case kKey_V: case kKey_v:
119 return kTRUE;
120 case kKey_C: case kKey_c:
122 return kTRUE;
123 case kKey_X: case kKey_x:
125 return kTRUE;
126 default:
127 return kFALSE;
128 }
129 }
130 default:
131 {
132 return kFALSE;
133 }
134 }
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Mouse has left the element.
139
141{
143 manip->SetActive(kFALSE);
144 manip->SetSelectedWidget(0);
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Render the manipulator and bounding-box.
149
151{
152 if (fPShape == nullptr)
153 return;
154
155 if (rnrCtx.Selection())
156 {
158 fManip[fType]->Draw(rnrCtx.RefCamera());
160 } else {
161 fManip[fType]->Draw(rnrCtx.RefCamera());
162 }
163
164 if (fDrawBBox && ! rnrCtx.Selection())
165 {
166 // TODO: This must be replaced by some color in rnrCtx,
167 // like def-overlay-color, background-color, foreground-color
168 // Or at least bkgcol ... i can then find high contrast.
169 TGLUtil::Color(rnrCtx.ColorSet().Markup());
171 fPShape->BoundingBox().Draw();
173 }
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Set manipulator type, range checked.
178
180{
182 return;
183 fType = (EManip) type;
184}
@ 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
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
void MouseLeave() override
Mouse has left the element.
Bool_t Handle(TGLRnrCtx &rnrCtx, TGLOvlSelectRecord &selRec, Event_t *event) override
Handle overlay event.
TGLManip * fManip[3]
Definition TGLManipSet.h:31
Bool_t MouseEnter(TGLOvlSelectRecord &selRec) override
Mouse has entered this element.
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
Bool_t fDrawBBox
current manipulator
Definition TGLManipSet.h:34
void Render(TGLRnrCtx &rnrCtx) override
Render the manipulator and bounding-box.
~TGLManipSet() override
Destructor.
TGLManip * GetCurrentManip() const
Definition TGLManipSet.h:49
void SetPShape(TGLPhysicalShape *shape) override
Set phys-shape, override of virtual from TGLPShapeRef.
Abstract base class for viewer manipulators, which allow direct in viewer manipulation of a (TGlPhysi...
Definition TGLManip.h:29
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
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
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.
Translation manipulator - attaches to physical shape and draws local axes widgets with arrow heads.
static void SetDrawQuality(UInt_t dq)
static: set draw quality
Definition TGLUtil.cxx:1604
static void ResetDrawQuality()
static: reset draw quality
Definition TGLUtil.cxx:1612
static void Color(const TGLColor &color)
Set color from TGLColor.
Definition TGLUtil.cxx:1688
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175