1 // Created on: 2011-07-13
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_GlCore11.hxx>
22 #include <OpenGl_Context.hxx>
24 #include <OpenGl_Marker.hxx>
26 #include <OpenGl_AspectMarker.hxx>
27 #include <OpenGl_Structure.hxx>
28 #include <OpenGl_Display.hxx>
30 /*----------------------------------------------------------------------*/
32 void OpenGl_Marker::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
34 const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker( Standard_True );
36 // Use highlight colours
37 glColor3fv( (AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)? AWorkspace->HighlightColor->rgb : aspect_marker->Color().rgb );
39 switch ( aspect_marker->Type() )
41 case Aspect_TOM_O_POINT :
43 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, aspect_marker->Scale() );
44 glRasterPos3fv( myPoint.xyz );
45 AWorkspace->GetDisplay()->SetBaseForMarker();
46 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
48 case Aspect_TOM_POINT :
50 glPointSize( aspect_marker->Scale() );
52 glVertex3fv( myPoint.xyz );
58 glRasterPos3fv( myPoint.xyz );
59 switch ( aspect_marker->Type() )
61 case Aspect_TOM_RING1 :
62 case Aspect_TOM_RING2 :
63 case Aspect_TOM_RING3 :
65 const float ADelta = 0.1f;
66 float AScale = aspect_marker->Scale();
68 if (aspect_marker->Type() == Aspect_TOM_RING1)
69 ALimit = AScale * 0.2f;
70 else if (aspect_marker->Type() == Aspect_TOM_RING2)
71 ALimit = AScale * 0.5f;
73 ALimit = AScale * 0.8f;
74 AWorkspace->GetDisplay()->SetBaseForMarker();
75 while (AScale > ALimit && AScale >= 1.f)
77 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, AScale );
78 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
83 case Aspect_TOM_USERDEFINED :
85 glCallList( openglDisplay->GetUserMarkerListIndex( (int)aspect_marker->Scale() ) );
90 AWorkspace->GetDisplay()->SetBaseForMarker();
91 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( aspect_marker->Type(), aspect_marker->Scale() );
92 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *)str );
96 if (AWorkspace->GetGlContext()->IsFeedback())
99 glVertex3fv( myPoint.xyz );
101 /* it is necessary to indicate end of marker information*/
107 /*----------------------------------------------------------------------*/