Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-09-20 |
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> |
22 | ||
2166f0fa SK |
23 | #include <InterfaceGraphic.hxx> |
24 | ||
25 | #include <OpenGl_Workspace.hxx> | |
26 | ||
27 | #include <OpenGl_AspectLine.hxx> | |
28 | #include <OpenGl_AspectFace.hxx> | |
29 | #include <OpenGl_AspectMarker.hxx> | |
30 | #include <OpenGl_AspectText.hxx> | |
31 | ||
2166f0fa SK |
32 | #include <OpenGl_TextureBox.hxx> |
33 | ||
34 | IMPLEMENT_STANDARD_HANDLE(OpenGl_Workspace,OpenGl_Window) | |
35 | IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,OpenGl_Window) | |
36 | ||
37 | namespace | |
38 | { | |
39 | static const TEL_COLOUR myDefaultHighlightColor = { { 1.F, 1.F, 1.F, 1.F } }; | |
40 | ||
41 | static const OpenGl_AspectLine myDefaultAspectLine; | |
42 | static const OpenGl_AspectFace myDefaultAspectFace; | |
43 | static const OpenGl_AspectMarker myDefaultAspectMarker; | |
44 | static const OpenGl_AspectText myDefaultAspectText; | |
45 | ||
46 | static const OpenGl_TextParam myDefaultTextParam = | |
47 | { | |
48 | 16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM | |
49 | }; | |
50 | ||
51 | static const OpenGl_Matrix myDefaultMatrix = | |
52 | { | |
53 | {{ 1.0F, 0.0F, 0.0F, 0.0F }, | |
54 | { 0.0F, 1.0F, 0.0F, 0.0F }, | |
55 | { 0.0F, 0.0F, 1.0F, 0.0F }, | |
56 | { 0.0F, 0.0F, 0.0F, 1.0F }} | |
57 | }; | |
58 | }; | |
59 | ||
60 | // ======================================================================= | |
61 | // function : OpenGl_Workspace | |
62 | // purpose : | |
63 | // ======================================================================= | |
64 | OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, | |
65 | const CALL_DEF_WINDOW& theCWindow, | |
5e27df78 | 66 | Aspect_RenderingContext theGContext, |
67 | const Handle(OpenGl_Context)& theShareCtx) | |
68 | : OpenGl_Window (theDisplay, theCWindow, theGContext, theShareCtx), | |
2166f0fa SK |
69 | myTransientList (0), |
70 | myIsTransientOpen (Standard_False), | |
71 | myRetainMode (Standard_False), | |
72 | myUseTransparency (Standard_False), | |
73 | myUseZBuffer (Standard_False), | |
74 | myUseDepthTest (Standard_True), | |
75 | myUseGLLight (Standard_True), | |
76 | myBackBufferRestored (Standard_False), | |
77 | // | |
78 | NamedStatus (0), | |
79 | DegenerateModel (0), | |
80 | SkipRatio (0.F), | |
81 | HighlightColor (&myDefaultHighlightColor), | |
82 | AspectLine_set (&myDefaultAspectLine), | |
83 | AspectLine_applied (NULL), | |
84 | AspectFace_set (&myDefaultAspectFace), | |
85 | AspectFace_applied (NULL), | |
86 | AspectMarker_set (&myDefaultAspectMarker), | |
87 | AspectMarker_applied (NULL), | |
88 | AspectText_set (&myDefaultAspectText), | |
89 | AspectText_applied (NULL), | |
90 | TextParam_set (&myDefaultTextParam), | |
91 | TextParam_applied (NULL), | |
92 | ViewMatrix_applied (&myDefaultMatrix), | |
93 | StructureMatrix_applied (&myDefaultMatrix), | |
94 | PolygonOffset_applied (NULL) | |
95 | { | |
96 | theDisplay->InitAttributes(); | |
97 | ||
98 | // General initialization of the context | |
99 | ||
100 | // Eviter d'avoir les faces mal orientees en noir. | |
101 | // Pourrait etre utiliser pour detecter les problemes d'orientation | |
102 | glLightModeli ((GLenum )GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); | |
103 | ||
104 | // Optimisation pour le Fog et l'antialiasing | |
105 | glHint (GL_FOG_HINT, GL_FASTEST); | |
106 | glHint (GL_POINT_SMOOTH_HINT, GL_FASTEST); | |
107 | glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); | |
108 | glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST); | |
109 | ||
110 | // Polygon Offset | |
111 | EnablePolygonOffset(); | |
112 | } | |
113 | ||
114 | // ======================================================================= | |
115 | // function : ~OpenGl_Workspace | |
116 | // purpose : | |
117 | // ======================================================================= | |
118 | OpenGl_Workspace::~OpenGl_Workspace() | |
119 | { | |
120 | } | |
121 | ||
122 | // ======================================================================= | |
123 | // function : Activate | |
124 | // purpose : | |
125 | // ======================================================================= | |
126 | Standard_Boolean OpenGl_Workspace::Activate() | |
127 | { | |
128 | if (!OpenGl_Window::Activate()) | |
129 | return Standard_False; | |
130 | ||
2166f0fa SK |
131 | DegenerateModel = 0; |
132 | SkipRatio = 0.0f; | |
2166f0fa SK |
133 | ViewMatrix_applied = &myDefaultMatrix; |
134 | StructureMatrix_applied = &myDefaultMatrix; | |
26395493 | 135 | |
136 | ResetAppliedAspect(); | |
137 | ||
138 | return Standard_True; | |
2166f0fa SK |
139 | } |
140 | ||
141 | // ======================================================================= | |
142 | // function : UseTransparency | |
143 | // purpose : call_togl_transparency | |
144 | // ======================================================================= | |
145 | void OpenGl_Workspace::UseTransparency (const Standard_Boolean theFlag) | |
146 | { | |
147 | if ((myUseTransparency ? 1 : 0) != (theFlag ? 1 : 0)) | |
148 | { | |
149 | myUseTransparency = theFlag; | |
150 | EraseAnimation(); | |
2166f0fa SK |
151 | } |
152 | } | |
26395493 | 153 | |
154 | //======================================================================= | |
155 | //function : ResetAppliedAspect | |
156 | //purpose : Sets default values of GL parameters in accordance with default aspects | |
157 | //======================================================================= | |
158 | void OpenGl_Workspace::ResetAppliedAspect() | |
159 | { | |
160 | NamedStatus = IsTextureEnabled() ? OPENGL_NS_TEXTURE : 0; | |
161 | HighlightColor = &myDefaultHighlightColor; | |
162 | AspectLine_set = &myDefaultAspectLine; | |
163 | AspectLine_applied = NULL; | |
164 | AspectFace_set = &myDefaultAspectFace; | |
165 | AspectFace_applied = NULL; | |
166 | AspectMarker_set = &myDefaultAspectMarker; | |
167 | AspectMarker_applied = NULL; | |
168 | AspectText_set = &myDefaultAspectText; | |
169 | AspectText_applied = NULL; | |
170 | TextParam_set = &myDefaultTextParam; | |
171 | TextParam_applied = NULL; | |
172 | PolygonOffset_applied = NULL; | |
173 | ||
174 | AspectLine(Standard_True); | |
175 | AspectFace(Standard_True); | |
176 | AspectMarker(Standard_True); | |
177 | AspectText(Standard_True); | |
178 | } |