]> SALOME platform Git repositories - modules/gui.git/blob - src/GLViewer/GLViewer_CoordSystem.h
Salome HOME
ca571daab8e1a08f3171082a6f5aa0b710b317d7
[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 class GLVIEWER_API GLViewer_CoordSystem
39 {
40 public:
41   //! A type of coordinate system
42   enum CSType
43   {
44     Cartesian,
45     Polar     
46   };
47   
48 private:
49   //! The coordinates of origin in the reference CS
50   double myX0, myY0;
51   //! The lengths of axis units in the reference unit
52   double myXUnit, myYUnit;
53   //! The rotation in radians relative to reference CS
54   double myRotation;
55   
56   //! In the polar CS myYUnit is ignored, but myXUnit is the unit of polar radius  
57   CSType myType;
58   
59 public:
60   //! A constructor ( by default new system is identical to reference )
61   GLViewer_CoordSystem( CSType aType, double X0 = 0.0, double Y0 = 0.0, 
62                         double XUnit = 1.0, double YUnit = 1.0, double Rotation = 0.0 );
63   
64   //! Returns the origin in reference system
65   void getOrigin( double& x, double& y ) const;
66   //! A function installing the origin in reference system
67   void setOrigin( double x, double y );
68   
69   //! Returns units along axes
70   void getUnits( double& x, double& y ) const;
71   //! A function installing units along axes
72   void setUnits( double x, double y );
73   
74   //! Returns rotation angle of axes in reference system
75   double getRotation() const;
76   //! A function installing rotation angle of axes in reference system
77   void   setRotation( double rotation );
78   
79   //! Returns type of system
80   CSType getType() const;
81   //! A function installing type of system
82   void setType( CSType type );
83   
84   //! Transform the coordinates x, y from current CS to aSystem
85   void transform( GLViewer_CoordSystem& aSystem, double& x, double& y );
86   
87   
88   //! Return how many times line width in aSystem system bigger than in current
89   virtual void getStretching( GLViewer_CoordSystem& aSystem, double& theX, double& theY );
90   
91   
92 protected:
93   //! A function transforms system coords to coords in reference system
94   virtual void toReference( double& x, double& y );
95   //! A function transforms from coords in reference system to system coords
96   virtual void fromReference( double& x, double& y );
97 };
98
99 #ifdef WNT
100 #pragma warning ( default:4251 )
101 #endif
102
103 #endif