0023652: Non zoomable text with alignment slides away when zooming view
[occt.git] / src / OpenGl / OpenGl_Marker.cxx
CommitLineData
b311480e 1// Created on: 2011-07-13
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
2166f0fa 20
5f8b738e 21#include <OpenGl_GlCore11.hxx>
664cae74 22#include <OpenGl_Context.hxx>
2166f0fa 23
5f8b738e 24#include <OpenGl_Marker.hxx>
2166f0fa
SK
25
26#include <OpenGl_AspectMarker.hxx>
27#include <OpenGl_Structure.hxx>
28#include <OpenGl_Display.hxx>
bf75be98 29#include <OpenGl_Workspace.hxx>
2166f0fa
SK
30
31/*----------------------------------------------------------------------*/
32
5e27df78 33void OpenGl_Marker::Release (const Handle(OpenGl_Context)& theContext)
34{
35 //
36}
37
2166f0fa
SK
38void OpenGl_Marker::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
39{
40 const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker( Standard_True );
41
42 // Use highlight colours
43 glColor3fv( (AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)? AWorkspace->HighlightColor->rgb : aspect_marker->Color().rgb );
44
45 switch ( aspect_marker->Type() )
46 {
47 case Aspect_TOM_O_POINT :
48 {
49 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, aspect_marker->Scale() );
50 glRasterPos3fv( myPoint.xyz );
51 AWorkspace->GetDisplay()->SetBaseForMarker();
52 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
53 }
54 case Aspect_TOM_POINT :
55 {
2166f0fa
SK
56 glBegin( GL_POINTS );
57 glVertex3fv( myPoint.xyz );
58 glEnd();
59 break;
60 }
61 default:
62 {
63 glRasterPos3fv( myPoint.xyz );
64 switch ( aspect_marker->Type() )
65 {
66 case Aspect_TOM_RING1 :
67 case Aspect_TOM_RING2 :
68 case Aspect_TOM_RING3 :
69 {
70 const float ADelta = 0.1f;
71 float AScale = aspect_marker->Scale();
72 float ALimit = 0.f;
73 if (aspect_marker->Type() == Aspect_TOM_RING1)
74 ALimit = AScale * 0.2f;
75 else if (aspect_marker->Type() == Aspect_TOM_RING2)
76 ALimit = AScale * 0.5f;
77 else
78 ALimit = AScale * 0.8f;
79 AWorkspace->GetDisplay()->SetBaseForMarker();
80 while (AScale > ALimit && AScale >= 1.f)
81 {
82 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, AScale );
83 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
84 AScale -= ADelta;
85 }
86 break;
87 }
88 case Aspect_TOM_USERDEFINED :
bf75be98 89 {
2166f0fa
SK
90 glCallList( openglDisplay->GetUserMarkerListIndex( (int)aspect_marker->Scale() ) );
91 break;
92 }
93 default :
94 {
95 AWorkspace->GetDisplay()->SetBaseForMarker();
96 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( aspect_marker->Type(), aspect_marker->Scale() );
97 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *)str );
98 }
99 }
664cae74 100
101 if (AWorkspace->GetGlContext()->IsFeedback())
2166f0fa
SK
102 {
103 glBegin( GL_POINTS );
104 glVertex3fv( myPoint.xyz );
105 glEnd();
106 /* it is necessary to indicate end of marker information*/
107 }
108 }
109 }
110}
111
112/*----------------------------------------------------------------------*/