OpenFrames
RadialPlane.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_RADIALPLANE_
22 #define _OF_RADIALPLANE_
23 
24 #include <OpenFrames/Export.h>
26 
27 namespace OpenFrames
28 {
37  class OF_EXPORT RadialPlane : public ReferenceFrame
38  {
39  public:
40  RadialPlane( const std::string &name );
41  RadialPlane( const std::string &name, float r, float g, float b, float a = 1.0 );
42 
43  // Show/hide this frame's contents, e.g. everything a frame shows (excluding axes, labels, and children)
44  // Inherited from ReferenceFrame
45  virtual void showContents(bool showContents);
46  virtual bool getContentsShown() const;
47 
49  void setParameters(const double &radius, const double &radSpace, const double &lonSpace);
50  void getParameters(double &radius, double &radSpace, double &lonSpace) const;
51 
53  void setPlaneColor(const osg::Vec4 &color);
54  void setPlaneColor(float r, float g, float b, float a = 1.0);
55  const osg::Vec4& getPlaneColor() const { return (*_planeColor)[0]; }
56 
58  void setLineColor(const osg::Vec4 &color);
59  void setLineColor(float r, float g, float b, float a = 1.0);
60  const osg::Vec4& getLineColor() const { return (*_lineColor)[0]; }
61 
63  virtual const osg::BoundingSphere& getBound() const;
64 
65  protected:
66  virtual ~RadialPlane();
67 
68  void init();
69  void createPlane();
70  void addCell(const osg::Vec2d v[], unsigned int nV);
71 
72  double _radius; // Radius of plane
73  double _radialSpacing; // Distance between radial circles
74  double _longitudeSpacing; // Angular distance between longitude lines
75 
76  osg::ref_ptr<osg::Geode> _planeGeode; // Node to hold plane geometry
77  osg::ref_ptr<osg::Geode> _linesGeode; // Node to hold lines geometry
78 
79  // Geometry objects that draw each of the overlaid lines
80  osg::ref_ptr<osg::Geometry> _linesGeom;
81  osg::ref_ptr<osg::Geometry> _lonGeom; // For 0 degree longitude line
82 
83  // Array of points that define the plane and the lines
84  osg::ref_ptr<osg::Vec2dArray> _lineVertices;
85  osg::ref_ptr<osg::Vec2dArray> _planeVertices;
86 
87  // Arrays that define plane and line colors
88  osg::ref_ptr<osg::Vec4Array> _lineColor;
89  osg::ref_ptr<osg::Vec4Array> _planeColor;
90 
91  // Array defining normals
92  osg::ref_ptr<osg::Vec3Array> _normals;
93 
94  // Level of Detail for cells that make up the plane tesselation
95  unsigned int _planeLOD;
96  };
97 
98 } // !namespace OpenFrames
99 
100 #endif
Definition: CoordinateAxes.hpp:29
ReferenceFrame for drawing radial plane.
Definition: RadialPlane.hpp:37
Definition: ReferenceFrame.hpp:54