Commit | Line | Data |
---|---|---|
2166f0fa SK |
1 | // File: OpenGl_Marker.cxx |
2 | // Created: 13 July 2011 | |
3 | // Author: Sergey ZERCHANINOV | |
4 | // Copyright: OPEN CASCADE 2011 | |
5 | ||
6 | #include <OpenGl_Marker.hxx> | |
7 | ||
8 | #include <OpenGl_tgl_all.hxx> | |
9 | #include <GL/gl.h> | |
10 | ||
11 | #include <OpenGl_AspectMarker.hxx> | |
12 | #include <OpenGl_Structure.hxx> | |
13 | #include <OpenGl_Display.hxx> | |
14 | ||
15 | /*----------------------------------------------------------------------*/ | |
16 | ||
17 | void OpenGl_Marker::Render (const Handle(OpenGl_Workspace) &AWorkspace) const | |
18 | { | |
19 | const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker( Standard_True ); | |
20 | ||
21 | // Use highlight colours | |
22 | glColor3fv( (AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)? AWorkspace->HighlightColor->rgb : aspect_marker->Color().rgb ); | |
23 | ||
24 | switch ( aspect_marker->Type() ) | |
25 | { | |
26 | case Aspect_TOM_O_POINT : | |
27 | { | |
28 | const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, aspect_marker->Scale() ); | |
29 | glRasterPos3fv( myPoint.xyz ); | |
30 | AWorkspace->GetDisplay()->SetBaseForMarker(); | |
31 | glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str ); | |
32 | } | |
33 | case Aspect_TOM_POINT : | |
34 | { | |
35 | glPointSize( aspect_marker->Scale() ); | |
36 | glBegin( GL_POINTS ); | |
37 | glVertex3fv( myPoint.xyz ); | |
38 | glEnd(); | |
39 | break; | |
40 | } | |
41 | default: | |
42 | { | |
43 | glRasterPos3fv( myPoint.xyz ); | |
44 | switch ( aspect_marker->Type() ) | |
45 | { | |
46 | case Aspect_TOM_RING1 : | |
47 | case Aspect_TOM_RING2 : | |
48 | case Aspect_TOM_RING3 : | |
49 | { | |
50 | const float ADelta = 0.1f; | |
51 | float AScale = aspect_marker->Scale(); | |
52 | float ALimit = 0.f; | |
53 | if (aspect_marker->Type() == Aspect_TOM_RING1) | |
54 | ALimit = AScale * 0.2f; | |
55 | else if (aspect_marker->Type() == Aspect_TOM_RING2) | |
56 | ALimit = AScale * 0.5f; | |
57 | else | |
58 | ALimit = AScale * 0.8f; | |
59 | AWorkspace->GetDisplay()->SetBaseForMarker(); | |
60 | while (AScale > ALimit && AScale >= 1.f) | |
61 | { | |
62 | const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, AScale ); | |
63 | glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str ); | |
64 | AScale -= ADelta; | |
65 | } | |
66 | break; | |
67 | } | |
68 | case Aspect_TOM_USERDEFINED : | |
69 | { | |
70 | glCallList( openglDisplay->GetUserMarkerListIndex( (int)aspect_marker->Scale() ) ); | |
71 | break; | |
72 | } | |
73 | default : | |
74 | { | |
75 | AWorkspace->GetDisplay()->SetBaseForMarker(); | |
76 | const char *str = AWorkspace->GetDisplay()->GetStringForMarker( aspect_marker->Type(), aspect_marker->Scale() ); | |
77 | glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *)str ); | |
78 | } | |
79 | } | |
80 | GLint mode; | |
81 | glGetIntegerv( GL_RENDER_MODE, &mode ); | |
82 | if( mode==GL_FEEDBACK ) | |
83 | { | |
84 | glBegin( GL_POINTS ); | |
85 | glVertex3fv( myPoint.xyz ); | |
86 | glEnd(); | |
87 | /* it is necessary to indicate end of marker information*/ | |
88 | } | |
89 | } | |
90 | } | |
91 | } | |
92 | ||
93 | /*----------------------------------------------------------------------*/ |