OpenSceneGraph 3.6.5
Command
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13//osgManipulator - Copyright (C) 2007 Fugro-Jason B.V.
14
15#ifndef OSGMANIPULATOR_COMMAND
16#define OSGMANIPULATOR_COMMAND 1
17
19
20#include <osg/LineSegment>
21#include <osg/Plane>
22#include <osg/Vec2>
23
24#include <vector>
25
26namespace osgManipulator {
27
28
31{
32 public:
33
49
51
54
59 virtual osg::Matrix getMotionMatrix() const = 0;
60
61 virtual void accept(const Constraint& constraint) { constraint.constrain(*this); }
62 virtual void accept(DraggerCallback& callback) { callback.receive(*this); }
63
68 void setLocalToWorldAndWorldToLocal(const osg::Matrix& localToWorld, const osg::Matrix& worldToLocal)
69 {
70 _localToWorld = localToWorld;
71 _worldToLocal = worldToLocal;
72 }
73
78 inline const osg::Matrix& getLocalToWorld() const { return _localToWorld; }
79
84 inline const osg::Matrix& getWorldToLocal() const { return _worldToLocal; }
85
86 void setStage(const Stage s) { _stage = s; }
87 Stage getStage() const { return _stage; }
88
89 protected:
90
91 virtual ~MotionCommand();
92
93 private:
94 osg::Matrix _localToWorld;
95 osg::Matrix _worldToLocal;
96
97 Stage _stage;
98};
99
100
105{
106 public:
107
109
111
112 virtual void accept(const Constraint& constraint) {constraint.constrain(*this); }
113 virtual void accept(DraggerCallback& callback) { callback.receive(*this); }
114
116
117 inline void setLine(const osg::LineSegment::vec_type& s, const osg::LineSegment::vec_type& e) { _line->start() = s; _line->end() = e; }
118 inline const osg::LineSegment::vec_type& getLineStart() const { return _line->start(); }
119 inline const osg::LineSegment::vec_type& getLineEnd() const { return _line->end(); }
120
121 inline void setTranslation(const osg::Vec3d& t) { _translation = t; }
122 inline const osg::Vec3d& getTranslation() const { return _translation; }
123
125 {
126 return osg::Matrix::translate(_translation);
127 }
128
129 protected:
130
132
133 private:
135 osg::Vec3d _translation;
136};
137
142{
143 public:
144
146
148
149 virtual void accept(const Constraint& constraint) {constraint.constrain(*this); }
150 virtual void accept(DraggerCallback& callback) { callback.receive(*this); }
151
153
154 inline void setPlane(const osg::Plane& plane) { _plane = plane; }
155 inline const osg::Plane& getPlane() const { return _plane; }
156
157 inline void setTranslation(const osg::Vec3d& t) { _translation = t; }
158 inline const osg::Vec3d& getTranslation() const { return _translation; }
159
161 inline void setReferencePoint(const osg::Vec3d& rp) { _referencePoint = rp; }
162 inline const osg::Vec3d& getReferencePoint() const { return _referencePoint; }
163
165 {
166 return osg::Matrix::translate(_translation);
167 }
168
169 protected:
170
172
173 private:
174 osg::Plane _plane;
175 osg::Vec3d _translation;
176 osg::Vec3d _referencePoint;
177};
178
183{
184 public:
185
187
188 virtual void accept(const Constraint& constraint) {constraint.constrain(*this); }
189 virtual void accept(DraggerCallback& callback) { callback.receive(*this); }
190
192
193 inline void setScale(double s) { _scale = s; }
194 inline double getScale() const { return _scale; }
195
196 inline void setScaleCenter(double center) { _scaleCenter = center; }
197 inline double getScaleCenter() const { return _scaleCenter; }
198
200 inline void setReferencePoint(double rp) { _referencePoint = rp; }
201 inline double getReferencePoint() const { return _referencePoint; }
202
203 inline void setMinScale(double min) { _minScale = min; }
204 inline double getMinScale() const { return _minScale; }
205
207 {
208 return (osg::Matrix::translate(-_scaleCenter,0.0,0.0)
209 * osg::Matrix::scale(_scale,1.0,1.0)
210 * osg::Matrix::translate(_scaleCenter,0.0,0.0));
211 }
212
213 protected:
214
216
217 private:
218 double _scale;
219 double _scaleCenter;
220 double _referencePoint;
221 double _minScale;
222};
223
228{
229 public:
230
232
233 virtual void accept(const Constraint& constraint) {constraint.constrain(*this); }
234 virtual void accept(DraggerCallback& callback) { callback.receive(*this); }
235
237
238 inline void setScale(const osg::Vec2d& s) { _scale = s; }
239 inline const osg::Vec2d& getScale() const { return _scale; }
240
241 inline void setScaleCenter(const osg::Vec2d& center) { _scaleCenter = center; }
242 inline const osg::Vec2d& getScaleCenter() const { return _scaleCenter; }
243
245 inline void setReferencePoint(const osg::Vec2d& rp) { _referencePoint = rp; }
246 inline const osg::Vec2d& getReferencePoint() const { return _referencePoint; }
247
248 inline void setMinScale(const osg::Vec2d& min) { _minScale = min; }
249 inline const osg::Vec2d& getMinScale() const { return _minScale; }
250
252 {
253 return (osg::Matrix::translate(-_scaleCenter[0],0.0,-_scaleCenter[1])
254 * osg::Matrix::scale(_scale[0],1.0,_scale[1])
255 * osg::Matrix::translate(_scaleCenter[0],0.0,_scaleCenter[1]));
256 }
257
258 protected:
259
261
262 private:
263 osg::Vec2d _scale;
264 osg::Vec2d _scaleCenter;
265 osg::Vec2d _referencePoint;
266 osg::Vec2d _minScale;
267};
268
273{
274 public:
275
277
278 virtual void accept(const Constraint& constraint) {constraint.constrain(*this); }
279 virtual void accept(DraggerCallback& callback) { callback.receive(*this); }
280
282
283 inline void setScale(double s) { _scale = s; }
284 inline double getScale() const { return _scale; }
285
286 inline void setScaleCenter(const osg::Vec3d& center) { _scaleCenter = center; }
287 inline const osg::Vec3d& getScaleCenter() const { return _scaleCenter; }
288
290 {
291 return (osg::Matrix::translate(-_scaleCenter)
292 * osg::Matrix::scale(_scale,_scale,_scale)
293 * osg::Matrix::translate(_scaleCenter));
294 }
295
296 protected:
297
299
300 private:
301 double _scale;
302 osg::Vec3d _scaleCenter;
303};
304
309{
310 public:
311
313
314 virtual void accept(const Constraint& constraint) {constraint.constrain(*this); }
315 virtual void accept(DraggerCallback& callback) { callback.receive(*this); }
316
318
319 inline void setRotation(const osg::Quat& rotation) { _rotation = rotation; }
320 inline const osg::Quat& getRotation() const { return _rotation; }
321
323 {
324 return osg::Matrix::rotate(_rotation);
325 }
326
327 protected:
328
330
331 private:
332 osg::Quat _rotation;
333};
334
335
336}
337
338#endif
Matrixd Matrix
Definition Matrix:27
The osgManipulator library is a NodeKit that extends the core scene graph to support 3D interactive m...
Definition AntiSquish:23
Vec3d vec_type
Definition LineSegment:28
static Matrixd scale(const Vec3f &sv)
Definition Matrixd:458
static Matrixd rotate(const Vec3f &from, const Vec3f &to)
Definition Matrixd:523
static Matrixd translate(const Vec3f &dv)
Definition Matrixd:475
A plane class.
Definition Plane:34
A quaternion class.
Definition Quat:30
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
General purpose double pair, uses include representation of texture coordinates.
Definition Vec2d:29
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
Stage
Motion command are based on click-drag-release actions.
Definition Command:40
@ FINISH
Release or pick finish.
Definition Command:47
@ NONE
Definition Command:41
@ MOVE
Drag or pick move.
Definition Command:45
@ START
Click or pick start.
Definition Command:43
virtual void accept(const Constraint &constraint)
Definition Command:61
void setLocalToWorldAndWorldToLocal(const osg::Matrix &localToWorld, const osg::Matrix &worldToLocal)
Sets the matrix for transforming the command's local coordinate system to the world/object coordinate...
Definition Command:68
Stage getStage() const
Definition Command:87
void setStage(const Stage s)
Definition Command:86
virtual void accept(DraggerCallback &callback)
Definition Command:62
const osg::Matrix & getWorldToLocal() const
Gets the matrix for transforming the command's world/object coordinate system to the command's local ...
Definition Command:84
virtual osg::Matrix getMotionMatrix() const =0
Gets the matrix for transforming the object being dragged.
const osg::Matrix & getLocalToWorld() const
Gets the matrix for transforming the command's local coordinate system to the world/object coordinate...
Definition Command:78
virtual MotionCommand * createCommandInverse()=0
create a MotionCommand that is the inverse of this command, and if applied will undo this commands ch...
void setLine(const osg::LineSegment::vec_type &s, const osg::LineSegment::vec_type &e)
Definition Command:117
const osg::Vec3d & getTranslation() const
Definition Command:122
virtual void accept(const Constraint &constraint)
Definition Command:112
void setTranslation(const osg::Vec3d &t)
Definition Command:121
const osg::LineSegment::vec_type & getLineEnd() const
Definition Command:119
virtual osg::Matrix getMotionMatrix() const
Gets the matrix for transforming the object being dragged.
Definition Command:124
TranslateInLineCommand(const osg::LineSegment::vec_type &s, const osg::LineSegment::vec_type &e)
virtual MotionCommand * createCommandInverse()
create a MotionCommand that is the inverse of this command, and if applied will undo this commands ch...
const osg::LineSegment::vec_type & getLineStart() const
Definition Command:118
virtual void accept(DraggerCallback &callback)
Definition Command:113
virtual void accept(DraggerCallback &callback)
Definition Command:150
void setReferencePoint(const osg::Vec3d &rp)
ReferencePoint is used only for snapping.
Definition Command:161
TranslateInPlaneCommand(const osg::Plane &plane)
virtual osg::Matrix getMotionMatrix() const
Gets the matrix for transforming the object being dragged.
Definition Command:164
const osg::Vec3d & getTranslation() const
Definition Command:158
void setTranslation(const osg::Vec3d &t)
Definition Command:157
const osg::Vec3d & getReferencePoint() const
Definition Command:162
const osg::Plane & getPlane() const
Definition Command:155
virtual void accept(const Constraint &constraint)
Definition Command:149
void setPlane(const osg::Plane &plane)
Definition Command:154
virtual MotionCommand * createCommandInverse()
create a MotionCommand that is the inverse of this command, and if applied will undo this commands ch...
void setReferencePoint(double rp)
ReferencePoint is used only for snapping.
Definition Command:200
virtual void accept(DraggerCallback &callback)
Definition Command:189
void setMinScale(double min)
Definition Command:203
double getScaleCenter() const
Definition Command:197
virtual osg::Matrix getMotionMatrix() const
Gets the matrix for transforming the object being dragged.
Definition Command:206
void setScaleCenter(double center)
Definition Command:196
virtual void accept(const Constraint &constraint)
Definition Command:188
virtual MotionCommand * createCommandInverse()
create a MotionCommand that is the inverse of this command, and if applied will undo this commands ch...
double getReferencePoint() const
Definition Command:201
void setScale(double s)
Definition Command:193
double getMinScale() const
Definition Command:204
double getScale() const
Definition Command:194
const osg::Vec2d & getScale() const
Definition Command:239
void setMinScale(const osg::Vec2d &min)
Definition Command:248
void setScaleCenter(const osg::Vec2d &center)
Definition Command:241
virtual void accept(const Constraint &constraint)
Definition Command:233
virtual MotionCommand * createCommandInverse()
create a MotionCommand that is the inverse of this command, and if applied will undo this commands ch...
const osg::Vec2d & getReferencePoint() const
Definition Command:246
const osg::Vec2d & getScaleCenter() const
Definition Command:242
virtual osg::Matrix getMotionMatrix() const
Gets the matrix for transforming the object being dragged.
Definition Command:251
const osg::Vec2d & getMinScale() const
Definition Command:249
void setScale(const osg::Vec2d &s)
Definition Command:238
virtual void accept(DraggerCallback &callback)
Definition Command:234
void setReferencePoint(const osg::Vec2d &rp)
ReferencePoint is used only for snapping.
Definition Command:245
const osg::Vec3d & getScaleCenter() const
Definition Command:287
virtual osg::Matrix getMotionMatrix() const
Gets the matrix for transforming the object being dragged.
Definition Command:289
virtual void accept(const Constraint &constraint)
Definition Command:278
virtual void accept(DraggerCallback &callback)
Definition Command:279
virtual MotionCommand * createCommandInverse()
create a MotionCommand that is the inverse of this command, and if applied will undo this commands ch...
void setScaleCenter(const osg::Vec3d &center)
Definition Command:286
void setScale(double s)
Definition Command:283
double getScale() const
Definition Command:284
const osg::Quat & getRotation() const
Definition Command:320
void setRotation(const osg::Quat &rotation)
Definition Command:319
virtual MotionCommand * createCommandInverse()
create a MotionCommand that is the inverse of this command, and if applied will undo this commands ch...
virtual osg::Matrix getMotionMatrix() const
Gets the matrix for transforming the object being dragged.
Definition Command:322
virtual void accept(DraggerCallback &callback)
Definition Command:315
virtual void accept(const Constraint &constraint)
Definition Command:314
Definition Constraint:36
virtual bool receive(const MotionCommand &)
Receive motion commands.
Definition Constraint:49
Definition Constraint:60
virtual bool constrain(MotionCommand &) const
Definition Constraint:63
#define OSGMANIPULATOR_EXPORT
Definition Export:27

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.