0024413: Visualization - get rid of projection shift from orthographic camera definition
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriver.cxx
1 // Created on: 1997-01-28
2 // Created by: CAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //              11/97 ; CAL : retrait de la dependance avec math
18
19
20 //-Version  
21
22 //-Design Declaration des variables specifiques aux Drivers
23
24 //-Warning  Un driver encapsule les Pex, Phigs et OpenGl drivers
25
26 //-References 
27
28 //-Language C++ 2.0
29
30 //-Declarations
31
32 // for the class
33 #include <Graphic3d_GraphicDriver.ixx>
34
35 #include <Aspect_DriverDefinitionError.hxx>
36
37 //-Aliases
38
39 //-Global data definitions
40
41 //-Constructors
42
43 Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Standard_CString AShrName) {
44
45   SetTrace (0);
46   MySharedLibrary.SetName (AShrName);
47   myDeviceLostFlag = Standard_False;
48
49   //if (! MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
50   //Aspect_DriverDefinitionError::Raise (MySharedLibrary.DlError ());
51
52 }
53
54 //-Internal methods, in order
55
56 void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
57
58   cout << "\t" << AComment << " : "
59     << (AValue ? "True" : "False") << "\n";
60   cout << flush;
61
62 }
63
64 void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
65
66   if (AField) {
67     cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
68     cout << "\tgroup\n";
69     cout << flush;
70   }
71
72 }
73
74 void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& theCLight,
75                                            const Standard_Integer  theField) const
76 {
77   if (theField)
78   {
79     switch (theCLight.Type) {
80     case 0 :
81       cout << "\tlight type : ambient\n";
82       break;
83     case 1 :
84       cout << "\tlight type : directional\n";
85       break;
86     case 2 :
87       cout << "\tlight type : positional\n";
88       break;
89     case 3 :
90       cout << "\tlight type : spot\n";
91       break;
92     default :
93       cout << "\tlight type : undefined, error\n";
94       break;
95     }
96     cout << flush;
97   }
98 }
99
100 void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
101
102   if (AField) {
103     cout << "\tws id " << ACPick.WsId
104       << " view id " << ACPick.ViewId << "\n";
105     cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
106     cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
107     cout << flush;
108   }
109
110 }
111
112 void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
113
114   if (AField) {
115     cout << "\tstruct id " << ACStructure.Id << "\n";
116     cout << flush;
117   }
118
119 }
120
121 void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
122
123   if (AField) {
124     cout << "\tws id " << ACView.WsId << ", "
125       << "view id " << ACView.ViewId << "\n";
126     cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
127       << "activity " << ACView.Active << "\n";
128     cout << flush;
129   }
130
131 }
132
133 void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
134
135   cout << AFunc << "\n";
136   cout << flush;
137
138 }
139
140 void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
141
142   cout << "\t" << AComment << " : " << AValue << "\n";
143   cout << flush;
144
145 }
146
147 void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
148
149   cout << AFunc << " = " << AResult << "\n";
150   cout << flush;
151
152 }
153
154 void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
155
156   Standard_Integer lr, ur, lc, uc;
157   Standard_Integer i, j;
158
159   lr = AMatrix.LowerRow ();
160   ur = AMatrix.UpperRow ();
161   lc = AMatrix.LowerCol ();
162   uc = AMatrix.UpperCol ();
163
164   if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
165     Graphic3d_TransformError::Raise
166     ("PrintMatrix : not a 4x4 matrix");
167
168   cout << "\t" << AComment << " :\n";
169   for (i=lr; i<=ur; i++) {
170     for (j=lc; j<=uc; j++) {
171       cout << AMatrix (i, j) << " ";
172     }
173     cout << "\n";
174   }
175   cout << flush;
176
177 }
178
179 void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
180
181   cout << "\t" << AComment << " : " << AValue << "\n";
182   cout << flush;
183
184 }
185
186 void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
187
188   cout << "\t" << AComment << " : " << AString << "\n";
189   cout << flush;
190
191 }
192
193 void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
194
195   MyTraceLevel = ALevel;
196
197 }
198
199 Standard_Integer Graphic3d_GraphicDriver::Trace () const {
200
201   return MyTraceLevel;
202
203 }
204
205 const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
206 {
207   return myDisplayConnection;
208 }
209
210 Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const
211 {
212   return myDeviceLostFlag;
213 }
214
215 void Graphic3d_GraphicDriver::ResetDeviceLostFlag()
216 {
217   myDeviceLostFlag = Standard_False;
218 }