1 // Created on: 2011-10-20
2 // Created by: Roman KOZLOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef __IVTKOCC_VIEWERSELECTOR_H__
17 #define __IVTKOCC_VIEWERSELECTOR_H__
19 #include <IVtk_IView.hxx>
20 #include <Select3D_Projector.hxx>
21 #include <SelectMgr_Selection.hxx>
22 #include <SelectMgr_ViewerSelector.hxx>
24 // -----------------------------------------------------------------------------
25 //! @class IVtkOCC_ViewerSelector
26 //! @brief Class that implements OCCT selection algorithm.
28 //! Inspired by StdSelect_ViewerSelector3d class from OCCT 6.5.1
30 class IVtkOCC_ViewerSelector : public SelectMgr_ViewerSelector
33 IVtkOCC_ViewerSelector();
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);
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);
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);
55 //! Implements point picking
56 void Pick (double** thePoly, const int theNbPoints, const IVtk_IView::Handle& theView);
58 //! Activates the given selection
59 void Activate (const Handle(SelectMgr_Selection)& theSelection,
60 const Standard_Boolean isAutomaticProj = Standard_True);
62 //! Deactivate the given selection
63 void Deactivate (const Handle(SelectMgr_Selection)& theSelection);
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);
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;
76 DEFINE_STANDARD_RTTI( IVtkOCC_ViewerSelector )
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;
88 DEFINE_STANDARD_HANDLE( IVtkOCC_ViewerSelector, SelectMgr_ViewerSelector )
89 #endif // __IVTKOCC_VIEWERSELECTOR_H__