0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_703.cxx
1
2 // File   OpenGl_GraphicDriver_703.cxx
3 // Created  Mardi 28 janvier 1997
4 // Author CAL
5
6 //-Copyright  MatraDatavision 1997
7
8 //-Version  
9
10 //-Design Declaration des variables specifiques aux Drivers
11
12 //-Warning  Un driver encapsule les Pex et OpenGl drivers
13
14 //-References 
15
16 //-Language C++ 2.0
17
18 //-Declarations
19
20 // for the class
21 #include <OpenGl_GraphicDriver.jxx>
22 #include <Aspect_TypeOfMarker.hxx>
23
24 #include <Aspect_DriverDefinitionError.hxx>
25
26 #include <OpenGl_tgl_funcs.hxx>
27
28 int GenerateMarkerBitmap( unsigned int theWidth, unsigned int theHeight, unsigned char* theArray);
29
30 //-Aliases
31
32 //-Global data definitions
33
34 //-Methods, in order
35
36 void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean ) 
37 {
38
39   Graphic3d_CGroup MyCGroup = ACGroup;
40
41   CALL_DEF_MARKER amarker;
42
43   amarker.x = float (APoint.X ());
44   amarker.y = float (APoint.Y ());
45   amarker.z = float (APoint.Z ());
46
47   Standard_Real AMR, AMG, AMB, R, G, B;
48   Aspect_TypeOfMarker AMType;
49   Standard_Real AMScale, AScale;
50
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);
57
58   int noinsert  = 0;
59   Standard_Real H, L, S;
60   Standard_Real LastS;
61   Standard_Real Limit=0, Delta;
62
63   switch (AMType) 
64   {
65
66   case Aspect_TOM_POINT :
67   case Aspect_TOM_PLUS :
68   case Aspect_TOM_STAR :
69   case Aspect_TOM_O :
70   case Aspect_TOM_X :
71   case Aspect_TOM_USERDEFINED:
72     if (MyTraceLevel) 
73     {
74       PrintFunction ("call_togl_marker");
75       PrintCGroup (MyCGroup, 1);
76     }
77     call_togl_marker (&MyCGroup, &amarker);
78     break;
79
80   case Aspect_TOM_O_POINT :
81     MyCGroup.ContextMarker.IsDef  = 1;
82
83     // we draw the circle
84     MyCGroup.ContextMarker.MarkerType =
85       int (Aspect_TOM_O);
86     call_togl_markercontextgroup (&MyCGroup, noinsert);
87
88     MyCGroup.ContextMarker.IsSet  = 1;
89
90     if (MyTraceLevel) {
91       PrintFunction ("call_togl_marker");
92       PrintCGroup (MyCGroup, 1);
93     }
94     call_togl_marker (&MyCGroup, &amarker);
95
96     // we draw the point
97     MyCGroup.ContextMarker.MarkerType =
98       int (Aspect_TOM_POINT);
99     call_togl_markercontextgroup (&MyCGroup, noinsert);
100     if (MyTraceLevel) {
101       PrintFunction ("call_togl_marker");
102       PrintCGroup (MyCGroup, 1);
103     }
104     call_togl_marker (&MyCGroup, &amarker);
105     break;
106
107   case Aspect_TOM_O_PLUS :
108     MyCGroup.ContextMarker.IsDef  = 1;
109
110     // we draw the circle
111     MyCGroup.ContextMarker.MarkerType =
112       int (Aspect_TOM_O);
113     call_togl_markercontextgroup (&MyCGroup, noinsert);
114
115     MyCGroup.ContextMarker.IsSet  = 1;
116
117     if (MyTraceLevel) {
118       PrintFunction ("call_togl_marker");
119       PrintCGroup (MyCGroup, 1);
120     }
121     call_togl_marker (&MyCGroup, &amarker);
122
123     // we draw the plus
124     MyCGroup.ContextMarker.MarkerType =
125       int (Aspect_TOM_PLUS);
126     call_togl_markercontextgroup (&MyCGroup, noinsert);
127     if (MyTraceLevel) {
128       PrintFunction ("call_togl_marker");
129       PrintCGroup (MyCGroup, 1);
130     }
131     call_togl_marker (&MyCGroup, &amarker);
132     break;
133
134   case Aspect_TOM_O_STAR :
135     MyCGroup.ContextMarker.IsDef  = 1;
136
137     // we draw the circle
138     MyCGroup.ContextMarker.MarkerType =
139       int (Aspect_TOM_O);
140     call_togl_markercontextgroup (&MyCGroup, noinsert);
141
142     MyCGroup.ContextMarker.IsSet  = 1;
143
144     if (MyTraceLevel) {
145       PrintFunction ("call_togl_marker");
146       PrintCGroup (MyCGroup, 1);
147     }
148     call_togl_marker (&MyCGroup, &amarker);
149
150     // we draw the star
151     MyCGroup.ContextMarker.MarkerType =
152       int (Aspect_TOM_STAR);
153     call_togl_markercontextgroup (&MyCGroup, noinsert);
154     if (MyTraceLevel) {
155       PrintFunction ("call_togl_marker");
156       PrintCGroup (MyCGroup, 1);
157     }
158     call_togl_marker (&MyCGroup, &amarker);
159     break;
160
161   case Aspect_TOM_O_X :
162     MyCGroup.ContextMarker.IsDef  = 1;
163
164     // we draw the circle
165     MyCGroup.ContextMarker.MarkerType =
166       int (Aspect_TOM_O);
167     call_togl_markercontextgroup (&MyCGroup, noinsert);
168
169     MyCGroup.ContextMarker.IsSet  = 1;
170
171     if (MyTraceLevel) {
172       PrintFunction ("call_togl_marker");
173       PrintCGroup (MyCGroup, 1);
174     }
175     call_togl_marker (&MyCGroup, &amarker);
176
177     // we draw the cross
178     MyCGroup.ContextMarker.MarkerType =
179       int (Aspect_TOM_X);
180     call_togl_markercontextgroup (&MyCGroup, noinsert);
181     if (MyTraceLevel) {
182       PrintFunction ("call_togl_marker");
183       PrintCGroup (MyCGroup, 1);
184     }
185     call_togl_marker (&MyCGroup, &amarker);
186     break;
187
188   case Aspect_TOM_BALL :
189     MyCGroup.ContextMarker.IsDef  = 1;
190
191     // we draw a set of circles
192     MyCGroup.ContextMarker.MarkerType =
193       int (Aspect_TOM_O);
194     Delta = 0.1;
195     while (AScale >= 1.0) {
196       Quantity_Color::RgbHls (R, G, B, H, L, S);
197       // Modification de la saturation de 5 %
198       LastS = S;
199       S = S - S * 0.05;
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);
207
208       MyCGroup.ContextMarker.IsSet  = 1;
209
210       if (MyTraceLevel) {
211         PrintFunction ("call_togl_marker");
212         PrintCGroup (MyCGroup, 1);
213       }
214       call_togl_marker (&MyCGroup, &amarker);
215       AScale  -= Delta;
216     }
217     break;
218
219   case Aspect_TOM_RING1 :
220   case Aspect_TOM_RING2 :
221   case Aspect_TOM_RING3 :
222     MyCGroup.ContextMarker.IsDef  = 1;
223
224     // we draw a set of circles
225     MyCGroup.ContextMarker.MarkerType =
226       int (Aspect_TOM_O);
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;
233     Delta = 0.1;
234     while (AScale > Limit && AScale >= 1.0) {
235       MyCGroup.ContextMarker.Scale  = float (AScale);
236       call_togl_markercontextgroup (&MyCGroup, noinsert);
237
238       MyCGroup.ContextMarker.IsSet  = 1;
239
240       if (MyTraceLevel) {
241         PrintFunction ("call_togl_marker");
242         PrintCGroup (MyCGroup, 1);
243       }
244       call_togl_marker (&MyCGroup, &amarker);
245       AScale  -= Delta;
246     }
247     break ;
248   default:
249     break ;
250   }
251
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);
258
259 }
260
261 void OpenGl_GraphicDriver::MarkerSet (const Graphic3d_CGroup& ACGroup,
262                                       const Graphic3d_Array1OfVertex& ListVertex,
263                                       const Standard_Boolean ) 
264 {
265   //                                      const Standard_Boolean EvalMinMax) {
266
267   Graphic3d_CGroup MyCGroup = ACGroup;
268
269   //static void (*fp2) (Graphic3d_CGroup *, CALL_DEF_LISTMARKERS *) = NULL;
270
271   //if (! fp2) {
272   //OSD_Function osdfp = NULL;
273   //osdfp = MySharedLibrary.DlSymb ("call_togl_marker_set");
274   //fp2 = (void (*)(Graphic3d_CGroup *, CALL_DEF_LISTMARKERS *)) osdfp;
275   //if (! osdfp)
276   //Aspect_DriverDefinitionError::Raise
277   //(MySharedLibrary.DlError ());
278   //}
279
280   //static void (*fp3) (Graphic3d_CGroup *, int) = NULL;
281
282   //if (! fp3) {
283   //OSD_Function osdfp = NULL;
284   //osdfp = MySharedLibrary.DlSymb ("call_togl_markercontextgroup");
285   //fp3 = (void (*)(Graphic3d_CGroup *, int)) osdfp;
286   //if (! osdfp)
287   //Aspect_DriverDefinitionError::Raise
288   //(MySharedLibrary.DlError ());
289   //}
290
291   Standard_Integer Lower  = ListVertex.Lower ();
292
293   CALL_DEF_LISTMARKERS almarkers;
294
295   almarkers.NbMarkers = int (ListVertex.Length ());
296   almarkers.Markers = (CALL_DEF_MARKER *) &ListVertex (Lower);
297
298   Standard_Real AMR, AMG, AMB, R, G, B;
299   Aspect_TypeOfMarker AMType;
300   Standard_Real AMScale, AScale;
301
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);
308
309   int noinsert  = 0;
310   Standard_Real H, L, S;
311   Standard_Real LastS;
312   Standard_Real Limit=0, Delta;
313
314   switch (AMType) {
315
316     case Aspect_TOM_POINT :
317     case Aspect_TOM_PLUS :
318     case Aspect_TOM_STAR :
319     case Aspect_TOM_O :
320     case Aspect_TOM_X :
321     case Aspect_TOM_USERDEFINED:
322       if (MyTraceLevel) {
323         PrintFunction ("call_togl_marker_set");
324         PrintCGroup (MyCGroup, 1);
325       }
326       call_togl_marker_set (&MyCGroup, &almarkers);
327       break;
328
329     case Aspect_TOM_O_POINT :
330       MyCGroup.ContextMarker.IsDef  = 1;
331
332       // we draw the circle
333       MyCGroup.ContextMarker.MarkerType =
334         int (Aspect_TOM_O);
335       call_togl_markercontextgroup (&MyCGroup, noinsert);
336
337       MyCGroup.ContextMarker.IsSet  = 1;
338
339       if (MyTraceLevel) {
340         PrintFunction ("call_togl_marker_set");
341         PrintCGroup (MyCGroup, 1);
342       }
343       call_togl_marker_set (&MyCGroup, &almarkers);
344
345       // we draw the point
346       MyCGroup.ContextMarker.MarkerType =
347         int (Aspect_TOM_POINT);
348       call_togl_markercontextgroup (&MyCGroup, noinsert);
349       if (MyTraceLevel) {
350         PrintFunction ("call_togl_marker_set");
351         PrintCGroup (MyCGroup, 1);
352       }
353       call_togl_marker_set (&MyCGroup, &almarkers);
354       break;
355
356     case Aspect_TOM_O_PLUS :
357       MyCGroup.ContextMarker.IsDef  = 1;
358
359       // we draw the circle
360       MyCGroup.ContextMarker.MarkerType =
361         int (Aspect_TOM_O);
362       call_togl_markercontextgroup (&MyCGroup, noinsert);
363
364       MyCGroup.ContextMarker.IsSet  = 1;
365
366       if (MyTraceLevel) {
367         PrintFunction ("call_togl_marker_set");
368         PrintCGroup (MyCGroup, 1);
369       }
370       call_togl_marker_set (&MyCGroup, &almarkers);
371
372       // we draw the plus
373       MyCGroup.ContextMarker.MarkerType =
374         int (Aspect_TOM_PLUS);
375       call_togl_markercontextgroup (&MyCGroup, noinsert);
376       if (MyTraceLevel) {
377         PrintFunction ("call_togl_marker_set");
378         PrintCGroup (MyCGroup, 1);
379       }
380       call_togl_marker_set (&MyCGroup, &almarkers);
381       break;
382
383     case Aspect_TOM_O_STAR :
384       MyCGroup.ContextMarker.IsDef  = 1;
385
386       // we draw the circle
387       MyCGroup.ContextMarker.MarkerType =
388         int (Aspect_TOM_O);
389       call_togl_markercontextgroup (&MyCGroup, noinsert);
390
391       MyCGroup.ContextMarker.IsSet  = 1;
392
393       if (MyTraceLevel) {
394         PrintFunction ("call_togl_marker_set");
395         PrintCGroup (MyCGroup, 1);
396       }
397       call_togl_marker_set (&MyCGroup, &almarkers);
398
399       // we draw the star
400       MyCGroup.ContextMarker.MarkerType =
401         int (Aspect_TOM_STAR);
402       call_togl_markercontextgroup (&MyCGroup, noinsert);
403       if (MyTraceLevel) {
404         PrintFunction ("call_togl_marker_set");
405         PrintCGroup (MyCGroup, 1);
406       }
407       call_togl_marker_set (&MyCGroup, &almarkers);
408       break;
409
410     case Aspect_TOM_O_X :
411       MyCGroup.ContextMarker.IsDef  = 1;
412
413       // we draw the circle
414       MyCGroup.ContextMarker.MarkerType =
415         int (Aspect_TOM_O);
416       call_togl_markercontextgroup (&MyCGroup, noinsert);
417
418       MyCGroup.ContextMarker.IsSet  = 1;
419
420       if (MyTraceLevel) {
421         PrintFunction ("call_togl_marker_set");
422         PrintCGroup (MyCGroup, 1);
423       }
424       call_togl_marker_set (&MyCGroup, &almarkers);
425
426       // we draw the cross
427       MyCGroup.ContextMarker.MarkerType =
428         int (Aspect_TOM_X);
429       call_togl_markercontextgroup (&MyCGroup, noinsert);
430       if (MyTraceLevel) {
431         PrintFunction ("call_togl_marker_set");
432         PrintCGroup (MyCGroup, 1);
433       }
434       call_togl_marker_set (&MyCGroup, &almarkers);
435       break;
436
437     case Aspect_TOM_BALL :
438       MyCGroup.ContextMarker.IsDef  = 1;
439
440       // we draw a set of circles
441       MyCGroup.ContextMarker.MarkerType =
442         int (Aspect_TOM_O);
443       Delta = 0.1;
444       while (AScale >= 1.0) {
445         Quantity_Color::RgbHls (R, G, B, H, L, S);
446         // Modification de la saturation de 5 %
447         LastS = S;
448         S = S - S * 0.05;
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);
456
457         MyCGroup.ContextMarker.IsSet  = 1;
458
459         if (MyTraceLevel) {
460           PrintFunction ("call_togl_marker_set");
461           PrintCGroup (MyCGroup, 1);
462         }
463         call_togl_marker_set (&MyCGroup, &almarkers);
464         AScale  -= Delta;
465       }
466       break;
467
468     case Aspect_TOM_RING1 :
469     case Aspect_TOM_RING2 :
470     case Aspect_TOM_RING3 :
471       MyCGroup.ContextMarker.IsDef  = 1;
472
473       // we draw a set of circles
474       MyCGroup.ContextMarker.MarkerType =
475         int (Aspect_TOM_O);
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;
482       Delta = 0.1;
483       while (AScale > Limit && AScale >= 1.0) {
484         MyCGroup.ContextMarker.Scale  = float (AScale);
485         call_togl_markercontextgroup (&MyCGroup, noinsert);
486
487         MyCGroup.ContextMarker.IsSet  = 1;
488
489         if (MyTraceLevel) {
490           PrintFunction ("call_togl_marker_set");
491           PrintCGroup (MyCGroup, 1);
492         }
493         call_togl_marker_set (&MyCGroup, &almarkers);
494         AScale  -= Delta;
495       }
496       break;
497     default:
498       break;
499   }
500
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);
507
508 }