1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
13//osgManipulator - Copyright (C) 2007 Fugro-Jason B.V.
15#ifndef OSGMANIPULATOR_SCALE1DDRAGGER
16#define OSGMANIPULATOR_SCALE1DDRAGGER 1
18#include <osgManipulator/Dragger>
19#include <osgManipulator/Projector>
21namespace osgManipulator {
24 * Dragger for performing 1D scaling.
26class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger
32 SCALE_WITH_ORIGIN_AS_PIVOT = 0,
33 SCALE_WITH_OPPOSITE_HANDLE_AS_PIVOT
36 Scale1DDragger(ScaleMode scaleMode=SCALE_WITH_ORIGIN_AS_PIVOT);
38 META_OSGMANIPULATOR_Object(osgManipulator,Scale1DDragger)
41 * Handle pick events on dragger and generate TranslateInLine commands.
43 virtual bool handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
45 /** Setup default geometry for dragger. */
46 void setupDefaultGeometry();
48 /** Set/Get min scale for dragger. */
49 inline void setMinScale(double min) { _minScale = min; }
50 inline double getMinScale() const { return _minScale; }
52 /** Set/Get color for dragger. */
53 inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
54 inline const osg::Vec4& getColor() const { return _color; }
57 * Set/Get pick color for dragger. Pick color is color of the dragger
58 * when picked. It gives a visual feedback to show that the dragger has
61 inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
62 inline const osg::Vec4& getPickColor() const { return _pickColor; }
64 /** Set/Get left and right handle nodes for dragger. */
65 inline void setLeftHandleNode (osg::Node& node) { _leftHandleNode = &node; }
66 inline void setRightHandleNode(osg::Node& node) { _rightHandleNode = &node; }
67 inline osg::Node* getLeftHandleNode() { return _leftHandleNode.get(); }
68 inline const osg::Node* getLeftHandleNode() const { return _leftHandleNode.get(); }
69 inline osg::Node* getRightHandleNode() { return _rightHandleNode.get(); }
70 inline const osg::Node* getRightHandleNode() const { return _rightHandleNode.get(); }
72 /** Set left/right handle position. */
73 inline void setLeftHandlePosition(double pos) { _projector->getLineStart() = osg::Vec3d(pos,0.0,0.0); }
74 inline double getLeftHandlePosition() const { return _projector->getLineStart()[0]; }
75 inline void setRightHandlePosition(double pos) { _projector->getLineEnd() = osg::Vec3d(pos,0.0,0.0); }
76 inline double getRightHandlePosition() const { return _projector->getLineEnd()[0]; }
80 virtual ~Scale1DDragger();
82 osg::ref_ptr< LineProjector > _projector;
83 osg::Vec3d _startProjectedPoint;
87 osg::ref_ptr< osg::Node > _leftHandleNode;
88 osg::ref_ptr< osg::Node > _rightHandleNode;