Salome HOME
studyActivated() virtual method has been added
[modules/gui.git] / src / GLViewer / GLViewer_Detector.h
1 // File:      GLViewer_Detector.h
2 // Created:   11/16/2004 09:33:22
3 // Author:    Sergey ANIKIN
4 // Copyright: CEA 2004
5
6 #ifndef GLVIEWER_DETECTOR_H
7 #define GLVIEWER_DETECTOR_H
8
9 #include <GLViewer_Object.h>
10
11 //================================================================
12 // Class       : GLViewer_Segment
13 // Description : segment for 2d detection
14 //================================================================
15 class GLVIEWER_EXPORT GLViewer_Segment
16 {
17 public:
18   GLViewer_Segment( const GLViewer_Pnt& thePnt1, 
19                     const GLViewer_Pnt& thePnt2 );
20   // Ordinary segment construction
21
22   GLViewer_Segment( const GLViewer_Pnt& thePnt, 
23                     const GLfloat theA, 
24                     const GLfloat theB,
25                     const GLfloat theC );
26   // Construction of a ray with given equation Ax + By + C = 0
27
28   ~GLViewer_Segment();
29
30   bool              HasIntersection( const GLViewer_Segment& theOther ) const;
31   // Detects intersection with another segment or ray
32
33 private:
34   GLViewer_Pnt      myPnt1;
35   GLViewer_Pnt      myPnt2;
36   GLfloat           myA;
37   GLfloat           myB;
38   GLfloat           myC;
39 };
40
41 //================================================================
42 // Class       : GLViewer_Poly
43 // Description : polygon for 2d detection
44 //================================================================
45 class GLVIEWER_EXPORT GLViewer_Poly 
46 {
47 public:
48   GLViewer_Poly( const GLViewer_PntList* thePoints );
49   virtual ~GLViewer_Poly();
50
51
52   int               Count() const { return myPoints->count(); }
53   virtual bool      IsIn( const GLViewer_Pnt& thePnt ) const;
54   // Detects if a point lies inside this polygon
55   
56   virtual bool      IsCovers( const GLViewer_Poly& thePoly ) const;
57   // Detect if a other polygon covers this polygon
58
59   virtual bool      IsCovers( const GLViewer_Rect& theRect ) const;
60   // likes the above function
61
62   virtual bool      HasIntersection( const GLViewer_Segment& theSegment ) const;
63   // Detects intersection of this polygon with a segment or a ray
64
65 private:
66   GLViewer_PntList* myPoints;
67 };
68
69 #endif
70
71 #ifdef _MSC_VER
72 #pragma once
73 #endif