0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IVtk / IVtk_IShapePickerAlgo.hxx
1 // Created on: 2011-10-12 
2 // Created by: Roman KOZLOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS 
4 // 
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef __IVTK_ISHAPEPICKERALGO_H__
17 #define __IVTK_ISHAPEPICKERALGO_H__
18
19 #include <IVtk_IView.hxx>
20 #include <IVtk_IShape.hxx>
21
22 class IVtk_IShapePickerAlgo;
23 DEFINE_STANDARD_HANDLE( IVtk_IShapePickerAlgo, IVtk_Interface )
24
25 //! @class IVtk_IShapePickerAlgo 
26 //! @brief Interface for 3D shapes picking algorithm.
27 class IVtk_IShapePickerAlgo : public IVtk_Interface
28 {
29 public:
30   typedef Handle(IVtk_IShapePickerAlgo) Handle;
31
32   virtual ~IVtk_IShapePickerAlgo() { }
33
34   DEFINE_STANDARD_RTTIEXT(IVtk_IShapePickerAlgo,IVtk_Interface)
35
36   virtual void SetView (const IVtk_IView::Handle& theView) = 0;
37   virtual int  NbPicked() = 0;
38
39   //! Get activated selection modes for a shape.
40   //! @param [in] theShape a shape with activated selection mode(s)
41   //! @return list of active selection modes
42   virtual IVtk_SelectionModeList GetSelectionModes (const IVtk_IShape::Handle& theShape) const = 0;
43
44 public: // @name Set selectable shapes and selection modes
45
46   //! Activates/deactivates the given selection mode for the shape.
47   //! If mode == SM_None, the shape becomes non-selectable and 
48   //! is removed from the internal selection data.
49   //! @param [in] theShape Shape for which the selection mode should be activated
50   //! @param [in] theMode Selection mode to be activated
51   //! @param [in] theIsTurnOn Flag to turn on/off the selection mode
52   virtual void SetSelectionMode (const IVtk_IShape::Handle& theShape,
53                                  const IVtk_SelectionMode theMode,
54                                  const bool theIsTurnOn = true) = 0;
55
56   //! Activates/deactivates the given selection mode for the shape.
57   //! If mode == SM_None, the shape becomes non-selectable and 
58   //! is removed from the internal selection data.
59   //! @param [in] theShapes List of shapes for which the selection mode should be activated
60   //! @param [in] theMode Selection mode to be activated
61   //! @param [in] theIsTurnOn Flag to turn on/off the selection mode
62   virtual void SetSelectionMode (const IVtk_ShapePtrList& theShapes,
63                                  const IVtk_SelectionMode theMode,
64                                  const bool theIsTurnOn = true) = 0;
65
66 public: // @name Picking methods
67
68   virtual bool Pick (const double theX, const double theY) = 0;
69   virtual bool Pick (const double theXMin,
70                      const double theYMin,
71                      const double theXMax,
72                      const double theYMax) = 0;
73                      
74   virtual bool Pick (double** /* double poly[][3]*/, const int theNbPoints) = 0;
75
76 public: // @name Obtain picking results
77
78   //! @return the list of picked top-level shape IDs,
79   //! in the order of increasing depth (the ID of the shape closest to the eye 
80   //! is the first in the list)
81   virtual const IVtk_ShapeIdList& ShapesPicked() const = 0;
82
83   //! @param [in] theId Top-level shape ID
84   //! @param [out] theShapeList the list of picked sub-shape IDs for the given top-level shape ID,
85   //! in the order of increasing depth (the ID of the sub-shape closest to the eye 
86   //! is the first in the list)
87   virtual void SubShapesPicked (const IVtk_IdType theId, IVtk_ShapeIdList& theShapeList) const = 0;
88 };
89
90 #endif // __IVTK_ISHAPEPICKERALGO_H__