source: geovis/branches/rex/Renderer.h @ 6570

Last change on this file since 6570 was 6570, checked in by ldelgass, 7 years ago

First pass at porting to new Map layer API

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