summaryrefslogtreecommitdiff
path: root/src/OpenGl/OpenGl_GraphicDriver_8.cxx
blob: 39853acc1a7d24eaabbf8ffdf6b8109347ef0250 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// File   OpenGl_GraphicDriver_8.cxx
// Created  Mardi 28 janvier 1997
// Author CAL

//-Copyright  MatraDatavision 1997

//-Version  

//-Design Declaration des variables specifiques aux Drivers

//-Warning  Un driver encapsule les Pex et OpenGl drivers

//-References 

//-Language C++ 2.0

//-Declarations

// for the class
#include <OpenGl_GraphicDriver.jxx>

#include <Aspect_DriverDefinitionError.hxx>


#include <OpenGl_tgl_funcs.hxx>

//-Aliases

//-Global data definitions

//-Methods, in order


Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& ACView) 
{

  Graphic3d_CView MyCView = ACView;
  Standard_Boolean Result;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_begin_ajout_mode");
    PrintCView (MyCView, 1);
  }
  Result = call_togl_begin_ajout_mode (&MyCView);
  if (MyTraceLevel) {
    PrintIResult ("call_togl_begin_ajout_mode", Result);
  }
  return Result;

}

void OpenGl_GraphicDriver::EndAddMode (void) 
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_end_ajout_mode");
  }
  call_togl_end_ajout_mode ();

}

Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode) 
{

  Graphic3d_CView MyCView = ACView;
  Aspect_CLayer2d MyCUnderLayer = ACUnderLayer;
  Aspect_CLayer2d MyCOverLayer = ACOverLayer;
  Standard_Boolean Result;


  if (MyTraceLevel) {
    PrintFunction ("call_togl_begin_immediat_mode");
    PrintCView (MyCView, 1);
    PrintBoolean ("DoubleBuffer", DoubleBuffer);
    PrintBoolean ("RetainMode", RetainMode);
  }
  Result = call_togl_begin_immediat_mode
    (&MyCView, &MyCUnderLayer, &MyCOverLayer,
    (DoubleBuffer ? 1 : 0), (RetainMode ? 1 : 0));
  if (MyTraceLevel) {
    PrintIResult ("call_togl_begin_immediat_mode", Result);
  }
  return Result;

}

void OpenGl_GraphicDriver::BeginPolyline () 
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_begin_polyline");
  }
  call_togl_begin_polyline ();

}

void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& ACView,
                                              const Standard_Boolean aFlush) 
{

  Graphic3d_CView MyCView = ACView;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_clear_immediat_mode");
    PrintCView (MyCView, 1);
  }
  call_togl_clear_immediat_mode (&MyCView, aFlush);

}

void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z) 
{


  if (MyTraceLevel) {
    PrintFunction ("call_togl_draw");
    PrintShortReal ("X", X);
    PrintShortReal ("Y", Y);
    PrintShortReal ("Z", Z);
  }
  call_togl_draw (X, Y, Z);

}

void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& ACStructure) {

  Graphic3d_CStructure MyCStructure = ACStructure;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_draw_structure");
    PrintCStructure (MyCStructure, 1);
  }
  call_togl_draw_structure (ACStructure.Id);

}

void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer Synchronize) 
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_end_immediat_mode");
    PrintInteger ("Synchronize", Synchronize);
  }
  call_togl_end_immediat_mode (int (Synchronize));

}

void OpenGl_GraphicDriver::EndPolyline () 
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_end_polyline");
  }
  call_togl_end_polyline ();

}

void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z) 
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_move");
    PrintShortReal ("X", X);
    PrintShortReal ("Y", Y);
    PrintShortReal ("Z", Z);
  }
  call_togl_move (X, Y, Z);

}

void OpenGl_GraphicDriver::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B) 
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_linecolor");
    PrintShortReal ("R", R);
    PrintShortReal ("G", G);
    PrintShortReal ("B", B);
  }
  call_togl_set_linecolor (R, G, B);

}

void OpenGl_GraphicDriver::SetLineType (const Standard_Integer Type) 
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_linetype");
    PrintInteger ("Type", Type);
  }
  call_togl_set_linetype (long (Type));

}

void OpenGl_GraphicDriver::SetLineWidth (const Standard_ShortReal Width)
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_linewidth");
    PrintShortReal ("Width", Width);
  }
  call_togl_set_linewidth (float (Width));

}

void 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)
{

  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_minmax");
    PrintShortReal ("X1", X1);
    PrintShortReal ("Y1", Y1);
    PrintShortReal ("Z1", Z1);
    PrintShortReal ("X2", X2);
    PrintShortReal ("Y2", Y2);
    PrintShortReal ("Z2", Z2);
  }
  call_togl_set_minmax (X1, Y1, Z1, X2, Y2, Z2);

}

void OpenGl_GraphicDriver::Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType)
{

  float theMatrix[4][4];
  Standard_Integer i, j;
  Standard_Integer lr, lc;

  lr = AMatrix.LowerRow ();
  lc = AMatrix.LowerCol ();

  for (i=0; i<=3; i++)
    for (j=0; j<=3; j++)
      theMatrix[i][j] = float (AMatrix (i+lr, j+lc));

  if (MyTraceLevel) {
    PrintFunction ("call_togl_transform");
    PrintMatrix ("AMatrix", AMatrix);
  }
  call_togl_transform (theMatrix, (AType == Graphic3d_TOC_REPLACE) ? 1 : 0);

}