0024904: Visualization - Integration of VIS component:
[occt.git] / src / IVtkOCC / IVtkOCC_ViewerSelector.hxx
1 // Created on: 2011-10-20 
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 __IVTKOCC_VIEWERSELECTOR_H__
17 #define __IVTKOCC_VIEWERSELECTOR_H__
18
19 #include <IVtk_IView.hxx>
20 #include <Select3D_Projector.hxx>
21 #include <SelectMgr_Selection.hxx>
22 #include <SelectMgr_ViewerSelector.hxx>
23
24 // -----------------------------------------------------------------------------
25 //! @class IVtkOCC_ViewerSelector
26 //! @brief Class that implements OCCT selection algorithm.
27 //!
28 //! Inspired by StdSelect_ViewerSelector3d class from OCCT 6.5.1
29
30 class IVtkOCC_ViewerSelector : public SelectMgr_ViewerSelector
31 {
32 public:
33   IVtkOCC_ViewerSelector();
34
35   //! Projects all sensitive entities from the given selection container to 2D space
36   //! param [in] theSelection Container with sensitive entities to project
37   void Convert (const Handle(SelectMgr_Selection)& theSelection);
38
39   //! Implements point picking
40   //! @param [in] theXPix, theYPix Display coordinates of the point
41   //! @param [in] theView  ICamera interface to update the projection parameters.
42   void Pick (const Standard_Integer    theXPix,
43              const Standard_Integer    theYPix,
44              const IVtk_IView::Handle& theView);
45
46   //! Picking by rectangle
47   //! @param [in] theXMin, theYMin, theXMax, theYMax Rectangle coords
48   //! @param [in] theView ICamera interface to calculate projections
49   void Pick (const Standard_Integer    theXMin,
50              const Standard_Integer    theYMin,
51              const Standard_Integer    theXMax,
52              const Standard_Integer    theYMax,
53              const IVtk_IView::Handle& theView);
54
55   //! Implements point picking
56   void Pick (double** thePoly, const int theNbPoints, const IVtk_IView::Handle& theView);
57
58   //! Activates the given selection
59   void Activate (const Handle(SelectMgr_Selection)& theSelection,
60                  const Standard_Boolean             isAutomaticProj = Standard_True);
61
62   //! Deactivate the given selection
63   void Deactivate (const Handle(SelectMgr_Selection)& theSelection);
64
65   //! Checks if some projection parameters have changed,
66   //! and updates the 2D projections of all sensitive entities if necessary.
67   //! @param [in] theView Interface to VTK renderer to access projection parameters
68   Standard_Boolean Update (const IVtk_IView::Handle& theView);
69
70   //! Returns picking line.
71   //! @param theX direction X.
72   //! @param theX direction Y.
73   //! @return picking direction.
74   virtual gp_Lin PickingLine (const Standard_Real theX, const Standard_Real theY) const;
75
76   DEFINE_STANDARD_RTTI( IVtkOCC_ViewerSelector )
77
78 private:
79   Standard_Real myCoeff[14];
80   Standard_Real myPrevCoeff[14];
81   Standard_Real myCenter[2];
82   Standard_Real myPrevCenter[2];
83   Standard_Integer myPixTol;
84   Handle(Select3D_Projector) myPrj;
85   Standard_Boolean myToUpdateTol;
86 };
87
88 DEFINE_STANDARD_HANDLE( IVtkOCC_ViewerSelector, SelectMgr_ViewerSelector )
89 #endif // __IVTKOCC_VIEWERSELECTOR_H__