Salome HOME
ad40ab124905f31f8e9f485836f8b3893812b129
[modules/gui.git] / src / GLViewer / GLViewer_Selector.h
1 //  Copyright (C) 2005 OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
18 //
19 //  Author : OPEN CASCADE
20 //
21
22 // File:      GLViewer_Selector.h
23 // Created:   November, 2004
24
25 /****************************************************************************
26 **  Class:   GLViewer_Selector
27 **  Descr:   Base class for object selection in QAD-based application
28 **  Module:  GLViewer
29 **  Created: UI team, 22.09.00
30 *****************************************************************************/
31 #ifndef GLVIEWER_SELECTOR_H
32 #define GLVIEWER_SELECTOR_H
33
34 #include "GLViewer.h"
35 #include "GLViewer_Defs.h"
36
37 #include <qsize.h>
38 #include <qobject.h>
39
40 #include <Quantity_NameOfColor.hxx>
41
42 class GLViewer_Viewer;
43
44 /*! Class GLViewer_Selector
45 *   Based select manager for GLViewer
46 */
47
48 class GLVIEWER_API GLViewer_Selector : public QObject
49 {
50     Q_OBJECT
51
52 public:
53     GLViewer_Selector( GLViewer_Viewer* );
54     ~GLViewer_Selector();
55
56 public:
57     //! Sets lock status (enable/disable interavtive)
58     void                  lock( bool );
59     void                  setMinRectSize( const QSize& minSize );
60
61     //! Highlights in point (x,y)
62     virtual void          detect( int x, int y ) = 0;    
63     virtual void          undetectAll() = 0;
64
65     //! Selects highlight objects
66     virtual void          select( bool append = false ) = 0;
67     //! Selects by rect
68     virtual void          select( const QRect&, bool append = false ) = 0;
69     virtual void          unselectAll() = 0;
70     virtual int           numSelected() const = 0;
71
72     virtual void          setHilightColor( Quantity_NameOfColor ) = 0;
73     virtual void          setSelectColor( Quantity_NameOfColor ) = 0;
74     //!Checks selection state and emits  'selSelectionDone' or 'selSelectionCancel'     
75     /*!Should be called by after non-interactive selection. */
76     virtual void          checkSelection( int, bool, int ) = 0;
77
78     /*! Sets/returns the key for appending selected objects ( SHIFT by default ) */
79     static int            appendKey() { return apppendKey; }
80     static void           setAppendKey( int k ) { apppendKey = k; }
81
82 signals:
83     void                  selSelectionCancel();
84     void                  selSelectionDone( bool append, SelectionChangeStatus status );
85
86 protected:
87 //    void                  setStatus( SelectionChangeStatus theStatus ){ myStatus = theStatus; }
88 //    SelectionChangeStatus status( return myStatus; }
89
90     GLViewer_Viewer*      myViewer;
91     bool                  myLocked;
92     QSize                 myMinRectSize;
93
94 private:
95 //    SelectionChangeStatus myStatus;
96     static int            apppendKey;
97 };
98
99 #endif