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;
|
||||
|
||||
Reference in New Issue
Block a user