]> SALOME platform Git repositories - modules/gui.git/blob - src/GLViewer/GLViewer_CoordSystem.h
Salome HOME
4ea7795b14283ce0b5ae5ea226355a35f8ce202b
[modules/gui.git] / src / GLViewer / GLViewer_CoordSystem.h
1 //  Copyright (C) 2005 OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
18 //
19 //  Author : OPEN CASCADE
20 //
21
22 // File:      GLViewer_CoordSystem.h
23 // Created:   November, 2004
24
25 /*! Class GLViewer_CoordSystem
26  *  Class implementing mathematical model of 2D coordinate system 
27  */
28
29 #ifndef GLVIEWER_COORDSYSTEM_H
30 #define GLVIEWER_COORDSYSTEM_H
31
32 #include "GLViewer.h"
33
34 #ifdef WNT
35 #pragma warning( disable:4251 )
36 #endif
37
38 /*!
39   \class GLViewer_CoordSystem
40   \brief Class implementing mathematical model of 2D coordinate system 
41 */
42 class GLVIEWER_API GLViewer_CoordSystem
43 {
44 public:
45   //! A type of coordinate system
46   enum CSType
47   {
48     Cartesian,
49     Polar     
50   };
51   
52 private:
53   //! The coordinates of origin in the reference CS
54   double myX0, myY0;
55   //! The lengths of axis units in the reference unit
56   double myXUnit, myYUnit;
57   //! The rotation in radians relative to reference CS
58   double myRotation;
59   
60   //! In the polar CS myYUnit is ignored, but myXUnit is the unit of polar radius  
61   CSType myType;
62   
63 public:
64   //! A constructor ( by default new system is identical to reference )
65   GLViewer_CoordSystem( CSType aType, double X0 = 0.0, double Y0 = 0.0, 
66                         double XUnit = 1.0, double YUnit = 1.0, double Rotation = 0.0 );
67   
68   //! Returns the origin in reference system
69   void getOrigin( double& x, double& y ) const;
70   //! A function installing the origin in reference system
71   void setOrigin( double x, double y );
72   
73   //! Returns units along axes
74   void getUnits( double& x, double& y ) const;
75   //! A function installing units along axes
76   void setUnits( double x, double y );
77   
78   //! Returns rotation angle of axes in reference system
79   double getRotation() const;
80   //! A function installing rotation angle of axes in reference system
81   void   setRotation( double rotation );
82   
83   //! Returns type of system
84   CSType getType() const;
85   //! A function installing type of system
86   void setType( CSType type );
87   
88   //! Transform the coordinates x, y from current CS to aSystem
89   void transform( GLViewer_CoordSystem& aSystem, double& x, double& y );
90   
91   
92   //! Return how many times line width in aSystem system bigger than in current
93   virtual void getStretching( GLViewer_CoordSystem& aSystem, double& theX, double& theY );
94   
95   
96 protected:
97   //! A function transforms system coords to coords in reference system
98   virtual void toReference( double& x, double& y );
99   //! A function transforms from coords in reference system to system coords
100   virtual void fromReference( double& x, double& y );
101 };
102
103 #ifdef WNT
104 #pragma warning ( default:4251 )
105 #endif
106
107 #endif