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