0031431: Visualization, PrsMgr_PresentableObject - simplify HLR computing interface
[occt.git] / src / AIS / AIS_PointCloud.hxx
CommitLineData
d33222c1 1// Created on: 2014-08-13
2// Created by: Maxim GLIBIN
3// Copyright (c) 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 _AIS_PointCloud_HeaderFile
17#define _AIS_PointCloud_HeaderFile
18
19#include <AIS.hxx>
20#include <AIS_InteractiveObject.hxx>
21#include <Bnd_Box.hxx>
22#include <Graphic3d_ArrayOfPoints.hxx>
23#include <Quantity_HArray1OfColor.hxx>
4a056d20 24#include <SelectMgr_EntityOwner.hxx>
d33222c1 25#include <TColgp_HArray1OfDir.hxx>
26#include <TColgp_HArray1OfPnt.hxx>
27
4a056d20 28class TColStd_HPackedMapOfInteger;
d33222c1 29
30//! Interactive object for set of points.
31//! The presentation supports two display modes:
32//! - Points.
33//! - Bounding box for highlighting.
34//! Presentation provides selection by bouding box.
35//! Selection and consequently highlighting can disabled by
36//! setting default selection mode to -1. There will be no way
37//! to select object from interactive view. Any calls to
38//! AIS_InteractiveContext::AddOrRemoveSelected should be also prohibited,
39//! to avoid programmatic highlighting (workaround is setting non-supported
40//! hilight mode, e.g. 100);
41class AIS_PointCloud : public AIS_InteractiveObject
42{
4a056d20 43 DEFINE_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
d33222c1 44public:
45
46 //! Display modes supported by this Point Cloud object
47 enum DisplayMode
48 {
49 DM_Points = 0, //!< display as normal points, default presentation
50 DM_BndBox = 2 //!< display as bounding box, default for highlighting
51 };
52
8b9a309b 53 //! Selection modes supported by this Point Cloud object
54 enum SelectionMode
55 {
4a056d20 56 SM_Points = 0, //!< detected by points
57 SM_SubsetOfPoints = 1, //!< detect point(s) within Point Cloud rather than object as whole
58 SM_BndBox = 2, //!< detected by bounding box
8b9a309b 59 };
60
d33222c1 61public:
62
63 //! Constructor.
64 Standard_EXPORT AIS_PointCloud();
65
66 //! Sets the points from array of points.
67 //! Method will not copy the input data - array will be stored as handle.
68 //! @param thePoints [in] the array of points
69 Standard_EXPORT virtual void SetPoints (const Handle(Graphic3d_ArrayOfPoints)& thePoints);
70
71 //! Sets the points with optional colors.
72 //! The input data will be copied into internal buffer.
73 //! The input arrays should have equal length, otherwise
74 //! the presentation will not be computed and displayed.
75 //! @param theCoords [in] the array of coordinates
76 //! @param theColors [in] optional array of colors
77 //! @param theNormals [in] optional array of normals
78 Standard_EXPORT virtual void SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords,
79 const Handle(Quantity_HArray1OfColor)& theColors = NULL,
80 const Handle(TColgp_HArray1OfDir)& theNormals = NULL);
81
82public:
83
84 //! Get the points array.
85 //! Method might be overridden to fill in points array dynamically from application data structures.
86 //! @return the array of points
87 Standard_EXPORT virtual const Handle(Graphic3d_ArrayOfPoints) GetPoints() const;
88
89 //! Get bounding box for presentation.
90 Standard_EXPORT virtual Bnd_Box GetBoundingBox() const;
91
92public:
93
d33222c1 94 //! Setup custom color. Affects presentation only when no per-point color attribute has been assigned.
79104795 95 Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
d33222c1 96
97 //! Restore default color.
79104795 98 Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
d33222c1 99
d33222c1 100 //! Setup custom material. Affects presentation only when normals are defined.
79104795 101 Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE;
d33222c1 102
103 //! Restore default material.
79104795 104 Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
d33222c1 105
106protected:
107
108 //! Prepare presentation for this object.
109 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
110 const Handle(Prs3d_Presentation)& thePrs,
79104795 111 const Standard_Integer theMode) Standard_OVERRIDE;
d33222c1 112
113 //! Prepare selection for this object.
114 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
79104795 115 const Standard_Integer theMode) Standard_OVERRIDE;
d33222c1 116
117private:
118
119 Handle(Graphic3d_ArrayOfPoints) myPoints; //!< points array for presentation
120 Bnd_Box myBndBox; //!< bounding box for presentation
121
4a056d20 122};
123
124DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject)
125
126//! Custom owner for highlighting selected points.
127class AIS_PointCloudOwner : public SelectMgr_EntityOwner
128{
129 DEFINE_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
d33222c1 130public:
4a056d20 131 //! Main constructor.
132 Standard_EXPORT AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin);
d33222c1 133
4a056d20 134 //! Destructor.
135 Standard_EXPORT virtual ~AIS_PointCloudOwner();
d33222c1 136
4a056d20 137 //! Return selected points.
138 //! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
139 const Handle(TColStd_HPackedMapOfInteger)& SelectedPoints() const { return mySelPoints; }
140
141 //! Return last detected points.
142 //! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
143 const Handle(TColStd_HPackedMapOfInteger)& DetectedPoints() const { return myDetPoints; }
144
145 //! Always update dynamic highlighting.
146 Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
147
148 //! Handle dynamic highlighting.
149 Standard_EXPORT virtual void HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
150 const Handle(Prs3d_Drawer)& theStyle,
151 const Standard_Integer theMode) Standard_OVERRIDE;
152
153 //! Removes highlighting.
154 Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
155
156 //! Clears presentation.
157 Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
158protected:
159 Handle(TColStd_HPackedMapOfInteger) myDetPoints; //!< last detected points
160 Handle(TColStd_HPackedMapOfInteger) mySelPoints; //!< selected points
d33222c1 161};
162
163#endif // _AIS_PointCloud_HeaderFile