1 // Created on: 2011-03-06
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Graphic3d_GraduatedTrihedron_HeaderFile
17 #define _Graphic3d_GraduatedTrihedron_HeaderFile
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>
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
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,
38 const Standard_Integer theTickmarksNumber = 5, const Standard_Integer theTickmarksLength = 10,
39 const Standard_Boolean theToDrawName = Standard_True,
40 const Standard_Boolean theToDrawValues = Standard_True,
41 const Standard_Boolean theToDrawTickmarks = Standard_True)
43 myToDrawName (theToDrawName),
44 myToDrawTickmarks (theToDrawTickmarks),
45 myToDrawValues (theToDrawValues),
46 myNameColor (theNameColor),
47 myTickmarksNumber (theTickmarksNumber),
48 myTickmarksLength (theTickmarksLength),
50 myValuesOffset (theValuesOffset),
51 myNameOffset (theNameOffset)
56 void SetName (const TCollection_ExtendedString& theName) { myName = theName; }
57 const TCollection_ExtendedString& Name() const { return myName; }
59 const Standard_Boolean ToDrawName() const { return myToDrawName; }
60 void SetDrawName (const Standard_Boolean theToDraw) { myToDrawName = theToDraw; }
62 const Standard_Boolean ToDrawTickmarks() const { return myToDrawTickmarks; }
63 void SetDrawTickmarks (const Standard_Boolean theToDraw) { myToDrawTickmarks = theToDraw; }
65 const Standard_Boolean ToDrawValues() const { return myToDrawValues; }
66 void SetDrawValues (const Standard_Boolean theToDraw) { myToDrawValues = theToDraw; }
68 const Quantity_Color& NameColor() const { return myNameColor; }
69 void SetNameColor (const Quantity_Color& theColor) { myNameColor = theColor; }
71 //! Color of axis and values
72 const Quantity_Color& Color() const { return myColor; }
74 //! Sets color of axis and values
75 void SetColor (const Quantity_Color& theColor) { myColor = theColor; }
77 const Standard_Integer TickmarksNumber() const { return myTickmarksNumber; }
78 void SetTickmarksNumber (const Standard_Integer theValue) { myTickmarksNumber = theValue; }
80 const Standard_Integer TickmarksLength() const { return myTickmarksLength; }
81 void SetTickmarksLength (const Standard_Integer theValue) { myTickmarksLength = theValue; }
83 const Standard_Integer ValuesOffset() const { return myValuesOffset; }
84 void SetValuesOffset (const Standard_Integer theValue) { myValuesOffset = theValue; }
86 const Standard_Integer NameOffset() const { return myNameOffset; }
87 void SetNameOffset (const Standard_Integer theValue) { myNameOffset = theValue; }
91 TCollection_ExtendedString myName;
93 Standard_Boolean myToDrawName;
94 Standard_Boolean myToDrawTickmarks;
95 Standard_Boolean myToDrawValues;
97 Quantity_Color myNameColor;
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
103 Standard_Integer myValuesOffset; //!< Offset for drawing values
104 Standard_Integer myNameOffset; //!< Offset for drawing name of axis
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
114 typedef void (*MinMaxValuesCallback) (Visual3d_View*);
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",
121 const Font_FontAspect& theNamesStyle = Font_FA_Bold, const Standard_Integer theNamesSize = 12,
122 const TCollection_AsciiString& theValuesFont = "Arial",
123 const Font_FontAspect& theValuesStyle = Font_FA_Regular, const Standard_Integer theValuesSize = 12,
124 const Standard_ShortReal theArrowsLength = 30.0f, const Quantity_Color theGridColor = Quantity_NOC_WHITE,
125 const Standard_Boolean theToDrawGrid = Standard_True, const Standard_Boolean theToDrawAxes = Standard_True)
126 : myNamesFont (theNamesFont),
127 myNamesStyle (theNamesStyle),
128 myNamesSize (theNamesSize),
129 myValuesFont (theValuesFont),
130 myValuesStyle (theValuesStyle),
131 myValuesSize (theValuesSize),
132 myArrowsLength (theArrowsLength),
133 myGridColor (theGridColor),
134 myToDrawGrid (theToDrawGrid),
135 myToDrawAxes (theToDrawAxes),
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;
146 Graphic3d_AxisAspect& ChangeXAxisAspect() { return myAxes(0); }
147 Graphic3d_AxisAspect& ChangeYAxisAspect() { return myAxes(1); }
148 Graphic3d_AxisAspect& ChangeZAxisAspect() { return myAxes(2); }
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); }
154 const Graphic3d_AxisAspect& AxisAspect (const Standard_Integer theIndex) const
156 Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 2, "Graphic3d_GraduatedTrihedron::AxisAspect: theIndex is out of bounds [0,2].");
157 return myAxes (theIndex);
160 const Standard_ShortReal ArrowsLength() const { return myArrowsLength; }
161 void SetArrowsLength (const Standard_ShortReal theValue) { myArrowsLength = theValue; }
163 const Quantity_Color& GridColor() const { return myGridColor; }
164 void SetGridColor (const Quantity_Color& theColor) {myGridColor = theColor; }
166 const Standard_Boolean ToDrawGrid() const { return myToDrawGrid; }
167 void SetDrawGrid (const Standard_Boolean theToDraw) { myToDrawGrid = theToDraw; }
169 const Standard_Boolean ToDrawAxes() const { return myToDrawAxes; }
170 void SetDrawAxes (const Standard_Boolean theToDraw) { myToDrawAxes = theToDraw; }
172 const TCollection_AsciiString& NamesFont() const { return myNamesFont; }
173 void SetNamesFont (const TCollection_AsciiString& theFont) { myNamesFont = theFont; }
175 Font_FontAspect NamesFontAspect() const { return myNamesStyle; }
176 void SetNamesFontAspect (Font_FontAspect theAspect) { myNamesStyle = theAspect; }
178 const Standard_Integer NamesSize() const { return myNamesSize; }
179 void SetNamesSize (const Standard_Integer theValue) { myNamesSize = theValue; }
181 const TCollection_AsciiString& ValuesFont () const { return myValuesFont; }
182 void SetValuesFont (const TCollection_AsciiString& theFont) { myValuesFont = theFont; }
184 Font_FontAspect ValuesFontAspect() const { return myValuesStyle; }
185 void SetValuesFontAspect (Font_FontAspect theAspect) { myValuesStyle = theAspect; }
187 const Standard_Integer ValuesSize() const { return myValuesSize; }
188 void SetValuesSize (const Standard_Integer theValue) { myValuesSize = theValue; }
192 MinMaxValuesCallback CubicAxesCallback; //!< Callback function to define boundary box of displayed objects
193 Visual3d_View* PtrVisual3dView;
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,..
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, ...
209 Standard_ShortReal myArrowsLength;
210 Quantity_Color myGridColor;
212 Standard_Boolean myToDrawGrid;
213 Standard_Boolean myToDrawAxes;
215 NCollection_Array1<Graphic3d_AxisAspect> myAxes; //!< X, Y and Z axes parameters
218 #endif // Graphic3d_GraduatedTrihedron_HeaderFile