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 ());
60 Standard_Integer Graphic3d_GraphicDriver::Light (const Graphic3d_CLight& ACLight, const Standard_Boolean Update) {
62 static Standard_Integer NbLights = 1;
63 Standard_Boolean Result;
65 Result = Update ? ACLight.LightId : NbLights++;
70 //-Internal methods, in order
72 void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const {
74 cout << "\t" << AComment << " : "
75 << (AValue ? "True" : "False") << "\n";
80 void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, const Standard_Integer AField) const {
83 cout << "\tstruct id " << ACGroup.Struct->Id << "\n";
90 void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& ACLight, const Standard_Integer AField) const {
93 cout << "\tws id " << ACLight.WsId << ", "
94 << "view id " << ACLight.ViewId << "\n";
95 switch (ACLight.LightType) {
97 cout << "\tlight type : ambient\n";
100 cout << "\tlight type : directional\n";
103 cout << "\tlight type : positional\n";
106 cout << "\tlight type : spot\n";
109 cout << "\tlight type : undefined, error\n";
117 void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
120 cout << "\tws id " << ACPick.WsId
121 << " view id " << ACPick.ViewId << "\n";
122 cout << "\twindow id " << ACPick.DefWindow.XWindow << "\n";
123 cout << "\tposition " << ACPick.x << " , " << ACPick.y << "\n";
129 void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
132 cout << "\tstruct id " << ACStructure.Id << "\n";
138 void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
141 cout << "\tws id " << ACView.WsId << ", "
142 << "view id " << ACView.ViewId << "\n";
143 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
144 << "activity " << ACView.Active << "\n";
150 void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
152 cout << AFunc << "\n";
157 void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
159 cout << "\t" << AComment << " : " << AValue << "\n";
164 void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
166 cout << AFunc << " = " << AResult << "\n";
171 void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
173 Standard_Integer lr, ur, lc, uc;
174 Standard_Integer i, j;
176 lr = AMatrix.LowerRow ();
177 ur = AMatrix.UpperRow ();
178 lc = AMatrix.LowerCol ();
179 uc = AMatrix.UpperCol ();
181 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
182 Graphic3d_TransformError::Raise
183 ("PrintMatrix : not a 4x4 matrix");
185 cout << "\t" << AComment << " :\n";
186 for (i=lr; i<=ur; i++) {
187 for (j=lc; j<=uc; j++) {
188 cout << AMatrix (i, j) << " ";
196 void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
198 cout << "\t" << AComment << " : " << AValue << "\n";
203 void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
205 cout << "\t" << AComment << " : " << AString << "\n";
210 void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
212 MyTraceLevel = ALevel;
216 Standard_Integer Graphic3d_GraphicDriver::Trace () const {
222 const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
224 return myDisplayConnection;
227 Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const
229 return myDeviceLostFlag;
232 void Graphic3d_GraphicDriver::ResetDeviceLostFlag()
234 myDeviceLostFlag = Standard_False;