0024070: OpenGL capped object-level clipping planes
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriver.cxx
... / ...
CommitLineData
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
21// 11/97 ; CAL : retrait de la dependance avec math
22
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
69//-Internal methods, in order
70
71void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
72
73 cout << "\t" << AComment << " : "
74 << (AValue ? "True" : "False") << "\n";
75 cout << flush;
76
77}
78
79void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
80
81 if (AField) {
82 cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
83 cout << "\tgroup\n";
84 cout << flush;
85 }
86
87}
88
89void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& ACLight, const Standard_Integer AField) const {
90
91 if (AField) {
92 cout << "\tws id " << ACLight.WsId << ", "
93 << "view id " << ACLight.ViewId << "\n";
94 switch (ACLight.LightType) {
95 case 0 :
96 cout << "\tlight type : ambient\n";
97 break;
98 case 1 :
99 cout << "\tlight type : directional\n";
100 break;
101 case 2 :
102 cout << "\tlight type : positional\n";
103 break;
104 case 3 :
105 cout << "\tlight type : spot\n";
106 break;
107 default :
108 cout << "\tlight type : undefined, error\n";
109 break;
110 }
111 cout << flush;
112 }
113
114}
115
116void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
117
118 if (AField) {
119 cout << "\tws id " << ACPick.WsId
120 << " view id " << ACPick.ViewId << "\n";
121 cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
122 cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
123 cout << flush;
124 }
125
126}
127
128void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
129
130 if (AField) {
131 cout << "\tstruct id " << ACStructure.Id << "\n";
132 cout << flush;
133 }
134
135}
136
137void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
138
139 if (AField) {
140 cout << "\tws id " << ACView.WsId << ", "
141 << "view id " << ACView.ViewId << "\n";
142 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
143 << "activity " << ACView.Active << "\n";
144 cout << flush;
145 }
146
147}
148
149void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
150
151 cout << AFunc << "\n";
152 cout << flush;
153
154}
155
156void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
157
158 cout << "\t" << AComment << " : " << AValue << "\n";
159 cout << flush;
160
161}
162
163void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
164
165 cout << AFunc << " = " << AResult << "\n";
166 cout << flush;
167
168}
169
170void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
171
172 Standard_Integer lr, ur, lc, uc;
173 Standard_Integer i, j;
174
175 lr = AMatrix.LowerRow ();
176 ur = AMatrix.UpperRow ();
177 lc = AMatrix.LowerCol ();
178 uc = AMatrix.UpperCol ();
179
180 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
181 Graphic3d_TransformError::Raise
182 ("PrintMatrix : not a 4x4 matrix");
183
184 cout << "\t" << AComment << " :\n";
185 for (i=lr; i<=ur; i++) {
186 for (j=lc; j<=uc; j++) {
187 cout << AMatrix (i, j) << " ";
188 }
189 cout << "\n";
190 }
191 cout << flush;
192
193}
194
195void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
196
197 cout << "\t" << AComment << " : " << AValue << "\n";
198 cout << flush;
199
200}
201
202void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
203
204 cout << "\t" << AComment << " : " << AString << "\n";
205 cout << flush;
206
207}
208
209void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
210
211 MyTraceLevel = ALevel;
212
213}
214
215Standard_Integer Graphic3d_GraphicDriver::Trace () const {
216
217 return MyTraceLevel;
218
219}
220
221const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
222{
223 return myDisplayConnection;
224}