0030674: Visualization, AIS_InteractiveObject - fix accessibility of several properties
[occt.git] / src / AIS / AIS_Triangulation.hxx
1 // Created on: 2009-12-10
2 // Created by: Paul SUPRYATKIN
3 // Copyright (c) 2009-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_Triangulation_HeaderFile
17 #define _AIS_Triangulation_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21
22 #include <TColStd_HArray1OfInteger.hxx>
23 #include <Standard_Integer.hxx>
24 #include <AIS_InteractiveObject.hxx>
25 #include <PrsMgr_PresentationManager3d.hxx>
26 #include <SelectMgr_Selection.hxx>
27 #include <Standard_Real.hxx>
28 class Poly_Triangulation;
29 class Prs3d_Presentation;
30
31
32 class AIS_Triangulation;
33 DEFINE_STANDARD_HANDLE(AIS_Triangulation, AIS_InteractiveObject)
34
35 //! Interactive object that draws data from  Poly_Triangulation, optionally with colors associated
36 //! with each triangulation vertex. For maximum efficiency colors are represented as 32-bit integers
37 //! instead of classic Quantity_Color values.
38 //! Interactive selection of triangles and vertices is not yet implemented.
39 class AIS_Triangulation : public AIS_InteractiveObject
40 {
41
42 public:
43
44   
45   //! Constructs the Triangulation display object
46   Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation);
47   
48
49   //! Set the color for each node.
50   //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
51   //! Order of color components is essential for further usage by OpenGL
52   Standard_EXPORT void SetColors (const Handle(TColStd_HArray1OfInteger)& aColor);
53   
54
55   //! Get the color for each node.
56   //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
57   Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const;
58
59   //! Returns true if triangulation has vertex colors.
60   Standard_Boolean HasVertexColors() const
61   {
62     return (myFlagColor == 1);
63   }
64   
65   Standard_EXPORT void SetTriangulation (const Handle(Poly_Triangulation)& aTriangulation);
66   
67   //! Returns Poly_Triangulation .
68   Standard_EXPORT Handle(Poly_Triangulation) GetTriangulation() const;
69
70   //! Sets the value aValue for transparency in the reconstructed compound shape.
71   Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE;
72
73   //! Removes the setting for transparency in the reconstructed compound shape.
74   Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
75
76   DEFINE_STANDARD_RTTIEXT(AIS_Triangulation,AIS_InteractiveObject)
77
78 protected:
79
80   Standard_EXPORT void updatePresentation();
81
82
83
84 private:
85
86   
87   Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
88   
89   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
90   
91   //! Attenuates 32-bit color by a given attenuation factor (0...1):
92   //! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
93   //! All color components are multiplied by aComponent, the result is then packed again as 32-bit integer.
94   //! Color attenuation is applied to the vertex colors in order to have correct visual result
95   //! after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat.
96   Standard_EXPORT Graphic3d_Vec4ub attenuateColor (const Standard_Integer theColor, const Standard_Real theComponent);
97
98   Handle(Poly_Triangulation) myTriangulation;
99   Handle(TColStd_HArray1OfInteger) myColor;
100   Standard_Integer myFlagColor;
101   Standard_Integer myNbNodes;
102   Standard_Integer myNbTriangles;
103
104
105 };
106
107
108
109
110
111
112
113 #endif // _AIS_Triangulation_HeaderFile