OpenWalnut  1.5.0dev
WRulerOrtho.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WRULERORTHO_H
26 #define WRULERORTHO_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <osgText/Text>
32 
33 #include "WCoordConverter.h"
34 #include "WRuler.h"
35 #include "core/common/math/linearAlgebra/WVectorFixed.h"
36 
37 typedef enum
38 {
39  RULER_ALONG_X_AXIS_SCALE_Y = 0,
40  RULER_ALONG_X_AXIS_SCALE_Z,
41  RULER_ALONG_Y_AXIS_SCALE_X,
42  RULER_ALONG_Y_AXIS_SCALE_Z,
43  RULER_ALONG_Z_AXIS_SCALE_X,
44  RULER_ALONG_Z_AXIS_SCALE_Y
45 }
46 scaleMode;
47 
48 /**
49  * class to implement rulers orthogonally
50  */
51 class WRulerOrtho : public WRuler
52 {
53 public:
54  /**
55  * standard constructor
56  * \param coordConverter
57  * \param origin
58  * \param mode
59  * \param showNumbers
60  */
61  WRulerOrtho( std::shared_ptr<WCoordConverter>coordConverter, osg::Vec3 origin, scaleMode mode, bool showNumbers = true );
62 
63  /**
64  * destructor
65  */
66  ~WRulerOrtho();
67 
68 
69 protected:
70 private:
71  std::shared_ptr<WCoordConverter>m_coordConverter; //!< stores pointer to a coordinate converter
72 
73  /**
74  * Origin of the ruler, it will be drawn in the positive direction
75  */
76  osg::Vec3 m_origin;
77 
78  /**
79  * orientation of ruler
80  */
81  scaleMode m_scaleMode;
82 
83  bool m_showNumbers; //!< flag to indicate wether to show number labels
84 
85  WVector3d m_lb; //!< = m_coordConverter->getBoundingBox().first;
86  WVector3d m_ub; //!< = m_coordConverter->getBoundingBox().second;
87 
88 
89  /**
90  * creates the osg node for the ruler representation
91  */
92  void create();
93 
94  /**
95  * helper function to add a label to the ruler
96  *
97  * \param position position of thelabel
98  * \param text text
99  */
100  void addLabel( osg::Vec3 position, std::string text );
101 
102  /**
103  * Helper function to create the ruler along the x axis
104  *
105  * \return A part of the geometry of the ruler
106  */
107  osg::ref_ptr< osg::Geometry > createXY();
108 
109  /**
110  * Helper function to create the ruler along the x axis
111  *
112  * \return A part of the geometry of the ruler
113  */
114  osg::ref_ptr< osg::Geometry > createXZ();
115 
116  /**
117  * Helper function to create the ruler along the y axis
118  *
119  * \return A part of the geometry of the ruler
120  */
121  osg::ref_ptr< osg::Geometry > createYX();
122 
123  /**
124  * Helper function to create the ruler along the y axis
125  *
126  * \return A part of the geometry of the ruler
127  */
128  osg::ref_ptr< osg::Geometry > createYZ();
129 
130  /**
131  * Helper function to create the ruler along the z axis
132  *
133  * \return A part of the geometry of the ruler
134  */
135  osg::ref_ptr< osg::Geometry > createZX();
136 
137  /**
138  * Helper function to create the ruler along the z axis
139  *
140  * \return A part of the geometry of the ruler
141  */
142  osg::ref_ptr< osg::Geometry > createZY();
143 
144  /**
145  * converts a number into a string according to the currently selected coordinate system
146  * \param number
147  * \return string
148  */
149  std::string numberToString( int number );
150 };
151 
152 #endif // WRULERORTHO_H
class to implement rulers orthogonally
Definition: WRulerOrtho.h:52
void create()
creates the osg node for the ruler representation
Definition: WRulerOrtho.cpp:55
std::shared_ptr< WCoordConverter > m_coordConverter
stores pointer to a coordinate converter
Definition: WRulerOrtho.h:71
bool m_showNumbers
flag to indicate wether to show number labels
Definition: WRulerOrtho.h:83
osg::ref_ptr< osg::Geometry > createXZ()
Helper function to create the ruler along the x axis.
void addLabel(osg::Vec3 position, std::string text)
helper function to add a label to the ruler
~WRulerOrtho()
destructor
Definition: WRulerOrtho.cpp:51
osg::ref_ptr< osg::Geometry > createXY()
Helper function to create the ruler along the x axis.
osg::ref_ptr< osg::Geometry > createYZ()
Helper function to create the ruler along the y axis.
WRulerOrtho(std::shared_ptr< WCoordConverter >coordConverter, osg::Vec3 origin, scaleMode mode, bool showNumbers=true)
standard constructor
Definition: WRulerOrtho.cpp:38
osg::ref_ptr< osg::Geometry > createZY()
Helper function to create the ruler along the z axis.
osg::ref_ptr< osg::Geometry > createZX()
Helper function to create the ruler along the z axis.
osg::ref_ptr< osg::Geometry > createYX()
Helper function to create the ruler along the y axis.
WVector3d m_lb
= m_coordConverter->getBoundingBox().first;
Definition: WRulerOrtho.h:85
osg::Vec3 m_origin
Origin of the ruler, it will be drawn in the positive direction.
Definition: WRulerOrtho.h:76
scaleMode m_scaleMode
orientation of ruler
Definition: WRulerOrtho.h:81
WVector3d m_ub
= m_coordConverter->getBoundingBox().second;
Definition: WRulerOrtho.h:86
std::string numberToString(int number)
converts a number into a string according to the currently selected coordinate system
class to implement various rulers
Definition: WRuler.h:34