Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLTransManip.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Richard Maunder 16/09/2005
3
4/*************************************************************************
5 * Copyright (C) 1995-2005, 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 "TGLTransManip.h"
13#include "TGLPhysicalShape.h"
14#include "TGLCamera.h"
15#include "TGLIncludes.h"
16
17/** \class TGLTransManip
18\ingroup opengl
19Translation manipulator - attaches to physical shape and draws local
20axes widgets with arrow heads. User can mouse over (turns yellow) and
21L click/drag to translate along this axis.
22Widgets use standard 3D package axes colours: X red, Y green, Z blue.
23*/
24
25
26////////////////////////////////////////////////////////////////////////////////
27/// Construct translation manipulator not bound to any physical shape.
28
32
33////////////////////////////////////////////////////////////////////////////////
34/// Construct translation manipulator, attached to supplied TGLViewer
35/// 'viewer', bound to TGLPhysicalShape 'shape'.
36
41
42////////////////////////////////////////////////////////////////////////////////
43/// Destroy the translation manipulator
44
48
49////////////////////////////////////////////////////////////////////////////////
50/// Draw translation manipulator - tubes with arrow heads, in local axes of
51/// attached shape, in red(X), green(Y) and blue(Z), with white center sphere.
52/// If selected widget (mouse over) this is drawn in active colour (yellow).
53
55{
56 if (!fShape) {
57 return;
58 }
59
60 // Get draw scales
65
66 // Get permitted manipulations on shape
68
72
73 // Draw three axis widgets out of bounding box where permitted
74 // Not drawing will prevent interaction
75 // GL name loading for hit testing - 0 reserved for no selection
77 glPushName(1);
80 glPopName();
81 } else {
84 }
86 glPushName(2);
89 glPopName();
90 } else {
93 }
95 glPushName(3);
98 glPopName();
99 } else {
102 }
103 // Draw white center sphere
105
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Handle mouse motion over manipulator - if active (selected
112/// widget) translate physical along selected widget (axis) of the
113/// manipulator, so it tracks mouse action. Returns kTRUE if redraw
114/// required kFALSE otherwise.
115
117 const TGLCamera & camera)
118{
119 if (fActive) {
120 // Find mouse delta projected into world at attached object center
121 TGLVector3 shift =
122 camera.ViewportDeltaToWorld( fShape->BoundingBox().Center(),
123 event.fX - fLastMouse.GetX(),
124 -event.fY + fLastMouse.GetY() ); // Y inverted
125
126 // Now project this delta onto the current widget (axis) to give
127 // a constrained shift along this
128 UInt_t axisIndex = fSelectedWidget - 1; // Ugg sort out axis / widget id mapping
132
133 fLastMouse.SetX(event.fX);
134 fLastMouse.SetY(event.fY);
135
136 return kTRUE;
137 }
138 return kFALSE;
139}
140
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.
Double_t Dot(const TGLVector3 &v1, const TGLVector3 &v2)
Definition TGLUtil.h:317
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition TGLCamera.h:44
Abstract base class for viewer manipulators, which allow direct in viewer manipulation of a (TGlPhysi...
Definition TGLManip.h:29
TPoint fLastMouse
first (start) mouse position (in WINDOW coords)
Definition TGLManip.h:37
const UChar_t * ColorFor(UInt_t widget) const
Returns color to be used for given widget.
Definition TGLManip.cxx:93
Bool_t fActive
active width (axis) component
Definition TGLManip.h:33
void CalcDrawScale(const TGLBoundingBox &box, const TGLCamera &camera, Double_t &base, TGLVector3 axis[3]) const
Calculates base and axis scale factor (in world units) for drawing manipulators with reasonable size ...
Definition TGLManip.cxx:152
UInt_t fSelectedWidget
manipulated shape
Definition TGLManip.h:32
TGLPhysicalShape * fShape
Definition TGLManip.h:31
Concrete physical shape - a GL drawable.
const TGLBoundingBox & BoundingBox() const
void Translate(const TGLVector3 &vect)
EManip GetManip() const
Bool_t HandleMotion(const Event_t &event, const TGLCamera &camera) override
Handle mouse motion over manipulator - if active (selected widget) translate physical along selected ...
void Draw(const TGLCamera &camera) const override
Draw translation manipulator - tubes with arrow heads, in local axes of attached shape,...
~TGLTransManip() override
Destroy the translation manipulator.
TGLTransManip()
Construct translation manipulator not bound to any physical shape.
static void DrawSphere(const TGLVertex3 &position, Double_t radius, const UChar_t rgba[4])
Draw sphere, centered on vertex 'position', with radius 'radius', color 'rgba'.
Definition TGLUtil.cxx:2348
static const UChar_t fgWhite[4]
Definition TGLUtil.h:1425
@ kLineHeadArrow
Definition TGLUtil.h:951
static void DrawLine(const TGLLine3 &line, ELineHeadShape head, Double_t size, const UChar_t rgba[4])
Draw thick line (tube) defined by 'line', with head at end shape 'head' - box/arrow/none,...
Definition TGLUtil.cxx:2363
static const UChar_t fgGrey[4]
Definition TGLUtil.h:1426
3 component (x/y/z) vector class.
Definition TGLUtil.h:248
SCoord_t GetY() const
Definition TPoint.h:47
void SetX(SCoord_t x)
Definition TPoint.h:48
void SetY(SCoord_t y)
Definition TPoint.h:49
SCoord_t GetX() const
Definition TPoint.h:46
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Event structure.
Definition GuiTypes.h:174
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fX
Definition GuiTypes.h:178