osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthFeatures/FilterContext

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2010 Pelican Mapping
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 #ifndef OSGEARTHFEATURES_FILTER_CONTEXT_H
00020 #define OSGEARTHFEATURES_FILTER_CONTEXT_H 1
00021 
00022 #include <osgEarthFeatures/Common>
00023 #include <osgEarthFeatures/Feature>
00024 #include <osgEarthFeatures/OptimizerHints>
00025 #include <osgEarthFeatures/Session>
00026 #include <osgEarthSymbology/ResourceCache>
00027 #include <osgEarth/GeoData>
00028 #include <osg/Matrix>
00029 #include <list>
00030 
00031 namespace osgEarth { namespace Features
00032 {
00033     using namespace osgEarth;
00034     using namespace osgEarth::Symbology;
00035     class Session;
00036 
00040     class OSGEARTHFEATURES_EXPORT FilterContext
00041     {
00042     public:
00043         FilterContext(
00044             Session*              session       =0L,
00045             const FeatureProfile* profile       =0L,
00046             const GeoExtent&      workingExtent =GeoExtent::INVALID );
00047 
00048         FilterContext( const FilterContext& rhs );
00049 
00054         void setResourceCache( ResourceCache* value ) { _resourceCache = value; }
00055 
00056     public: // properties
00057 
00061         Session* getSession() { return _session.get(); }
00062         const Session* getSession() const { return _session.get(); }
00063 
00067         const FeatureProfile* profile() const { return _profile.get(); }
00068         osg::ref_ptr<const FeatureProfile>& profile() { return _profile; }
00069 
00073         optional<GeoExtent>& extent() { return _extent; }
00074         const optional<GeoExtent>& extent() const { return _extent; }
00075 
00079         bool isGeocentric() const { return _isGeocentric; }
00080         bool& isGeocentric() { return _isGeocentric; }
00081 
00085         bool hasReferenceFrame() const { return !_referenceFrame.isIdentity(); }
00086 
00090         osg::Vec3d toLocal( const osg::Vec3d& world ) const { return world * _referenceFrame; }
00091 
00095         void toLocal( Geometry* geom ) const;
00096 
00100         osg::Vec3d toWorld( const osg::Vec3d& local ) const { return local * _inverseReferenceFrame; }
00101 
00105         void toWorld( Geometry* geom ) const;
00106 
00110         osg::Vec3d toMap( const osg::Vec3d& local ) const;
00111 
00115         osg::Vec3d fromMap( const osg::Vec3d& map ) const;
00116 
00120         const osg::Matrixd& referenceFrame() const { return _referenceFrame; }
00121 
00125         const osg::Matrix& inverseReferenceFrame() const { return _inverseReferenceFrame; }
00126 
00130         void setReferenceFrame( const osg::Matrixd& in ) {
00131             _referenceFrame = in;
00132             _inverseReferenceFrame.invert( _referenceFrame ); // = osg::Matrixd::inverse( _referenceFrame );
00133         }      
00134 
00138         ResourceCache* resourceCache() { return _resourceCache.get(); }
00139 
00144         OptimizerHints& optimizerHints() { return _optimizerHints; }
00145 
00147         std::string toString() const;
00148 
00149     protected:
00150         osg::ref_ptr<Session>              _session;
00151         osg::ref_ptr<const FeatureProfile> _profile;
00152         bool                               _isGeocentric;
00153         optional<GeoExtent>                _extent;
00154         osg::Matrixd                       _referenceFrame;
00155         osg::Matrixd                       _inverseReferenceFrame;
00156         OptimizerHints                     _optimizerHints;
00157         osg::ref_ptr<ResourceCache>        _resourceCache;
00158     };
00159 
00160 } } // namespace osgEarth::Features
00161 
00162 #endif // OSGEARTHFEATURES_FILTER_CONTEXT_H
00163 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines