2 // File OpenGl_GraphicDriver_703.cxx
3 // Created Mardi 28 janvier 1997
6 //-Copyright MatraDatavision 1997
10 //-Design Declaration des variables specifiques aux Drivers
12 //-Warning Un driver encapsule les Pex et OpenGl drivers
21 #include <OpenGl_GraphicDriver.jxx>
22 #include <Aspect_TypeOfMarker.hxx>
24 #include <Aspect_DriverDefinitionError.hxx>
26 #include <OpenGl_tgl_funcs.hxx>
28 int GenerateMarkerBitmap( unsigned int theWidth, unsigned int theHeight, unsigned char* theArray);
32 //-Global data definitions
36 void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean )
39 Graphic3d_CGroup MyCGroup = ACGroup;
41 CALL_DEF_MARKER amarker;
43 amarker.x = float (APoint.X ());
44 amarker.y = float (APoint.Y ());
45 amarker.z = float (APoint.Z ());
47 Standard_Real AMR, AMG, AMB, R, G, B;
48 Aspect_TypeOfMarker AMType;
49 Standard_Real AMScale, AScale;
51 // Sauvegarde des valeurs initiales
52 AMR = R = Standard_Real (MyCGroup.ContextMarker.Color.r);
53 AMG = G = Standard_Real (MyCGroup.ContextMarker.Color.g);
54 AMB = B = Standard_Real (MyCGroup.ContextMarker.Color.b);
55 AMType = Aspect_TypeOfMarker (MyCGroup.ContextMarker.MarkerType);
56 AMScale = AScale = Standard_Real (MyCGroup.ContextMarker.Scale);
59 Standard_Real H, L, S;
61 Standard_Real Limit=0, Delta;
66 case Aspect_TOM_POINT :
67 case Aspect_TOM_PLUS :
68 case Aspect_TOM_STAR :
71 case Aspect_TOM_USERDEFINED:
74 PrintFunction ("call_togl_marker");
75 PrintCGroup (MyCGroup, 1);
77 call_togl_marker (&MyCGroup, &amarker);
80 case Aspect_TOM_O_POINT :
81 MyCGroup.ContextMarker.IsDef = 1;
84 MyCGroup.ContextMarker.MarkerType =
86 call_togl_markercontextgroup (&MyCGroup, noinsert);
88 MyCGroup.ContextMarker.IsSet = 1;
91 PrintFunction ("call_togl_marker");
92 PrintCGroup (MyCGroup, 1);
94 call_togl_marker (&MyCGroup, &amarker);
97 MyCGroup.ContextMarker.MarkerType =
98 int (Aspect_TOM_POINT);
99 call_togl_markercontextgroup (&MyCGroup, noinsert);
101 PrintFunction ("call_togl_marker");
102 PrintCGroup (MyCGroup, 1);
104 call_togl_marker (&MyCGroup, &amarker);
107 case Aspect_TOM_O_PLUS :
108 MyCGroup.ContextMarker.IsDef = 1;
110 // we draw the circle
111 MyCGroup.ContextMarker.MarkerType =
113 call_togl_markercontextgroup (&MyCGroup, noinsert);
115 MyCGroup.ContextMarker.IsSet = 1;
118 PrintFunction ("call_togl_marker");
119 PrintCGroup (MyCGroup, 1);
121 call_togl_marker (&MyCGroup, &amarker);
124 MyCGroup.ContextMarker.MarkerType =
125 int (Aspect_TOM_PLUS);
126 call_togl_markercontextgroup (&MyCGroup, noinsert);
128 PrintFunction ("call_togl_marker");
129 PrintCGroup (MyCGroup, 1);
131 call_togl_marker (&MyCGroup, &amarker);
134 case Aspect_TOM_O_STAR :
135 MyCGroup.ContextMarker.IsDef = 1;
137 // we draw the circle
138 MyCGroup.ContextMarker.MarkerType =
140 call_togl_markercontextgroup (&MyCGroup, noinsert);
142 MyCGroup.ContextMarker.IsSet = 1;
145 PrintFunction ("call_togl_marker");
146 PrintCGroup (MyCGroup, 1);
148 call_togl_marker (&MyCGroup, &amarker);
151 MyCGroup.ContextMarker.MarkerType =
152 int (Aspect_TOM_STAR);
153 call_togl_markercontextgroup (&MyCGroup, noinsert);
155 PrintFunction ("call_togl_marker");
156 PrintCGroup (MyCGroup, 1);
158 call_togl_marker (&MyCGroup, &amarker);
161 case Aspect_TOM_O_X :
162 MyCGroup.ContextMarker.IsDef = 1;
164 // we draw the circle
165 MyCGroup.ContextMarker.MarkerType =
167 call_togl_markercontextgroup (&MyCGroup, noinsert);
169 MyCGroup.ContextMarker.IsSet = 1;
172 PrintFunction ("call_togl_marker");
173 PrintCGroup (MyCGroup, 1);
175 call_togl_marker (&MyCGroup, &amarker);
178 MyCGroup.ContextMarker.MarkerType =
180 call_togl_markercontextgroup (&MyCGroup, noinsert);
182 PrintFunction ("call_togl_marker");
183 PrintCGroup (MyCGroup, 1);
185 call_togl_marker (&MyCGroup, &amarker);
188 case Aspect_TOM_BALL :
189 MyCGroup.ContextMarker.IsDef = 1;
191 // we draw a set of circles
192 MyCGroup.ContextMarker.MarkerType =
195 while (AScale >= 1.0) {
196 Quantity_Color::RgbHls (R, G, B, H, L, S);
197 // Modification de la saturation de 5 %
200 if (S < 0.0) S = LastS;
201 Quantity_Color::HlsRgb (H, L, S, R, G, B);
202 MyCGroup.ContextMarker.Color.r = float (R);
203 MyCGroup.ContextMarker.Color.g = float (G);
204 MyCGroup.ContextMarker.Color.b = float (B);
205 MyCGroup.ContextMarker.Scale = float (AScale);
206 call_togl_markercontextgroup (&MyCGroup, noinsert);
208 MyCGroup.ContextMarker.IsSet = 1;
211 PrintFunction ("call_togl_marker");
212 PrintCGroup (MyCGroup, 1);
214 call_togl_marker (&MyCGroup, &amarker);
219 case Aspect_TOM_RING1 :
220 case Aspect_TOM_RING2 :
221 case Aspect_TOM_RING3 :
222 MyCGroup.ContextMarker.IsDef = 1;
224 // we draw a set of circles
225 MyCGroup.ContextMarker.MarkerType =
227 if (AMType == Aspect_TOM_RING1)
228 Limit = AScale - AScale * 0.8;
229 if (AMType == Aspect_TOM_RING2)
230 Limit = AScale - AScale * 0.5;
231 if (AMType == Aspect_TOM_RING3)
232 Limit = AScale - AScale * 0.2;
234 while (AScale > Limit && AScale >= 1.0) {
235 MyCGroup.ContextMarker.Scale = float (AScale);
236 call_togl_markercontextgroup (&MyCGroup, noinsert);
238 MyCGroup.ContextMarker.IsSet = 1;
241 PrintFunction ("call_togl_marker");
242 PrintCGroup (MyCGroup, 1);
244 call_togl_marker (&MyCGroup, &amarker);
252 // Restauration des valeurs initiales
253 MyCGroup.ContextMarker.Color.r = float (AMR);
254 MyCGroup.ContextMarker.Color.g = float (AMR);
255 MyCGroup.ContextMarker.Color.b = float (AMR);
256 MyCGroup.ContextMarker.MarkerType = int (AMType);
257 MyCGroup.ContextMarker.Scale = float (AMScale);
261 void OpenGl_GraphicDriver::MarkerSet (const Graphic3d_CGroup& ACGroup,
262 const Graphic3d_Array1OfVertex& ListVertex,
263 const Standard_Boolean )
265 // const Standard_Boolean EvalMinMax) {
267 Graphic3d_CGroup MyCGroup = ACGroup;
269 //static void (*fp2) (Graphic3d_CGroup *, CALL_DEF_LISTMARKERS *) = NULL;
272 //OSD_Function osdfp = NULL;
273 //osdfp = MySharedLibrary.DlSymb ("call_togl_marker_set");
274 //fp2 = (void (*)(Graphic3d_CGroup *, CALL_DEF_LISTMARKERS *)) osdfp;
276 //Aspect_DriverDefinitionError::Raise
277 //(MySharedLibrary.DlError ());
280 //static void (*fp3) (Graphic3d_CGroup *, int) = NULL;
283 //OSD_Function osdfp = NULL;
284 //osdfp = MySharedLibrary.DlSymb ("call_togl_markercontextgroup");
285 //fp3 = (void (*)(Graphic3d_CGroup *, int)) osdfp;
287 //Aspect_DriverDefinitionError::Raise
288 //(MySharedLibrary.DlError ());
291 Standard_Integer Lower = ListVertex.Lower ();
293 CALL_DEF_LISTMARKERS almarkers;
295 almarkers.NbMarkers = int (ListVertex.Length ());
296 almarkers.Markers = (CALL_DEF_MARKER *) &ListVertex (Lower);
298 Standard_Real AMR, AMG, AMB, R, G, B;
299 Aspect_TypeOfMarker AMType;
300 Standard_Real AMScale, AScale;
302 // Sauvegarde des valeurs initiales
303 AMR = R = Standard_Real (MyCGroup.ContextMarker.Color.r);
304 AMG = G = Standard_Real (MyCGroup.ContextMarker.Color.g);
305 AMB = B = Standard_Real (MyCGroup.ContextMarker.Color.b);
306 AMType = Aspect_TypeOfMarker (MyCGroup.ContextMarker.MarkerType);
307 AMScale = AScale = Standard_Real (MyCGroup.ContextMarker.Scale);
310 Standard_Real H, L, S;
312 Standard_Real Limit=0, Delta;
316 case Aspect_TOM_POINT :
317 case Aspect_TOM_PLUS :
318 case Aspect_TOM_STAR :
321 case Aspect_TOM_USERDEFINED:
323 PrintFunction ("call_togl_marker_set");
324 PrintCGroup (MyCGroup, 1);
326 call_togl_marker_set (&MyCGroup, &almarkers);
329 case Aspect_TOM_O_POINT :
330 MyCGroup.ContextMarker.IsDef = 1;
332 // we draw the circle
333 MyCGroup.ContextMarker.MarkerType =
335 call_togl_markercontextgroup (&MyCGroup, noinsert);
337 MyCGroup.ContextMarker.IsSet = 1;
340 PrintFunction ("call_togl_marker_set");
341 PrintCGroup (MyCGroup, 1);
343 call_togl_marker_set (&MyCGroup, &almarkers);
346 MyCGroup.ContextMarker.MarkerType =
347 int (Aspect_TOM_POINT);
348 call_togl_markercontextgroup (&MyCGroup, noinsert);
350 PrintFunction ("call_togl_marker_set");
351 PrintCGroup (MyCGroup, 1);
353 call_togl_marker_set (&MyCGroup, &almarkers);
356 case Aspect_TOM_O_PLUS :
357 MyCGroup.ContextMarker.IsDef = 1;
359 // we draw the circle
360 MyCGroup.ContextMarker.MarkerType =
362 call_togl_markercontextgroup (&MyCGroup, noinsert);
364 MyCGroup.ContextMarker.IsSet = 1;
367 PrintFunction ("call_togl_marker_set");
368 PrintCGroup (MyCGroup, 1);
370 call_togl_marker_set (&MyCGroup, &almarkers);
373 MyCGroup.ContextMarker.MarkerType =
374 int (Aspect_TOM_PLUS);
375 call_togl_markercontextgroup (&MyCGroup, noinsert);
377 PrintFunction ("call_togl_marker_set");
378 PrintCGroup (MyCGroup, 1);
380 call_togl_marker_set (&MyCGroup, &almarkers);
383 case Aspect_TOM_O_STAR :
384 MyCGroup.ContextMarker.IsDef = 1;
386 // we draw the circle
387 MyCGroup.ContextMarker.MarkerType =
389 call_togl_markercontextgroup (&MyCGroup, noinsert);
391 MyCGroup.ContextMarker.IsSet = 1;
394 PrintFunction ("call_togl_marker_set");
395 PrintCGroup (MyCGroup, 1);
397 call_togl_marker_set (&MyCGroup, &almarkers);
400 MyCGroup.ContextMarker.MarkerType =
401 int (Aspect_TOM_STAR);
402 call_togl_markercontextgroup (&MyCGroup, noinsert);
404 PrintFunction ("call_togl_marker_set");
405 PrintCGroup (MyCGroup, 1);
407 call_togl_marker_set (&MyCGroup, &almarkers);
410 case Aspect_TOM_O_X :
411 MyCGroup.ContextMarker.IsDef = 1;
413 // we draw the circle
414 MyCGroup.ContextMarker.MarkerType =
416 call_togl_markercontextgroup (&MyCGroup, noinsert);
418 MyCGroup.ContextMarker.IsSet = 1;
421 PrintFunction ("call_togl_marker_set");
422 PrintCGroup (MyCGroup, 1);
424 call_togl_marker_set (&MyCGroup, &almarkers);
427 MyCGroup.ContextMarker.MarkerType =
429 call_togl_markercontextgroup (&MyCGroup, noinsert);
431 PrintFunction ("call_togl_marker_set");
432 PrintCGroup (MyCGroup, 1);
434 call_togl_marker_set (&MyCGroup, &almarkers);
437 case Aspect_TOM_BALL :
438 MyCGroup.ContextMarker.IsDef = 1;
440 // we draw a set of circles
441 MyCGroup.ContextMarker.MarkerType =
444 while (AScale >= 1.0) {
445 Quantity_Color::RgbHls (R, G, B, H, L, S);
446 // Modification de la saturation de 5 %
449 if (S < 0.0) S = LastS;
450 Quantity_Color::HlsRgb (H, L, S, R, G, B);
451 MyCGroup.ContextMarker.Color.r = float (R);
452 MyCGroup.ContextMarker.Color.g = float (G);
453 MyCGroup.ContextMarker.Color.b = float (B);
454 MyCGroup.ContextMarker.Scale = float (AScale);
455 call_togl_markercontextgroup (&MyCGroup, noinsert);
457 MyCGroup.ContextMarker.IsSet = 1;
460 PrintFunction ("call_togl_marker_set");
461 PrintCGroup (MyCGroup, 1);
463 call_togl_marker_set (&MyCGroup, &almarkers);
468 case Aspect_TOM_RING1 :
469 case Aspect_TOM_RING2 :
470 case Aspect_TOM_RING3 :
471 MyCGroup.ContextMarker.IsDef = 1;
473 // we draw a set of circles
474 MyCGroup.ContextMarker.MarkerType =
476 if (AMType == Aspect_TOM_RING1)
477 Limit = AScale - AScale * 0.8;
478 if (AMType == Aspect_TOM_RING2)
479 Limit = AScale - AScale * 0.5;
480 if (AMType == Aspect_TOM_RING3)
481 Limit = AScale - AScale * 0.2;
483 while (AScale > Limit && AScale >= 1.0) {
484 MyCGroup.ContextMarker.Scale = float (AScale);
485 call_togl_markercontextgroup (&MyCGroup, noinsert);
487 MyCGroup.ContextMarker.IsSet = 1;
490 PrintFunction ("call_togl_marker_set");
491 PrintCGroup (MyCGroup, 1);
493 call_togl_marker_set (&MyCGroup, &almarkers);
501 // Restauration des valeurs initiales
502 MyCGroup.ContextMarker.Color.r = float (AMR);
503 MyCGroup.ContextMarker.Color.g = float (AMR);
504 MyCGroup.ContextMarker.Color.b = float (AMR);
505 MyCGroup.ContextMarker.MarkerType = int (AMType);
506 MyCGroup.ContextMarker.Scale = float (AMScale);