1 // Created on: 1997-01-28
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // 11/97 ; CAL : retrait de la dependance avec math
22 //-Design Declaration des variables specifiques aux Drivers
24 //-Warning Un driver encapsule les Pex, Phigs et OpenGl drivers
33 #include <Graphic3d_GraphicDriver.ixx>
35 #include <Aspect_DriverDefinitionError.hxx>
39 //-Global data definitions
43 Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Standard_CString AShrName) {
46 MySharedLibrary.SetName (AShrName);
47 myDeviceLostFlag = Standard_False;
49 //if (! MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
50 //Aspect_DriverDefinitionError::Raise (MySharedLibrary.DlError ());
54 //-Internal methods, in order
56 void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
58 cout << "\t" << AComment << " : "
59 << (AValue ? "True" : "False") << "\n";
64 void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& theCLight,
65 const Standard_Integer theField) const
69 switch (theCLight.Type) {
71 cout << "\tlight type : ambient\n";
74 cout << "\tlight type : directional\n";
77 cout << "\tlight type : positional\n";
80 cout << "\tlight type : spot\n";
83 cout << "\tlight type : undefined, error\n";
90 void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
93 cout << "\tws id " << ACPick.WsId
94 << " view id " << ACPick.ViewId << "\n";
95 cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
96 cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
102 void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
105 cout << "\tstruct id " << ACStructure.Id << "\n";
111 void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
114 cout << "\tws id " << ACView.WsId << ", "
115 << "view id " << ACView.ViewId << "\n";
116 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
117 << "activity " << ACView.Active << "\n";
123 void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
125 cout << AFunc << "\n";
130 void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
132 cout << "\t" << AComment << " : " << AValue << "\n";
137 void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
139 cout << AFunc << " = " << AResult << "\n";
144 void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
146 Standard_Integer lr, ur, lc, uc;
147 Standard_Integer i, j;
149 lr = AMatrix.LowerRow ();
150 ur = AMatrix.UpperRow ();
151 lc = AMatrix.LowerCol ();
152 uc = AMatrix.UpperCol ();
154 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
155 Graphic3d_TransformError::Raise
156 ("PrintMatrix : not a 4x4 matrix");
158 cout << "\t" << AComment << " :\n";
159 for (i=lr; i<=ur; i++) {
160 for (j=lc; j<=uc; j++) {
161 cout << AMatrix (i, j) << " ";
169 void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
171 cout << "\t" << AComment << " : " << AValue << "\n";
176 void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
178 cout << "\t" << AComment << " : " << AString << "\n";
183 void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
185 MyTraceLevel = ALevel;
189 Standard_Integer Graphic3d_GraphicDriver::Trace () const {
195 const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
197 return myDisplayConnection;
200 Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const
202 return myDeviceLostFlag;
205 void Graphic3d_GraphicDriver::ResetDeviceLostFlag()
207 myDeviceLostFlag = Standard_False;