|
osgEarth 2.1.1
|
Public Member Functions | |
| AddPointHandler (osgEarth::Features::Feature *feature, osgEarth::Features::FeatureListSource *source, const osgEarth::SpatialReference *mapSRS) | |
| bool | handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa) |
| void | setMouseButton (osgGA::GUIEventAdapter::MouseButtonMask mouseButton) |
| osgGA::GUIEventAdapter::MouseButtonMask | getMouseButton () const |
| void | setIntersectionMask (osg::Node::NodeMask intersectionMask) |
| osg::Node::NodeMask | getIntersectionMask () const |
Private Member Functions | |
| bool | addPoint (float x, float y, osgViewer::View *view) |
Private Attributes | |
| osgGA::GUIEventAdapter::MouseButtonMask | _mouseButton |
| bool | _mouseDown |
| bool | _firstMove |
| osg::ref_ptr < osgEarth::Features::FeatureListSource > | _source |
| osg::ref_ptr < osgEarth::Features::Feature > | _feature |
| osg::ref_ptr< const SpatialReference > | _mapSRS |
| osg::Node::NodeMask | _intersectionMask |
AddPointHandler is a GUIEventHandler that allows you to append points to a Feature's Geometry
Definition at line 34 of file FeatureEditing.
| AddPointHandler::AddPointHandler | ( | osgEarth::Features::Feature * | feature, |
| osgEarth::Features::FeatureListSource * | source, | ||
| const osgEarth::SpatialReference * | mapSRS | ||
| ) |
Constructs a new AddPointHandler
| feature | The Feature to edit |
| source | The FeatureSource that the Feature belongs to |
| mapSRS | The srs of the Map |
Definition at line 28 of file FeatureEditing.cpp.
: _feature(feature), _source( source ), _mapSRS( mapSRS ), _mouseDown( false ), _firstMove( false ), _mouseButton( osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ), _intersectionMask( 0xffffffff ) { }
| bool AddPointHandler::addPoint | ( | float | x, |
| float | y, | ||
| osgViewer::View * | view | ||
| ) | [private] |
Definition at line 52 of file FeatureEditing.cpp.
{
osgUtil::LineSegmentIntersector::Intersections results;
if ( view->computeIntersections( x, y, results, _intersectionMask ) )
{
// find the first hit under the mouse:
osgUtil::LineSegmentIntersector::Intersection first = *(results.begin());
osg::Vec3d point = first.getWorldIntersectPoint();
// transform it to map coordinates:
double lat_rad, lon_rad, dummy;
_mapSRS->getEllipsoid()->convertXYZToLatLongHeight( point.x(), point.y(), point.z(), lat_rad, lon_rad, dummy );
double lat_deg = osg::RadiansToDegrees( lat_rad );
double lon_deg = osg::RadiansToDegrees( lon_rad );
if (_feature.valid())
{
_feature->getGeometry()->push_back( osg::Vec3d(lon_deg, lat_deg, 0) );
_source->dirty();
}
return true;
}
return false;
}
Here is the caller graph for this function:| osg::Node::NodeMask osgEarth::Util::AddPointHandler::getIntersectionMask | ( | ) | const [inline] |
Definition at line 61 of file FeatureEditing.
{ return _intersectionMask;}
| osgGA::GUIEventAdapter::MouseButtonMask AddPointHandler::getMouseButton | ( | ) | const |
Gets the mouse button used for adding new points
Definition at line 46 of file FeatureEditing.cpp.
{
return _mouseButton;
}
| bool AddPointHandler::handle | ( | const osgGA::GUIEventAdapter & | ea, |
| osgGA::GUIActionAdapter & | aa | ||
| ) |
Definition at line 79 of file FeatureEditing.cpp.
{
osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH )
{
if (ea.getButton() == _mouseButton)
{
_mouseDown = true;
_firstMove = true;
return addPoint( ea.getX(), ea.getY(), view );
}
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
{
if (ea.getButton() == _mouseButton)
{
_mouseDown = false;
}
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::MOVE || ea.getEventType() == osgGA::GUIEventAdapter::DRAG)
{
if (_mouseDown)
{
if (!_firstMove)
{
return addPoint( ea.getX(), ea.getY(), view );
}
_firstMove = false;
}
return true;
}
return false;
}
Here is the call graph for this function:| void osgEarth::Util::AddPointHandler::setIntersectionMask | ( | osg::Node::NodeMask | intersectionMask | ) | [inline] |
Definition at line 60 of file FeatureEditing.
{ _intersectionMask = intersectionMask; }
| void AddPointHandler::setMouseButton | ( | osgGA::GUIEventAdapter::MouseButtonMask | mouseButton | ) |
Sets the mouse button used for adding new points
Definition at line 40 of file FeatureEditing.cpp.
{
_mouseButton = mouseButton;
}
osg::ref_ptr< osgEarth::Features::Feature > osgEarth::Util::AddPointHandler::_feature [private] |
Definition at line 71 of file FeatureEditing.
bool osgEarth::Util::AddPointHandler::_firstMove [private] |
Definition at line 69 of file FeatureEditing.
osg::Node::NodeMask osgEarth::Util::AddPointHandler::_intersectionMask [private] |
Definition at line 73 of file FeatureEditing.
osg::ref_ptr<const SpatialReference> osgEarth::Util::AddPointHandler::_mapSRS [private] |
Definition at line 72 of file FeatureEditing.
osgGA::GUIEventAdapter::MouseButtonMask osgEarth::Util::AddPointHandler::_mouseButton [private] |
Definition at line 67 of file FeatureEditing.
bool osgEarth::Util::AddPointHandler::_mouseDown [private] |
Definition at line 68 of file FeatureEditing.
osg::ref_ptr< osgEarth::Features::FeatureListSource > osgEarth::Util::AddPointHandler::_source [private] |
Definition at line 70 of file FeatureEditing.
1.7.3