Refactored osgManipulator so that CommandManager is no longer required, instead Dragger directly manages Constaints and associate Selections.
This commit is contained in:
@@ -27,54 +27,23 @@ CommandManager::~CommandManager()
|
||||
|
||||
bool CommandManager::connect(Dragger& dragger, Selection& selection)
|
||||
{
|
||||
dragger.setCommandManager(this);
|
||||
|
||||
// Check to see if the selection is already associated with the dragger.
|
||||
if (_draggerSelectionMap.count(&dragger) > 0)
|
||||
{
|
||||
std::pair<DraggerSelectionMap::iterator,DraggerSelectionMap::iterator> s;
|
||||
s = _draggerSelectionMap.equal_range(&dragger);
|
||||
|
||||
for (DraggerSelectionMap::iterator iter = s.first; iter != s.second; ++iter)
|
||||
{
|
||||
if (iter->second == &selection)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Associate selection with dragger
|
||||
_draggerSelectionMap.insert(DraggerSelectionMap::value_type(&dragger,&selection));
|
||||
dragger.addSelection(&selection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommandManager::connect(Dragger& dragger, Constraint& constraint)
|
||||
{
|
||||
dragger.setCommandManager(this);
|
||||
|
||||
// Check to see if the selection is already associated with the dragger.
|
||||
if (_draggerConstraintMap.count(&dragger) > 0)
|
||||
{
|
||||
std::pair<DraggerConstraintMap::iterator,DraggerConstraintMap::iterator> s;
|
||||
s = _draggerConstraintMap.equal_range(&dragger);
|
||||
|
||||
for (DraggerConstraintMap::iterator iter = s.first; iter != s.second; ++iter)
|
||||
{
|
||||
if (iter->second == &constraint)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Associate selection with dragger
|
||||
_draggerConstraintMap.insert(DraggerConstraintMap::value_type(&dragger,&constraint));
|
||||
dragger.addConstraint(&constraint);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommandManager::disconnect(Dragger& dragger)
|
||||
{
|
||||
_draggerSelectionMap.erase(&dragger);
|
||||
_draggerConstraintMap.erase(&dragger);
|
||||
dragger.getConstraints().clear();
|
||||
dragger.getSelections().clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,41 +54,21 @@ void CommandManager::dispatch(MotionCommand& command)
|
||||
|
||||
void CommandManager::addSelectionsToCommand(MotionCommand& command, Dragger& dragger)
|
||||
{
|
||||
// Apply constraints to the command.
|
||||
if (_draggerConstraintMap.count(&dragger) > 0)
|
||||
for(Dragger::Constraints::iterator itr = dragger.getConstraints().begin();
|
||||
itr != dragger.getConstraints().end();
|
||||
++itr)
|
||||
{
|
||||
// Get all the selections assoicated with this dragger.
|
||||
std::pair<DraggerConstraintMap::iterator,DraggerConstraintMap::iterator> s;
|
||||
s = _draggerConstraintMap.equal_range(&dragger);
|
||||
|
||||
for (DraggerConstraintMap::iterator iter = s.first; iter != s.second; ++iter)
|
||||
{
|
||||
// Add the selection to the command.
|
||||
if (iter->second.valid())
|
||||
{
|
||||
command.applyConstraint(iter->second.get());
|
||||
}
|
||||
}
|
||||
command.applyConstraint(itr->get());
|
||||
}
|
||||
|
||||
// Add the dragger to the selection list first.
|
||||
command.addSelection(&dragger);
|
||||
|
||||
// Add the remaining selections.
|
||||
if (_draggerSelectionMap.count(&dragger) > 0)
|
||||
for(Dragger::Selections::iterator itr = dragger.getSelections().begin();
|
||||
itr != dragger.getSelections().end();
|
||||
++itr)
|
||||
{
|
||||
// Get all the selections assoicated with this dragger.
|
||||
std::pair<DraggerSelectionMap::iterator,DraggerSelectionMap::iterator> s;
|
||||
s = _draggerSelectionMap.equal_range(&dragger);
|
||||
|
||||
for (DraggerSelectionMap::iterator iter = s.first; iter != s.second; ++iter)
|
||||
{
|
||||
// Add the selection to the command.
|
||||
if (iter->second.valid())
|
||||
{
|
||||
command.addSelection(iter->second.get());
|
||||
}
|
||||
}
|
||||
command.addSelection(*itr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,18 +77,12 @@ CommandManager::Selections CommandManager::getConnectedSelections(Dragger& dragg
|
||||
{
|
||||
Selections selections;
|
||||
|
||||
//Test if the dragger is in the list
|
||||
if (_draggerSelectionMap.count(&dragger) > 0)
|
||||
for(Dragger::Selections::iterator itr = dragger.getSelections().begin();
|
||||
itr != dragger.getSelections().end();
|
||||
++itr)
|
||||
{
|
||||
//Get the iterator range on key 'dragger'
|
||||
std::pair<DraggerSelectionMap::iterator,DraggerSelectionMap::iterator> draggerRange = _draggerSelectionMap.equal_range(&dragger);
|
||||
for (DraggerSelectionMap::iterator selectionsIterator = draggerRange.first;
|
||||
selectionsIterator != draggerRange.second;
|
||||
++selectionsIterator)
|
||||
{
|
||||
//Push in the list all selections connected with the dragger
|
||||
selections.push_back((*selectionsIterator).second);
|
||||
}
|
||||
selections.push_back(*itr);
|
||||
}
|
||||
|
||||
return selections;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ osg::Vec3d snap_point_to_grid(const osg::Vec3d& point, const osg::Vec3d& origin,
|
||||
|
||||
void Constraint::computeLocalToWorldAndWorldToLocal() const
|
||||
{
|
||||
if (!_refNode)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"osgManipulator::Constraint::computeLocalToWorldAndWorldToLocal() error, _refNode is null"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
osg::NodePath pathToRoot;
|
||||
computeNodePathToRoot(const_cast<osg::Node&>(getReferenceNode()),pathToRoot);
|
||||
_localToWorld = osg::computeLocalToWorld(pathToRoot);
|
||||
|
||||
@@ -13,12 +13,17 @@
|
||||
//osgManipulator - Copyright (C) 2007 Fugro-Jason B.V.
|
||||
|
||||
#include <osgManipulator/Dragger>
|
||||
#include <osgManipulator/Command>
|
||||
#include <osg/Material>
|
||||
#include <osgGA/EventVisitor>
|
||||
#include <osgViewer/View>
|
||||
|
||||
using namespace osgManipulator;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PointerInfo
|
||||
//
|
||||
PointerInfo::PointerInfo():
|
||||
_nearPoint(osg::Vec3d()),
|
||||
_farPoint(osg::Vec3d()),
|
||||
@@ -41,10 +46,14 @@ bool PointerInfo::projectWindowXYIntoObject(const osg::Vec2d& windowCoord, osg::
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dragger
|
||||
//
|
||||
Dragger::Dragger() :
|
||||
_handleEvents(false),
|
||||
_draggerActive(false),
|
||||
_commandManager(0)
|
||||
_draggerActive(false)
|
||||
{
|
||||
_parentDragger = this;
|
||||
getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
|
||||
@@ -65,6 +74,69 @@ void Dragger::setHandleEvents(bool flag)
|
||||
else if (getNumChildrenRequiringEventTraversal()>=1) setNumChildrenRequiringEventTraversal(getNumChildrenRequiringEventTraversal()-1);
|
||||
}
|
||||
|
||||
void Dragger::addConstraint(Constraint* constraint)
|
||||
{
|
||||
// check to make sure constaint hasn't already been attached.
|
||||
for(Constraints::iterator itr = _constraints.begin();
|
||||
itr != _constraints.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr = constraint) return;
|
||||
}
|
||||
|
||||
_constraints.push_back(constraint);
|
||||
}
|
||||
|
||||
void Dragger::removeConstraint(Constraint* constraint)
|
||||
{
|
||||
for(Constraints::iterator itr = _constraints.begin();
|
||||
itr != _constraints.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr = constraint)
|
||||
{
|
||||
_constraints.erase(itr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Dragger::objectDeleted(void* object)
|
||||
{
|
||||
removeSelection(reinterpret_cast<Selection*>(object));
|
||||
}
|
||||
|
||||
void Dragger::addSelection(Selection* selection)
|
||||
{
|
||||
// check to make sure constaint hasn't already been attached.
|
||||
for(Selections::iterator itr = _selections.begin();
|
||||
itr != _selections.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr == selection) return;
|
||||
}
|
||||
|
||||
selection->addObserver(this);
|
||||
_selections.push_back(selection);
|
||||
}
|
||||
|
||||
void Dragger::removeSelection(Selection* selection)
|
||||
{
|
||||
for(Selections::iterator itr = _selections.begin();
|
||||
itr != _selections.end();
|
||||
++itr)
|
||||
{
|
||||
if (*itr == selection)
|
||||
{
|
||||
selection->removeObserver(this);
|
||||
_selections.erase(itr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Dragger::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_handleEvents && nv.getVisitorType()==osg::NodeVisitor::EVENT_VISITOR)
|
||||
@@ -159,6 +231,34 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&
|
||||
return handled;
|
||||
}
|
||||
|
||||
void Dragger::dispatch(MotionCommand& command)
|
||||
{
|
||||
// apply any constraints
|
||||
for(Constraints::iterator itr = _constraints.begin();
|
||||
itr != _constraints.end();
|
||||
++itr)
|
||||
{
|
||||
command.applyConstraint(itr->get());
|
||||
}
|
||||
|
||||
// move self
|
||||
getParentDragger()->receive(command);
|
||||
|
||||
// then run through any selections
|
||||
for(Selections::iterator itr = getParentDragger()->getSelections().begin();
|
||||
itr != getParentDragger()->getSelections().end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->receive(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CompositeDragger
|
||||
//
|
||||
|
||||
bool CompositeDragger::handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
|
||||
{
|
||||
// Check if the dragger node is in the nodepath.
|
||||
@@ -172,7 +272,6 @@ bool CompositeDragger::handle(const PointerInfo& pi, const osgGA::GUIEventAdapte
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CompositeDragger::containsDragger( const Dragger* dragger ) const
|
||||
{
|
||||
for (DraggerList::const_iterator itr = _draggerList.begin(); itr != _draggerList.end(); ++itr)
|
||||
@@ -213,14 +312,6 @@ bool CompositeDragger::removeDragger(Dragger *dragger)
|
||||
else return false;
|
||||
|
||||
}
|
||||
void CompositeDragger::setCommandManager(CommandManager* cm)
|
||||
{
|
||||
for (DraggerList::iterator itr = _draggerList.begin(); itr != _draggerList.end(); ++itr)
|
||||
{
|
||||
(*itr)->setCommandManager(cm);
|
||||
}
|
||||
Dragger::setCommandManager(cm);
|
||||
}
|
||||
|
||||
void CompositeDragger::setParentDragger(Dragger* dragger)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <osgManipulator/RotateCylinderDragger>
|
||||
#include <osgManipulator/Command>
|
||||
#include <osgManipulator/CommandManager>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Geometry>
|
||||
@@ -67,11 +66,7 @@ bool RotateCylinderDragger::handle(const PointerInfo& pointer, const osgGA::GUIE
|
||||
cmd->setLocalToWorldAndWorldToLocal(_startLocalToWorld,_startWorldToLocal);
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Set color to pick color.
|
||||
setMaterialColor(_pickColor,*this);
|
||||
@@ -107,11 +102,7 @@ bool RotateCylinderDragger::handle(const PointerInfo& pointer, const osgGA::GUIE
|
||||
cmd->setRotation(rotation);
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
_prevWorldProjPt = projectedPoint * _projector->getLocalToWorld();
|
||||
_prevRotation = rotation;
|
||||
@@ -128,17 +119,13 @@ bool RotateCylinderDragger::handle(const PointerInfo& pointer, const osgGA::GUIE
|
||||
|
||||
cmd->setStage(MotionCommand::FINISH);
|
||||
cmd->setLocalToWorldAndWorldToLocal(_startLocalToWorld,_startWorldToLocal);
|
||||
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Reset color.
|
||||
setMaterialColor(_color,*this);
|
||||
|
||||
|
||||
aa.requestRedraw();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <osgManipulator/RotateSphereDragger>
|
||||
#include <osgManipulator/Command>
|
||||
#include <osgManipulator/CommandManager>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Geometry>
|
||||
@@ -68,11 +67,7 @@ bool RotateSphereDragger::handle(const PointerInfo& pointer, const osgGA::GUIEve
|
||||
cmd->setLocalToWorldAndWorldToLocal(_startLocalToWorld,_startWorldToLocal);
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Set color to pick color.
|
||||
setMaterialColor(_pickColor,*this);
|
||||
@@ -109,11 +104,7 @@ bool RotateSphereDragger::handle(const PointerInfo& pointer, const osgGA::GUIEve
|
||||
cmd->setRotation(rotation);
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
_prevWorldProjPt = projectedPoint * _projector->getLocalToWorld();
|
||||
_prevRotation = rotation;
|
||||
@@ -130,17 +121,13 @@ bool RotateSphereDragger::handle(const PointerInfo& pointer, const osgGA::GUIEve
|
||||
|
||||
cmd->setStage(MotionCommand::FINISH);
|
||||
cmd->setLocalToWorldAndWorldToLocal(_startLocalToWorld,_startWorldToLocal);
|
||||
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Reset color.
|
||||
setMaterialColor(_color,*this);
|
||||
|
||||
|
||||
aa.requestRedraw();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <osgManipulator/Scale1DDragger>
|
||||
#include <osgManipulator/Command>
|
||||
#include <osgManipulator/CommandManager>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Geometry>
|
||||
@@ -80,11 +79,7 @@ bool Scale1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda
|
||||
cmd->setLocalToWorldAndWorldToLocal(_projector->getLocalToWorld(),_projector->getWorldToLocal());
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Set color to pick color.
|
||||
setMaterialColor(_pickColor,*this);
|
||||
@@ -123,11 +118,7 @@ bool Scale1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda
|
||||
cmd->setMinScale(getMinScale());
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
aa.requestRedraw();
|
||||
}
|
||||
@@ -141,17 +132,13 @@ bool Scale1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda
|
||||
|
||||
cmd->setStage(MotionCommand::FINISH);
|
||||
cmd->setLocalToWorldAndWorldToLocal(_projector->getLocalToWorld(),_projector->getWorldToLocal());
|
||||
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Reset color.
|
||||
setMaterialColor(_color,*this);
|
||||
|
||||
|
||||
aa.requestRedraw();
|
||||
|
||||
return true;
|
||||
@@ -172,7 +159,7 @@ void Scale1DDragger::setupDefaultGeometry()
|
||||
// Create a line.
|
||||
{
|
||||
osg::Geometry* geometry = new osg::Geometry();
|
||||
|
||||
|
||||
osg::Vec3Array* vertices = new osg::Vec3Array(2);
|
||||
(*vertices)[0] = _projector->getLineStart();
|
||||
(*vertices)[1] = _projector->getLineEnd();
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <osgManipulator/Scale2DDragger>
|
||||
#include <osgManipulator/Command>
|
||||
#include <osgManipulator/CommandManager>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Geometry>
|
||||
@@ -109,11 +108,7 @@ bool Scale2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda
|
||||
cmd->setReferencePoint(_referencePoint);
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Set color to pick color.
|
||||
setMaterialColor(_pickColor,*this);
|
||||
@@ -145,11 +140,7 @@ bool Scale2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda
|
||||
cmd->setMinScale(getMinScale());
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
aa.requestRedraw();
|
||||
}
|
||||
@@ -164,17 +155,13 @@ bool Scale2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAda
|
||||
cmd->setStage(MotionCommand::FINISH);
|
||||
cmd->setReferencePoint(_referencePoint);
|
||||
cmd->setLocalToWorldAndWorldToLocal(_projector->getLocalToWorld(),_projector->getWorldToLocal());
|
||||
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Reset color.
|
||||
setMaterialColor(_color,*this);
|
||||
|
||||
|
||||
aa.requestRedraw();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <osgManipulator/Translate1DDragger>
|
||||
#include <osgManipulator/Command>
|
||||
#include <osgManipulator/CommandManager>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Geometry>
|
||||
@@ -69,11 +68,7 @@ bool Translate1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven
|
||||
cmd->setLocalToWorldAndWorldToLocal(_projector->getLocalToWorld(),_projector->getWorldToLocal());
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Set color to pick color.
|
||||
setMaterialColor(_pickColor,*this);
|
||||
@@ -97,11 +92,7 @@ bool Translate1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven
|
||||
cmd->setTranslation(projectedPoint - _startProjectedPoint);
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
aa.requestRedraw();
|
||||
}
|
||||
@@ -121,11 +112,7 @@ bool Translate1DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven
|
||||
cmd->setLocalToWorldAndWorldToLocal(_projector->getLocalToWorld(),_projector->getWorldToLocal());
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Reset color.
|
||||
setMaterialColor(_color,*this);
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <osgManipulator/Translate2DDragger>
|
||||
#include <osgManipulator/Command>
|
||||
#include <osgManipulator/CommandManager>
|
||||
|
||||
#include <osg/ShapeDrawable>
|
||||
#include <osg/Geometry>
|
||||
@@ -69,11 +68,7 @@ bool Translate2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven
|
||||
cmd->setLocalToWorldAndWorldToLocal(_projector->getLocalToWorld(),_projector->getWorldToLocal());
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
// Set color to pick color.
|
||||
setMaterialColor(_pickColor,*this);
|
||||
@@ -99,17 +94,13 @@ bool Translate2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven
|
||||
cmd->setReferencePoint(_startProjectedPoint);
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
dispatch(*cmd);
|
||||
|
||||
aa.requestRedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Pick finish.
|
||||
case (osgGA::GUIEventAdapter::RELEASE):
|
||||
{
|
||||
@@ -118,18 +109,14 @@ bool Translate2DDragger::handle(const PointerInfo& pointer, const osgGA::GUIEven
|
||||
cmd->setStage(MotionCommand::FINISH);
|
||||
cmd->setReferencePoint(_startProjectedPoint);
|
||||
cmd->setLocalToWorldAndWorldToLocal(_projector->getLocalToWorld(),_projector->getWorldToLocal());
|
||||
|
||||
// Dispatch command.
|
||||
if (_commandManager)
|
||||
{
|
||||
_commandManager->addSelectionsToCommand(*cmd, *getParentDragger());
|
||||
_commandManager->dispatch(*cmd);
|
||||
}
|
||||
|
||||
// Dispatch command.
|
||||
dispatch(*cmd);
|
||||
|
||||
// Reset color.
|
||||
setMaterialColor(_color,*this);
|
||||
getOrCreateStateSet()->removeAttribute(_polygonOffset.get());
|
||||
|
||||
|
||||
aa.requestRedraw();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
#include <osg/Vec3d>
|
||||
#include <osgGA/GUIActionAdapter>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
#include <osgManipulator/CommandManager>
|
||||
#include <osgManipulator/Constraint>
|
||||
#include <osgManipulator/Dragger>
|
||||
#include <osgManipulator/Selection>
|
||||
|
||||
// Must undefine IN and OUT macros defined in Windows headers
|
||||
#ifdef IN
|
||||
@@ -58,11 +59,6 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::CompositeDragger)
|
||||
__CompositeDragger_P1__getComposite,
|
||||
"Returns 0 if this Dragger is not a CompositeDragger. ",
|
||||
"");
|
||||
I_Method1(void, setCommandManager, IN, osgManipulator::CommandManager *, cm,
|
||||
Properties::VIRTUAL,
|
||||
__void__setCommandManager__CommandManager_P1,
|
||||
"Set/Get the CommandManager. ",
|
||||
"Draggers use CommandManager to dispatch commands. ");
|
||||
I_Method1(void, setParentDragger, IN, osgManipulator::Dragger *, parent,
|
||||
Properties::VIRTUAL,
|
||||
__void__setParentDragger__Dragger_P1,
|
||||
@@ -111,9 +107,6 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::CompositeDragger)
|
||||
I_ProtectedConstructor0(____CompositeDragger,
|
||||
"",
|
||||
"");
|
||||
I_SimpleProperty(osgManipulator::CommandManager *, CommandManager,
|
||||
0,
|
||||
__void__setCommandManager__CommandManager_P1);
|
||||
I_SimpleProperty(osgManipulator::CompositeDragger *, Composite,
|
||||
__CompositeDragger_P1__getComposite,
|
||||
0);
|
||||
@@ -129,9 +122,14 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::CompositeDragger)
|
||||
__void__setParentDragger__Dragger_P1);
|
||||
END_REFLECTOR
|
||||
|
||||
TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osgManipulator::Constraint > >, osgManipulator::Dragger::Constraints)
|
||||
|
||||
TYPE_NAME_ALIAS(std::vector< osgManipulator::Selection * >, osgManipulator::Dragger::Selections)
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger)
|
||||
I_DeclaringFile("osgManipulator/Dragger");
|
||||
I_BaseType(osgManipulator::Selection);
|
||||
I_BaseType(osg::Observer);
|
||||
I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj,
|
||||
Properties::VIRTUAL,
|
||||
__bool__isSameKindAs__C5_osg_Object_P1,
|
||||
@@ -147,21 +145,6 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger)
|
||||
__C5_char_P1__className,
|
||||
"return the name of the node's class type. ",
|
||||
"");
|
||||
I_Method1(void, setCommandManager, IN, osgManipulator::CommandManager *, cm,
|
||||
Properties::VIRTUAL,
|
||||
__void__setCommandManager__CommandManager_P1,
|
||||
"Set/Get the CommandManager. ",
|
||||
"Draggers use CommandManager to dispatch commands. ");
|
||||
I_Method0(osgManipulator::CommandManager *, getCommandManager,
|
||||
Properties::NON_VIRTUAL,
|
||||
__CommandManager_P1__getCommandManager,
|
||||
"",
|
||||
"");
|
||||
I_Method0(const osgManipulator::CommandManager *, getCommandManager,
|
||||
Properties::NON_VIRTUAL,
|
||||
__C5_CommandManager_P1__getCommandManager,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, setParentDragger, IN, osgManipulator::Dragger *, parent,
|
||||
Properties::VIRTUAL,
|
||||
__void__setParentDragger__Dragger_P1,
|
||||
@@ -222,15 +205,67 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger)
|
||||
__bool__handle__C5_PointerInfo_R1__C5_osgGA_GUIEventAdapter_R1__osgGA_GUIActionAdapter_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, addConstraint, IN, osgManipulator::Constraint *, constraint,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__addConstraint__Constraint_P1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, removeConstraint, IN, osgManipulator::Constraint *, constraint,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__removeConstraint__Constraint_P1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osgManipulator::Dragger::Constraints &, getConstraints,
|
||||
Properties::NON_VIRTUAL,
|
||||
__Constraints_R1__getConstraints,
|
||||
"",
|
||||
"");
|
||||
I_Method0(const osgManipulator::Dragger::Constraints &, getConstraints,
|
||||
Properties::NON_VIRTUAL,
|
||||
__C5_Constraints_R1__getConstraints,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, addSelection, IN, osgManipulator::Selection *, selection,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__addSelection__Selection_P1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, removeSelection, IN, osgManipulator::Selection *, selection,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__removeSelection__Selection_P1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osgManipulator::Dragger::Selections &, getSelections,
|
||||
Properties::NON_VIRTUAL,
|
||||
__Selections_R1__getSelections,
|
||||
"",
|
||||
"");
|
||||
I_Method0(const osgManipulator::Dragger::Selections &, getSelections,
|
||||
Properties::NON_VIRTUAL,
|
||||
__C5_Selections_R1__getSelections,
|
||||
"",
|
||||
"");
|
||||
I_ProtectedConstructor0(____Dragger,
|
||||
"",
|
||||
"");
|
||||
I_SimpleProperty(osgManipulator::CommandManager *, CommandManager,
|
||||
__CommandManager_P1__getCommandManager,
|
||||
__void__setCommandManager__CommandManager_P1);
|
||||
I_ProtectedMethod1(void, dispatch, IN, osgManipulator::MotionCommand &, command,
|
||||
Properties::NON_VIRTUAL,
|
||||
Properties::NON_CONST,
|
||||
__void__dispatch__MotionCommand_R1,
|
||||
"",
|
||||
"");
|
||||
I_ProtectedMethod1(void, objectDeleted, IN, void *, object,
|
||||
Properties::VIRTUAL,
|
||||
Properties::NON_CONST,
|
||||
__void__objectDeleted__void_P1,
|
||||
"",
|
||||
"");
|
||||
I_SimpleProperty(osgManipulator::CompositeDragger *, Composite,
|
||||
__CompositeDragger_P1__getComposite,
|
||||
0);
|
||||
I_SimpleProperty(osgManipulator::Dragger::Constraints &, Constraints,
|
||||
__Constraints_R1__getConstraints,
|
||||
0);
|
||||
I_SimpleProperty(bool, DraggerActive,
|
||||
__bool__getDraggerActive,
|
||||
__void__setDraggerActive__bool);
|
||||
@@ -240,6 +275,9 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger)
|
||||
I_SimpleProperty(osgManipulator::Dragger *, ParentDragger,
|
||||
__Dragger_P1__getParentDragger,
|
||||
__void__setParentDragger__Dragger_P1);
|
||||
I_SimpleProperty(osgManipulator::Dragger::Selections &, Selections,
|
||||
__Selections_R1__getSelections,
|
||||
0);
|
||||
END_REFLECTOR
|
||||
|
||||
TYPE_NAME_ALIAS(std::pair< osg::NodePath COMMA osg::Vec3d >, osgManipulator::PointerInfo::NodePathIntersectionPair)
|
||||
@@ -329,6 +367,46 @@ BEGIN_VALUE_REFLECTOR(osgManipulator::PointerInfo)
|
||||
I_PublicMemberProperty(osgManipulator::PointerInfo::IntersectionList, _hitList);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osgManipulator::Constraint >)
|
||||
I_DeclaringFile("osg/ref_ptr");
|
||||
I_Constructor0(____ref_ptr,
|
||||
"",
|
||||
"");
|
||||
I_Constructor1(IN, osgManipulator::Constraint *, ptr,
|
||||
Properties::NON_EXPLICIT,
|
||||
____ref_ptr__T_P1,
|
||||
"",
|
||||
"");
|
||||
I_Constructor1(IN, const osg::ref_ptr< osgManipulator::Constraint > &, rp,
|
||||
Properties::NON_EXPLICIT,
|
||||
____ref_ptr__C5_ref_ptr_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osgManipulator::Constraint *, get,
|
||||
Properties::NON_VIRTUAL,
|
||||
__T_P1__get,
|
||||
"",
|
||||
"");
|
||||
I_Method0(bool, valid,
|
||||
Properties::NON_VIRTUAL,
|
||||
__bool__valid,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osgManipulator::Constraint *, release,
|
||||
Properties::NON_VIRTUAL,
|
||||
__T_P1__release,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, swap, IN, osg::ref_ptr< osgManipulator::Constraint > &, rp,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__swap__ref_ptr_R1,
|
||||
"",
|
||||
"");
|
||||
I_SimpleProperty(osgManipulator::Constraint *, ,
|
||||
__T_P1__get,
|
||||
0);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osgManipulator::Dragger >)
|
||||
I_DeclaringFile("osg/ref_ptr");
|
||||
I_Constructor0(____ref_ptr,
|
||||
@@ -373,5 +451,9 @@ STD_LIST_REFLECTOR(std::list< osgManipulator::PointerInfo::NodePathIntersectionP
|
||||
|
||||
STD_PAIR_REFLECTOR(std::pair< osg::NodePath COMMA osg::Vec3d >)
|
||||
|
||||
STD_VECTOR_REFLECTOR(std::vector< osg::ref_ptr< osgManipulator::Constraint > >)
|
||||
|
||||
STD_VECTOR_REFLECTOR(std::vector< osg::ref_ptr< osgManipulator::Dragger > >)
|
||||
|
||||
STD_VECTOR_REFLECTOR(std::vector< osgManipulator::Selection * >)
|
||||
|
||||
|
||||
@@ -22,6 +22,48 @@
|
||||
#undef OUT
|
||||
#endif
|
||||
|
||||
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osgManipulator::CommandProcessor)
|
||||
I_DeclaringFile("osgManipulator/Selection");
|
||||
I_Constructor0(____CommandProcessor,
|
||||
"",
|
||||
"");
|
||||
I_Method1(bool, receive, IN, const osgManipulator::MotionCommand &, x,
|
||||
Properties::PURE_VIRTUAL,
|
||||
__bool__receive__C5_MotionCommand_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(bool, receive, IN, const osgManipulator::TranslateInLineCommand &, command,
|
||||
Properties::PURE_VIRTUAL,
|
||||
__bool__receive__C5_TranslateInLineCommand_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(bool, receive, IN, const osgManipulator::TranslateInPlaneCommand &, command,
|
||||
Properties::PURE_VIRTUAL,
|
||||
__bool__receive__C5_TranslateInPlaneCommand_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(bool, receive, IN, const osgManipulator::Scale1DCommand &, command,
|
||||
Properties::PURE_VIRTUAL,
|
||||
__bool__receive__C5_Scale1DCommand_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(bool, receive, IN, const osgManipulator::Scale2DCommand &, command,
|
||||
Properties::PURE_VIRTUAL,
|
||||
__bool__receive__C5_Scale2DCommand_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(bool, receive, IN, const osgManipulator::ScaleUniformCommand &, command,
|
||||
Properties::PURE_VIRTUAL,
|
||||
__bool__receive__C5_ScaleUniformCommand_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(bool, receive, IN, const osgManipulator::Rotate3DCommand &, command,
|
||||
Properties::PURE_VIRTUAL,
|
||||
__bool__receive__C5_Rotate3DCommand_R1,
|
||||
"",
|
||||
"");
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_OBJECT_REFLECTOR(osgManipulator::Selection)
|
||||
I_DeclaringFile("osgManipulator/Selection");
|
||||
I_BaseType(osg::MatrixTransform);
|
||||
|
||||
Reference in New Issue
Block a user