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