0023634: Eliminate Polyline and Polygon usage in drawers
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriver.cxx
CommitLineData
b311480e 1// Created on: 1997-01-28
2// Created by: CAL
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21// 11/97 ; CAL : retrait de la dependance avec math
22
7fd59977 23
24//-Version
25
26//-Design Declaration des variables specifiques aux Drivers
27
28//-Warning Un driver encapsule les Pex, Phigs et OpenGl drivers
29
30//-References
31
32//-Language C++ 2.0
33
34//-Declarations
35
36// for the class
37#include <Graphic3d_GraphicDriver.ixx>
38
39#include <Aspect_DriverDefinitionError.hxx>
40
41//-Aliases
42
43//-Global data definitions
44
45//-Constructors
46
47Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Standard_CString AShrName) {
48
49 SetTrace (0);
50 MySharedLibrary.SetName (AShrName);
51
52 //if (! MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
53 //Aspect_DriverDefinitionError::Raise (MySharedLibrary.DlError ());
54
55}
56
57//-Methods, in order
58
59Standard_Integer Graphic3d_GraphicDriver::Light (const Graphic3d_CLight& ACLight, const Standard_Boolean Update) {
60
61 static Standard_Integer NbLights = 1;
62 Standard_Boolean Result;
63
64 Result = Update ? ACLight.LightId : NbLights++;
65 return Result;
66
67}
68
69Standard_Integer Graphic3d_GraphicDriver::Plane (const Graphic3d_CPlane& ACPlane, const Standard_Boolean Update) {
70
71 static Standard_Integer NbPlanes = 1;
72 Standard_Boolean Result;
73
74 Result = Update ? ACPlane.PlaneId : NbPlanes++;
75 return Result;
76
77}
78
79//-Internal methods, in order
80
81void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
82
83 cout << "\t" << AComment << " : "
84 << (AValue ? "True" : "False") << "\n";
85 cout << flush;
86
87}
88
89void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
90
91 if (AField) {
92 cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
b8ddfc2f 93 cout << "\tgroup\n";
7fd59977 94 cout << flush;
95 }
96
97}
98
99void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& ACLight, const Standard_Integer AField) const {
100
101 if (AField) {
102 cout << "\tws id " << ACLight.WsId << ", "
103 << "view id " << ACLight.ViewId << "\n";
104 switch (ACLight.LightType) {
105 case 0 :
106 cout << "\tlight type : ambient\n";
107 break;
108 case 1 :
109 cout << "\tlight type : directional\n";
110 break;
111 case 2 :
112 cout << "\tlight type : positional\n";
113 break;
114 case 3 :
115 cout << "\tlight type : spot\n";
116 break;
117 default :
118 cout << "\tlight type : undefined, error\n";
119 break;
120 }
121 cout << flush;
122 }
123
124}
125
126void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
127
128 if (AField) {
129 cout << "\tws id " << ACPick.WsId
130 << " view id " << ACPick.ViewId << "\n";
131 cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
132 cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
133 cout << flush;
134 }
135
136}
137
138void Graphic3d_GraphicDriver::PrintCPlane (const Graphic3d_CPlane& ACPlane, const Standard_Integer AField) const {
139
140 if (AField) {
141 cout << "\tws id " << ACPlane.WsId << ", "
142 << "view id " << ACPlane.ViewId << "\n";
143 cout << flush;
144 }
145
146}
147
148void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
149
150 if (AField) {
151 cout << "\tstruct id " << ACStructure.Id << "\n";
152 cout << flush;
153 }
154
155}
156
157void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
158
159 if (AField) {
160 cout << "\tws id " << ACView.WsId << ", "
161 << "view id " << ACView.ViewId << "\n";
162 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
163 << "activity " << ACView.Active << "\n";
164 cout << flush;
165 }
166
167}
168
169void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
170
171 cout << AFunc << "\n";
172 cout << flush;
173
174}
175
176void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
177
178 cout << "\t" << AComment << " : " << AValue << "\n";
179 cout << flush;
180
181}
182
183void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
184
185 cout << AFunc << " = " << AResult << "\n";
186 cout << flush;
187
188}
189
190void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
191
192 Standard_Integer lr, ur, lc, uc;
193 Standard_Integer i, j;
194
195 lr = AMatrix.LowerRow ();
196 ur = AMatrix.UpperRow ();
197 lc = AMatrix.LowerCol ();
198 uc = AMatrix.UpperCol ();
199
200 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
201 Graphic3d_TransformError::Raise
202 ("PrintMatrix : not a 4x4 matrix");
203
204 cout << "\t" << AComment << " :\n";
205 for (i=lr; i<=ur; i++) {
206 for (j=lc; j<=uc; j++) {
207 cout << AMatrix (i, j) << " ";
208 }
209 cout << "\n";
210 }
211 cout << flush;
212
213}
214
215void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
216
217 cout << "\t" << AComment << " : " << AValue << "\n";
218 cout << flush;
219
220}
221
222void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
223
224 cout << "\t" << AComment << " : " << AString << "\n";
225 cout << flush;
226
227}
228
229void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
230
231 MyTraceLevel = ALevel;
232
233}
234
235Standard_Integer Graphic3d_GraphicDriver::Trace () const {
236
237 return MyTraceLevel;
238
239}