0022627: Change OCCT memory management defaults
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_703.cxx
CommitLineData
2166f0fa
SK
1// File: OpenGl_GraphicDriver_703.cxx
2// Created: 20 October 2011
3// Author: Sergey ZERCHANINOV
4// Copyright: OPEN CASCADE 2011
7fd59977 5
2166f0fa 6#include <OpenGl_GraphicDriver.hxx>
7fd59977 7
7fd59977 8#include <Aspect_TypeOfMarker.hxx>
2166f0fa
SK
9#include <OpenGl_Group.hxx>
10#include <OpenGl_MarkerSet.hxx>
11#include <Graphic3d_Array1OfVertex.hxx>
7fd59977 12
2166f0fa 13static void OpenGl_CreateMarkers(const Graphic3d_CGroup& ACGroup, const Standard_Integer NbPoints, const Graphic3d_Vertex *Points)
7fd59977 14{
2166f0fa
SK
15 OpenGl_MarkerSet *amarkerset = new OpenGl_MarkerSet( NbPoints, Points );
16 ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelMarkerSet, amarkerset );
17}
7fd59977 18
2166f0fa
SK
19void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean )
20{
21 if (!ACGroup.ptrGroup)
22 return;
7fd59977 23
2166f0fa 24 const Aspect_TypeOfMarker AType = Aspect_TypeOfMarker (ACGroup.ContextMarker.MarkerType);
7fd59977 25
2166f0fa 26 switch (AType)
7fd59977 27 {
2166f0fa
SK
28 case Aspect_TOM_POINT :
29 case Aspect_TOM_PLUS :
30 case Aspect_TOM_STAR :
31 case Aspect_TOM_O :
32 case Aspect_TOM_X :
33 case Aspect_TOM_O_POINT :
34 case Aspect_TOM_O_PLUS :
35 case Aspect_TOM_O_STAR :
36 case Aspect_TOM_O_X :
37 case Aspect_TOM_RING1 :
38 case Aspect_TOM_RING2 :
39 case Aspect_TOM_RING3 :
40 case Aspect_TOM_USERDEFINED:
41 OpenGl_CreateMarkers(ACGroup, 1, &APoint);
42 break;
7fd59977 43
2166f0fa 44 case Aspect_TOM_BALL :
7fd59977 45 {
2166f0fa 46 const Standard_Real Delta = 0.1;
7fd59977 47
2166f0fa
SK
48 Standard_Real R, G, B, H, L, S, AScale;
49 R = Standard_Real (ACGroup.ContextMarker.Color.r);
50 G = Standard_Real (ACGroup.ContextMarker.Color.g);
51 B = Standard_Real (ACGroup.ContextMarker.Color.b);
52 AScale = Standard_Real (ACGroup.ContextMarker.Scale);
7fd59977 53
2166f0fa
SK
54 // we draw a set of circles
55 CALL_DEF_CONTEXTMARKER AContext;
56 AContext.MarkerType = int (Aspect_TOM_O);
57 while (AScale >= 1.0)
58 {
59 Quantity_Color::RgbHls (R, G, B, H, L, S);
60 // Modification de la saturation de 5 %
61 S *= 0.95;
62 Quantity_Color::HlsRgb (H, L, S, R, G, B);
63 AContext.Color.r = float (R);
64 AContext.Color.g = float (G);
65 AContext.Color.b = float (B);
66 AContext.Scale = float (AScale);
67 ((OpenGl_Group *)ACGroup.ptrGroup)->SetAspectMarker(AContext, Standard_False);
68 OpenGl_CreateMarkers(ACGroup, 1, &APoint);
69 AScale -= Delta;
7fd59977 70 }
2166f0fa 71 break;
7fd59977 72 }
2166f0fa
SK
73 default:
74 break;
7fd59977 75 }
7fd59977 76}
77
78void OpenGl_GraphicDriver::MarkerSet (const Graphic3d_CGroup& ACGroup,
2166f0fa
SK
79 const Graphic3d_Array1OfVertex& ListVertex,
80 const Standard_Boolean )
7fd59977 81{
2166f0fa
SK
82 if (!ACGroup.ptrGroup)
83 return;
7fd59977 84
2166f0fa
SK
85 const Standard_Integer nb = ListVertex.Length();
86 const Graphic3d_Vertex *arr = &ListVertex( ListVertex.Lower() );
7fd59977 87
2166f0fa 88 const Aspect_TypeOfMarker AType = Aspect_TypeOfMarker (ACGroup.ContextMarker.MarkerType);
7fd59977 89
2166f0fa
SK
90 switch (AType)
91 {
7fd59977 92 case Aspect_TOM_POINT :
93 case Aspect_TOM_PLUS :
94 case Aspect_TOM_STAR :
95 case Aspect_TOM_O :
96 case Aspect_TOM_X :
7fd59977 97 case Aspect_TOM_O_POINT :
7fd59977 98 case Aspect_TOM_O_PLUS :
7fd59977 99 case Aspect_TOM_O_STAR :
7fd59977 100 case Aspect_TOM_O_X :
2166f0fa
SK
101 case Aspect_TOM_RING1 :
102 case Aspect_TOM_RING2 :
103 case Aspect_TOM_RING3 :
104 case Aspect_TOM_USERDEFINED:
105 OpenGl_CreateMarkers(ACGroup, nb, arr);
7fd59977 106 break;
107
108 case Aspect_TOM_BALL :
2166f0fa
SK
109 {
110 const Standard_Real Delta = 0.1;
111
112 Standard_Real R, G, B, H, L, S, AScale;
113 R = Standard_Real (ACGroup.ContextMarker.Color.r);
114 G = Standard_Real (ACGroup.ContextMarker.Color.g);
115 B = Standard_Real (ACGroup.ContextMarker.Color.b);
116 AScale = Standard_Real (ACGroup.ContextMarker.Scale);
7fd59977 117
118 // we draw a set of circles
2166f0fa
SK
119 CALL_DEF_CONTEXTMARKER AContext;
120 AContext.MarkerType = int (Aspect_TOM_O);
121 while (AScale >= 1.0)
122 {
7fd59977 123 Quantity_Color::RgbHls (R, G, B, H, L, S);
124 // Modification de la saturation de 5 %
2166f0fa 125 S *= 0.95;
7fd59977 126 Quantity_Color::HlsRgb (H, L, S, R, G, B);
2166f0fa
SK
127 AContext.Color.r = float (R);
128 AContext.Color.g = float (G);
129 AContext.Color.b = float (B);
130 AContext.Scale = float (AScale);
131 ((OpenGl_Group *)ACGroup.ptrGroup)->SetAspectMarker(AContext, Standard_False);
132 OpenGl_CreateMarkers(ACGroup, nb, arr);
133 AScale -= Delta;
7fd59977 134 }
135 break;
2166f0fa 136 }
7fd59977 137 default:
138 break;
139 }
7fd59977 140}