1 // Created on: 2011-10-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
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.
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.
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.
21 #include <OpenGl_GraphicDriver.hxx>
23 #include <Aspect_TypeOfMarker.hxx>
24 #include <OpenGl_Group.hxx>
25 #include <OpenGl_MarkerSet.hxx>
26 #include <Graphic3d_Array1OfVertex.hxx>
28 static void OpenGl_CreateMarkers(const Graphic3d_CGroup& ACGroup, const Standard_Integer NbPoints, const Graphic3d_Vertex *Points)
30 OpenGl_MarkerSet *amarkerset = new OpenGl_MarkerSet( NbPoints, Points );
31 ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelMarkerSet, amarkerset );
34 void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean )
36 if (!ACGroup.ptrGroup)
39 const Aspect_TypeOfMarker AType = Aspect_TypeOfMarker (ACGroup.ContextMarker.MarkerType);
43 case Aspect_TOM_POINT :
44 case Aspect_TOM_PLUS :
45 case Aspect_TOM_STAR :
48 case Aspect_TOM_O_POINT :
49 case Aspect_TOM_O_PLUS :
50 case Aspect_TOM_O_STAR :
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);
59 case Aspect_TOM_BALL :
61 const Standard_Real Delta = 0.1;
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);
69 // we draw a set of circles
70 CALL_DEF_CONTEXTMARKER AContext;
71 AContext.MarkerType = int (Aspect_TOM_O);
74 Quantity_Color::RgbHls (R, G, B, H, L, S);
75 // Modification de la saturation de 5 %
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);
93 void OpenGl_GraphicDriver::MarkerSet (const Graphic3d_CGroup& ACGroup,
94 const Graphic3d_Array1OfVertex& ListVertex,
95 const Standard_Boolean )
97 if (!ACGroup.ptrGroup)
100 const Standard_Integer nb = ListVertex.Length();
101 const Graphic3d_Vertex *arr = &ListVertex( ListVertex.Lower() );
103 const Aspect_TypeOfMarker AType = Aspect_TypeOfMarker (ACGroup.ContextMarker.MarkerType);
107 case Aspect_TOM_POINT :
108 case Aspect_TOM_PLUS :
109 case Aspect_TOM_STAR :
112 case Aspect_TOM_O_POINT :
113 case Aspect_TOM_O_PLUS :
114 case Aspect_TOM_O_STAR :
115 case Aspect_TOM_O_X :
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);
123 case Aspect_TOM_BALL :
125 const Standard_Real Delta = 0.1;
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);
133 // we draw a set of circles
134 CALL_DEF_CONTEXTMARKER AContext;
135 AContext.MarkerType = int (Aspect_TOM_O);
136 while (AScale >= 1.0)
138 Quantity_Color::RgbHls (R, G, B, H, L, S);
139 // Modification de la saturation de 5 %
141 Quantity_Color::HlsRgb (H, L, S, R, G, B);
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);