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::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
67 cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
74 void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& theCLight,
75 const Standard_Integer theField) const
79 switch (theCLight.Type) {
81 cout << "\tlight type : ambient\n";
84 cout << "\tlight type : directional\n";
87 cout << "\tlight type : positional\n";
90 cout << "\tlight type : spot\n";
93 cout << "\tlight type : undefined, error\n";
100 void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
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";
112 void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
115 cout << "\tstruct id " << ACStructure.Id << "\n";
121 void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
124 cout << "\tws id " << ACView.WsId << ", "
125 << "view id " << ACView.ViewId << "\n";
126 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
127 << "activity " << ACView.Active << "\n";
133 void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
135 cout << AFunc << "\n";
140 void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
142 cout << "\t" << AComment << " : " << AValue << "\n";
147 void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
149 cout << AFunc << " = " << AResult << "\n";
154 void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
156 Standard_Integer lr, ur, lc, uc;
157 Standard_Integer i, j;
159 lr = AMatrix.LowerRow ();
160 ur = AMatrix.UpperRow ();
161 lc = AMatrix.LowerCol ();
162 uc = AMatrix.UpperCol ();
164 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
165 Graphic3d_TransformError::Raise
166 ("PrintMatrix : not a 4x4 matrix");
168 cout << "\t" << AComment << " :\n";
169 for (i=lr; i<=ur; i++) {
170 for (j=lc; j<=uc; j++) {
171 cout << AMatrix (i, j) << " ";
179 void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
181 cout << "\t" << AComment << " : " << AValue << "\n";
186 void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
188 cout << "\t" << AComment << " : " << AString << "\n";
193 void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
195 MyTraceLevel = ALevel;
199 Standard_Integer Graphic3d_GraphicDriver::Trace () const {
205 const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
207 return myDisplayConnection;
210 Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const
212 return myDeviceLostFlag;
215 void Graphic3d_GraphicDriver::ResetDeviceLostFlag()
217 myDeviceLostFlag = Standard_False;