a79f67f8 |
1 | // Created on: 2011-03-06 |
2 | // Created by: Sergey ZERCHANINOV |
3 | // Copyright (c) 2011-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 _Graphic3d_GraduatedTrihedron_HeaderFile |
17 | #define _Graphic3d_GraduatedTrihedron_HeaderFile |
18 | |
19 | #include <Font_FontAspect.hxx> |
20 | #include <NCollection_Array1.hxx> |
21 | #include <Quantity_Color.hxx> |
22 | #include <Standard_Boolean.hxx> |
23 | #include <Standard_Integer.hxx> |
24 | #include <TCollection_AsciiString.hxx> |
25 | #include <TCollection_ExtendedString.hxx> |
26 | |
27 | class Visual3d_View; |
28 | |
29 | //! Class that stores style for one graduated trihedron axis such as colors, lengths and customization flags. |
30 | //! It is used in Graphic3d_GraduatedTrihedron. |
31 | class Graphic3d_AxisAspect |
32 | { |
33 | public: |
34 | |
35 | Graphic3d_AxisAspect (const TCollection_ExtendedString theName = "", const Quantity_Color theNameColor = Quantity_NOC_BLACK, |
36 | const Quantity_Color theColor = Quantity_NOC_BLACK, |
37 | const Standard_Integer theValuesOffset = 10, const Standard_Integer theNameOffset = 30, |
536d98e2 |
38 | const Standard_Integer theTickmarksNumber = 5, const Standard_Integer theTickmarksLength = 10, |
a79f67f8 |
39 | const Standard_Boolean theToDrawName = Standard_True, |
40 | const Standard_Boolean theToDrawValues = Standard_True, |
41 | const Standard_Boolean theToDrawTickmarks = Standard_True) |
42 | : myName (theName), |
43 | myToDrawName (theToDrawName), |
44 | myToDrawTickmarks (theToDrawTickmarks), |
45 | myToDrawValues (theToDrawValues), |
46 | myNameColor (theNameColor), |
536d98e2 |
47 | myTickmarksNumber (theTickmarksNumber), |
48 | myTickmarksLength (theTickmarksLength), |
a79f67f8 |
49 | myColor (theColor), |
50 | myValuesOffset (theValuesOffset), |
51 | myNameOffset (theNameOffset) |
52 | { } |
53 | |
54 | public: |
55 | |
56 | void SetName (const TCollection_ExtendedString& theName) { myName = theName; } |
57 | const TCollection_ExtendedString& Name() const { return myName; } |
58 | |
59 | const Standard_Boolean ToDrawName() const { return myToDrawName; } |
536d98e2 |
60 | void SetDrawName (const Standard_Boolean theToDraw) { myToDrawName = theToDraw; } |
a79f67f8 |
61 | |
62 | const Standard_Boolean ToDrawTickmarks() const { return myToDrawTickmarks; } |
536d98e2 |
63 | void SetDrawTickmarks (const Standard_Boolean theToDraw) { myToDrawTickmarks = theToDraw; } |
a79f67f8 |
64 | |
65 | const Standard_Boolean ToDrawValues() const { return myToDrawValues; } |
536d98e2 |
66 | void SetDrawValues (const Standard_Boolean theToDraw) { myToDrawValues = theToDraw; } |
a79f67f8 |
67 | |
68 | const Quantity_Color& NameColor() const { return myNameColor; } |
69 | void SetNameColor (const Quantity_Color& theColor) { myNameColor = theColor; } |
70 | |
71 | //! Color of axis and values |
72 | const Quantity_Color& Color() const { return myColor; } |
73 | |
74 | //! Sets color of axis and values |
75 | void SetColor (const Quantity_Color& theColor) { myColor = theColor; } |
76 | |
536d98e2 |
77 | const Standard_Integer TickmarksNumber() const { return myTickmarksNumber; } |
78 | void SetTickmarksNumber (const Standard_Integer theValue) { myTickmarksNumber = theValue; } |
a79f67f8 |
79 | |
536d98e2 |
80 | const Standard_Integer TickmarksLength() const { return myTickmarksLength; } |
81 | void SetTickmarksLength (const Standard_Integer theValue) { myTickmarksLength = theValue; } |
a79f67f8 |
82 | |
83 | const Standard_Integer ValuesOffset() const { return myValuesOffset; } |
84 | void SetValuesOffset (const Standard_Integer theValue) { myValuesOffset = theValue; } |
85 | |
86 | const Standard_Integer NameOffset() const { return myNameOffset; } |
87 | void SetNameOffset (const Standard_Integer theValue) { myNameOffset = theValue; } |
88 | |
89 | protected: |
90 | |
91 | TCollection_ExtendedString myName; |
92 | |
93 | Standard_Boolean myToDrawName; |
94 | Standard_Boolean myToDrawTickmarks; |
95 | Standard_Boolean myToDrawValues; |
96 | |
97 | Quantity_Color myNameColor; |
98 | |
536d98e2 |
99 | Standard_Integer myTickmarksNumber; //!< Number of splits along axes |
100 | Standard_Integer myTickmarksLength; //!< Length of tickmarks |
101 | Quantity_Color myColor; //!< Color of axis and values |
a79f67f8 |
102 | |
536d98e2 |
103 | Standard_Integer myValuesOffset; //!< Offset for drawing values |
104 | Standard_Integer myNameOffset; //!< Offset for drawing name of axis |
a79f67f8 |
105 | }; |
106 | |
107 | //! Defines the class of a graduated trihedron. |
108 | //! It contains main style parameters for implementation of graduated trihedron |
109 | //! @sa OpenGl_GraduatedTrihedron |
110 | class Graphic3d_GraduatedTrihedron |
111 | { |
112 | public: |
113 | |
114 | typedef void (*MinMaxValuesCallback) (Visual3d_View*); |
115 | |
116 | public: |
117 | |
118 | //! Default constructor |
119 | //! Constructs the default graduated trihedron with grid, X, Y, Z axes, and tickmarks |
120 | Graphic3d_GraduatedTrihedron (const TCollection_AsciiString& theNamesFont = "Arial", |
536d98e2 |
121 | const Font_FontAspect& theNamesStyle = Font_FA_Bold, const Standard_Integer theNamesSize = 12, |
a79f67f8 |
122 | const TCollection_AsciiString& theValuesFont = "Arial", |
123 | const Font_FontAspect& theValuesStyle = Font_FA_Regular, const Standard_Integer theValuesSize = 12, |
536d98e2 |
124 | const Standard_ShortReal theArrowsLength = 30.0f, const Quantity_Color theGridColor = Quantity_NOC_WHITE, |
a79f67f8 |
125 | const Standard_Boolean theToDrawGrid = Standard_True, const Standard_Boolean theToDrawAxes = Standard_True) |
126 | : myNamesFont (theNamesFont), |
536d98e2 |
127 | myNamesStyle (theNamesStyle), |
a79f67f8 |
128 | myNamesSize (theNamesSize), |
129 | myValuesFont (theValuesFont), |
130 | myValuesStyle (theValuesStyle), |
131 | myValuesSize (theValuesSize), |
536d98e2 |
132 | myArrowsLength (theArrowsLength), |
a79f67f8 |
133 | myGridColor (theGridColor), |
134 | myToDrawGrid (theToDrawGrid), |
135 | myToDrawAxes (theToDrawAxes), |
136 | myAxes(0, 2) |
137 | { |
138 | myAxes (0) = Graphic3d_AxisAspect ("X", Quantity_NOC_RED, Quantity_NOC_RED); |
139 | myAxes (1) = Graphic3d_AxisAspect ("Y", Quantity_NOC_GREEN, Quantity_NOC_GREEN); |
140 | myAxes (2) = Graphic3d_AxisAspect ("Z", Quantity_NOC_BLUE1, Quantity_NOC_BLUE1); |
141 | PtrVisual3dView = NULL; |
142 | } |
143 | |
144 | public: |
145 | |
146 | Graphic3d_AxisAspect& ChangeXAxisAspect() { return myAxes(0); } |
147 | Graphic3d_AxisAspect& ChangeYAxisAspect() { return myAxes(1); } |
148 | Graphic3d_AxisAspect& ChangeZAxisAspect() { return myAxes(2); } |
149 | |
150 | const Graphic3d_AxisAspect& XAxisAspect() const { return myAxes(0); } |
151 | const Graphic3d_AxisAspect& YAxisAspect() const { return myAxes(1); } |
152 | const Graphic3d_AxisAspect& ZAxisAspect() const { return myAxes(2); } |
153 | |
154 | const Graphic3d_AxisAspect& AxisAspect (const Standard_Integer theIndex) const |
155 | { |
156 | Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 2, "Graphic3d_GraduatedTrihedron::AxisAspect: theIndex is out of bounds [0,2]."); |
157 | return myAxes (theIndex); |
158 | } |
159 | |
536d98e2 |
160 | const Standard_ShortReal ArrowsLength() const { return myArrowsLength; } |
161 | void SetArrowsLength (const Standard_ShortReal theValue) { myArrowsLength = theValue; } |
a79f67f8 |
162 | |
163 | const Quantity_Color& GridColor() const { return myGridColor; } |
164 | void SetGridColor (const Quantity_Color& theColor) {myGridColor = theColor; } |
165 | |
166 | const Standard_Boolean ToDrawGrid() const { return myToDrawGrid; } |
536d98e2 |
167 | void SetDrawGrid (const Standard_Boolean theToDraw) { myToDrawGrid = theToDraw; } |
a79f67f8 |
168 | |
169 | const Standard_Boolean ToDrawAxes() const { return myToDrawAxes; } |
536d98e2 |
170 | void SetDrawAxes (const Standard_Boolean theToDraw) { myToDrawAxes = theToDraw; } |
a79f67f8 |
171 | |
172 | const TCollection_AsciiString& NamesFont() const { return myNamesFont; } |
173 | void SetNamesFont (const TCollection_AsciiString& theFont) { myNamesFont = theFont; } |
174 | |
a3ee6e9f |
175 | Font_FontAspect NamesFontAspect() const { return myNamesStyle; } |
176 | void SetNamesFontAspect (Font_FontAspect theAspect) { myNamesStyle = theAspect; } |
a79f67f8 |
177 | |
178 | const Standard_Integer NamesSize() const { return myNamesSize; } |
179 | void SetNamesSize (const Standard_Integer theValue) { myNamesSize = theValue; } |
180 | |
181 | const TCollection_AsciiString& ValuesFont () const { return myValuesFont; } |
182 | void SetValuesFont (const TCollection_AsciiString& theFont) { myValuesFont = theFont; } |
183 | |
a3ee6e9f |
184 | Font_FontAspect ValuesFontAspect() const { return myValuesStyle; } |
185 | void SetValuesFontAspect (Font_FontAspect theAspect) { myValuesStyle = theAspect; } |
a79f67f8 |
186 | |
187 | const Standard_Integer ValuesSize() const { return myValuesSize; } |
188 | void SetValuesSize (const Standard_Integer theValue) { myValuesSize = theValue; } |
189 | |
190 | public: |
191 | |
192 | MinMaxValuesCallback CubicAxesCallback; //!< Callback function to define boundary box of displayed objects |
193 | Visual3d_View* PtrVisual3dView; |
194 | |
195 | protected: |
196 | |
197 | TCollection_AsciiString myNamesFont; //!< Font name of names of axes: Courier, Arial, ... |
198 | Font_FontAspect myNamesStyle; //!< Style of names of axes: OSD_FA_Regular, OSD_FA_Bold,.. |
199 | Standard_Integer myNamesSize; //!< Size of names of axes: 8, 10,.. |
200 | |
201 | protected: |
202 | |
203 | TCollection_AsciiString myValuesFont; //!< Font name of values: Courier, Arial, ... |
204 | Font_FontAspect myValuesStyle; //!< Style of values: OSD_FA_Regular, OSD_FA_Bold, ... |
205 | Standard_Integer myValuesSize; //!< Size of values: 8, 10, 12, 14, ... |
206 | |
207 | protected: |
208 | |
536d98e2 |
209 | Standard_ShortReal myArrowsLength; |
a79f67f8 |
210 | Quantity_Color myGridColor; |
211 | |
212 | Standard_Boolean myToDrawGrid; |
213 | Standard_Boolean myToDrawAxes; |
214 | |
215 | NCollection_Array1<Graphic3d_AxisAspect> myAxes; //!< X, Y and Z axes parameters |
216 | |
217 | }; |
218 | #endif // Graphic3d_GraduatedTrihedron_HeaderFile |