0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / Graphic3d / Graphic3d_GraduatedTrihedron.hxx
CommitLineData
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
c357e426 27class Graphic3d_CView;
a79f67f8 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.
31class 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
54public:
55
56 void SetName (const TCollection_ExtendedString& theName) { myName = theName; }
57 const TCollection_ExtendedString& Name() const { return myName; }
58
487bf1ce 59 Standard_Boolean ToDrawName() const { return myToDrawName; }
536d98e2 60 void SetDrawName (const Standard_Boolean theToDraw) { myToDrawName = theToDraw; }
a79f67f8 61
487bf1ce 62 Standard_Boolean ToDrawTickmarks() const { return myToDrawTickmarks; }
536d98e2 63 void SetDrawTickmarks (const Standard_Boolean theToDraw) { myToDrawTickmarks = theToDraw; }
a79f67f8 64
487bf1ce 65 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
487bf1ce 77 Standard_Integer TickmarksNumber() const { return myTickmarksNumber; }
536d98e2 78 void SetTickmarksNumber (const Standard_Integer theValue) { myTickmarksNumber = theValue; }
a79f67f8 79
487bf1ce 80 Standard_Integer TickmarksLength() const { return myTickmarksLength; }
536d98e2 81 void SetTickmarksLength (const Standard_Integer theValue) { myTickmarksLength = theValue; }
a79f67f8 82
487bf1ce 83 Standard_Integer ValuesOffset() const { return myValuesOffset; }
a79f67f8 84 void SetValuesOffset (const Standard_Integer theValue) { myValuesOffset = theValue; }
85
487bf1ce 86 Standard_Integer NameOffset() const { return myNameOffset; }
a79f67f8 87 void SetNameOffset (const Standard_Integer theValue) { myNameOffset = theValue; }
88
89protected:
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
110class Graphic3d_GraduatedTrihedron
111{
112public:
113
c357e426 114 typedef void (*MinMaxValuesCallback) (Graphic3d_CView*);
a79f67f8 115
116public:
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);
c357e426 141 PtrView = NULL;
a79f67f8 142 }
143
144public:
145
146 Graphic3d_AxisAspect& ChangeXAxisAspect() { return myAxes(0); }
147 Graphic3d_AxisAspect& ChangeYAxisAspect() { return myAxes(1); }
148 Graphic3d_AxisAspect& ChangeZAxisAspect() { return myAxes(2); }
149
2afd4e98 150 Graphic3d_AxisAspect& ChangeAxisAspect (const Standard_Integer theIndex)
151 {
152 Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 2, "Graphic3d_GraduatedTrihedron::ChangeAxisAspect: theIndex is out of bounds [0,2].");
153 return myAxes (theIndex);
154 }
155
a79f67f8 156 const Graphic3d_AxisAspect& XAxisAspect() const { return myAxes(0); }
157 const Graphic3d_AxisAspect& YAxisAspect() const { return myAxes(1); }
158 const Graphic3d_AxisAspect& ZAxisAspect() const { return myAxes(2); }
159
160 const Graphic3d_AxisAspect& AxisAspect (const Standard_Integer theIndex) const
161 {
162 Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 2, "Graphic3d_GraduatedTrihedron::AxisAspect: theIndex is out of bounds [0,2].");
163 return myAxes (theIndex);
164 }
165
487bf1ce 166 Standard_ShortReal ArrowsLength() const { return myArrowsLength; }
536d98e2 167 void SetArrowsLength (const Standard_ShortReal theValue) { myArrowsLength = theValue; }
a79f67f8 168
169 const Quantity_Color& GridColor() const { return myGridColor; }
170 void SetGridColor (const Quantity_Color& theColor) {myGridColor = theColor; }
171
487bf1ce 172 Standard_Boolean ToDrawGrid() const { return myToDrawGrid; }
536d98e2 173 void SetDrawGrid (const Standard_Boolean theToDraw) { myToDrawGrid = theToDraw; }
a79f67f8 174
487bf1ce 175 Standard_Boolean ToDrawAxes() const { return myToDrawAxes; }
536d98e2 176 void SetDrawAxes (const Standard_Boolean theToDraw) { myToDrawAxes = theToDraw; }
a79f67f8 177
178 const TCollection_AsciiString& NamesFont() const { return myNamesFont; }
179 void SetNamesFont (const TCollection_AsciiString& theFont) { myNamesFont = theFont; }
180
a3ee6e9f 181 Font_FontAspect NamesFontAspect() const { return myNamesStyle; }
182 void SetNamesFontAspect (Font_FontAspect theAspect) { myNamesStyle = theAspect; }
a79f67f8 183
487bf1ce 184 Standard_Integer NamesSize() const { return myNamesSize; }
a79f67f8 185 void SetNamesSize (const Standard_Integer theValue) { myNamesSize = theValue; }
186
187 const TCollection_AsciiString& ValuesFont () const { return myValuesFont; }
188 void SetValuesFont (const TCollection_AsciiString& theFont) { myValuesFont = theFont; }
189
a3ee6e9f 190 Font_FontAspect ValuesFontAspect() const { return myValuesStyle; }
191 void SetValuesFontAspect (Font_FontAspect theAspect) { myValuesStyle = theAspect; }
a79f67f8 192
487bf1ce 193 Standard_Integer ValuesSize() const { return myValuesSize; }
a79f67f8 194 void SetValuesSize (const Standard_Integer theValue) { myValuesSize = theValue; }
195
196public:
197
198 MinMaxValuesCallback CubicAxesCallback; //!< Callback function to define boundary box of displayed objects
c357e426 199 Graphic3d_CView* PtrView;
a79f67f8 200
201protected:
202
203 TCollection_AsciiString myNamesFont; //!< Font name of names of axes: Courier, Arial, ...
204 Font_FontAspect myNamesStyle; //!< Style of names of axes: OSD_FA_Regular, OSD_FA_Bold,..
205 Standard_Integer myNamesSize; //!< Size of names of axes: 8, 10,..
206
207protected:
208
209 TCollection_AsciiString myValuesFont; //!< Font name of values: Courier, Arial, ...
210 Font_FontAspect myValuesStyle; //!< Style of values: OSD_FA_Regular, OSD_FA_Bold, ...
211 Standard_Integer myValuesSize; //!< Size of values: 8, 10, 12, 14, ...
212
213protected:
214
536d98e2 215 Standard_ShortReal myArrowsLength;
a79f67f8 216 Quantity_Color myGridColor;
217
218 Standard_Boolean myToDrawGrid;
219 Standard_Boolean myToDrawAxes;
220
221 NCollection_Array1<Graphic3d_AxisAspect> myAxes; //!< X, Y and Z axes parameters
222
223};
224#endif // Graphic3d_GraduatedTrihedron_HeaderFile