source: geovis/trunk/Renderer.h @ 6517

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

Add comments to header

File size: 22.8 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    // Elevation raster layers
295
296    int getNumElevationLayers() const
297    {
298        return (_map.valid() ? _map->getNumElevationLayers() : 0);
299    }
300
301    void getElevationLayerNames(std::vector<std::string>& names) const
302    {
303        if (_map.valid()) {
304            osgEarth::ElevationLayerVector layerVector;
305            _map->getElevationLayers(layerVector);
306            osgEarth::ElevationLayerVector::const_iterator itr;
307            for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
308                //osgEarth::UID uid = (*itr)->getUID();
309                names.push_back((*itr)->getName());
310            }
311        }
312    }
313
314    void addElevationLayer(const char *name,
315                           osgEarth::TileSourceOptions& opts,
316                           unsigned int pos = UINT_MAX,
317                           bool enableCache = true,
318                           bool visible = true,
319                           const char *verticalDatum = NULL,
320                           unsigned int minLOD = 0,
321                           unsigned int maxLOD = 23);
322
323    void removeElevationLayer(const char *name);
324
325    void moveElevationLayer(const char *name, unsigned int pos);
326
327    bool getElevationLayerExtent(const char *name, osgEarth::GeoExtent &ext);
328
329    void setElevationLayerVisibleRange(const char *name, float min, float max);
330
331    void setElevationLayerVisibility(const char *name, bool state);
332
333    // Terrain mask layers
334
335    int getNumTerrainMaskLayers() const
336    {
337        if (!_map.valid()) return 0;
338
339        osgEarth::MaskLayerVector layers;
340        _map->getTerrainMaskLayers(layers);
341        return (int)layers.size();
342    }
343
344    void getTerrainMaskLayerNames(std::vector<std::string>& names) const
345    {
346        if (_map.valid()) {
347            osgEarth::MaskLayerVector layerVector;
348            _map->getTerrainMaskLayers(layerVector);
349            osgEarth::MaskLayerVector::const_iterator itr;
350            for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
351                //osgEarth::UID uid = (*itr)->getUID();
352                names.push_back((*itr)->getName());
353            }
354        }
355    }
356
357    osgEarth::MaskLayer *getTerrainMaskLayerByName(const std::string& name)
358    {
359        if (!_map.valid())
360            return NULL;
361
362        osgEarth::MaskLayerVector layerVector;
363        _map->getTerrainMaskLayers(layerVector);
364        osgEarth::MaskLayerVector::iterator itr;
365        for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
366            if ((*itr)->getName() == name) {
367                return (*itr).get();
368            }
369        }
370        return NULL;
371    }
372
373    void addTerrainMaskLayer(const char *name,
374                             osgEarth::MaskSourceOptions& opts,
375                             unsigned int minLOD = 0);
376
377    void removeTerrainMaskLayer(const char *name);
378
379    bool getTerrainMaskLayerExtent(const char *name, osgEarth::GeoExtent &ext);
380
381    // Model layers
382
383    int getNumModelLayers() const
384    {
385        return (_map.valid() ? _map->getNumModelLayers() : 0);
386    }
387
388    void getModelLayerNames(std::vector<std::string>& names) const
389    {
390        if (_map.valid()) {
391            osgEarth::ModelLayerVector layerVector;
392            _map->getModelLayers(layerVector);
393            osgEarth::ModelLayerVector::const_iterator itr;
394            for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) {
395                //osgEarth::UID uid = (*itr)->getUID();
396                names.push_back((*itr)->getName());
397            }
398        }
399    }
400
401    void addModelLayer(const char *name,
402                       osgEarth::ModelSourceOptions& opts,
403                       unsigned int pos = UINT_MAX,
404                       bool enableCache = true,
405                       bool lighting = true,
406                       bool visible = true);
407
408    void removeModelLayer(const char *name);
409
410    void moveModelLayer(const char *name, unsigned int pos);
411
412    bool getModelLayerExtent(const char *name, osgEarth::GeoExtent &ext);
413
414    //void setModelLayerVisibleRange(const char *name, float min, float max);
415
416    void setModelLayerOpacity(const char *name, double opacity);
417
418    void setModelLayerVisibility(const char *name, bool state);
419
420    // Render window
421
422    void setWindowSize(int width, int height);
423
424    int getWindowWidth() const
425    {
426        return _windowWidth;
427    }
428
429    int getWindowHeight() const
430    {
431        return _windowHeight;
432    }
433
434    // Camera
435
436    void saveNamedViewpoint(const char *name);
437
438    bool restoreNamedViewpoint(const char *name, double durationSecs);
439
440    bool removeNamedViewpoint(const char *name);
441
442    osgEarth::Viewpoint getViewpoint();
443
444    void setViewpoint(const osgEarth::Viewpoint& v, double durationSecs = 0.0);
445
446    double getMaxDistanceFromExtent(const osgEarth::GeoExtent& extent);
447
448    void setViewpointFromExtent(const osgEarth::GeoExtent& ext,
449                                double durationSecs = 0.0);
450
451    void setViewpointFromRect(double xmin, double ymin,
452                              double xmax, double ymax,
453                              const osgEarth::SpatialReference *srs = NULL,
454                              double durationSecs = 0.0);
455
456    void resetCamera(bool resetOrientation = true);
457
458    void setCameraOrientation(const double quat[4], bool absolute = true);
459
460    void panCamera(double x, double y);
461
462    void rotateCamera(double x, double y);
463
464    void zoomCamera(double z);
465
466    void setCameraDistance(double dist);
467
468    // Keyboard events
469
470    void keyPress(int key);
471
472    void keyRelease(int key);
473
474    // Mouse events
475
476    void setThrowingEnabled(bool state);
477
478    void mouseClick(int button, double x, double y);
479
480    void mouseDoubleClick(int button, double x, double y);
481
482    void mouseDrag(int button, double x, double y);
483
484    void mouseRelease(int button, double x, double y);
485
486    void mouseMotion(double x, double y);
487
488    void mouseScroll(int direction);
489
490    void pickPending(bool value)
491    { _pickPending = value; }
492
493    // Rendering an image
494
495    void setBackgroundColor(float color[3]);
496
497    void eventuallyRender();
498
499    bool render();
500
501    osg::Image *getRenderedFrame();
502
503    bool mapMouseCoords(float mouseX, float mouseY,
504                        osgEarth::GeoPoint &pt, bool invertY = true);
505
506    double computeMapScale();
507
508    const osgEarth::SpatialReference *getMapSRS()
509    {
510        if (_mapNode.valid()) {
511            return _mapNode->getMapSRS();
512        } else {
513            return NULL;
514        }
515    }
516
517    void addPlaceNode(double latitude, double longitude, char *labelText);
518
519    void hoverPlaceNode(int x, int y, bool invertY = true);
520
521    void deletePlaceNode(int x, int y, bool invertY = true);
522
523    bool getMousePoint(double *x, double *y, double *z)
524    {
525        return (_coordsCallback.valid() && _coordsCallback->report(x, y, z));
526    }
527
528    bool mouseToLatLong(int mouseX, int mouseY,
529                        double *latitude, double *longitude);
530
531    bool getWorldCoords(const osgEarth::GeoPoint& mapPt, osg::Vec3d *world);
532
533    bool worldToScreen(const osg::Vec3d& world, osg::Vec3d *screen,
534                       bool invertY = true);
535
536    bool worldToScreen(std::vector<osg::Vec3d>& coords, bool invertY = true);
537
538    void setMaximumFrameRateInHertz(double rate)
539    {
540        if (rate > 60.0)
541            rate = 60.0;
542        if (rate < 0.25)
543            rate = 0.25;
544        _minFrameTime = 1.0/rate;
545        if (_viewer.valid()) {
546            osgUtil::IncrementalCompileOperation *op =
547                _viewer->getDatabasePager()->getIncrementalCompileOperation();
548            if (op != NULL) {
549                TRACE("Setting DB Pager target frame rate to %g", rate);
550                op->setTargetFrameRate(rate);
551            }
552        }
553        TRACE("Frame rate target: %.2f Hz", (float)getMaximumFrameRateInHertz());
554        TRACE("Frame time target: %.2f msec", _minFrameTime * 1000.0f);
555    }
556
557    void setMaximumBitrate(double bitsPerSecond)
558    {
559        TRACE("Setting max bitrate to %g", bitsPerSecond);
560        unsigned long bitsPerFrame = (_windowWidth * _windowHeight * 3 + 16) * 8;
561        double fps = bitsPerSecond / ((double)bitsPerFrame);
562        setMaximumFrameRateInHertz(fps);
563        TRACE("Bandwidth target: %.2f Mbps", (float)(getMaximumBitrate()/1.0e6));
564    }
565
566    double getMaximumFrameRateInHertz()
567    {
568        return (1.0/_minFrameTime);
569    }
570
571    double getMaximumBitrate()
572    {
573        unsigned long bitsPerFrame = (_windowWidth * _windowHeight * 3 + 16) * 8;
574        return ((double)bitsPerFrame * getMaximumFrameRateInHertz());
575    }
576
577    void markFrameStart();
578
579    void markFrameEnd();
580
581    void setIdleTimeout(long timeout)
582    {
583        if (timeout != -1L &&
584            (double)timeout < _minFrameTime) {
585            ERROR("Timeout must be more than %g sec", _minFrameTime);
586            return;
587        }
588        TRACE("Setting idle timeout to %ld sec", timeout);
589        _idleTimeout = timeout;
590    }
591
592    long getIdleTimeout()
593    {
594        return _idleTimeout;
595    }
596
597    void getTimeout(struct timeval *tv);
598
599    void mapNodeUpdate();
600
601    std::string getCanonicalPath(const std::string& url) const;
602
603    void writeScene(const std::string& file);
604
605    // Placard info window
606
607    void enablePlacard(const char *layerName, bool state);
608
609    void setPlacardConfig(const Placard& placardConf, const char *layerName);
610
611    Placard getPlacardConfig(const char *layerName)
612    {
613        Placard ret;
614        PlacardHashmap::iterator itr = _placardConfigs.find(layerName);
615        if (itr != _placardConfigs.end()) {
616            ret = itr->second;
617        }
618        return ret;
619    }
620
621    // Selection
622
623    void setSelectMode(SelectMode mode);
624
625    void selectFeatures(std::vector<unsigned long>& featureIDs,
626                        const char *layerName, bool clear = true);
627
628    void deselectFeatures(std::vector<unsigned long>& featureIDs,
629                          const char *layerName);
630
631    void addPlacard(const osgEarth::GeoPoint& location,
632                    osgEarth::Features::Feature *feature,
633                    const char *layerName);
634
635    void clearSelection();
636
637    void addRhumbBox(double latMin, double latMax,
638                     double longMin, double longMax);
639
640    void initBoxSelection(int x, int y);
641    void updateBoxSelection(int x, int y);
642    void getBoxSelection(double *latMin, double *latMax,
643                         double *longMin, double *longMax,
644                         const osgEarth::SpatialReference *outSRS = NULL);
645    void clearBoxSelection();
646
647    // These methods are based on the deprecated annotation API
648    bool select(osgEarth::Annotation::AnnotationNode *node)
649    {
650        if (_selected.find(node) == _selected.end()) {
651            _selected.insert(node);
652            return true;
653        } else {
654            return false;
655        }
656    }
657    std::set<osgEarth::Annotation::AnnotationNode*>& getHovered()
658    { return _hovered; }
659    std::set<osgEarth::Annotation::AnnotationNode*>& getSelected()
660    { return _selected; }
661
662    // Scene Graph
663
664    osg::Group *getSceneRoot()
665    { return _sceneRoot.get(); }
666    osgEarth::MapNode *getMapNode()
667    { return _mapNode.get(); }
668    osg::Group *getAnnotations()
669    {
670        initAnnotations();
671        return _annotations.get();
672    }
673    osg::Group *getPlaceNodes()
674    {
675        initAnnotations();
676        return _placeNodes.get();
677    }
678
679private:
680    typedef std::tr1::unordered_map<ColorMapId, osg::ref_ptr<osg::TransferFunction1D> > ColorMapHashmap;
681    typedef std::tr1::unordered_map<ViewpointId, osgEarth::Viewpoint> ViewpointHashmap;
682    typedef std::tr1::unordered_map<std::string, Placard> PlacardHashmap;
683    typedef std::tr1::unordered_map<std::string, std::set<unsigned long> > FeatureSelectionHashmap;
684
685    void initAnnotations();
686
687    void clearSelectionAnnotationNodes();
688
689    void initViewer();
690
691    void finalizeViewer();
692   
693    void initControls();
694
695    void updateDebugLabel();
696
697    void initEarthManipulator();
698
699    void initMouseCoordsTool(CoordinateDisplayType type = COORDS_LATLONG_DECIMAL_DEGREES,
700                             int precision = -1);
701
702    osgEarth::Util::MGRSFormatter::Precision getMGRSPrecision(int precisionInMeters);
703
704    void initColorMaps();
705
706    void initCamera();
707
708    bool isPagerIdle();
709
710    bool checkNeedToDoFrame();
711
712    osgGA::EventQueue *getEventQueue();
713
714    bool _needsRedraw;
715    int _windowWidth, _windowHeight;
716    double _mapScale;
717    float _bgColor[3];
718
719    long _idleTimeout;
720    double _minFrameTime;
721    double _lastFrameTime;
722    double _renderTime;
723    osg::Timer_t _startFrameTime;
724    osg::Timer_t _renderStartTime;
725    osg::Timer_t _renderStopTime;
726
727    ColorMapHashmap _colorMaps;
728
729    std::string _resourcePath;
730    std::string _cacheBaseDir;
731    std::string _cacheDir;
732    std::string _baseURI;
733    std::string _attribution;
734
735    osg::ref_ptr<osg::Group> _sceneRoot;
736    osg::ref_ptr<osg::Group> _graticule;
737    osg::ref_ptr<osg::Group> _annotations;
738    PlacardHashmap _placardConfigs;
739    double _anchorLat, _anchorLong;
740    SelectMode _selectMode;
741    osg::ref_ptr<osgEarth::Annotation::FeatureNode> _selectionBox;
742#ifdef USE_RTT_PICKER
743    osg::ref_ptr<osgEarth::Util::RTTPicker> _picker;
744#endif
745    bool _pickPending;
746    osg::ref_ptr<osg::Group> _placeNodes;
747    FeatureSelectionHashmap _selectedFeatures;
748    std::set<osgEarth::Annotation::AnnotationNode *> _hovered;
749    std::set<osgEarth::Annotation::AnnotationNode *> _selected;
750    osg::ref_ptr<osgEarth::MapNode> _mapNode;
751    osg::ref_ptr<osgEarth::Map> _map;
752    osg::ref_ptr<osgEarth::Util::SkyNode> _skyNode;
753    osg::ref_ptr<osgViewer::Viewer> _viewer;
754    osg::ref_ptr<ScreenCaptureCallback> _captureCallback;
755    osg::ref_ptr<osgEarth::Util::AutoClipPlaneCullCallback> _clipPlaneCullCallback;
756    osg::ref_ptr<osgEarth::Util::Controls::HBox> _coordsBox;
757    osg::ref_ptr<MouseCoordsTool> _mouseCoordsTool;
758    osg::ref_ptr<MouseCoordsCallback> _coordsCallback;
759    osg::ref_ptr<osgEarth::Util::Controls::HBox> _debugBox;
760    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _debugLabel;
761    osg::ref_ptr<osgEarth::Util::Controls::HBox> _copyrightScaleBox;
762    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _copyrightLabel;
763    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _scaleLabel;
764    osg::ref_ptr<osgEarth::Util::Controls::Frame> _scaleBar;
765    ScaleBarUnits _scaleBarUnits;
766    osg::ref_ptr<osgEarth::Util::EarthManipulator> _manipulator;
767    osg::ref_ptr<osgGA::StateSetManipulator> _stateManip;
768    osg::ref_ptr<osgEarth::Util::VerticalScale> _verticalScale;
769    ViewpointHashmap _viewpoints;
770};
771
772class MapNodeCallback : public osg::NodeCallback
773{
774public:
775    MapNodeCallback(Renderer *renderer) :
776        _renderer(renderer)
777    {}
778
779    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
780    {
781        _renderer->mapNodeUpdate();
782        traverse(node, nv);
783    }
784private:
785    Renderer *_renderer;
786};
787
788class SelectPlaceNodesVisitor : public osg::NodeVisitor
789{
790public:
791    SelectPlaceNodesVisitor(Renderer *renderer,
792                            double latMin, double latMax,
793                            double longMin, double longMax) :
794        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
795        _renderer(renderer),
796        _latMin(latMin), _latMax(latMax),
797        _longMin(longMin), _longMax(longMax)
798    {}
799
800    virtual void apply(osg::Node& node);
801
802private:
803    Renderer *_renderer;
804    double _latMin, _latMax, _longMin, _longMax;
805};
806
807}
808
809#endif
Note: See TracBrowser for help on using the repository browser.