Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-10-20 |
2 | // Created by: Sergey ZERCHANINOV | |
3 | // Copyright (c) 2011-2012 OPEN CASCADE SAS | |
4 | // | |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
7fd59977 | 20 | |
2166f0fa | 21 | #include <OpenGl_GraphicDriver.hxx> |
7fd59977 | 22 | |
7fd59977 | 23 | #include <Aspect_TypeOfMarker.hxx> |
2166f0fa SK |
24 | #include <OpenGl_Group.hxx> |
25 | #include <OpenGl_MarkerSet.hxx> | |
26 | #include <Graphic3d_Array1OfVertex.hxx> | |
7fd59977 | 27 | |
2166f0fa | 28 | static void OpenGl_CreateMarkers(const Graphic3d_CGroup& ACGroup, const Standard_Integer NbPoints, const Graphic3d_Vertex *Points) |
7fd59977 | 29 | { |
2166f0fa SK |
30 | OpenGl_MarkerSet *amarkerset = new OpenGl_MarkerSet( NbPoints, Points ); |
31 | ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelMarkerSet, amarkerset ); | |
32 | } | |
7fd59977 | 33 | |
2166f0fa SK |
34 | void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean ) |
35 | { | |
36 | if (!ACGroup.ptrGroup) | |
37 | return; | |
7fd59977 | 38 | |
2166f0fa | 39 | const Aspect_TypeOfMarker AType = Aspect_TypeOfMarker (ACGroup.ContextMarker.MarkerType); |
7fd59977 | 40 | |
2166f0fa | 41 | switch (AType) |
7fd59977 | 42 | { |
2166f0fa SK |
43 | case Aspect_TOM_POINT : |
44 | case Aspect_TOM_PLUS : | |
45 | case Aspect_TOM_STAR : | |
46 | case Aspect_TOM_O : | |
47 | case Aspect_TOM_X : | |
48 | case Aspect_TOM_O_POINT : | |
49 | case Aspect_TOM_O_PLUS : | |
50 | case Aspect_TOM_O_STAR : | |
51 | case Aspect_TOM_O_X : | |
52 | case Aspect_TOM_RING1 : | |
53 | case Aspect_TOM_RING2 : | |
54 | case Aspect_TOM_RING3 : | |
55 | case Aspect_TOM_USERDEFINED: | |
56 | OpenGl_CreateMarkers(ACGroup, 1, &APoint); | |
57 | break; | |
7fd59977 | 58 | |
2166f0fa | 59 | case Aspect_TOM_BALL : |
7fd59977 | 60 | { |
2166f0fa | 61 | const Standard_Real Delta = 0.1; |
7fd59977 | 62 | |
2166f0fa SK |
63 | Standard_Real R, G, B, H, L, S, AScale; |
64 | R = Standard_Real (ACGroup.ContextMarker.Color.r); | |
65 | G = Standard_Real (ACGroup.ContextMarker.Color.g); | |
66 | B = Standard_Real (ACGroup.ContextMarker.Color.b); | |
67 | AScale = Standard_Real (ACGroup.ContextMarker.Scale); | |
7fd59977 | 68 | |
2166f0fa SK |
69 | // we draw a set of circles |
70 | CALL_DEF_CONTEXTMARKER AContext; | |
71 | AContext.MarkerType = int (Aspect_TOM_O); | |
72 | while (AScale >= 1.0) | |
73 | { | |
74 | Quantity_Color::RgbHls (R, G, B, H, L, S); | |
75 | // Modification de la saturation de 5 % | |
76 | S *= 0.95; | |
77 | Quantity_Color::HlsRgb (H, L, S, R, G, B); | |
78 | AContext.Color.r = float (R); | |
79 | AContext.Color.g = float (G); | |
80 | AContext.Color.b = float (B); | |
81 | AContext.Scale = float (AScale); | |
82 | ((OpenGl_Group *)ACGroup.ptrGroup)->SetAspectMarker(AContext, Standard_False); | |
83 | OpenGl_CreateMarkers(ACGroup, 1, &APoint); | |
84 | AScale -= Delta; | |
7fd59977 | 85 | } |
2166f0fa | 86 | break; |
7fd59977 | 87 | } |
2166f0fa SK |
88 | default: |
89 | break; | |
7fd59977 | 90 | } |
7fd59977 | 91 | } |
92 | ||
93 | void OpenGl_GraphicDriver::MarkerSet (const Graphic3d_CGroup& ACGroup, | |
2166f0fa SK |
94 | const Graphic3d_Array1OfVertex& ListVertex, |
95 | const Standard_Boolean ) | |
7fd59977 | 96 | { |
2166f0fa SK |
97 | if (!ACGroup.ptrGroup) |
98 | return; | |
7fd59977 | 99 | |
2166f0fa SK |
100 | const Standard_Integer nb = ListVertex.Length(); |
101 | const Graphic3d_Vertex *arr = &ListVertex( ListVertex.Lower() ); | |
7fd59977 | 102 | |
2166f0fa | 103 | const Aspect_TypeOfMarker AType = Aspect_TypeOfMarker (ACGroup.ContextMarker.MarkerType); |
7fd59977 | 104 | |
2166f0fa SK |
105 | switch (AType) |
106 | { | |
7fd59977 | 107 | case Aspect_TOM_POINT : |
108 | case Aspect_TOM_PLUS : | |
109 | case Aspect_TOM_STAR : | |
110 | case Aspect_TOM_O : | |
111 | case Aspect_TOM_X : | |
7fd59977 | 112 | case Aspect_TOM_O_POINT : |
7fd59977 | 113 | case Aspect_TOM_O_PLUS : |
7fd59977 | 114 | case Aspect_TOM_O_STAR : |
7fd59977 | 115 | case Aspect_TOM_O_X : |
2166f0fa SK |
116 | case Aspect_TOM_RING1 : |
117 | case Aspect_TOM_RING2 : | |
118 | case Aspect_TOM_RING3 : | |
119 | case Aspect_TOM_USERDEFINED: | |
120 | OpenGl_CreateMarkers(ACGroup, nb, arr); | |
7fd59977 | 121 | break; |
122 | ||
123 | case Aspect_TOM_BALL : | |
2166f0fa SK |
124 | { |
125 | const Standard_Real Delta = 0.1; | |
126 | ||
127 | Standard_Real R, G, B, H, L, S, AScale; | |
128 | R = Standard_Real (ACGroup.ContextMarker.Color.r); | |
129 | G = Standard_Real (ACGroup.ContextMarker.Color.g); | |
130 | B = Standard_Real (ACGroup.ContextMarker.Color.b); | |
131 | AScale = Standard_Real (ACGroup.ContextMarker.Scale); | |
7fd59977 | 132 | |
133 | // we draw a set of circles | |
2166f0fa SK |
134 | CALL_DEF_CONTEXTMARKER AContext; |
135 | AContext.MarkerType = int (Aspect_TOM_O); | |
136 | while (AScale >= 1.0) | |
137 | { | |
7fd59977 | 138 | Quantity_Color::RgbHls (R, G, B, H, L, S); |
139 | // Modification de la saturation de 5 % | |
2166f0fa | 140 | S *= 0.95; |
7fd59977 | 141 | Quantity_Color::HlsRgb (H, L, S, R, G, B); |
2166f0fa SK |
142 | AContext.Color.r = float (R); |
143 | AContext.Color.g = float (G); | |
144 | AContext.Color.b = float (B); | |
145 | AContext.Scale = float (AScale); | |
146 | ((OpenGl_Group *)ACGroup.ptrGroup)->SetAspectMarker(AContext, Standard_False); | |
147 | OpenGl_CreateMarkers(ACGroup, nb, arr); | |
148 | AScale -= Delta; | |
7fd59977 | 149 | } |
150 | break; | |
2166f0fa | 151 | } |
7fd59977 | 152 | default: |
153 | break; | |
154 | } | |
7fd59977 | 155 | } |