OpenFrames
LatLonGrid.hpp
Go to the documentation of this file.
1 /***********************************
2  Copyright 2018 Ravishankar Mathur
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 ***********************************/
16 
21 #ifndef _OF_LATLONGRID_
22 #define _OF_LATLONGRID_
23 
24 #include <OpenFrames/Export.h>
26 #include <osg/Geometry>
27 #include <osg/ref_ptr>
28 
29 namespace OpenFrames
30 {
39  class OF_EXPORT LatLonGrid : public ReferenceFrame
40  {
41  public:
42  LatLonGrid( const std::string &name );
43  LatLonGrid( const std::string &name, float r, float g, float b, float a = 1.0 );
44 
45  // Show/hide this frame's contents, e.g. everything a frame shows (excluding axes, labels, and children)
46  // Inherited from ReferenceFrame
47  virtual void showContents(bool showContents);
48  virtual bool getContentsShown() const;
49 
53  void setParameters(const double &radius, const double &latSpace, const double &lonSpace);
54  void getParameters(double &radius, double &latSpace, double &lonSpace) const;
55 
57  virtual const osg::BoundingSphere& getBound() const;
58 
60  virtual void setColor( const osg::Vec4 &color );
61  using ReferenceFrame::setColor; // Unhide inherited setColor
62 
63  protected:
64  virtual ~LatLonGrid();
65 
66  void _init();
67  void _createGrid();
68 
69  double _latSpacing, _lonSpacing; // Grid line spacing, in radians
70  double _radius; // Radius of sphere
71 
72  osg::ref_ptr<osg::Geode> _geode; // Node to hold grid geometry
73  osg::ref_ptr<osg::Geometry> _gridGeom; // Geometry that draws everything
74  osg::ref_ptr<osg::Geometry> _mainGeom; // For equator and prime meridian
75  osg::ref_ptr<osg::Vec3Array> _vertices; // Vertices that define the grid
76  osg::ref_ptr<osg::Vec4Array> _colors; // Colors
77  };
78 
79 } // !namespace OpenFrames
80 
81 #endif
This class draws a spherical lat-lon grid.
Definition: LatLonGrid.hpp:39
Definition: CoordinateAxes.hpp:29
Definition: ReferenceFrame.hpp:54