0027536: Visualization - incorrect behavior of zoom persisted objects
[occt.git] / src / MeshVS / MeshVS_VectorPrsBuilder.hxx
1 // Created on: 2003-10-13
2 // Created by: Alexander SOLOVYOV
3 // Copyright (c) 2003-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 _MeshVS_VectorPrsBuilder_HeaderFile
17 #define _MeshVS_VectorPrsBuilder_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21
22 #include <Standard_Boolean.hxx>
23 #include <Standard_Real.hxx>
24 #include <MeshVS_DataMapOfIntegerVector.hxx>
25 #include <MeshVS_PrsBuilder.hxx>
26 #include <MeshVS_DisplayModeFlags.hxx>
27 #include <Standard_Integer.hxx>
28 #include <MeshVS_BuilderPriority.hxx>
29 #include <TColStd_PackedMapOfInteger.hxx>
30 #include <TColgp_Array1OfPnt.hxx>
31 class MeshVS_Mesh;
32 class Quantity_Color;
33 class MeshVS_DataSource;
34 class Prs3d_Presentation;
35 class gp_Trsf;
36 class Graphic3d_ArrayOfPrimitives;
37 class gp_Vec;
38
39
40 class MeshVS_VectorPrsBuilder;
41 DEFINE_STANDARD_HANDLE(MeshVS_VectorPrsBuilder, MeshVS_PrsBuilder)
42
43 //! This class provides methods to create vector data presentation.
44 //! It store map of vectors assigned with nodes or elements.
45 //! In simplified mode vectors draws with thickened ends instead of arrows
46 class MeshVS_VectorPrsBuilder : public MeshVS_PrsBuilder
47 {
48
49 public:
50
51   
52   Standard_EXPORT MeshVS_VectorPrsBuilder(const Handle(MeshVS_Mesh)& Parent, const Standard_Real MaxLength, const Quantity_Color& VectorColor, const MeshVS_DisplayModeFlags& Flags = MeshVS_DMF_VectorDataPrs, const Handle(MeshVS_DataSource)& DS = 0, const Standard_Integer Id = -1, const MeshVS_BuilderPriority& Priority = MeshVS_BP_Vector, const Standard_Boolean IsSimplePrs = Standard_False);
53   
54   //! Builds vector data presentation
55   Standard_EXPORT virtual void Build (const Handle(Prs3d_Presentation)& Prs, const TColStd_PackedMapOfInteger& IDs, TColStd_PackedMapOfInteger& IDsToExclude, const Standard_Boolean IsElement, const Standard_Integer theDisplayMode) const Standard_OVERRIDE;
56   
57   //! Adds to array of polygons and polylines some primitive representing single vector
58   Standard_EXPORT void DrawVector (const gp_Trsf& theTrsf, const Standard_Real Length, const Standard_Real MaxLength, const TColgp_Array1OfPnt& ArrowPoints, const Handle(Graphic3d_ArrayOfPrimitives)& Lines, const Handle(Graphic3d_ArrayOfPrimitives)& ArrowLines, const Handle(Graphic3d_ArrayOfPrimitives)& Triangles) const;
59   
60   //! Calculates points of arrow presentation
61   Standard_EXPORT static Standard_Real calculateArrow (TColgp_Array1OfPnt& Points, const Standard_Real Length, const Standard_Real ArrowPart);
62   
63   //! Returns map of vectors assigned with nodes or elements
64   Standard_EXPORT const MeshVS_DataMapOfIntegerVector& GetVectors (const Standard_Boolean IsElement) const;
65   
66   //! Sets map of vectors assigned with nodes or elements
67   Standard_EXPORT void SetVectors (const Standard_Boolean IsElement, const MeshVS_DataMapOfIntegerVector& Map);
68   
69   //! Returns true, if map isn't empty
70   Standard_EXPORT Standard_Boolean HasVectors (const Standard_Boolean IsElement) const;
71   
72   //! Returns vector assigned with certain node or element
73   Standard_EXPORT Standard_Boolean GetVector (const Standard_Boolean IsElement, const Standard_Integer ID, gp_Vec& Vect) const;
74   
75   //! Sets vector assigned with certain node or element
76   Standard_EXPORT void SetVector (const Standard_Boolean IsElement, const Standard_Integer ID, const gp_Vec& Vect);
77   
78   //! Calculates minimal and maximal length of vectors in map
79   //! ( nodal, if IsElement = False or elemental, if IsElement = True )
80   Standard_EXPORT void GetMinMaxVectorValue (const Standard_Boolean IsElement, Standard_Real& MinValue, Standard_Real& MaxValue) const;
81   
82   //! Sets flag that indicates is simple vector arrow mode uses or not
83   //! default value is False
84   Standard_EXPORT void SetSimplePrsMode (const Standard_Boolean IsSimpleArrow);
85   
86   //! Sets parameters of simple vector arrwo presentation
87   //! theLineWidthParam - coefficient of vector line width (to draw line instead of arrow)
88   //! theStartParam and theEndParam parameters of start and end of thickened ends
89   //! position of thickening calculates according to parameters and maximum vector length
90   //! default values are:
91   //! theLineWidthParam = 2.5
92   //! theStartParam     = 0.85
93   //! theEndParam       = 0.95
94   Standard_EXPORT void SetSimplePrsParams (const Standard_Real theLineWidthParam, const Standard_Real theStartParam, const Standard_Real theEndParam);
95
96
97
98
99   DEFINE_STANDARD_RTTIEXT(MeshVS_VectorPrsBuilder,MeshVS_PrsBuilder)
100
101 protected:
102
103
104
105
106 private:
107
108
109   Standard_Boolean myIsSimplePrs;
110   Standard_Real mySimpleWidthPrm;
111   Standard_Real mySimpleStartPrm;
112   Standard_Real mySimpleEndPrm;
113   MeshVS_DataMapOfIntegerVector myNodeVectorMap;
114   MeshVS_DataMapOfIntegerVector myElemVectorMap;
115
116
117 };
118
119
120
121
122
123
124
125 #endif // _MeshVS_VectorPrsBuilder_HeaderFile