Keystone
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGVIEWER_Keystone
#define OSGVIEWER_Keystone 1
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/DisplaySettings>
#include <osgGA/GUIEventHandler>
#include <osgViewer/Export>
namespace osgViewer
{
class OSGVIEWER_EXPORT Keystone : public osg::Object
{
public:
Keystone();
Keystone(const Keystone& rhs, const osg::CopyOp& copop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgViewer, Keystone)
void reset();
Keystone& operator = (const Keystone& rhs);
void setKeystoneEditingEnabled(bool flag) { keystoneEditingEnabled = flag; }
bool getKeystoneEditingEnabled() const { return keystoneEditingEnabled; }
void setGridColor(const osg::Vec4& color) { gridColour = color; }
osg::Vec4& getGridColor() { return gridColour; }
const osg::Vec4& getGridColor() const { return gridColour; }
void setBottomLeft(const osg::Vec2d& v) { bottom_left = v; }
osg::Vec2d& getBottomLeft() { return bottom_left; }
const osg::Vec2d& getBottomLeft() const { return bottom_left; }
void setBottomRight(const osg::Vec2d& v) { bottom_right = v; }
osg::Vec2d& getBottomRight() { return bottom_right; }
const osg::Vec2d& getBottomRight() const { return bottom_right; }
void setTopLeft(const osg::Vec2d& v) { top_left = v; }
osg::Vec2d& getTopLeft() { return top_left; }
const osg::Vec2d& getTopLeft() const { return top_left; }
void setTopRight(const osg::Vec2d& v) { top_right = v; }
osg::Vec2d& getTopRight() { return top_right; }
const osg::Vec2d& getTopRight() const { return top_right; }
void compute3DPositions(osg::DisplaySettings* ds, osg::Vec3& tl, osg::Vec3& tr, osg::Vec3& br, osg::Vec3& bl) const;
osg::Geode* createKeystoneDistortionMesh();
osg::Node* createGrid();
bool writeToFile();
static bool loadKeystoneFiles(osg::DisplaySettings* ds);
protected:
bool keystoneEditingEnabled;
osg::Vec4 gridColour;
osg::Vec2d bottom_left;
osg::Vec2d bottom_right;
osg::Vec2d top_left;
osg::Vec2d top_right;
protected:
virtual ~Keystone() {}
};
class OSGVIEWER_EXPORT KeystoneHandler : public osgGA::GUIEventHandler
{
public:
KeystoneHandler(Keystone* keystone);
~KeystoneHandler() {}
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv);
void setKeystoneEditingEnabled(bool enabled) { if (_currentControlPoints.valid()) _currentControlPoints->setKeystoneEditingEnabled(enabled); }
bool getKeystoneEditingEnabled() const { return _currentControlPoints.valid() ? _currentControlPoints->getKeystoneEditingEnabled() : false; }
enum Region
{
NONE_SELECTED,
TOP_LEFT,
TOP,
TOP_RIGHT,
RIGHT,
BOTTOM_RIGHT,
BOTTOM,
BOTTOM_LEFT,
LEFT,
CENTER
};
osg::Vec2d incrementScale(const osgGA::GUIEventAdapter& ea) const;
Region computeRegion(const osgGA::GUIEventAdapter& ea) const;
void move(Region region, const osg::Vec2d& delta);
protected:
osg::ref_ptr<Keystone> _keystone;
osg::Vec2d _defaultIncrement;
osg::Vec2d _ctrlIncrement;
osg::Vec2d _shiftIncrement;
osg::Vec2d _keyIncrement;
osg::Vec2d _startPosition;
osg::ref_ptr<Keystone> _startControlPoints;
Region _selectedRegion;
osg::ref_ptr<Keystone> _currentControlPoints;
};
}
#endif
DisplaySettings
GUIEventHandler
Geode
Geometry
osgGA::GUIActionAdapter
Definition GUIActionAdapter:62
osgGA::GUIEventAdapter
Definition GUIEventAdapter:82
osgGA::GUIEventHandler
Definition GUIEventHandler:50
osgViewer::KeystoneHandler::getKeystoneEditingEnabled
bool getKeystoneEditingEnabled() const
Definition Keystone:109
osgViewer::KeystoneHandler::incrementScale
osg::Vec2d incrementScale(const osgGA::GUIEventAdapter &ea) const
osgViewer::KeystoneHandler::_currentControlPoints
osg::ref_ptr< Keystone > _currentControlPoints
Definition Keystone:143
osgViewer::KeystoneHandler::_ctrlIncrement
osg::Vec2d _ctrlIncrement
Definition Keystone:135
osgViewer::KeystoneHandler::_startPosition
osg::Vec2d _startPosition
Definition Keystone:139
osgViewer::KeystoneHandler::_startControlPoints
osg::ref_ptr< Keystone > _startControlPoints
Definition Keystone:140
osgViewer::KeystoneHandler::_shiftIncrement
osg::Vec2d _shiftIncrement
Definition Keystone:136
osgViewer::KeystoneHandler::move
void move(Region region, const osg::Vec2d &delta)
osgViewer::KeystoneHandler::_keyIncrement
osg::Vec2d _keyIncrement
Definition Keystone:137
osgViewer::KeystoneHandler::KeystoneHandler
KeystoneHandler(Keystone *keystone)
osgViewer::KeystoneHandler::_keystone
osg::ref_ptr< Keystone > _keystone
Definition Keystone:132
osgViewer::KeystoneHandler::Region
Region
Definition Keystone:112
osgViewer::KeystoneHandler::TOP
@ TOP
Definition Keystone:115
osgViewer::KeystoneHandler::CENTER
@ CENTER
Definition Keystone:122
osgViewer::KeystoneHandler::NONE_SELECTED
@ NONE_SELECTED
Definition Keystone:113
osgViewer::KeystoneHandler::RIGHT
@ RIGHT
Definition Keystone:117
osgViewer::KeystoneHandler::TOP_RIGHT
@ TOP_RIGHT
Definition Keystone:116
osgViewer::KeystoneHandler::LEFT
@ LEFT
Definition Keystone:121
osgViewer::KeystoneHandler::BOTTOM
@ BOTTOM
Definition Keystone:119
osgViewer::KeystoneHandler::TOP_LEFT
@ TOP_LEFT
Definition Keystone:114
osgViewer::KeystoneHandler::BOTTOM_LEFT
@ BOTTOM_LEFT
Definition Keystone:120
osgViewer::KeystoneHandler::BOTTOM_RIGHT
@ BOTTOM_RIGHT
Definition Keystone:118
osgViewer::KeystoneHandler::handle
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *obj, osg::NodeVisitor *nv)
osgViewer::KeystoneHandler::setKeystoneEditingEnabled
void setKeystoneEditingEnabled(bool enabled)
Definition Keystone:108
osgViewer::KeystoneHandler::computeRegion
Region computeRegion(const osgGA::GUIEventAdapter &ea) const
osgViewer::KeystoneHandler::~KeystoneHandler
~KeystoneHandler()
Definition Keystone:104
osgViewer::KeystoneHandler::_selectedRegion
Region _selectedRegion
Definition Keystone:142
osgViewer::KeystoneHandler::_defaultIncrement
osg::Vec2d _defaultIncrement
Definition Keystone:134
osgViewer::Keystone
Definition Keystone:29
osgViewer::Keystone::setGridColor
void setGridColor(const osg::Vec4 &color)
Definition Keystone:44
osgViewer::Keystone::getTopRight
const osg::Vec2d & getTopRight() const
Definition Keystone:62
osgViewer::Keystone::getBottomRight
const osg::Vec2d & getBottomRight() const
Definition Keystone:54
osgViewer::Keystone::META_Object
META_Object(osgViewer, Keystone) void reset()
osgViewer::Keystone::top_right
osg::Vec2d top_right
Definition Keystone:88
osgViewer::Keystone::getTopRight
osg::Vec2d & getTopRight()
Definition Keystone:61
osgViewer::Keystone::getTopLeft
osg::Vec2d & getTopLeft()
Definition Keystone:57
osgViewer::Keystone::setTopLeft
void setTopLeft(const osg::Vec2d &v)
Definition Keystone:56
osgViewer::Keystone::top_left
osg::Vec2d top_left
Definition Keystone:87
osgViewer::Keystone::getBottomRight
osg::Vec2d & getBottomRight()
Definition Keystone:53
osgViewer::Keystone::compute3DPositions
void compute3DPositions(osg::DisplaySettings *ds, osg::Vec3 &tl, osg::Vec3 &tr, osg::Vec3 &br, osg::Vec3 &bl) const
osgViewer::Keystone::setTopRight
void setTopRight(const osg::Vec2d &v)
Definition Keystone:60
osgViewer::Keystone::setBottomRight
void setBottomRight(const osg::Vec2d &v)
Definition Keystone:52
osgViewer::Keystone::createGrid
osg::Node * createGrid()
osgViewer::Keystone::loadKeystoneFiles
static bool loadKeystoneFiles(osg::DisplaySettings *ds)
osgViewer::Keystone::setBottomLeft
void setBottomLeft(const osg::Vec2d &v)
Definition Keystone:48
osgViewer::Keystone::~Keystone
virtual ~Keystone()
Definition Keystone:93
osgViewer::Keystone::Keystone
Keystone()
osgViewer::Keystone::getTopLeft
const osg::Vec2d & getTopLeft() const
Definition Keystone:58
osgViewer::Keystone::getBottomLeft
const osg::Vec2d & getBottomLeft() const
Definition Keystone:50
osgViewer::Keystone::gridColour
osg::Vec4 gridColour
Definition Keystone:83
osgViewer::Keystone::getGridColor
const osg::Vec4 & getGridColor() const
Definition Keystone:46
osgViewer::Keystone::writeToFile
bool writeToFile()
osgViewer::Keystone::getKeystoneEditingEnabled
bool getKeystoneEditingEnabled() const
Definition Keystone:42
osgViewer::Keystone::keystoneEditingEnabled
bool keystoneEditingEnabled
Definition Keystone:81
osgViewer::Keystone::setKeystoneEditingEnabled
void setKeystoneEditingEnabled(bool flag)
Definition Keystone:41
osgViewer::Keystone::createKeystoneDistortionMesh
osg::Geode * createKeystoneDistortionMesh()
osgViewer::Keystone::Keystone
Keystone(const Keystone &rhs, const osg::CopyOp &copop=osg::CopyOp::SHALLOW_COPY)
osgViewer::Keystone::bottom_right
osg::Vec2d bottom_right
Definition Keystone:86
osgViewer::Keystone::bottom_left
osg::Vec2d bottom_left
Definition Keystone:85
osgViewer::Keystone::getBottomLeft
osg::Vec2d & getBottomLeft()
Definition Keystone:49
osgViewer::Keystone::getGridColor
osg::Vec4 & getGridColor()
Definition Keystone:45
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::DisplaySettings
Definition DisplaySettings:34
osg::Geode
Definition Geode:29
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node
Definition Node:72
osg::Object
Definition Object:61
osg::Vec2d
Definition Vec2d:29
osg::ref_ptr
Definition ref_ptr:32
osgViewer
osg::Vec3
Vec3f Vec3
Definition Vec3:21
osg::Vec4
Vec4f Vec4
Definition Vec4:21
Export
OSGVIEWER_EXPORT
#define OSGVIEWER_EXPORT
Definition osgViewer/Export:40