osgEarth 2.1.1
|
Public Member Functions | |
MoveFeatureDraggerCallback (Feature *feature, FeatureSource *source, const Map *map, int point) | |
osg::Vec2d | getLocation (const osg::Matrixd &matrix) |
virtual bool | receive (const osgManipulator::MotionCommand &command) |
Public Attributes | |
osg::ref_ptr< const Map > | _map |
osg::ref_ptr< Feature > | _feature |
osg::ref_ptr< FeatureSource > | _source |
osg::Matrix | _startMotionMatrix |
int | _point |
osg::Matrix | _localToWorld |
osg::Matrix | _worldToLocal |
Definition at line 116 of file FeatureEditing.cpp.
MoveFeatureDraggerCallback::MoveFeatureDraggerCallback | ( | Feature * | feature, |
FeatureSource * | source, | ||
const Map * | map, | ||
int | point | ||
) | [inline] |
osg::Vec2d MoveFeatureDraggerCallback::getLocation | ( | const osg::Matrixd & | matrix | ) | [inline] |
Definition at line 126 of file FeatureEditing.cpp.
{ osg::Vec3d trans = matrix.getTrans(); double lat, lon, height; _map->getProfile()->getSRS()->getEllipsoid()->convertXYZToLatLongHeight(trans.x(), trans.y(), trans.z(), lat, lon, height); return osg::Vec2d(osg::RadiansToDegrees(lon), osg::RadiansToDegrees(lat)); }
virtual bool MoveFeatureDraggerCallback::receive | ( | const osgManipulator::MotionCommand & | command | ) | [inline, virtual] |
Definition at line 135 of file FeatureEditing.cpp.
{ switch (command.getStage()) { case osgManipulator::MotionCommand::START: { // Save the current matrix osg::Vec3d startLocation = (*_feature->getGeometry())[_point]; double x, y, z; _map->getProfile()->getSRS()->getEllipsoid()->convertLatLongHeightToXYZ(osg::DegreesToRadians(startLocation.y()), osg::DegreesToRadians(startLocation.x()), 0, x, y, z); _startMotionMatrix = osg::Matrixd::translate(x, y, z); // Get the LocalToWorld and WorldToLocal matrix for this node. osg::NodePath nodePathToRoot; _localToWorld = osg::Matrixd::identity(); _worldToLocal = osg::Matrixd::identity(); return true; } case osgManipulator::MotionCommand::MOVE: { // Transform the command's motion matrix into local motion matrix. osg::Matrix localMotionMatrix = _localToWorld * command.getWorldToLocal() * command.getMotionMatrix() * command.getLocalToWorld() * _worldToLocal; osg::Matrixd newMatrix = localMotionMatrix * _startMotionMatrix; osg::Vec2d location = getLocation( newMatrix ); (*_feature->getGeometry())[_point] = osg::Vec3d(location.x(), location.y(), 0); _source->dirty(); return true; } case osgManipulator::MotionCommand::FINISH: { return true; } case osgManipulator::MotionCommand::NONE: default: return false; } }
osg::ref_ptr< Feature > MoveFeatureDraggerCallback::_feature |
Definition at line 180 of file FeatureEditing.cpp.
osg::Matrix MoveFeatureDraggerCallback::_localToWorld |
Definition at line 186 of file FeatureEditing.cpp.
osg::ref_ptr<const Map> MoveFeatureDraggerCallback::_map |
Definition at line 179 of file FeatureEditing.cpp.
Definition at line 184 of file FeatureEditing.cpp.
osg::ref_ptr< FeatureSource > MoveFeatureDraggerCallback::_source |
Definition at line 181 of file FeatureEditing.cpp.
osg::Matrix MoveFeatureDraggerCallback::_startMotionMatrix |
Definition at line 183 of file FeatureEditing.cpp.
osg::Matrix MoveFeatureDraggerCallback::_worldToLocal |
Definition at line 187 of file FeatureEditing.cpp.