Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / OCCViewer / OCCViewer_AISSelector.h
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, 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.
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 #if !defined( OCCVIEWER_AISSELECTOR_H )
24 #define OCCVIEWER_AISSELECTOR_H
25
26 #include "OCCViewer.h"
27 #include <QObject>
28
29 #include <Quantity_NameOfColor.hxx>
30 #include <AIS_InteractiveContext.hxx>
31
32 class OCCVIEWER_EXPORT OCCViewer_AISSelector : public QObject
33 {
34   Q_OBJECT
35     
36 public:
37   // constructor
38   OCCViewer_AISSelector( QObject* parent, const Handle (AIS_InteractiveContext)& );
39   // destructor
40   ~OCCViewer_AISSelector();
41   
42   // enables/disables selection
43   void enableSelection( bool );
44   // enables/disables multiple selection
45   void enableMultipleSelection( bool );
46   
47   // detects the interactive objects at position (x,y).
48   bool moveTo ( int, int, const Handle (V3d_View)& );
49   // selects the objects covered by the rectangle.
50   bool select ( int, int, int, int, const Handle (V3d_View)& );
51   // adds new selected objects covered by the rectangle to the objects
52   // previously selected.
53   bool shiftSelect ( int, int, int, int, const Handle (V3d_View)& );
54   // selects the detected interactive objects.
55   bool select ();
56   // adds new selected objects to the objects previously selected.
57   bool shiftSelect ();
58   
59   // sets the interactive context for this selector
60   void setAISContext ( const Handle (AIS_InteractiveContext)& );
61   // sets the color to hilight the detected objects
62   void setHilightColor ( Quantity_NameOfColor color );
63   // sets the color to display the selected objects
64   void setSelectColor ( Quantity_NameOfColor color );
65   
66 protected:
67   // checks the status of pick and emits 'selSelectionDone' or 'selSelectionCancel'.
68   bool checkSelection ( AIS_StatusOfPick status, bool hadSelection, bool addTo );
69   
70 signals:
71   // 'selection done' signal
72   void selSelectionDone( bool bAdded );
73   // 'selection cancelled' signal
74   void selSelectionCancel( bool bAdded );
75   
76 protected:
77   Handle (AIS_InteractiveContext) myAISContext;    // graphic context
78   Quantity_NameOfColor            myHilightColor;  // color for hilight object
79   Quantity_NameOfColor            mySelectColor;   // color for selected object
80   
81   int  myNumSelected;                              // nymber of selected objects
82   bool myEnableSelection;                          // enable selection flag
83   bool myEnableMultipleSelection;                  // enable multiple selection flag
84 };
85
86 #endif // OCCVIEWER_AISSELECTOR_H