Salome HOME
dbc2b92028040a0c3a5d251b684710027f3fe30e
[modules/gui.git] / src / GLViewer / GLViewer_CoordSystem.h
1 // File:      GLViewer_CoordSystem.h
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 /*! Class GLViewer_CoordSystem
7  *  Class implementing mathematical model of 2D coordinate system 
8  */
9
10 #ifndef GLVIEWER_COORDSYSTEM_H
11 #define GLVIEWER_COORDSYSTEM_H
12
13 #include "GLViewer.h"
14
15 #ifdef WNT
16 #pragma warning( disable:4251 )
17 #endif
18
19 class GLVIEWER_API GLViewer_CoordSystem
20 {
21 public:
22   //! A type of coordinate system
23   enum CSType
24   {
25     Cartesian,
26     Polar     
27   };
28   
29 private:
30   //! The coordinates of origin in the reference CS
31   double myX0, myY0;
32   //! The lengths of axis units in the reference unit
33   double myXUnit, myYUnit;
34   //! The rotation in radians relative to reference CS
35   double myRotation;
36   
37   //! In the polar CS myYUnit is ignored, but myXUnit is the unit of polar radius  
38   CSType myType;
39   
40 public:
41   //! A constructor ( by default new system is identical to reference )
42   GLViewer_CoordSystem( CSType aType, double X0 = 0.0, double Y0 = 0.0, 
43                         double XUnit = 1.0, double YUnit = 1.0, double Rotation = 0.0 );
44   
45   //! Returns the origin in reference system
46   void getOrigin( double& x, double& y ) const;
47   //! A function installing the origin in reference system
48   void setOrigin( double x, double y );
49   
50   //! Returns units along axes
51   void getUnits( double& x, double& y ) const;
52   //! A function installing units along axes
53   void setUnits( double x, double y );
54   
55   //! Returns rotation angle of axes in reference system
56   double getRotation() const;
57   //! A function installing rotation angle of axes in reference system
58   void   setRotation( double rotation );
59   
60   //! Returns type of system
61   CSType getType() const;
62   //! A function installing type of system
63   void setType( CSType type );
64   
65   //! Transform the coordinates x, y from current CS to aSystem
66   void transform( GLViewer_CoordSystem& aSystem, double& x, double& y );
67   
68   
69   //! Return how many times line width in aSystem system bigger than in current
70   virtual void getStretching( GLViewer_CoordSystem& aSystem, double& theX, double& theY );
71   
72   
73 protected:
74   //! A function transforms system coords to coords in reference system
75   virtual void toReference( double& x, double& y );
76   //! A function transforms from coords in reference system to system coords
77   virtual void fromReference( double& x, double& y );
78 };
79
80 #ifdef WNT
81 #pragma warning ( default:4251 )
82 #endif
83
84 #endif