0031431: Visualization, PrsMgr_PresentableObject - simplify HLR computing interface
[occt.git] / src / StdSelect / StdSelect_ViewerSelector3d.hxx
1 // Created on: 1995-03-15
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _StdSelect_ViewerSelector3d_HeaderFile
18 #define _StdSelect_ViewerSelector3d_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22 #include <Standard_Type.hxx>
23
24 #include <Graphic3d_SequenceOfStructure.hxx>
25 #include <Graphic3d_SequenceOfHClipPlane.hxx>
26 #include <SelectMgr_ViewerSelector.hxx>
27 #include <SelectMgr_Selection.hxx>
28 #include <StdSelect_TypeOfSelectionImage.hxx>
29 #include <NCollection_Handle.hxx>
30 #include <V3d_ImageDumpOptions.hxx>
31
32 class Graphic3d_Group;
33 class Graphic3d_Structure;
34 class Graphic3d_TransformPers;
35 class V3d_View;
36 class SelectMgr_EntityOwner;
37 class SelectMgr_SelectableObjectSet;
38
39
40 //! Selector Usable by Viewers from V3d
41 class StdSelect_ViewerSelector3d : public SelectMgr_ViewerSelector
42 {
43
44 public:
45
46   //! Constructs an empty 3D selector object.
47   Standard_EXPORT StdSelect_ViewerSelector3d();
48
49   //! Sets the pixel tolerance <theTolerance>.
50   Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance);
51
52   //! Returns the pixel tolerance.
53   Standard_Integer PixelTolerance() const { return myTolerances.Tolerance(); }
54
55   //! Picks the sensitive entity at the pixel coordinates of
56   //! the mouse <theXPix> and <theYPix>. The selector looks for touched areas and owners.
57   Standard_EXPORT void Pick (const Standard_Integer theXPix,
58                              const Standard_Integer theYPix,
59                              const Handle(V3d_View)& theView);
60
61   //! Picks the sensitive entity according to the minimum
62   //! and maximum pixel values <theXPMin>, <theYPMin>, <theXPMax>
63   //! and <theYPMax> defining a 2D area for selection in the 3D view aView.
64   Standard_EXPORT void Pick (const Standard_Integer theXPMin,
65                              const Standard_Integer theYPMin,
66                              const Standard_Integer theXPMax,
67                              const Standard_Integer theYPMax,
68                              const Handle(V3d_View)& theView);
69
70   //! pick action - input pixel values for polyline selection for selection.
71   Standard_EXPORT void Pick (const TColgp_Array1OfPnt2d& thePolyline,
72                              const Handle(V3d_View)& theView);
73
74   //! Dump of detection results into image.
75   //! This method performs axis picking for each pixel in the image
76   //! and generates a color depending on picking results and selection image type.
77   //! @param theImage       result image, should be initialized
78   //! @param theView        3D view defining camera position
79   //! @param theType        type of image to define
80   //! @param thePickedIndex index of picked entity (1 means topmost)
81   Standard_EXPORT Standard_Boolean ToPixMap (Image_PixMap&                        theImage,
82                                              const Handle(V3d_View)&              theView,
83                                              const StdSelect_TypeOfSelectionImage theType,
84                                              const Standard_Integer               thePickedIndex = 1);
85
86   //! Displays sensitives in view <theView>.
87   Standard_EXPORT void DisplaySensitive (const Handle(V3d_View)& theView);
88   
89   Standard_EXPORT void ClearSensitive (const Handle(V3d_View)& theView);
90   
91   Standard_EXPORT void DisplaySensitive (const Handle(SelectMgr_Selection)& theSel,
92                                          const gp_Trsf& theTrsf,
93                                          const Handle(V3d_View)& theView,
94                                          const Standard_Boolean theToClearOthers = Standard_True);
95
96   //! Dumps the content of me into the stream
97   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
98
99   DEFINE_STANDARD_RTTIEXT(StdSelect_ViewerSelector3d,SelectMgr_ViewerSelector)
100
101 protected:
102
103   Standard_EXPORT void computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
104                                             const Handle(SelectMgr_Selection)& theSel,
105                                             const gp_Trsf& theLoc,
106                                             const Handle(Graphic3d_TransformPers)& theTrsfPers);
107
108   //! Update z-layers order map.
109   Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView);
110
111 protected:
112
113   Graphic3d_SequenceOfStructure myStructs;
114 };
115
116 DEFINE_STANDARD_HANDLE(StdSelect_ViewerSelector3d, SelectMgr_ViewerSelector)
117
118 #endif