source: geovis/trunk/Renderer.h @ 6549

Last change on this file since 6549 was 6549, checked in by ldelgass, 8 years ago

Add geovis support for WMS-T animated sequence

File size: 23.1 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2004-2015  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#ifndef GEOVIS_RENDERER_H
9#define GEOVIS_RENDERER_H
10
11#include <sys/time.h> // For struct timeval
12#include <ctime> // For time_t
13#include <string>
14#include <vector>
15#include <tr1/unordered_map>
16#include <typeinfo>
17
18#include <osg/ref_ptr>
19#include <osg/Node>
20#include <osg/Image>
21#include <osg/TransferFunction>
22#include <osgText/String>
23#include <osgViewer/Viewer>
24#include <osgGA/StateSetManipulator>
25#include <osgUtil/IncrementalCompileOperation>
26
27#include <osgEarth/Version>
28#include <osgEarth/StringUtils>
29#include <osgEarth/Map>
30#include <osgEarth/Viewpoint>
31#include <osgEarth/ImageLayer>
32#include <osgEarth/ElevationLayer>
33#include <osgEarth/ModelLayer>
34#include <osgEarth/MaskLayer>
35#include <osgEarth/TileSource>
36#include <osgEarth/ModelSource>
37#include <osgEarth/GeoData>
38#include <osgEarthAnnotation/AnnotationNode>
39#include <osgEarthAnnotation/FeatureNode>
40#include <osgEarthUtil/Sky>
41#include <osgEarthUtil/RTTPicker>
42#include <osgEarthUtil/EarthManipulator>
43#include <osgEarthUtil/MouseCoordsTool>
44#include <osgEarthUtil/Controls>
45#include <osgEarthUtil/Formatter>
46#include <osgEarthUtil/MGRSFormatter>
47#include <osgEarthUtil/AutoClipPlaneHandler>
48#include <osgEarthUtil/VerticalScale>
49
50#define USE_RTT_PICKER
51
52#include "Types.h"
53#include "Trace.h"
54#include "MouseCoordsTool.h"
55#include "ScaleBar.h"
56#include "Placard.h"
57
58// Controls if TGA format is sent to client
59//#define RENDER_TARGA
60#define TARGA_BYTES_PER_PIXEL 3
61
62namespace GeoVis {
63
64class ScreenCaptureCallback : public osg::Camera::DrawCallback
65{
66public:
67    ScreenCaptureCallback(osg::Texture2D *texture = NULL) :
68        osg::Camera::DrawCallback(),
69        _texture(texture)
70    {
71        _image = new osg::Image;
72    }
73
74    virtual void operator()(osg::RenderInfo &renderInfo) const
75    {
76        FRAME("Enter ScreenCaptureCallback");
77        int width, height;
78        if (renderInfo.getCurrentCamera() == NULL) {
79            ERROR("No camera");
80            return;
81        }
82        if (renderInfo.getCurrentCamera()->getViewport() == NULL) {
83            ERROR("No viewport");
84            return;
85        }
86        width = (int)renderInfo.getCurrentCamera()->getViewport()->width();
87        height = (int)renderInfo.getCurrentCamera()->getViewport()->height();
88        FRAME("readPixels: %d x %d", width, height);
89#if 0 //USE_OFFSCREEN_FRAMEBUFFER
90        _image = _texture->getImage();
91#else
92#ifdef RENDER_TARGA
93        _image->readPixels(0, 0, width, height,
94                           GL_BGR, GL_UNSIGNED_BYTE);
95#else
96        _image->readPixels(0, 0, width, height,
97                           GL_RGB, GL_UNSIGNED_BYTE);
98#endif
99#endif
100    }
101
102    osg::Image *getImage()
103    {
104        return _image.get();
105    }
106
107    osg::Texture2D *getTexture()
108    {
109        return _texture.get();
110    }
111
112private:
113    osg::ref_ptr<osg::Texture2D> _texture;
114    osg::ref_ptr<osg::Image> _image;
115};
116
117/**
118 * \brief GIS Renderer
119 */
120class Renderer
121{
122public:
123    typedef std::string ColorMapId;
124    typedef std::string ViewpointId;
125
126    enum GraticuleType {
127        GRATICULE_UTM,
128        GRATICULE_MGRS,
129        GRATICULE_GEODETIC,
130        GRATICULE_SHADER
131    };
132
133    enum CoordinateDisplayType {
134        COORDS_LATLONG_DECIMAL_DEGREES,
135        COORDS_LATLONG_DEGREES_DECIMAL_MINUTES,
136        COORDS_LATLONG_DEGREES_MINUTES_SECONDS,
137        COORDS_MGRS
138    };
139
140    enum SelectMode {
141        SELECT_OFF,
142        SELECT_ON
143    };
144
145    Renderer();
146    virtual ~Renderer();
147
148    void setResourcePath(const std::string& path)
149    {
150        TRACE("Set resource path to %s", path.c_str());
151        _resourcePath = path;
152    }
153
154    void setCacheBaseDirectory(const std::string& path)
155    {
156        TRACE("Set cache base dir to %s", path.c_str());
157        _cacheBaseDir = path;
158    }
159
160    std::string getCacheDirectory() const
161    {
162        return _cacheDir;
163    }
164
165    void setupCache();
166
167    std::string getIconFile(const char *name) const;
168
169    std::string getBaseImage() const;
170
171    std::string getPinIcon() const;
172
173    void setAttribution(const std::string& attrib);
174
175    // Colormaps
176
177    void addColorMap(const ColorMapId& id, osg::TransferFunction1D *xfer);
178
179    void deleteColorMap(const ColorMapId& id);
180
181    void setColorMapNumberOfTableEntries(const ColorMapId& id, int numEntries);
182
183    bool renderColorMap(const ColorMapId& id, int width, int height,
184                        osg::Image *imgData,
185                        bool opaque, float bgColor[3],
186                        bool bgr = false,
187                        int bytesPerPixel = 3) const;
188
189    void getColorMapRange(const ColorMapId& id, float *min, float *max) const;
190
191    std::string getColorMapFilePath(const ColorMapId& id) const;
192
193    void saveCLRFile(const std::string& path, osg::TransferFunction1D *xfer);
194
195    // Scene
196
197    void loadEarthFile(const char *path);
198
199    void resetMap(osgEarth::MapOptions::CoordinateSystemType type,
200                  const osg::Vec4f& bgColor = osg::Vec4f(1,1,1,1),
201                  const char *profile = NULL,
202                  double bounds[4] = NULL);
203
204    void clearMap();
205
206    // Map options
207
208    void setCoordinateReadout(bool state,
209                              CoordinateDisplayType type = COORDS_LATLONG_DECIMAL_DEGREES,
210                              int precision = -1);
211
212    void setReadout(int mouseX, int mouseY);
213
214    void clearReadout();
215
216    void setScaleBar(bool state);
217
218    void setScaleBarUnits(ScaleBarUnits units);
219
220    void setGraticule(bool enable, GraticuleType type = GRATICULE_SHADER);
221
222    void setViewerLightType(osg::View::LightingMode mode);
223
224    void setLighting(bool state);
225
226    void setTerrainColor(const osg::Vec4f& color);
227
228    void setTerrainEdges(bool state) {}
229
230    void setTerrainLineColor(const osg::Vec4f& color) {}
231
232    void setTerrainLineWidth(float width) {}
233
234    void setTerrainLighting(bool state);
235
236    void setTerrainVerticalScale(double scale);
237
238    void setTerrainWireframe(bool state);
239
240    void setEphemerisTime(time_t utcTime);
241
242    void setEphemerisTime(int year, int month, int day, double hours);
243
244    void setSkyAmbient(float ambientLevel);
245
246    // Image raster layers
247
248    int getNumImageLayers() const
249    {
250        return (_map.valid() ? _map->getNumImageLayers() : 0);
251    }
252
253    void getImageLayerNames(std::vector<std::string>& names) const
254    {
255        if (_map.valid()) {
256            osgEarth::ImageLayerVector layerVector;
257            _map->getImageLayers(layerVector);
258            osgEarth::ImageLayerVector::const_iterator itr;
259            for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
260                //osgEarth::UID uid = (*itr)->getUID();
261                names.push_back((*itr)->getName());
262            }
263        }
264    }
265
266    bool addImageLayer(const char *name,
267                       osgEarth::TileSourceOptions& opts,
268                       unsigned int pos = UINT_MAX,
269                       bool enableCache = true,
270                       bool coverage = false,
271                       bool makeShared = false,
272                       bool visible = true,
273                       unsigned int minLOD = 0,
274                       unsigned int maxLOD = 23);
275
276    void removeImageLayer(const char *name);
277
278    void moveImageLayer(const char *name, unsigned int pos);
279
280    bool getImageLayerExtent(const char *name, osgEarth::GeoExtent &ext);
281
282    void setImageLayerVisibleRange(const char *name, float min, float max);
283
284    void setImageLayerLODRange(const char *name, int min, int max);
285
286    void setImageLayerOpacity(const char *name, double opacity);
287
288    void setImageLayerVisibility(const char *name, bool state);
289
290    void addColorFilter(const char *name, const char *shader);
291
292    void removeColorFilter(const char *name, int idx = -1);
293
294    // Sequence control
295
296    bool layerHasSequence(const char *name);
297
298    bool sequencePause(const char *name);
299
300    bool sequencePlay(const char *name);
301
302    bool sequenceSeek(const char *name, unsigned int frame);
303
304    // Elevation raster layers
305
306    int getNumElevationLayers() const
307    {
308        return (_map.valid() ? _map->getNumElevationLayers() : 0);
309    }
310
311    void getElevationLayerNames(std::vector<std::string>& names) const
312    {
313        if (_map.valid()) {
314            osgEarth::ElevationLayerVector layerVector;
315            _map->getElevationLayers(layerVector);
316            osgEarth::ElevationLayerVector::const_iterator itr;
317            for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
318                //osgEarth::UID uid = (*itr)->getUID();
319                names.push_back((*itr)->getName());
320            }
321        }
322    }
323
324    void addElevationLayer(const char *name,
325                           osgEarth::TileSourceOptions& opts,
326                           unsigned int pos = UINT_MAX,
327                           bool enableCache = true,
328                           bool visible = true,
329                           const char *verticalDatum = NULL,
330                           unsigned int minLOD = 0,
331                           unsigned int maxLOD = 23);
332
333    void removeElevationLayer(const char *name);
334
335    void moveElevationLayer(const char *name, unsigned int pos);
336
337    bool getElevationLayerExtent(const char *name, osgEarth::GeoExtent &ext);
338
339    void setElevationLayerVisibleRange(const char *name, float min, float max);
340
341    void setElevationLayerVisibility(const char *name, bool state);
342
343    // Terrain mask layers
344
345    int getNumTerrainMaskLayers() const
346    {
347        if (!_map.valid()) return 0;
348
349        osgEarth::MaskLayerVector layers;
350        _map->getTerrainMaskLayers(layers);
351        return (int)layers.size();
352    }
353
354    void getTerrainMaskLayerNames(std::vector<std::string>& names) const
355    {
356        if (_map.valid()) {
357            osgEarth::MaskLayerVector layerVector;
358            _map->getTerrainMaskLayers(layerVector);
359            osgEarth::MaskLayerVector::const_iterator itr;
360            for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
361                //osgEarth::UID uid = (*itr)->getUID();
362                names.push_back((*itr)->getName());
363            }
364        }
365    }
366
367    osgEarth::MaskLayer *getTerrainMaskLayerByName(const std::string& name)
368    {
369        if (!_map.valid())
370            return NULL;
371
372        osgEarth::MaskLayerVector layerVector;
373        _map->getTerrainMaskLayers(layerVector);
374        osgEarth::MaskLayerVector::iterator itr;
375        for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
376            if ((*itr)->getName() == name) {
377                return (*itr).get();
378            }
379        }
380        return NULL;
381    }
382
383    void addTerrainMaskLayer(const char *name,
384                             osgEarth::MaskSourceOptions& opts,
385                             unsigned int minLOD = 0);
386
387    void removeTerrainMaskLayer(const char *name);
388
389    bool getTerrainMaskLayerExtent(const char *name, osgEarth::GeoExtent &ext);
390
391    // Model layers
392
393    int getNumModelLayers() const
394    {
395        return (_map.valid() ? _map->getNumModelLayers() : 0);
396    }
397
398    void getModelLayerNames(std::vector<std::string>& names) const
399    {
400        if (_map.valid()) {
401            osgEarth::ModelLayerVector layerVector;
402            _map->getModelLayers(layerVector);
403            osgEarth::ModelLayerVector::const_iterator itr;
404            for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
405                //osgEarth::UID uid = (*itr)->getUID();
406                names.push_back((*itr)->getName());
407            }
408        }
409    }
410
411    void addModelLayer(const char *name,
412                       osgEarth::ModelSourceOptions& opts,
413                       unsigned int pos = UINT_MAX,
414                       bool enableCache = true,
415                       bool lighting = true,
416                       bool visible = true,
417                       bool terrainPatch = false);
418
419    void removeModelLayer(const char *name);
420
421    void moveModelLayer(const char *name, unsigned int pos);
422
423    bool getModelLayerExtent(const char *name, osgEarth::GeoExtent &ext);
424
425    //void setModelLayerVisibleRange(const char *name, float min, float max);
426
427    void setModelLayerOpacity(const char *name, double opacity);
428
429    void setModelLayerVisibility(const char *name, bool state);
430
431    // Render window
432
433    void setWindowSize(int width, int height);
434
435    int getWindowWidth() const
436    {
437        return _windowWidth;
438    }
439
440    int getWindowHeight() const
441    {
442        return _windowHeight;
443    }
444
445    // Camera
446
447    void saveNamedViewpoint(const char *name);
448
449    bool restoreNamedViewpoint(const char *name, double durationSecs);
450
451    bool removeNamedViewpoint(const char *name);
452
453    osgEarth::Viewpoint getViewpoint();
454
455    void setViewpoint(const osgEarth::Viewpoint& v, double durationSecs = 0.0);
456
457    double getMaxDistanceFromExtent(const osgEarth::GeoExtent& extent);
458
459    void setViewpointFromExtent(const osgEarth::GeoExtent& ext,
460                                double durationSecs = 0.0);
461
462    void setViewpointFromRect(double xmin, double ymin,
463                              double xmax, double ymax,
464                              const osgEarth::SpatialReference *srs = NULL,
465                              double durationSecs = 0.0);
466
467    void resetCamera(bool resetOrientation = true);
468
469    void setCameraOrientation(const double quat[4], bool absolute = true);
470
471    void panCamera(double x, double y);
472
473    void rotateCamera(double x, double y);
474
475    void zoomCamera(double z);
476
477    void setCameraDistance(double dist);
478
479    // Keyboard events
480
481    void keyPress(int key);
482
483    void keyRelease(int key);
484
485    // Mouse events
486
487    void setThrowingEnabled(bool state);
488
489    void mouseClick(int button, double x, double y);
490
491    void mouseDoubleClick(int button, double x, double y);
492
493    void mouseDrag(int button, double x, double y);
494
495    void mouseRelease(int button, double x, double y);
496
497    void mouseMotion(double x, double y);
498
499    void mouseScroll(int direction);
500
501    void pickPending(bool value)
502    { _pickPending = value; }
503
504    // Rendering an image
505
506    void setBackgroundColor(float color[3]);
507
508    void eventuallyRender();
509
510    bool render();
511
512    osg::Image *getRenderedFrame();
513
514    bool mapMouseCoords(float mouseX, float mouseY,
515                        osgEarth::GeoPoint &pt, bool invertY = true);
516
517    double computeMapScale();
518
519    const osgEarth::SpatialReference *getMapSRS()
520    {
521        if (_mapNode.valid()) {
522            return _mapNode->getMapSRS();
523        } else {
524            return NULL;
525        }
526    }
527
528    void addPlaceNode(double latitude, double longitude, char *labelText);
529
530    void hoverPlaceNode(int x, int y, bool invertY = true);
531
532    void deletePlaceNode(int x, int y, bool invertY = true);
533
534    bool getMousePoint(double *x, double *y, double *z)
535    {
536        return (_coordsCallback.valid() && _coordsCallback->report(x, y, z));
537    }
538
539    bool mouseToLatLong(int mouseX, int mouseY,
540                        double *latitude, double *longitude);
541
542    bool getWorldCoords(const osgEarth::GeoPoint& mapPt, osg::Vec3d *world);
543
544    bool worldToScreen(const osg::Vec3d& world, osg::Vec3d *screen,
545                       bool invertY = true);
546
547    bool worldToScreen(std::vector<osg::Vec3d>& coords, bool invertY = true);
548
549    void setMaximumFrameRateInHertz(double rate)
550    {
551        if (rate > 60.0)
552            rate = 60.0;
553        if (rate < 0.25)
554            rate = 0.25;
555        _minFrameTime = 1.0/rate;
556        if (_viewer.valid()) {
557            osgUtil::IncrementalCompileOperation *op =
558                _viewer->getDatabasePager()->getIncrementalCompileOperation();
559            if (op != NULL) {
560                TRACE("Setting DB Pager target frame rate to %g", rate);
561                op->setTargetFrameRate(rate);
562            }
563        }
564        TRACE("Frame rate target: %.2f Hz", (float)getMaximumFrameRateInHertz());
565        TRACE("Frame time target: %.2f msec", _minFrameTime * 1000.0f);
566    }
567
568    void setMaximumBitrate(double bitsPerSecond)
569    {
570        TRACE("Setting max bitrate to %g", bitsPerSecond);
571        unsigned long bitsPerFrame = (_windowWidth * _windowHeight * 3 + 16) * 8;
572        double fps = bitsPerSecond / ((double)bitsPerFrame);
573        setMaximumFrameRateInHertz(fps);
574        TRACE("Bandwidth target: %.2f Mbps", (float)(getMaximumBitrate()/1.0e6));
575    }
576
577    double getMaximumFrameRateInHertz()
578    {
579        return (1.0/_minFrameTime);
580    }
581
582    double getMaximumBitrate()
583    {
584        unsigned long bitsPerFrame = (_windowWidth * _windowHeight * 3 + 16) * 8;
585        return ((double)bitsPerFrame * getMaximumFrameRateInHertz());
586    }
587
588    void markFrameStart();
589
590    void markFrameEnd();
591
592    void setIdleTimeout(long timeout)
593    {
594        if (timeout != -1L &&
595            (double)timeout < _minFrameTime) {
596            ERROR("Timeout must be more than %g sec", _minFrameTime);
597            return;
598        }
599        TRACE("Setting idle timeout to %ld sec", timeout);
600        _idleTimeout = timeout;
601    }
602
603    long getIdleTimeout()
604    {
605        return _idleTimeout;
606    }
607
608    void getTimeout(struct timeval *tv);
609
610    void mapNodeUpdate();
611
612    std::string getCanonicalPath(const std::string& url) const;
613
614    void writeScene(const std::string& file);
615
616    // Placard info window
617
618    void enablePlacard(const char *layerName, bool state);
619
620    void setPlacardConfig(const Placard& placardConf, const char *layerName);
621
622    Placard getPlacardConfig(const char *layerName)
623    {
624        Placard ret;
625        PlacardHashmap::iterator itr = _placardConfigs.find(layerName);
626        if (itr != _placardConfigs.end()) {
627            ret = itr->second;
628        }
629        return ret;
630    }
631
632    // Selection
633
634    void setSelectMode(SelectMode mode);
635
636    void selectFeatures(std::vector<unsigned long>& featureIDs,
637                        const char *layerName, bool clear = true);
638
639    void deselectFeatures(std::vector<unsigned long>& featureIDs,
640                          const char *layerName);
641
642    void addPlacard(const osgEarth::GeoPoint& location,
643                    osgEarth::Features::Feature *feature,
644                    const char *layerName);
645
646    void clearSelection();
647
648    void addRhumbBox(double latMin, double latMax,
649                     double longMin, double longMax);
650
651    void initBoxSelection(int x, int y);
652    void updateBoxSelection(int x, int y);
653    void getBoxSelection(double *latMin, double *latMax,
654                         double *longMin, double *longMax,
655                         const osgEarth::SpatialReference *outSRS = NULL);
656    void clearBoxSelection();
657
658    // These methods are based on the deprecated annotation API
659    bool select(osgEarth::Annotation::AnnotationNode *node)
660    {
661        if (_selected.find(node) == _selected.end()) {
662            _selected.insert(node);
663            return true;
664        } else {
665            return false;
666        }
667    }
668    std::set<osgEarth::Annotation::AnnotationNode*>& getHovered()
669    { return _hovered; }
670    std::set<osgEarth::Annotation::AnnotationNode*>& getSelected()
671    { return _selected; }
672
673    // Scene Graph
674
675    osg::Group *getSceneRoot()
676    { return _sceneRoot.get(); }
677    osgEarth::MapNode *getMapNode()
678    { return _mapNode.get(); }
679    osg::Group *getAnnotations()
680    {
681        initAnnotations();
682        return _annotations.get();
683    }
684    osg::Group *getPlaceNodes()
685    {
686        initAnnotations();
687        return _placeNodes.get();
688    }
689
690private:
691    typedef std::tr1::unordered_map<ColorMapId, osg::ref_ptr<osg::TransferFunction1D> > ColorMapHashmap;
692    typedef std::tr1::unordered_map<ViewpointId, osgEarth::Viewpoint> ViewpointHashmap;
693    typedef std::tr1::unordered_map<std::string, Placard> PlacardHashmap;
694    typedef std::tr1::unordered_map<std::string, std::set<unsigned long> > FeatureSelectionHashmap;
695
696    void initAnnotations();
697
698    void clearSelectionAnnotationNodes();
699
700    void initViewer();
701
702    void finalizeViewer();
703   
704    void initControls();
705
706    void updateDebugLabel();
707
708    void initEarthManipulator();
709
710    void initMouseCoordsTool(CoordinateDisplayType type = COORDS_LATLONG_DECIMAL_DEGREES,
711                             int precision = -1);
712
713    osgEarth::Util::MGRSFormatter::Precision getMGRSPrecision(int precisionInMeters);
714
715    void initColorMaps();
716
717    void initCamera();
718
719    bool isPagerIdle();
720
721    bool checkNeedToDoFrame();
722
723    osgGA::EventQueue *getEventQueue();
724
725    bool _needsRedraw;
726    int _windowWidth, _windowHeight;
727    double _mapScale;
728    float _bgColor[3];
729
730    long _idleTimeout;
731    double _minFrameTime;
732    double _lastFrameTime;
733    double _renderTime;
734    osg::Timer_t _startFrameTime;
735    osg::Timer_t _renderStartTime;
736    osg::Timer_t _renderStopTime;
737
738    ColorMapHashmap _colorMaps;
739
740    std::string _resourcePath;
741    std::string _cacheBaseDir;
742    std::string _cacheDir;
743    std::string _baseURI;
744    std::string _attribution;
745
746    osg::ref_ptr<osg::Group> _sceneRoot;
747    osg::ref_ptr<osg::Group> _graticule;
748    osg::ref_ptr<osg::Group> _annotations;
749    PlacardHashmap _placardConfigs;
750    double _anchorLat, _anchorLong;
751    SelectMode _selectMode;
752    osg::ref_ptr<osgEarth::Annotation::FeatureNode> _selectionBox;
753#ifdef USE_RTT_PICKER
754    osg::ref_ptr<osgEarth::Util::RTTPicker> _picker;
755#endif
756    bool _pickPending;
757    osg::ref_ptr<osg::Group> _placeNodes;
758    FeatureSelectionHashmap _selectedFeatures;
759    std::set<osgEarth::Annotation::AnnotationNode *> _hovered;
760    std::set<osgEarth::Annotation::AnnotationNode *> _selected;
761    osg::ref_ptr<osgEarth::MapNode> _mapNode;
762    osg::ref_ptr<osgEarth::Map> _map;
763    osg::ref_ptr<osgEarth::Util::SkyNode> _skyNode;
764    osg::ref_ptr<osgViewer::Viewer> _viewer;
765    osg::ref_ptr<ScreenCaptureCallback> _captureCallback;
766    osg::ref_ptr<osgEarth::Util::AutoClipPlaneCullCallback> _clipPlaneCullCallback;
767    osg::ref_ptr<osgEarth::Util::Controls::HBox> _coordsBox;
768    osg::ref_ptr<MouseCoordsTool> _mouseCoordsTool;
769    osg::ref_ptr<MouseCoordsCallback> _coordsCallback;
770    osg::ref_ptr<osgEarth::Util::Controls::HBox> _debugBox;
771    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _debugLabel;
772    osg::ref_ptr<osgEarth::Util::Controls::HBox> _copyrightScaleBox;
773    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _copyrightLabel;
774    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _scaleLabel;
775    osg::ref_ptr<osgEarth::Util::Controls::Frame> _scaleBar;
776    ScaleBarUnits _scaleBarUnits;
777    osg::ref_ptr<osgEarth::Util::EarthManipulator> _manipulator;
778    osg::ref_ptr<osgGA::StateSetManipulator> _stateManip;
779    osg::ref_ptr<osgEarth::Util::VerticalScale> _verticalScale;
780    ViewpointHashmap _viewpoints;
781};
782
783class MapNodeCallback : public osg::NodeCallback
784{
785public:
786    MapNodeCallback(Renderer *renderer) :
787        _renderer(renderer)
788    {}
789
790    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
791    {
792        _renderer->mapNodeUpdate();
793        traverse(node, nv);
794    }
795private:
796    Renderer *_renderer;
797};
798
799class SelectPlaceNodesVisitor : public osg::NodeVisitor
800{
801public:
802    SelectPlaceNodesVisitor(Renderer *renderer,
803                            double latMin, double latMax,
804                            double longMin, double longMax) :
805        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
806        _renderer(renderer),
807        _latMin(latMin), _latMax(latMax),
808        _longMin(longMin), _longMax(longMax)
809    {}
810
811    virtual void apply(osg::Node& node);
812
813private:
814    Renderer *_renderer;
815    double _latMin, _latMax, _longMin, _longMax;
816};
817
818}
819
820#endif
Note: See TracBrowser for help on using the repository browser.