Back to index

salome-gui  6.5.0
OCCViewer_AISSelector.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #if !defined( OCCVIEWER_AISSELECTOR_H )
00024 #define OCCVIEWER_AISSELECTOR_H
00025 
00026 #include "OCCViewer.h"
00027 #include <QObject>
00028 
00029 #include <Quantity_NameOfColor.hxx>
00030 #include <AIS_InteractiveContext.hxx>
00031 
00032 class OCCVIEWER_EXPORT OCCViewer_AISSelector : public QObject
00033 {
00034   Q_OBJECT
00035     
00036 public:
00037   // constructor
00038   OCCViewer_AISSelector( QObject* parent, const Handle (AIS_InteractiveContext)& );
00039   // destructor
00040   ~OCCViewer_AISSelector();
00041   
00042   // enables/disables selection
00043   void enableSelection( bool );
00044   // enables/disables multiple selection
00045   void enableMultipleSelection( bool );
00046   
00047   // detects the interactive objects at position (x,y).
00048   bool moveTo ( int, int, const Handle (V3d_View)& );
00049   // selects the objects covered by the rectangle.
00050   bool select ( int, int, int, int, const Handle (V3d_View)& );
00051   // adds new selected objects covered by the rectangle to the objects
00052   // previously selected.
00053   bool shiftSelect ( int, int, int, int, const Handle (V3d_View)& );
00054   // selects the detected interactive objects.
00055   bool select ();
00056   // adds new selected objects to the objects previously selected.
00057   bool shiftSelect ();
00058   
00059   // sets the interactive context for this selector
00060   void setAISContext ( const Handle (AIS_InteractiveContext)& );
00061   // sets the color to hilight the detected objects
00062   void setHilightColor ( Quantity_NameOfColor color );
00063   // sets the color to display the selected objects
00064   void setSelectColor ( Quantity_NameOfColor color );
00065   
00066 protected:
00067   // checks the status of pick and emits 'selSelectionDone' or 'selSelectionCancel'.
00068   bool checkSelection ( AIS_StatusOfPick status, bool hadSelection, bool addTo );
00069   
00070 signals:
00071   // 'selection done' signal
00072   void selSelectionDone( bool bAdded );
00073   // 'selection cancelled' signal
00074   void selSelectionCancel( bool bAdded );
00075   
00076 protected:
00077   Handle (AIS_InteractiveContext) myAISContext;    // graphic context
00078   Quantity_NameOfColor            myHilightColor;  // color for hilight object
00079   Quantity_NameOfColor            mySelectColor;   // color for selected object
00080   
00081   int  myNumSelected;                              // nymber of selected objects
00082   bool myEnableSelection;                          // enable selection flag
00083   bool myEnableMultipleSelection;                  // enable multiple selection flag
00084 };
00085 
00086 #endif // OCCVIEWER_AISSELECTOR_H