00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef WGEVIEWER_H
00026 #define WGEVIEWER_H
00027
00028 #include <string>
00029
00030 #include <boost/shared_ptr.hpp>
00031 #include <boost/enable_shared_from_this.hpp>
00032
00033 #include <osg/Node>
00034 #include <osg/Version>
00035 #include <osgGA/DriveManipulator>
00036 #include <osgGA/FlightManipulator>
00037 #include <osgGA/TerrainManipulator>
00038 #include <osgGA/UFOManipulator>
00039 #include <osgViewer/View>
00040
00041
00042
00043 #if ( ( OPENSCENEGRAPH_MAJOR_VERSION > 2 ) || ( OPENSCENEGRAPH_MAJOR_VERSION == 2 && ( OPENSCENEGRAPH_MINOR_VERSION > 9 || \
00044 ( OPENSCENEGRAPH_MINOR_VERSION == 9 && OPENSCENEGRAPH_PATCH_VERSION >= 8 ) ) ) )
00045 #include <osgGA/CameraManipulator>
00046 namespace osgGA
00047 {
00048 typedef CameraManipulator MatrixManipulator;
00049 }
00050 #else
00051 #include <osgGA/MatrixManipulator>
00052 #endif
00053
00054 #include "../common/WColor.h"
00055 #include "../common/WFlag.h"
00056 #include "../common/WThreadedRunner.h"
00057 #include "WExportWGE.h"
00058 #include "WGECamera.h"
00059 #include "WGEGraphicsWindow.h"
00060 #include "WGEGroupNode.h"
00061 #include "WPickHandler.h"
00062
00063
00064
00065
00066
00067
00068 class WGE_EXPORT WGEViewer: public WGEGraphicsWindow,
00069 public boost::enable_shared_from_this< WGEViewer >
00070 {
00071 public:
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int x, int y, int width, int height,
00085 WGECamera::ProjectionMode projectionMode = WGECamera::ORTHOGRAPHIC );
00086
00087
00088
00089
00090 virtual ~WGEViewer();
00091
00092
00093
00094 virtual void paint();
00095
00096
00097
00098
00099
00100
00101
00102 virtual void resize( int width, int height );
00103
00104
00105
00106
00107 virtual void close();
00108
00109
00110
00111
00112
00113
00114 #ifdef __APPLE__
00115 osg::ref_ptr<osgViewer::Viewer> getView();
00116 #else
00117 osg::ref_ptr<osgViewer::View> getView();
00118 #endif
00119
00120
00121
00122
00123 void reset();
00124
00125
00126
00127
00128
00129
00130 void setCameraManipulator( osg::ref_ptr<osgGA::MatrixManipulator> manipulator );
00131
00132
00133
00134
00135
00136
00137 osg::ref_ptr<osgGA::MatrixManipulator> getCameraManipulator();
00138
00139
00140
00141
00142
00143
00144 void setCamera( osg::ref_ptr<osg::Camera> camera );
00145
00146
00147
00148
00149
00150
00151 osg::ref_ptr<osg::Camera> getCamera();
00152
00153
00154
00155
00156
00157
00158 void setScene( osg::ref_ptr< WGEGroupNode > node );
00159
00160
00161
00162
00163
00164
00165 osg::ref_ptr< WGEGroupNode > getScene();
00166
00167
00168
00169
00170
00171
00172 std::string getName() const;
00173
00174
00175
00176
00177
00178 void setBgColor( const WColor& bgColor );
00179
00180
00181
00182
00183
00184
00185 osg::ref_ptr< WPickHandler > getPickHandler();
00186
00187
00188
00189
00190
00191
00192 std::string getOpenGLVendor() const;
00193
00194
00195
00196
00197
00198
00199 WBoolFlag::SPtr isFrameRendered() const;
00200
00201 protected:
00202
00203
00204
00205 #ifdef __APPLE__
00206 osg::ref_ptr< osgViewer::Viewer > m_View;
00207 #else
00208 osg::ref_ptr< osgViewer::View > m_View;
00209 #endif
00210
00211
00212
00213
00214 std::string m_name;
00215
00216
00217
00218
00219 osg::ref_ptr<WPickHandler> m_pickHandler;
00220
00221
00222
00223
00224 osg::ref_ptr< WGEGroupNode > m_scene;
00225
00226
00227
00228
00229 WBoolFlag::SPtr m_rendered;
00230
00231
00232
00233
00234 class QueryCallback: public osg::Camera::DrawCallback
00235 {
00236 public:
00237
00238
00239
00240
00241
00242
00243 QueryCallback( osg::ref_ptr<osg::Camera> camera, WBoolFlag::SPtr run );
00244
00245
00246
00247
00248 virtual ~QueryCallback();
00249
00250
00251
00252
00253
00254
00255 virtual void operator()( osg::RenderInfo& renderInfo ) const;
00256
00257
00258
00259
00260
00261
00262 std::string getVendor() const;
00263
00264 protected:
00265
00266
00267
00268 mutable std::string m_vendor;
00269
00270
00271
00272
00273 WBoolFlag::SPtr m_run;
00274
00275
00276
00277
00278 osg::ref_ptr<osg::Camera> m_camera;
00279 };
00280
00281
00282
00283
00284 osg::ref_ptr< QueryCallback > m_queryCallback;
00285 private:
00286 };
00287
00288 #endif // WGEVIEWER_H