0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_8.cxx
CommitLineData
7fd59977 1// File OpenGl_GraphicDriver_8.cxx
2// Created Mardi 28 janvier 1997
3// Author CAL
4
5//-Copyright MatraDatavision 1997
6
7//-Version
8
9//-Design Declaration des variables specifiques aux Drivers
10
11//-Warning Un driver encapsule les Pex et OpenGl drivers
12
13//-References
14
15//-Language C++ 2.0
16
17//-Declarations
18
19// for the class
20#include <OpenGl_GraphicDriver.jxx>
21
22#include <Aspect_DriverDefinitionError.hxx>
23
24
25#include <OpenGl_tgl_funcs.hxx>
26
27//-Aliases
28
29//-Global data definitions
30
31//-Methods, in order
32
33
34Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& ACView)
35{
36
37 Graphic3d_CView MyCView = ACView;
38 Standard_Boolean Result;
39
40 if (MyTraceLevel) {
41 PrintFunction ("call_togl_begin_ajout_mode");
42 PrintCView (MyCView, 1);
43 }
44 Result = call_togl_begin_ajout_mode (&MyCView);
45 if (MyTraceLevel) {
46 PrintIResult ("call_togl_begin_ajout_mode", Result);
47 }
48 return Result;
49
50}
51
52void OpenGl_GraphicDriver::EndAddMode (void)
53{
54
55 if (MyTraceLevel) {
56 PrintFunction ("call_togl_end_ajout_mode");
57 }
58 call_togl_end_ajout_mode ();
59
60}
61
62Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode)
63{
64
65 Graphic3d_CView MyCView = ACView;
66 Aspect_CLayer2d MyCUnderLayer = ACUnderLayer;
67 Aspect_CLayer2d MyCOverLayer = ACOverLayer;
68 Standard_Boolean Result;
69
70
71 if (MyTraceLevel) {
72 PrintFunction ("call_togl_begin_immediat_mode");
73 PrintCView (MyCView, 1);
74 PrintBoolean ("DoubleBuffer", DoubleBuffer);
75 PrintBoolean ("RetainMode", RetainMode);
76 }
77 Result = call_togl_begin_immediat_mode
78 (&MyCView, &MyCUnderLayer, &MyCOverLayer,
79 (DoubleBuffer ? 1 : 0), (RetainMode ? 1 : 0));
80 if (MyTraceLevel) {
81 PrintIResult ("call_togl_begin_immediat_mode", Result);
82 }
83 return Result;
84
85}
86
87void OpenGl_GraphicDriver::BeginPolyline ()
88{
89
90 if (MyTraceLevel) {
91 PrintFunction ("call_togl_begin_polyline");
92 }
93 call_togl_begin_polyline ();
94
95}
96
97void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& ACView,
98 const Standard_Boolean aFlush)
99{
100
101 Graphic3d_CView MyCView = ACView;
102
103 if (MyTraceLevel) {
104 PrintFunction ("call_togl_clear_immediat_mode");
105 PrintCView (MyCView, 1);
106 }
107 call_togl_clear_immediat_mode (&MyCView, aFlush);
108
109}
110
111void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
112{
113
114
115 if (MyTraceLevel) {
116 PrintFunction ("call_togl_draw");
117 PrintShortReal ("X", X);
118 PrintShortReal ("Y", Y);
119 PrintShortReal ("Z", Z);
120 }
121 call_togl_draw (X, Y, Z);
122
123}
124
125void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& ACStructure) {
126
127 Graphic3d_CStructure MyCStructure = ACStructure;
128
129 if (MyTraceLevel) {
130 PrintFunction ("call_togl_draw_structure");
131 PrintCStructure (MyCStructure, 1);
132 }
133 call_togl_draw_structure (ACStructure.Id);
134
135}
136
137void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer Synchronize)
138{
139
140 if (MyTraceLevel) {
141 PrintFunction ("call_togl_end_immediat_mode");
142 PrintInteger ("Synchronize", Synchronize);
143 }
144 call_togl_end_immediat_mode (int (Synchronize));
145
146}
147
148void OpenGl_GraphicDriver::EndPolyline ()
149{
150
151 if (MyTraceLevel) {
152 PrintFunction ("call_togl_end_polyline");
153 }
154 call_togl_end_polyline ();
155
156}
157
158void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
159{
160
161 if (MyTraceLevel) {
162 PrintFunction ("call_togl_move");
163 PrintShortReal ("X", X);
164 PrintShortReal ("Y", Y);
165 PrintShortReal ("Z", Z);
166 }
167 call_togl_move (X, Y, Z);
168
169}
170
171void OpenGl_GraphicDriver::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
172{
173
174 if (MyTraceLevel) {
175 PrintFunction ("call_togl_set_linecolor");
176 PrintShortReal ("R", R);
177 PrintShortReal ("G", G);
178 PrintShortReal ("B", B);
179 }
180 call_togl_set_linecolor (R, G, B);
181
182}
183
184void OpenGl_GraphicDriver::SetLineType (const Standard_Integer Type)
185{
186
187 if (MyTraceLevel) {
188 PrintFunction ("call_togl_set_linetype");
189 PrintInteger ("Type", Type);
190 }
191 call_togl_set_linetype (long (Type));
192
193}
194
195void OpenGl_GraphicDriver::SetLineWidth (const Standard_ShortReal Width)
196{
197
198 if (MyTraceLevel) {
199 PrintFunction ("call_togl_set_linewidth");
200 PrintShortReal ("Width", Width);
201 }
202 call_togl_set_linewidth (float (Width));
203
204}
205
206void OpenGl_GraphicDriver::SetMinMax (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal Z1, const Standard_ShortReal X2, const Standard_ShortReal Y2, const Standard_ShortReal Z2)
207{
208
209 if (MyTraceLevel) {
210 PrintFunction ("call_togl_set_minmax");
211 PrintShortReal ("X1", X1);
212 PrintShortReal ("Y1", Y1);
213 PrintShortReal ("Z1", Z1);
214 PrintShortReal ("X2", X2);
215 PrintShortReal ("Y2", Y2);
216 PrintShortReal ("Z2", Z2);
217 }
218 call_togl_set_minmax (X1, Y1, Z1, X2, Y2, Z2);
219
220}
221
222void OpenGl_GraphicDriver::Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType)
223{
224
225 float theMatrix[4][4];
226 Standard_Integer i, j;
227 Standard_Integer lr, lc;
228
229 lr = AMatrix.LowerRow ();
230 lc = AMatrix.LowerCol ();
231
232 for (i=0; i<=3; i++)
233 for (j=0; j<=3; j++)
234 theMatrix[i][j] = float (AMatrix (i+lr, j+lc));
235
236 if (MyTraceLevel) {
237 PrintFunction ("call_togl_transform");
238 PrintMatrix ("AMatrix", AMatrix);
239 }
240 call_togl_transform (theMatrix, (AType == Graphic3d_TOC_REPLACE) ? 1 : 0);
241
242}