summaryrefslogtreecommitdiff
path: root/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx
blob: b00046b77d95cf9faec0de5b9c3335ff0d883f1d (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

// File   OpenGl_GraphicDriver_Layer.cxx
// Created  Mardi 3 novembre 1998
// Author CAL

//-Copyright  MatraDatavision 1998

//-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
#define NO_DEBUG

//-Global data definitions

//-Methods, in order

void OpenGl_GraphicDriver::Layer (Aspect_CLayer2d& ACLayer) {
  Aspect_CLayer2d MyCLayer = ACLayer;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_layer2d");
    PrintInteger ("ALayerType", int (ACLayer.layerType));
  }
  call_togl_layer2d (&MyCLayer);
  ACLayer = MyCLayer;
#ifdef DEBUG
  cout << "OpenGl_GraphicDriver::Layer" << endl;
  call_def_ptrLayer ptrLayer;
  ptrLayer = (call_def_ptrLayer) MyCLayer.ptrLayer;
  if (ptrLayer == NULL)
    cout << "\tptrLayer == NULL" << endl;
  else
    cout << "\tptrLayer->listIndex = " << ptrLayer->listIndex << endl;
#endif
}

void OpenGl_GraphicDriver::RemoveLayer (const Aspect_CLayer2d& ACLayer) {
  Aspect_CLayer2d MyCLayer = ACLayer;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_removelayer2d");
    PrintInteger ("ALayerType", int (ACLayer.layerType));
  }
  call_togl_removelayer2d (&MyCLayer);
}

void OpenGl_GraphicDriver::BeginLayer (const Aspect_CLayer2d& ACLayer) {
  Aspect_CLayer2d MyCLayer = ACLayer;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_begin_layer2d");
    PrintInteger ("ALayerType", int (ACLayer.layerType));
  }
  call_togl_begin_layer2d (&MyCLayer);
}

void OpenGl_GraphicDriver::BeginPolygon2d () {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_begin_polygon2d");
  }
  call_togl_begin_polygon2d ();
}

void OpenGl_GraphicDriver::BeginPolyline2d () {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_begin_polyline2d");
  }
  call_togl_begin_polyline2d ();
}

void OpenGl_GraphicDriver::ClearLayer (const Aspect_CLayer2d& ACLayer) {
  Aspect_CLayer2d MyCLayer = ACLayer;

  if (MyTraceLevel) {
    PrintFunction ("call_togl_clear_layer2d");
    PrintInteger ("ALayerType", int (ACLayer.layerType));
  }
  call_togl_clear_layer2d (&MyCLayer);
}

void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_draw2d");
    PrintShortReal ("X", X);
    PrintShortReal ("Y", Y);
  }
  call_togl_draw2d (X, Y);
}

void OpenGl_GraphicDriver::Edge (const Standard_ShortReal X, const Standard_ShortReal Y) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_edge2d");
    PrintShortReal ("X", X);
    PrintShortReal ("Y", Y);
  }
  call_togl_edge2d (X, Y);
}

void OpenGl_GraphicDriver::EndLayer () {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_end_layer2d");
  }
  call_togl_end_layer2d ();
}

void OpenGl_GraphicDriver::EndPolygon2d () {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_end_polygon2d");
  }
  call_togl_end_polygon2d ();
}

void OpenGl_GraphicDriver::EndPolyline2d () {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_end_polyline2d");
  }
  call_togl_end_polyline2d ();
}

void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_move2d");
    PrintShortReal ("X", X);
    PrintShortReal ("Y", Y);
  }
  call_togl_move2d (X, Y);
}

void OpenGl_GraphicDriver::Rectangle (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Width, const Standard_ShortReal Height) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_rectangle2d");
    PrintShortReal ("X", X);
    PrintShortReal ("Y", Y);
    PrintShortReal ("Width", Width);
    PrintShortReal ("Height", Height);
  }
  call_togl_rectangle2d (X, Y, Width, Height);
}

void OpenGl_GraphicDriver::SetColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_color");
    PrintShortReal ("R", R);
    PrintShortReal ("G", G);
    PrintShortReal ("B", B);
  }
  call_togl_set_color (R, G, B);
}

void OpenGl_GraphicDriver::SetTransparency (const Standard_ShortReal ATransparency) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_transparency");
    PrintShortReal ("Transparency", ATransparency);
  }
  call_togl_set_transparency (ATransparency);
}

void OpenGl_GraphicDriver::UnsetTransparency () {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_unset_transparency");
  }
  call_togl_unset_transparency ();
}

void OpenGl_GraphicDriver::SetLineAttributes (const Standard_Integer Type, const Standard_ShortReal Width) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_line_attributes");
    PrintInteger ("Type", Type);
    PrintShortReal ("Width", Width);
  }
  call_togl_set_line_attributes (Type, Width);
}

void OpenGl_GraphicDriver::SetTextAttributes (const Standard_CString Font, const Standard_Integer AType, const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B) {
  if (MyTraceLevel) {
    PrintFunction ("call_togl_set_text_attributes");
    PrintString ("Font", Font);
    PrintInteger ("Type", AType);
    PrintShortReal ("R", R);
    PrintShortReal ("G", G);
    PrintShortReal ("B", B);
  }
  call_togl_set_text_attributes ((Tchar*)Font, AType, R, G, B);
}   

void OpenGl_GraphicDriver::Text (const Standard_CString AText, const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Height)
{
  if (MyTraceLevel) {
    PrintFunction ("call_togl_text2d");
    PrintString ("Text", AText);
    PrintShortReal ("X", X);
    PrintShortReal ("Y", Y);
    PrintShortReal ("Height", Height);
  }
  const Standard_ShortReal h = (Height < 0)? DefaultTextHeight() : Height;
  TCollection_ExtendedString estr(AText);
  call_togl_text2d ((Techar *)estr.ToExtString(), X, Y, h);
}

void OpenGl_GraphicDriver::TextSize (const Standard_CString AText, const Standard_ShortReal AHeight, Standard_ShortReal& AWidth, Standard_ShortReal& AnAscent, Standard_ShortReal& ADescent) const
{
  TCollection_ExtendedString estr(AText);
  call_togl_textsize2d ((Techar *)estr.ToExtString(), AHeight, &AWidth, &AnAscent, &ADescent);
  if (MyTraceLevel) {
    PrintFunction ("call_togl_textsize2d");
    PrintString ("Text", AText);
    PrintShortReal ("AHeight", AHeight);
    PrintShortReal ("AWidth", AWidth);
    PrintShortReal ("AnAscent", AnAscent);
    PrintShortReal ("ADescent", ADescent);
  }
}