OpenFrames
CoordinateAxes.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_COORDINATEAXES_
22 #define _OF_COORDINATEAXES_
23 
24 #include <OpenFrames/Export.h>
26 #include <osg/Geometry>
27 #include <osg/ref_ptr>
28 
29 namespace OpenFrames
30 {
39  class OF_EXPORT CoordinateAxes : public ReferenceFrame
40  {
41  public:
42  CoordinateAxes( const std::string &name );
43  CoordinateAxes( 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 
51  void setAxisLength(double len);
52  inline double getAxisLength() { return _axisLength; }
53 
55  void setDrawAxes(unsigned int axes);
56  inline unsigned int getDrawAxes() const { return _drawAxes; }
57 
59  void setTickSpacing(double major_sp, double minor_sp);
60  inline double getMajorTickSpacing() const { return _majorTickSpacing; }
61  inline double getMinorTickSpacing() const { return _minorTickSpacing; }
62 
64  void setTickSize(unsigned majorSize, unsigned int minorSize);
65 
67  bool setTickImage(const std::string &fname);
68  bool setTickShader(const std::string &fname );
69 
71  virtual const osg::BoundingSphere& getBound() const;
72  virtual void setColor( const osg::Vec4 &color );
73  using ReferenceFrame::setColor;
74 
75  protected:
76  virtual ~CoordinateAxes();
77 
78  void _init();
79  void _computeTickAttenuation();
80  void _createAxes();
81 
83  void resetTickShader();
84 
85  double _axisLength; // Length of each axis
86  double _majorTickSpacing, _minorTickSpacing; // Tick mark spacing
87  unsigned int _drawAxes; // Which axes to draw
88 
89  osg::ref_ptr<osg::Geode> _axesGeode; // Node to hold axes geometry
90  osg::ref_ptr<osg::Geode> _tickGeode; // Node to hold tick geometry
91 
92  osg::ref_ptr<osg::Geometry> _axesGeom; // Geometry that draws axes
93  osg::ref_ptr<osg::Geometry> _majorTickGeom; // Major tick marks geom
94  osg::ref_ptr<osg::Geometry> _minorTickGeom; // Minor tick marks geom
95 
96  osg::ref_ptr<osg::Vec3dArray> _vertices; // Vertices that define the lines
97  osg::ref_ptr<osg::Vec4Array> _colors; // Colors for each line
98 
99  osg::ref_ptr<osg::Shader> _fragShader; // Tick mark fragment shader
100  };
101 
102 } // !namespace OpenFrames
103 
104 #endif
Definition: CoordinateAxes.hpp:29
A type of ReferenceFrame that displays X, Y, and Z axes.
Definition: CoordinateAxes.hpp:39
Definition: ReferenceFrame.hpp:54