Salome HOME
Upgrade to paraview 5.4
[modules/gui.git] / src / GLViewer / GLViewer_Geom.h
index cc55453bb57f8d8bf7e7065abd1a538b166e0bf1..b683011327d69e62761ed53df8c48607aa2aa339 100644 (file)
@@ -1,25 +1,45 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  Author : OPEN CASCADE
 // File:      GLViewer_Geom.h
 // Created:   November, 2004
-// Author:    OCC team
-// Copyright (C) CEA 2004
-
+//
 #ifndef GLVIEWER_GEOM_H
 #define GLVIEWER_GEOM_H
 
 #include "GLViewer.h"
 
-#include <qrect.h>
-#include <qvaluelist.h>
-#include <qgl.h>
+#include <QRect>
+#include <QtOpenGL>
 #include <math.h>
 
-
-#ifdef WNT
+#ifdef WIN32
 #pragma warning( disable:4251 )
 #endif
 
-// Class:   GLViewer_Pnt
-// Descr:   Substitution of QPoint for OpenGL
+/*! Struct GLViewer_Pnt
+* Substitution of QPoint for OpenGL
+*/
 
 struct GLVIEWER_API GLViewer_Pnt
 {
@@ -39,10 +59,11 @@ private:
   GLfloat myY;
 };
 
-typedef QValueList<GLViewer_Pnt> GLViewer_PntList;
+typedef QList<GLViewer_Pnt> GLViewer_PntList;
 
-// Class:   GLViewer_Rect
-// Descr:   Substitution of QRect for OpenGL
+/*! Class  GLViewer_Rect
+*  Substitution of QRect for OpenGL
+*/
 
 class GLVIEWER_API GLViewer_Rect
 {
@@ -70,20 +91,34 @@ public:
   void        setCoords( float theLeft, float theRight, float theBottom, float theTop )
   { myLeft = theLeft; myRight = theRight; myBottom = theBottom; myTop = theTop; }
   
+  //! \warning This method translate only rect format
   QRect       toQRect() { return QRect( ( int )myLeft, ( int )myBottom,
                                         ( int )( myRight - myLeft ),
                                         ( int )( myTop - myBottom ) ); }
 
+  //! On/off empty status
   void        setIsEmpty( bool on ) { myIsEmpty = on; }
+  //! Checks empty status
   bool        isEmpty() const { return myIsEmpty; }
 
+  //! Checks null status
   bool        isNull() const { return myLeft == 0.0 && myRight == 0.0 && myBottom == 0.0 && myTop == 0.0; }
+  //! Checks valid status
   bool        isValid() const { return ( myLeft < myRight && myBottom < myTop ); }
 
+  //! Checks staus of contains point 
   bool        contains( GLViewer_Pnt pnt ) { return ( pnt.x() > left() &&
                                                       pnt.x() < right() &&
                                                       pnt.y() > bottom() &&
-                                                      pnt.y() < top() ); } 
+                                                      pnt.y() < top() ); }
+  
+  void        move( const float x, const float y )
+                  {
+                    myLeft   += x;
+                    myRight  += x;
+                    myTop    += y;
+                    myBottom += y;
+                  }
 
 protected:
   float       myLeft;
@@ -94,22 +129,23 @@ protected:
   bool        myIsEmpty;
 };
 
-// Class:   GLViewer_Segment
-// Descr:   Segment for 2d detection
+/*! Class GLViewer_Segment
+* Segment for 2d detection
+*/
 
 class GLVIEWER_API GLViewer_Segment
 {
 public:
   GLViewer_Segment( const GLViewer_Pnt& thePnt1, 
                     const GLViewer_Pnt& thePnt2 );
-  // Ordinary segment construction
+  
+  //! Ordinary segment construction
+  /*!Construction of a ray with given equation Ax + By + C = 0 */
 
   GLViewer_Segment( const GLViewer_Pnt& thePnt, 
                     const GLfloat theA, 
                     const GLfloat theB,
                     const GLfloat theC );
-  // Construction of a ray with given equation Ax + By + C = 0
-
   ~GLViewer_Segment();
 
   bool              HasIntersection( const GLViewer_Segment& theOther ) const;
@@ -123,8 +159,9 @@ private:
   GLfloat           myC;
 };
 
-// Class:   GLViewer_Poly
-// Descr:   Polygon for 2d detection
+/*! Class  GLViewer_Poly
+* Polygon for 2d detection
+*/
 
 class GLVIEWER_API GLViewer_Poly 
 {
@@ -132,26 +169,29 @@ public:
   GLViewer_Poly( const GLViewer_PntList* thePoints );
   virtual ~GLViewer_Poly();
 
+  //! Adds point to polygon
+  void              AddPoint( GLViewer_Pnt& pnt ) { myPoints->append( pnt ); }
+
+  //! Returns number of point
   int               Count() const { return myPoints->count(); }
 
+  //! Returns true if a point lies inside this polygon
   virtual bool      IsIn( const GLViewer_Pnt& thePnt ) const;
-  //virtual bool      IsIn( const GLViewer_Pnt& thePnt, const float tolerance = 0 ) const;
-  // Detects if a point lies inside this polygon
-  
+
+  //! Returns true if a other polygon covers this polygon  
   virtual bool      IsCovers( const GLViewer_Poly& thePoly ) const;
-  // Detect if a other polygon covers this polygon
 
+  //! Likes the above function
   virtual bool      IsCovers( const GLViewer_Rect& theRect ) const;
-  // likes the above function
-
+  
+  // Returns true if intersection of this polygon with a segment or a ray not empty
   virtual bool      HasIntersection( const GLViewer_Segment& theSegment ) const;
-  // Detects intersection of this polygon with a segment or a ray
 
 private:
   GLViewer_PntList* myPoints;
 };
 
-#ifdef WNT
+#ifdef WIN32
 #pragma warning ( default:4251 )
 #endif