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 | |
42cf5bc1 |
17 | #include <Graphic3d_GraphicDriver.hxx> |
18 | #include <Graphic3d_Structure.hxx> |
19 | #include <Graphic3d_StructureManager.hxx> |
20 | #include <Graphic3d_TransformError.hxx> |
21 | #include <Quantity_Color.hxx> |
22 | #include <Standard_Type.hxx> |
23 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
24 | |
fe9fc669 |
25 | Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Handle(Aspect_DisplayConnection)& theDisp) |
26 | : MyTraceLevel (0), |
27 | myDisplayConnection (theDisp), |
28 | myDeviceLostFlag (Standard_False) |
29 | { |
30 | // |
7fd59977 |
31 | } |
32 | |
7fd59977 |
33 | //-Internal methods, in order |
34 | |
35 | void Graphic3d_GraphicDriver::PrintBoolean (const Standard_CString AComment, const Standard_Boolean AValue) const { |
36 | |
37 | cout << "\t" << AComment << " : " |
38 | << (AValue ? "True" : "False") << "\n"; |
39 | cout << flush; |
40 | |
41 | } |
42 | |
12381341 |
43 | void Graphic3d_GraphicDriver::PrintCLight (const Graphic3d_CLight& theCLight, |
44 | const Standard_Integer theField) const |
45 | { |
46 | if (theField) |
47 | { |
48 | switch (theCLight.Type) { |
7fd59977 |
49 | case 0 : |
50 | cout << "\tlight type : ambient\n"; |
51 | break; |
52 | case 1 : |
53 | cout << "\tlight type : directional\n"; |
54 | break; |
55 | case 2 : |
56 | cout << "\tlight type : positional\n"; |
57 | break; |
58 | case 3 : |
59 | cout << "\tlight type : spot\n"; |
60 | break; |
61 | default : |
62 | cout << "\tlight type : undefined, error\n"; |
63 | break; |
64 | } |
65 | cout << flush; |
66 | } |
7fd59977 |
67 | } |
68 | |
7fd59977 |
69 | void Graphic3d_GraphicDriver::PrintCStructure (const Graphic3d_CStructure& ACStructure, const Standard_Integer AField) const { |
70 | |
71 | if (AField) { |
72 | cout << "\tstruct id " << ACStructure.Id << "\n"; |
73 | cout << flush; |
74 | } |
75 | |
76 | } |
77 | |
78 | void Graphic3d_GraphicDriver::PrintCView (const Graphic3d_CView& ACView, const Standard_Integer AField) const { |
79 | |
80 | if (AField) { |
c357e426 |
81 | cout << "view id " << ACView.Identification() << "\n"; |
82 | cout << "\tXwindow id " << (ACView.Window().IsNull() ? 0 : ACView.Window()->NativeHandle()) << ", " |
83 | << "activity " << ACView.IsActive() << "\n"; |
7fd59977 |
84 | cout << flush; |
85 | } |
86 | |
87 | } |
88 | |
89 | void Graphic3d_GraphicDriver::PrintFunction (const Standard_CString AFunc) const { |
90 | |
91 | cout << AFunc << "\n"; |
92 | cout << flush; |
93 | |
94 | } |
95 | |
96 | void Graphic3d_GraphicDriver::PrintInteger (const Standard_CString AComment, const Standard_Integer AValue) const { |
97 | |
98 | cout << "\t" << AComment << " : " << AValue << "\n"; |
99 | cout << flush; |
100 | |
101 | } |
102 | |
103 | void Graphic3d_GraphicDriver::PrintIResult (const Standard_CString AFunc, const Standard_Integer AResult) const { |
104 | |
105 | cout << AFunc << " = " << AResult << "\n"; |
106 | cout << flush; |
107 | |
108 | } |
109 | |
110 | void Graphic3d_GraphicDriver::PrintMatrix (const Standard_CString AComment, const TColStd_Array2OfReal& AMatrix) const { |
111 | |
112 | Standard_Integer lr, ur, lc, uc; |
113 | Standard_Integer i, j; |
114 | |
115 | lr = AMatrix.LowerRow (); |
116 | ur = AMatrix.UpperRow (); |
117 | lc = AMatrix.LowerCol (); |
118 | uc = AMatrix.UpperCol (); |
119 | |
120 | if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) ) |
121 | Graphic3d_TransformError::Raise |
122 | ("PrintMatrix : not a 4x4 matrix"); |
123 | |
124 | cout << "\t" << AComment << " :\n"; |
125 | for (i=lr; i<=ur; i++) { |
126 | for (j=lc; j<=uc; j++) { |
127 | cout << AMatrix (i, j) << " "; |
128 | } |
129 | cout << "\n"; |
130 | } |
131 | cout << flush; |
132 | |
133 | } |
134 | |
135 | void Graphic3d_GraphicDriver::PrintShortReal (const Standard_CString AComment, const Standard_ShortReal AValue) const { |
136 | |
137 | cout << "\t" << AComment << " : " << AValue << "\n"; |
138 | cout << flush; |
139 | |
140 | } |
141 | |
142 | void Graphic3d_GraphicDriver::PrintString (const Standard_CString AComment, const Standard_CString AString) const { |
143 | |
144 | cout << "\t" << AComment << " : " << AString << "\n"; |
145 | cout << flush; |
146 | |
147 | } |
148 | |
149 | void Graphic3d_GraphicDriver::SetTrace (const Standard_Integer ALevel) { |
150 | |
151 | MyTraceLevel = ALevel; |
152 | |
153 | } |
154 | |
155 | Standard_Integer Graphic3d_GraphicDriver::Trace () const { |
156 | |
157 | return MyTraceLevel; |
158 | |
159 | } |
dc3fe572 |
160 | |
161 | const Handle(Aspect_DisplayConnection)& Graphic3d_GraphicDriver::GetDisplayConnection() const |
162 | { |
163 | return myDisplayConnection; |
164 | } |
eb4320f2 |
165 | |
166 | Standard_Boolean Graphic3d_GraphicDriver::IsDeviceLost() const |
167 | { |
168 | return myDeviceLostFlag; |
169 | } |
170 | |
171 | void Graphic3d_GraphicDriver::ResetDeviceLostFlag() |
172 | { |
173 | myDeviceLostFlag = Standard_False; |
174 | } |