0023000: Improve the way the gradient and textured background is managed in 3d viewer
[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>
2166f0fa 22
5f8b738e 23#include <OpenGl_Marker.hxx>
2166f0fa
SK
24
25#include <OpenGl_AspectMarker.hxx>
26#include <OpenGl_Structure.hxx>
27#include <OpenGl_Display.hxx>
28
29/*----------------------------------------------------------------------*/
30
31void OpenGl_Marker::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
32{
33 const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker( Standard_True );
34
35 // Use highlight colours
36 glColor3fv( (AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)? AWorkspace->HighlightColor->rgb : aspect_marker->Color().rgb );
37
38 switch ( aspect_marker->Type() )
39 {
40 case Aspect_TOM_O_POINT :
41 {
42 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, aspect_marker->Scale() );
43 glRasterPos3fv( myPoint.xyz );
44 AWorkspace->GetDisplay()->SetBaseForMarker();
45 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
46 }
47 case Aspect_TOM_POINT :
48 {
49 glPointSize( aspect_marker->Scale() );
50 glBegin( GL_POINTS );
51 glVertex3fv( myPoint.xyz );
52 glEnd();
53 break;
54 }
55 default:
56 {
57 glRasterPos3fv( myPoint.xyz );
58 switch ( aspect_marker->Type() )
59 {
60 case Aspect_TOM_RING1 :
61 case Aspect_TOM_RING2 :
62 case Aspect_TOM_RING3 :
63 {
64 const float ADelta = 0.1f;
65 float AScale = aspect_marker->Scale();
66 float ALimit = 0.f;
67 if (aspect_marker->Type() == Aspect_TOM_RING1)
68 ALimit = AScale * 0.2f;
69 else if (aspect_marker->Type() == Aspect_TOM_RING2)
70 ALimit = AScale * 0.5f;
71 else
72 ALimit = AScale * 0.8f;
73 AWorkspace->GetDisplay()->SetBaseForMarker();
74 while (AScale > ALimit && AScale >= 1.f)
75 {
76 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, AScale );
77 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
78 AScale -= ADelta;
79 }
80 break;
81 }
82 case Aspect_TOM_USERDEFINED :
83 {
84 glCallList( openglDisplay->GetUserMarkerListIndex( (int)aspect_marker->Scale() ) );
85 break;
86 }
87 default :
88 {
89 AWorkspace->GetDisplay()->SetBaseForMarker();
90 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( aspect_marker->Type(), aspect_marker->Scale() );
91 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *)str );
92 }
93 }
94 GLint mode;
95 glGetIntegerv( GL_RENDER_MODE, &mode );
96 if( mode==GL_FEEDBACK )
97 {
98 glBegin( GL_POINTS );
99 glVertex3fv( myPoint.xyz );
100 glEnd();
101 /* it is necessary to indicate end of marker information*/
102 }
103 }
104 }
105}
106
107/*----------------------------------------------------------------------*/