osgEarth 2.1.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

osgEarth::Util::ImageOverlayEditor Class Reference

List of all members.

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)
ControlPointDraggerMapgetDraggers ()
const osg::EllipsoidModel * getEllipsoid () const
void setEllipsoid (const osg::EllipsoidModel *ellipsoid)
osg::Node * getTerrain () const
void setTerrain (osg::Node *terrain)
ImageOverlaygetOverlay ()
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

Detailed Description

Definition at line 13 of file ImageOverlayEditor.


Member Typedef Documentation

typedef std::map< ImageOverlay::ControlPoint, osg::ref_ptr< osgManipulator::Dragger > > osgEarth::Util::ImageOverlayEditor::ControlPointDraggerMap

Definition at line 16 of file ImageOverlayEditor.


Constructor & Destructor Documentation

ImageOverlayEditor::ImageOverlayEditor ( ImageOverlay overlay,
const osg::EllipsoidModel *  ellipsoid,
osg::Node *  terrain 
)
ImageOverlayEditor::~ImageOverlayEditor ( ) [protected]

Definition at line 139 of file ImageOverlayEditor.cpp.

{
    _overlay->removeCallback( _overlayCallback.get() );
}

Member Function Documentation

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

Here is the call graph for this function:

Here is the caller graph for this function:

ControlPointDraggerMap& osgEarth::Util::ImageOverlayEditor::getDraggers ( ) [inline]

Definition at line 20 of file ImageOverlayEditor.

{ return _draggers; }

Here is the caller graph for this function:

const osg::EllipsoidModel* osgEarth::Util::ImageOverlayEditor::getEllipsoid ( ) const [inline]

Definition at line 22 of file ImageOverlayEditor.

{ return _ellipsoid.get();}

Here is the caller graph for this function:

ImageOverlay* osgEarth::Util::ImageOverlayEditor::getOverlay ( ) [inline]

Definition at line 28 of file ImageOverlayEditor.

{ return _overlay.get();}

Here is the caller graph for this function:

osg::Node* osgEarth::Util::ImageOverlayEditor::getTerrain ( ) const [inline]

Definition at line 25 of file ImageOverlayEditor.

{ return _terrain.get(); }

Here is the caller graph for this function:

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

    }
}

Here is the call graph for this function:


Member Data Documentation

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.

Definition at line 37 of file ImageOverlayEditor.

Definition at line 40 of file ImageOverlayEditor.

osg::ref_ptr< osg::Node > osgEarth::Util::ImageOverlayEditor::_terrain [protected]

Definition at line 39 of file ImageOverlayEditor.


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