osgEarth 2.1.1
|
Public Types | |
typedef std::map < ImageOverlay::ControlPoint, osg::ref_ptr < osgManipulator::Dragger > > | ControlPointDraggerMap |
Public Member Functions | |
ImageOverlayEditor (ImageOverlay *overlay, const osg::EllipsoidModel *ellipsoid, osg::Node *terrain) | |
ControlPointDraggerMap & | getDraggers () |
const osg::EllipsoidModel * | getEllipsoid () const |
void | setEllipsoid (const osg::EllipsoidModel *ellipsoid) |
osg::Node * | getTerrain () const |
void | setTerrain (osg::Node *terrain) |
ImageOverlay * | getOverlay () |
void | updateDraggers () |
Protected Member Functions | |
~ImageOverlayEditor () | |
void | addDragger (ImageOverlay::ControlPoint controlPoint) |
Protected Attributes | |
osg::ref_ptr< ImageOverlay > | _overlay |
osg::ref_ptr< const osg::EllipsoidModel > | _ellipsoid |
osg::ref_ptr< osg::Node > | _terrain |
osg::ref_ptr < osgEarth::Util::ImageOverlay::ImageOverlayCallback > | _overlayCallback |
ControlPointDraggerMap | _draggers |
Definition at line 13 of file ImageOverlayEditor.
typedef std::map< ImageOverlay::ControlPoint, osg::ref_ptr< osgManipulator::Dragger > > osgEarth::Util::ImageOverlayEditor::ControlPointDraggerMap |
Definition at line 16 of file ImageOverlayEditor.
ImageOverlayEditor::ImageOverlayEditor | ( | ImageOverlay * | overlay, |
const osg::EllipsoidModel * | ellipsoid, | ||
osg::Node * | terrain | ||
) |
Definition at line 125 of file ImageOverlayEditor.cpp.
: _overlay(overlay), _ellipsoid(ellipsoid), _terrain(terrain) { _overlayCallback = new OverlayCallback(this); _overlay->addCallback( _overlayCallback.get() ); addDragger( ImageOverlay::CONTROLPOINT_CENTER ); addDragger( ImageOverlay::CONTROLPOINT_LOWER_LEFT ); addDragger( ImageOverlay::CONTROLPOINT_LOWER_RIGHT ); addDragger( ImageOverlay::CONTROLPOINT_UPPER_LEFT ); addDragger( ImageOverlay::CONTROLPOINT_UPPER_RIGHT ); }
ImageOverlayEditor::~ImageOverlayEditor | ( | ) | [protected] |
Definition at line 139 of file ImageOverlayEditor.cpp.
{ _overlay->removeCallback( _overlayCallback.get() ); }
void ImageOverlayEditor::addDragger | ( | ImageOverlay::ControlPoint | controlPoint | ) | [protected] |
Definition at line 145 of file ImageOverlayEditor.cpp.
{ osg::Vec2d location = _overlay->getControlPoint( controlPoint ); osg::Matrixd matrix; _ellipsoid->computeLocalToWorldTransformFromLatLongHeight(osg::DegreesToRadians(location.y()), osg::DegreesToRadians(location.x()), 0, matrix); IntersectingDragger* dragger = new IntersectingDragger; dragger->setNode( _terrain.get() ); dragger->setupDefaultGeometry(); dragger->setMatrix(matrix); dragger->setHandleEvents( true ); dragger->addDraggerCallback(new ImageOverlayDraggerCallback(_overlay.get(), _ellipsoid.get(), controlPoint)); addChild(dragger); _draggers[ controlPoint ] = dragger; }
ControlPointDraggerMap& osgEarth::Util::ImageOverlayEditor::getDraggers | ( | ) | [inline] |
Definition at line 20 of file ImageOverlayEditor.
{ return _draggers; }
const osg::EllipsoidModel* osgEarth::Util::ImageOverlayEditor::getEllipsoid | ( | ) | const [inline] |
Definition at line 22 of file ImageOverlayEditor.
{ return _ellipsoid.get();}
ImageOverlay* osgEarth::Util::ImageOverlayEditor::getOverlay | ( | ) | [inline] |
Definition at line 28 of file ImageOverlayEditor.
{ return _overlay.get();}
osg::Node* osgEarth::Util::ImageOverlayEditor::getTerrain | ( | ) | const [inline] |
Definition at line 25 of file ImageOverlayEditor.
{ return _terrain.get(); }
void osgEarth::Util::ImageOverlayEditor::setEllipsoid | ( | const osg::EllipsoidModel * | ellipsoid | ) | [inline] |
Definition at line 23 of file ImageOverlayEditor.
{ _ellipsoid = ellipsoid; };
void osgEarth::Util::ImageOverlayEditor::setTerrain | ( | osg::Node * | terrain | ) | [inline] |
Definition at line 26 of file ImageOverlayEditor.
{ _terrain = terrain;}
void ImageOverlayEditor::updateDraggers | ( | ) |
Definition at line 163 of file ImageOverlayEditor.cpp.
{ for (ImageOverlayEditor::ControlPointDraggerMap::iterator itr = getDraggers().begin(); itr != getDraggers().end(); ++itr) { //Get the location of the control point osg::Vec2d location = getOverlay()->getControlPoint( itr->first ); osg::Matrixd matrix; //Compute the geocentric location osg::ref_ptr< const osg::EllipsoidModel > ellipsoid = getEllipsoid(); osg::Vec3d geo_loc; ellipsoid->convertLatLongHeightToXYZ(osg::DegreesToRadians(location.y()), osg::DegreesToRadians(location.x()), 0, geo_loc.x(), geo_loc.y(), geo_loc.z()); osg::Vec3d up = geo_loc; up.normalize(); double segOffset = 50000; osg::Vec3d start = geo_loc + (up * segOffset); osg::Vec3d end = geo_loc - (up * segOffset); osgUtil::LineSegmentIntersector* i = new osgUtil::LineSegmentIntersector( start, end ); osgUtil::IntersectionVisitor iv; iv.setIntersector( i ); getTerrain()->accept( iv ); osgUtil::LineSegmentIntersector::Intersections& results = i->getIntersections(); if ( !results.empty() ) { const osgUtil::LineSegmentIntersector::Intersection& result = *results.begin(); geo_loc = result.getWorldIntersectPoint(); } getEllipsoid()->computeLocalToWorldTransformFromXYZ(geo_loc.x(), geo_loc.y(), geo_loc.z(), matrix); itr->second.get()->setMatrix( matrix ); } }
Definition at line 41 of file ImageOverlayEditor.
osg::ref_ptr< const osg::EllipsoidModel > osgEarth::Util::ImageOverlayEditor::_ellipsoid [protected] |
Definition at line 38 of file ImageOverlayEditor.
osg::ref_ptr< ImageOverlay > osgEarth::Util::ImageOverlayEditor::_overlay [protected] |
Definition at line 37 of file ImageOverlayEditor.
osg::ref_ptr< osgEarth::Util::ImageOverlay::ImageOverlayCallback > osgEarth::Util::ImageOverlayEditor::_overlayCallback [protected] |
Definition at line 40 of file ImageOverlayEditor.
osg::ref_ptr< osg::Node > osgEarth::Util::ImageOverlayEditor::_terrain [protected] |
Definition at line 39 of file ImageOverlayEditor.