osgEarth 2.1.1
Public Member Functions | Public Attributes

MoveFeatureDraggerCallback Class Reference

List of all members.

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

Detailed Description

Definition at line 116 of file FeatureEditing.cpp.


Constructor & Destructor Documentation

MoveFeatureDraggerCallback::MoveFeatureDraggerCallback ( Feature feature,
FeatureSource source,
const Map map,
int  point 
) [inline]

Definition at line 119 of file FeatureEditing.cpp.

                                                                                                  :
      _feature(feature),
      _source(source),
      _map(map),
      _point(point)
      {}

Member Function Documentation

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;
          }
      }

Member Data Documentation

Definition at line 180 of file FeatureEditing.cpp.

Definition at line 186 of file FeatureEditing.cpp.

Definition at line 179 of file FeatureEditing.cpp.

Definition at line 184 of file FeatureEditing.cpp.

Definition at line 181 of file FeatureEditing.cpp.

Definition at line 183 of file FeatureEditing.cpp.

Definition at line 187 of file FeatureEditing.cpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines