Salome HOME
Updated copyright comment
[modules/gui.git] / src / GLViewer / GLViewer_CoordSystem.h
1 // Copyright (C) 2007-2024  CEA, EDF, 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, or (at your option) any later version.
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
23 //  Author : OPEN CASCADE
24 // File:      GLViewer_CoordSystem.h
25 // Created:   November, 2004
26 //
27 /*! Class GLViewer_CoordSystem
28  *  Class implementing mathematical model of 2D coordinate system 
29  */
30
31 #ifndef GLVIEWER_COORDSYSTEM_H
32 #define GLVIEWER_COORDSYSTEM_H
33
34 #include "GLViewer.h"
35
36 #ifdef WIN32
37 #pragma warning( disable:4251 )
38 #endif
39
40 /*!
41   \class GLViewer_CoordSystem
42   \brief Class implementing mathematical model of 2D coordinate system 
43 */
44 class GLVIEWER_API GLViewer_CoordSystem
45 {
46 public:
47   //! A type of coordinate system
48   enum CSType
49   {
50     Cartesian,
51     Polar     
52   };
53   
54 private:
55   //! The coordinates of origin in the reference CS
56   double myX0, myY0;
57   //! The lengths of axis units in the reference unit
58   double myXUnit, myYUnit;
59   //! The rotation in radians relative to reference CS
60   double myRotation;
61   
62   //! In the polar CS myYUnit is ignored, but myXUnit is the unit of polar radius  
63   CSType myType;
64   
65 public:
66   //! A constructor ( by default new system is identical to reference )
67   GLViewer_CoordSystem( CSType aType, double X0 = 0.0, double Y0 = 0.0, 
68                         double XUnit = 1.0, double YUnit = 1.0, double Rotation = 0.0 );
69   
70   //! Returns the origin in reference system
71   void getOrigin( double& x, double& y ) const;
72   //! A function installing the origin in reference system
73   void setOrigin( double x, double y );
74   
75   //! Returns units along axes
76   void getUnits( double& x, double& y ) const;
77   //! A function installing units along axes
78   void setUnits( double x, double y );
79   
80   //! Returns rotation angle of axes in reference system
81   double getRotation() const;
82   //! A function installing rotation angle of axes in reference system
83   void   setRotation( double rotation );
84   
85   //! Returns type of system
86   CSType getType() const;
87   //! A function installing type of system
88   void setType( CSType type );
89   
90   //! Transform the coordinates x, y from current CS to aSystem
91   void transform( GLViewer_CoordSystem& aSystem, double& x, double& y );
92   
93   
94   //! Return how many times line width in aSystem system bigger than in current
95   virtual void getStretching( GLViewer_CoordSystem& aSystem, double& theX, double& theY );
96   
97   
98 protected:
99   //! A function transforms system coords to coords in reference system
100   virtual void toReference( double& x, double& y );
101   //! A function transforms from coords in reference system to system coords
102   virtual void fromReference( double& x, double& y );
103 };
104
105 #ifdef WIN32
106 #pragma warning ( default:4251 )
107 #endif
108
109 #endif