Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriver.cxx
CommitLineData
7fd59977 1// File Graphic3d_GraphicDriver.cxx
2// Created Mardi 28 janvier 1997
3// Author CAL
4// 11/97 ; CAL : retrait de la dependance avec math
5
6//-Copyright MatraDatavision 1997
7
8//-Version
9
10//-Design Declaration des variables specifiques aux Drivers
11
12//-Warning Un driver encapsule les Pex, Phigs et OpenGl drivers
13
14//-References
15
16//-Language C++ 2.0
17
18//-Declarations
19
20// for the class
21#include <Graphic3d_GraphicDriver.ixx>
22
23#include <Aspect_DriverDefinitionError.hxx>
24
25//-Aliases
26
27//-Global data definitions
28
29//-Constructors
30
31Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Standard_CString AShrName) {
32
33 SetTrace (0);
34 MySharedLibrary.SetName (AShrName);
35
36 //if (! MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
37 //Aspect_DriverDefinitionError::Raise (MySharedLibrary.DlError ());
38
39}
40
41//-Methods, in order
42
43Standard_Integer Graphic3d_GraphicDriver::Light (const Graphic3d_CLight& ACLight, const Standard_Boolean Update) {
44
45 static Standard_Integer NbLights = 1;
46 Standard_Boolean Result;
47
48 Result = Update ? ACLight.LightId : NbLights++;
49 return Result;
50
51}
52
53Standard_Integer Graphic3d_GraphicDriver::Plane (const Graphic3d_CPlane& ACPlane, const Standard_Boolean Update) {
54
55 static Standard_Integer NbPlanes = 1;
56 Standard_Boolean Result;
57
58 Result = Update ? ACPlane.PlaneId : NbPlanes++;
59 return Result;
60
61}
62
63//-Internal methods, in order
64
65void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
66
67 cout << "\t" << AComment << " : "
68 << (AValue ? "True" : "False") << "\n";
69 cout << flush;
70
71}
72
73void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
74
75 if (AField) {
76 cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
77 cout << "\tgroup labels " << ACGroup.LabelBegin << ", "
78 << ACGroup.LabelEnd << "\n";
79 cout << flush;
80 }
81
82}
83
84void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& ACLight, const Standard_Integer AField) const {
85
86 if (AField) {
87 cout << "\tws id " << ACLight.WsId << ", "
88 << "view id " << ACLight.ViewId << "\n";
89 switch (ACLight.LightType) {
90 case 0 :
91 cout << "\tlight type : ambient\n";
92 break;
93 case 1 :
94 cout << "\tlight type : directional\n";
95 break;
96 case 2 :
97 cout << "\tlight type : positional\n";
98 break;
99 case 3 :
100 cout << "\tlight type : spot\n";
101 break;
102 default :
103 cout << "\tlight type : undefined, error\n";
104 break;
105 }
106 cout << flush;
107 }
108
109}
110
111void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
112
113 if (AField) {
114 cout << "\tws id " << ACPick.WsId
115 << " view id " << ACPick.ViewId << "\n";
116 cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
117 cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
118 cout << flush;
119 }
120
121}
122
123void Graphic3d_GraphicDriver::PrintCPlane (const Graphic3d_CPlane& ACPlane, const Standard_Integer AField) const {
124
125 if (AField) {
126 cout << "\tws id " << ACPlane.WsId << ", "
127 << "view id " << ACPlane.ViewId << "\n";
128 cout << flush;
129 }
130
131}
132
133void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
134
135 if (AField) {
136 cout << "\tstruct id " << ACStructure.Id << "\n";
137 cout << flush;
138 }
139
140}
141
142void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
143
144 if (AField) {
145 cout << "\tws id " << ACView.WsId << ", "
146 << "view id " << ACView.ViewId << "\n";
147 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
148 << "activity " << ACView.Active << "\n";
149 cout << flush;
150 }
151
152}
153
154void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
155
156 cout << AFunc << "\n";
157 cout << flush;
158
159}
160
161void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
162
163 cout << "\t" << AComment << " : " << AValue << "\n";
164 cout << flush;
165
166}
167
168void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
169
170 cout << AFunc << " = " << AResult << "\n";
171 cout << flush;
172
173}
174
175void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
176
177 Standard_Integer lr, ur, lc, uc;
178 Standard_Integer i, j;
179
180 lr = AMatrix.LowerRow ();
181 ur = AMatrix.UpperRow ();
182 lc = AMatrix.LowerCol ();
183 uc = AMatrix.UpperCol ();
184
185 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
186 Graphic3d_TransformError::Raise
187 ("PrintMatrix : not a 4x4 matrix");
188
189 cout << "\t" << AComment << " :\n";
190 for (i=lr; i<=ur; i++) {
191 for (j=lc; j<=uc; j++) {
192 cout << AMatrix (i, j) << " ";
193 }
194 cout << "\n";
195 }
196 cout << flush;
197
198}
199
200void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
201
202 cout << "\t" << AComment << " : " << AValue << "\n";
203 cout << flush;
204
205}
206
207void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
208
209 cout << "\t" << AComment << " : " << AString << "\n";
210 cout << flush;
211
212}
213
214void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
215
216 MyTraceLevel = ALevel;
217
218}
219
220Standard_Integer Graphic3d_GraphicDriver::Trace () const {
221
222 return MyTraceLevel;
223
224}