0024752: Visualization - inherit OpenGl_Group from Graphic3d_Group
[occt.git] / src / Graphic3d / Graphic3d_GraphicDriver.cxx
CommitLineData
b311480e 1// Created on: 1997-01-28
2// Created by: CAL
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17// 11/97 ; CAL : retrait de la dependance avec math
18
7fd59977 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
43Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Standard_CString AShrName) {
44
45 SetTrace (0);
46 MySharedLibrary.SetName (AShrName);
eb4320f2 47 myDeviceLostFlag = Standard_False;
7fd59977 48
49 //if (! MySharedLibrary.DlOpen (OSD_RTLD_LAZY))
50 //Aspect_DriverDefinitionError::Raise (MySharedLibrary.DlError ());
51
52}
53
7fd59977 54//-Internal methods, in order
55
56void 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
12381341 64void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& theCLight,
65 const Standard_Integer theField) const
66{
67 if (theField)
68 {
69 switch (theCLight.Type) {
7fd59977 70 case 0 :
71 cout << "\tlight type : ambient\n";
72 break;
73 case 1 :
74 cout << "\tlight type : directional\n";
75 break;
76 case 2 :
77 cout << "\tlight type : positional\n";
78 break;
79 case 3 :
80 cout << "\tlight type : spot\n";
81 break;
82 default :
83 cout << "\tlight type : undefined, error\n";
84 break;
85 }
86 cout << flush;
87 }
7fd59977 88}
89
90void Graphic3d_GraphicDriver::PrintCPick (const Graphic3d_CPick& ACPick, const Standard_Integer AField) const {
91
92 if (AField) {
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";
97 cout << flush;
98 }
99
100}
101
7fd59977 102void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const {
103
104 if (AField) {
105 cout << "\tstruct id " << ACStructure.Id << "\n";
106 cout << flush;
107 }
108
109}
110
111void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const {
112
113 if (AField) {
114 cout << "\tws id " << ACView.WsId << ", "
115 << "view id " << ACView.ViewId << "\n";
116 cout << "\tXwindow id " << ACView.DefWindow.XWindow << ", "
117 << "activity " << ACView.Active << "\n";
118 cout << flush;
119 }
120
121}
122
123void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const {
124
125 cout << AFunc << "\n";
126 cout << flush;
127
128}
129
130void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const {
131
132 cout << "\t" << AComment << " : " << AValue << "\n";
133 cout << flush;
134
135}
136
137void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const {
138
139 cout << AFunc << " = " << AResult << "\n";
140 cout << flush;
141
142}
143
144void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const {
145
146 Standard_Integer lr, ur, lc, uc;
147 Standard_Integer i, j;
148
149 lr = AMatrix.LowerRow ();
150 ur = AMatrix.UpperRow ();
151 lc = AMatrix.LowerCol ();
152 uc = AMatrix.UpperCol ();
153
154 if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
155 Graphic3d_TransformError::Raise
156 ("PrintMatrix : not a 4x4 matrix");
157
158 cout << "\t" << AComment << " :\n";
159 for (i=lr; i<=ur; i++) {
160 for (j=lc; j<=uc; j++) {
161 cout << AMatrix (i, j) << " ";
162 }
163 cout << "\n";
164 }
165 cout << flush;
166
167}
168
169void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const {
170
171 cout << "\t" << AComment << " : " << AValue << "\n";
172 cout << flush;
173
174}
175
176void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const {
177
178 cout << "\t" << AComment << " : " << AString << "\n";
179 cout << flush;
180
181}
182
183void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) {
184
185 MyTraceLevel = ALevel;
186
187}
188
189Standard_Integer Graphic3d_GraphicDriver::Trace () const {
190
191 return MyTraceLevel;
192
193}
dc3fe572 194
195const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const
196{
197 return myDisplayConnection;
198}
eb4320f2 199
200Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const
201{
202 return myDeviceLostFlag;
203}
204
205void Graphic3d_GraphicDriver::ResetDeviceLostFlag()
206{
207 myDeviceLostFlag = Standard_False;
208}