1 // Created on: 1997-01-28
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
21 // 11/97 ; CAL : retrait de la dependance avec math
26 //-Design Declaration des variables specifiques aux Drivers
28 //-Warning Un driver encapsule les Pex, Phigs et OpenGl drivers
37 #include <Graphic3d_GraphicDriver.ixx>
39 #include <Aspect_DriverDefinitionError.hxx>
43 //-Global data definitions
47 Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Standard_CString AShrName) {
50 MySharedLibrary.SetName (AShrName);
51 myDeviceLostFlag = Standard_False;
53 //if (! MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
54 //Aspect_DriverDefinitionError::Raise (MySharedLibrary.DlError ());
58 //-Internal methods, in order
60 void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
62 cout << "\t" << AComment << " : "
63 << (AValue ? "True" : "False") << "\n";
68 void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
71 cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
78 void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& theCLight,
79 const Standard_Integer theField) const
83 switch (theCLight.Type) {
85 cout << "\tlight type : ambient\n";
88 cout << "\tlight type : directional\n";
91 cout << "\tlight type : positional\n";
94 cout << "\tlight type : spot\n";
97 cout << "\tlight type : undefined, error\n";
104 void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
107 cout << "\tws id " << ACPick.WsId
108 << " view id " << ACPick.ViewId << "\n";
109 cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
110 cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
116 void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
119 cout << "\tstruct id " << ACStructure.Id << "\n";
125 void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
128 cout << "\tws id " << ACView.WsId << ", "
129 << "view id " << ACView.ViewId << "\n";
130 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
131 << "activity " << ACView.Active << "\n";
137 void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
139 cout << AFunc << "\n";
144 void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
146 cout << "\t" << AComment << " : " << AValue << "\n";
151 void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
153 cout << AFunc << " = " << AResult << "\n";
158 void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
160 Standard_Integer lr, ur, lc, uc;
161 Standard_Integer i, j;
163 lr = AMatrix.LowerRow ();
164 ur = AMatrix.UpperRow ();
165 lc = AMatrix.LowerCol ();
166 uc = AMatrix.UpperCol ();
168 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
169 Graphic3d_TransformError::Raise
170 ("PrintMatrix : not a 4x4 matrix");
172 cout << "\t" << AComment << " :\n";
173 for (i=lr; i<=ur; i++) {
174 for (j=lc; j<=uc; j++) {
175 cout << AMatrix (i, j) << " ";
183 void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
185 cout << "\t" << AComment << " : " << AValue << "\n";
190 void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
192 cout << "\t" << AComment << " : " << AString << "\n";
197 void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
199 MyTraceLevel = ALevel;
203 Standard_Integer Graphic3d_GraphicDriver::Trace () const {
209 const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
211 return myDisplayConnection;
214 Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const
216 return myDeviceLostFlag;
219 void Graphic3d_GraphicDriver::ResetDeviceLostFlag()
221 myDeviceLostFlag = Standard_False;