0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Prs3d / Prs3d_DimensionAspect.hxx
1 // Copyright (c) 1993-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _Prs3d_DimensionAspect_HeaderFile
16 #define _Prs3d_DimensionAspect_HeaderFile
17
18 #include <Prs3d_ArrowAspect.hxx>
19 #include <Prs3d_DimensionArrowOrientation.hxx>
20 #include <Prs3d_DimensionTextHorizontalPosition.hxx>
21 #include <Prs3d_DimensionTextVerticalPosition.hxx>
22 #include <Prs3d_LineAspect.hxx>
23 #include <Prs3d_TextAspect.hxx>
24 #include <TCollection_AsciiString.hxx>
25
26 //! defines the attributes when drawing a Length Presentation.
27 class Prs3d_DimensionAspect : public Prs3d_BasicAspect
28 {
29   DEFINE_STANDARD_RTTIEXT(Prs3d_DimensionAspect, Prs3d_BasicAspect)
30 public:
31
32   //! Constructs an empty framework to define the display of dimensions.
33   Standard_EXPORT Prs3d_DimensionAspect();
34   
35   //! Returns the settings for the display of lines used in presentation of dimensions.
36   const Handle(Prs3d_LineAspect)& LineAspect() const { return myLineAspect; }
37
38   //! Sets the display attributes of lines used in presentation of dimensions.
39   void SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect) { myLineAspect = theAspect; }
40
41   //! Returns the settings for the display of text used in presentation of dimensions.
42   const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
43
44   //! Sets the display attributes of text used in presentation of dimensions.
45   void SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect) { myTextAspect = theAspect; }
46
47   //! Check if text for dimension label is 3d.
48   Standard_Boolean IsText3d() const { return myIsText3d; }
49
50   //! Sets type of text.
51   void MakeText3d (const Standard_Boolean isText3d) { myIsText3d = isText3d; }
52
53   //! Check if 3d text for dimension label is shaded.
54   Standard_Boolean IsTextShaded() const { return myIsTextShaded; }
55
56   //! Turns on/off text shading for 3d text.
57   void MakeTextShaded (const Standard_Boolean theIsTextShaded) { myIsTextShaded = theIsTextShaded; }
58
59   //! Gets type of arrows.
60   Standard_Boolean IsArrows3d() const { return myIsArrows3d; }
61
62   //! Sets type of arrows.
63   void MakeArrows3d (const Standard_Boolean theIsArrows3d) { myIsArrows3d = theIsArrows3d; }
64
65   //! Shows if Units are to be displayed along with dimension value.
66   Standard_Boolean IsUnitsDisplayed() const { return myToDisplayUnits; }
67   
68   //! Specifies whether the units string should be displayed
69   //! along with value label or not.
70   void MakeUnitsDisplayed (const Standard_Boolean theIsDisplayed) { myToDisplayUnits = theIsDisplayed; }
71   
72   //! Sets orientation of arrows (external or internal).
73   //! By default orientation is chosen automatically according to situation and text label size.
74   void SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient) { myArrowOrientation = theArrowOrient; }
75
76   //! Gets orientation of arrows (external or internal).
77   Prs3d_DimensionArrowOrientation ArrowOrientation() const { return myArrowOrientation; }
78
79   //! Sets vertical text alignment for text label.
80   void SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition) { myTextVPosition = thePosition; }
81
82   //! Gets vertical text alignment for text label.
83   Prs3d_DimensionTextVerticalPosition TextVerticalPosition() const { return myTextVPosition; }
84
85   //! Sets horizontal text alignment for text label.
86   void SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition) { myTextHPosition = thePosition; }
87
88   //! Gets horizontal text alignment for text label.
89   Prs3d_DimensionTextHorizontalPosition TextHorizontalPosition() const { return myTextHPosition; }
90
91   //! Returns the settings for displaying arrows.
92   const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; }
93
94   //! Sets the display attributes of arrows used in presentation of dimensions.
95   void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) { myArrowAspect = theAspect; }
96
97   //! Sets the same color for all parts of dimension: lines, arrows and text.
98   Standard_EXPORT void SetCommonColor (const Quantity_Color& theColor);
99   
100   //! Sets extension size.
101   void SetExtensionSize (const Standard_Real theSize) { myExtensionSize = theSize; }
102
103   //! Returns extension size.
104   Standard_Real ExtensionSize() const { return myExtensionSize; }
105
106   //! Set size for arrow tail (extension without text).
107   void SetArrowTailSize (const Standard_Real theSize) { myArrowTailSize = theSize; }
108
109   //! Returns arrow tail size.
110   Standard_Real ArrowTailSize() const { return myArrowTailSize; }
111   
112   //! Sets "sprintf"-syntax format for formatting dimension value labels.
113   void SetValueStringFormat (const TCollection_AsciiString& theFormat) { myValueStringFormat = theFormat; }
114
115   //! Returns format.
116   const TCollection_AsciiString& ValueStringFormat() const { return myValueStringFormat; }
117
118   //! Dumps the content of me into the stream
119   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
120
121 protected:
122
123   Handle(Prs3d_LineAspect)  myLineAspect;
124   Handle(Prs3d_TextAspect)  myTextAspect;
125   Handle(Prs3d_ArrowAspect) myArrowAspect;
126   TCollection_AsciiString   myValueStringFormat;
127   Standard_Real             myExtensionSize;
128   Standard_Real             myArrowTailSize;
129   Prs3d_DimensionArrowOrientation       myArrowOrientation;
130   Prs3d_DimensionTextHorizontalPosition myTextHPosition;
131   Prs3d_DimensionTextVerticalPosition   myTextVPosition;
132   Standard_Boolean myToDisplayUnits;
133   Standard_Boolean myIsText3d;
134   Standard_Boolean myIsTextShaded;
135   Standard_Boolean myIsArrows3d;
136
137 };
138
139 DEFINE_STANDARD_HANDLE(Prs3d_DimensionAspect, Prs3d_BasicAspect)
140
141 #endif // _Prs3d_DimensionAspect_HeaderFile