osgEarth 2.1.1
|
00001 #ifndef OSGEARTH_UTIL_IMAGE_OVERLAY_H 00002 #define OSGEARTH_UTIL_IMAGE_OVERLAY_H 00003 00004 #include <osgEarthUtil/Common> 00005 #include <osgEarth/GeoData> 00006 #include <osgEarth/DrapeableNode> 00007 #include <osgEarth/Units> 00008 00009 #include <osg/Group> 00010 #include <osg/Geometry> 00011 #include <osg/Image> 00012 #include <osg/CoordinateSystemNode> 00013 00014 namespace osgEarth { namespace Util 00015 { 00016 class OSGEARTHUTIL_EXPORT ImageOverlay : public DrapeableNode 00017 { 00018 public: 00019 00020 enum ControlPoint 00021 { 00022 CONTROLPOINT_CENTER, 00023 CONTROLPOINT_LOWER_LEFT, 00024 CONTROLPOINT_LOWER_RIGHT, 00025 CONTROLPOINT_UPPER_LEFT, 00026 CONTROLPOINT_UPPER_RIGHT 00027 }; 00028 00029 ImageOverlay(MapNode* mapNode, osg::Image* image = NULL); 00030 00031 void setCorners(const osg::Vec2d& lowerLeft, const osg::Vec2d& lowerRight, 00032 const osg::Vec2d& upperLeft, const osg::Vec2d& upperRight); 00033 00034 void setLowerLeft(double lon_deg, double lat_deg); 00035 const osg::Vec2d& getLowerLeft() const { return _lowerLeft; } 00036 00037 void setLowerRight(double lon_deg, double lat_deg); 00038 const osg::Vec2d& getLowerRight() const { return _lowerRight;} 00039 00040 void setUpperLeft(double lon_deg, double lat_deg); 00041 const osg::Vec2d& getUpperLeft() const { return _upperLeft; } 00042 00043 void setUpperRight(double lon_deg, double lat_deg); 00044 const osg::Vec2d& getUpperRight() const { return _upperRight;} 00045 00046 osg::Vec2d getCenter() const; 00047 void setCenter(double lon_deg, double lat_deg); 00048 00049 osg::Vec2d getControlPoint(ControlPoint controlPoint); 00050 void setControlPoint(ControlPoint controlPoint, double lon_deg, double lat_deg, bool singleVert=false); 00051 00052 struct ImageOverlayCallback : public osg::Referenced 00053 { 00054 virtual void onOverlayChanged() {}; 00055 }; 00056 00057 typedef std::list< osg::ref_ptr<ImageOverlayCallback> > CallbackList; 00058 00059 void addCallback( ImageOverlayCallback* callback ); 00060 void removeCallback( ImageOverlayCallback* callback ); 00061 00062 00063 osgEarth::Bounds getBounds() const; 00064 void setBounds(const osgEarth::Bounds& bounds); 00065 00066 void setBoundsAndRotation(const osgEarth::Bounds& bounds, const Angular& rotation); 00067 00068 osg::Image* getImage() const; 00069 void setImage( osg::Image* image ); 00070 00071 void setNorth(double value_deg); 00072 void setSouth(double value_deg); 00073 void setEast(double value_deg); 00074 void setWest(double value_deg); 00075 00076 float getAlpha() const; 00077 void setAlpha(float alpha); 00078 00079 virtual void traverse(osg::NodeVisitor& nv); 00080 00081 void dirty(); 00082 private: 00083 void fireCallback(ImageOverlay::ControlPoint point, const osg::Vec2d& location); 00084 00085 void postCTOR(); 00086 void init(); 00087 void clampLatitudes(); 00088 osg::Vec2d _lowerLeft; 00089 osg::Vec2d _lowerRight; 00090 osg::Vec2d _upperRight; 00091 osg::Vec2d _upperLeft; 00092 osg::ref_ptr< osg::Image > _image; 00093 bool _dirty; 00094 OpenThreads::Mutex _mutex; 00095 osg::Geode* _geode; 00096 osg::Geometry* _geometry; 00097 float _alpha; 00098 CallbackList _callbacks; 00099 }; 00100 00101 } } // namespace osgEarth::Util 00102 00103 #endif // OSGEARTH_UTIL_IMAGE_OVERLAY_H 00104