Salome HOME
Merge branch 'abn/paravis_rearch'
[modules/gui.git] / src / GLViewer / GLViewer_CoordSystem.cxx
index 947ac6036e5a4aefd5539a74a3cbe4b5acd715c4..8e024bdf0607d9a65ff3ac4d8a56c0a50e980f22 100644 (file)
@@ -1,38 +1,41 @@
-//  Copyright (C) 2005 OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  Author : OPEN CASCADE
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+//  Author : OPEN CASCADE
 // File:      GLViewer_Context.cxx
 // Created:   November, 2004
-
-//================================================================
-// Class       : GLViewer_CoordSystem
-// Description : Class implementing mathematical model of 2D coordinate system 
-//================================================================
+//
 #include "GLViewer_CoordSystem.h"
 #include <math.h>
 
-//=======================================================================
-// Function: GLViewer_CoordSystem
-// Purpose :
-//=======================================================================
+/*!
+  Constructor
+  \param aType - type of CS
+  \param X0 - X of origin in reference CS
+  \param Y0 - Y of origin in reference CS
+  \param XUnit - X unit in reference CS
+  \param YUnit - Y unit in reference CS
+  \param Rotation - rotation relative reference CS
+*/
 GLViewer_CoordSystem::GLViewer_CoordSystem( CSType aType, double X0, double Y0, 
                                             double XUnit, double YUnit, double Rotation )
 {
@@ -42,40 +45,36 @@ GLViewer_CoordSystem::GLViewer_CoordSystem( CSType aType, double X0, double Y0,
     setRotation( Rotation );
 }
 
-//=======================================================================
-// Function: getOrigin
-// Purpose :
-//=======================================================================
+/*!
+  \return origin in reference CS
+*/
 void GLViewer_CoordSystem::getOrigin( double& x, double& y ) const
 {
     x = myX0;
     y = myY0;
 }
 
-//=======================================================================
-// Function: setOrigin
-// Purpose :
-//=======================================================================
+/*!
+  Sets origin in reference CS
+*/
 void GLViewer_CoordSystem::setOrigin( double x, double y )
 {
     myX0 = x;
     myY0 = y;
 }
 
-//=======================================================================
-// Function: getUnits
-// Purpose :
-//=======================================================================
+/*!
+  \return units
+*/
 void GLViewer_CoordSystem::getUnits( double& x, double& y ) const
 {
     x = myXUnit;
     y = myYUnit;
 }
 
-//=======================================================================
-// Function: setUnits
-// Purpose :
-//=======================================================================
+/*!
+  Sets units
+*/
 void GLViewer_CoordSystem::setUnits( double x, double y )
 {
     if( x>0 )
@@ -88,46 +87,43 @@ void GLViewer_CoordSystem::setUnits( double x, double y )
     else
         myYUnit = 1.0;
 }
-//=======================================================================
-// Function: getRotation
-// Purpose :
-//=======================================================================
+
+/*!
+  \return rotation
+*/
 double GLViewer_CoordSystem::getRotation() const
 {
     return myRotation;
 }
 
-//=======================================================================
-// Function: setRotation
-// Purpose :
-//=======================================================================
+/*!
+  Sets rotation
+*/
 void GLViewer_CoordSystem::setRotation( double rotation )
 {
     myRotation = rotation;
 }
 
-//=======================================================================
-// Function: getType
-// Purpose :
-//=======================================================================
+/*!
+  \return type
+*/
 GLViewer_CoordSystem::CSType GLViewer_CoordSystem::getType() const
 {
     return myType;
 }
 
-//=======================================================================
-// Function: setType
-// Purpose :
-//=======================================================================
+/*!
+  Sets type
+*/
 void GLViewer_CoordSystem::setType( CSType type )
 {
     myType = type;
 }
 
-//=======================================================================
-// Function: toReference
-// Purpose :
-//=======================================================================
+/*!
+  Recalculate co-ordinates to reference co-ordinates
+  \param x, y - co-ordinates
+*/
 void GLViewer_CoordSystem::toReference( double& x, double& y )
 {
     if( myType==Cartesian )
@@ -145,10 +141,10 @@ void GLViewer_CoordSystem::toReference( double& x, double& y )
     }
 }
 
-//=======================================================================
-// Function: fromReference
-// Purpose :
-//=======================================================================
+/*!
+  Recalculate co-ordinates from reference co-ordinates
+  \param x, y - co-ordinates
+*/
 void GLViewer_CoordSystem::fromReference( double& x, double& y )
 {
     x = (x - myX0) / myXUnit;
@@ -168,6 +164,7 @@ void GLViewer_CoordSystem::fromReference( double& x, double& y )
         double eps = 1E-8, pi = 3.14159265;
 
         if( r>eps )
+        {
             if( fabs(x)>eps )
             {
                 double arg = y/x;
@@ -179,26 +176,27 @@ void GLViewer_CoordSystem::fromReference( double& x, double& y )
                 phi = pi/2.0;
             else
                 phi = 3*pi/2.0;
+        }
 
         x = r;
         y = phi-myRotation;
     }
 }
 
-//=======================================================================
-// Function: transform
-// Purpose :
-//=======================================================================
+/*!
+  Recalculate co-ordinates to co-ordinates of other CS
+  \param aSystem - other CS
+  \param x, y - co-ordinates
+*/
 void GLViewer_CoordSystem::transform( GLViewer_CoordSystem& aSystem, double& x, double& y )
 {
     toReference( x, y );
     aSystem.fromReference( x, y );
 }
 
-//=======================================================================
-// Function: getStretching
-// Purpose :
-//=======================================================================
+/*!
+  \return stretching of CS along X and Y axis
+*/
 void GLViewer_CoordSystem::getStretching( GLViewer_CoordSystem& aSystem, double& theX, double& theY )
 {
     theX = myXUnit / aSystem.myXUnit;