1 // Created on: 2011-09-20
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.
24 #include <NCollection_Mat4.hxx>
26 #include <OpenGl_Context.hxx>
27 #include <OpenGl_Display.hxx>
28 #include <OpenGl_GlCore11.hxx>
29 #include <OpenGl_GraduatedTrihedron.hxx>
30 #include <OpenGl_GraphicDriver.hxx>
31 #include <OpenGl_ShaderManager.hxx>
32 #include <OpenGl_Texture.hxx>
33 #include <OpenGl_Trihedron.hxx>
34 #include <OpenGl_transform_persistence.hxx>
35 #include <OpenGl_View.hxx>
36 #include <OpenGl_Workspace.hxx>
38 #include <Graphic3d_TextureEnv.hxx>
40 IMPLEMENT_STANDARD_HANDLE(OpenGl_View,MMgt_TShared)
41 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_View,MMgt_TShared)
43 /*----------------------------------------------------------------------*/
45 static const OPENGL_BG_TEXTURE myDefaultBgTexture = { 0, 0, 0, Aspect_FM_CENTERED };
46 static const OPENGL_BG_GRADIENT myDefaultBgGradient = { {{ 0.F, 0.F, 0.F, 1.F }}, {{ 0.F, 0.F, 0.F, 1.F }}, Aspect_GFM_NONE };
47 static const Tmatrix3 myDefaultMatrix = { { 1.F, 0.F, 0.F, 0.F }, { 0.F, 1.F, 0.F, 0.F }, { 0.F, 0.F, 1.F, 0.F }, { 0.F, 0.F, 0.F, 1.F } };
48 static const OPENGL_ZCLIP myDefaultZClip = { { Standard_True, 0.F }, { Standard_True, 1.F } };
49 static const OPENGL_EXTRA_REP myDefaultExtra =
60 { 0.F, 0.F, 1.F, 1.F },
62 { 0.F, 0.F, 0.F, 1.F, 1.F, 1.F },
78 static const OPENGL_FOG myDefaultFog = { Standard_False, 0.F, 1.F, { { 0.F, 0.F, 0.F, 1.F } } };
79 static const TEL_TRANSFORM_PERSISTENCE myDefaultTransPers = { 0, 0.F, 0.F, 0.F };
80 static const GLdouble THE_IDENTITY_MATRIX[4][4] =
88 /*----------------------------------------------------------------------*/
90 OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext,
91 OpenGl_StateCounter* theCounter)
92 : mySurfaceDetail(Visual3d_TOD_NONE),
94 myBgTexture(myDefaultBgTexture),
95 myBgGradient(myDefaultBgGradient),
96 //myOrientationMatrix(myDefaultMatrix),
97 //myMappingMatrix(myDefaultMatrix),
98 //shield_indicator = TOn,
99 //shield_colour = { { 0.F, 0.F, 0.F, 1.F } },
100 //border_indicator = TOff,
101 //border_colour = { { 0.F, 0.F, 0.F, 1.F } },
102 //active_status = TOn,
103 myZClip(myDefaultZClip),
104 myExtra(myDefaultExtra),
107 myGraduatedTrihedron(NULL),
108 myVisualization(AContext.Visualization),
109 myIntShadingMethod(TEL_SM_GOURAUD),
110 myAntiAliasing(Standard_False),
111 myTransPers(&myDefaultTransPers),
112 myIsTransPers(Standard_False),
113 myStateCounter (theCounter),
114 myLastOrientationState (0, 0),
115 myLastViewMappingState (0, 0),
116 myLastLightSourceState (0, 0)
118 // Initialize matrices
119 memcpy(myOrientationMatrix,myDefaultMatrix,sizeof(Tmatrix3));
120 memcpy(myMappingMatrix,myDefaultMatrix,sizeof(Tmatrix3));
123 switch (AContext.Model)
125 case 1 : /* VISUAL3D_TOM_INTERP_COLOR */
126 case 3 : /* VISUAL3D_TOM_VERTEX */
127 myIntShadingMethod = TEL_SM_GOURAUD;
130 myIntShadingMethod = TEL_SM_FLAT;
134 myCurrOrientationState = myStateCounter->Increment(); // <-- delete after merge with camera
135 myCurrViewMappingState = myStateCounter->Increment(); // <-- delete after merge with camera
136 myCurrLightSourceState = myStateCounter->Increment();
139 myModificationState = 1; // initial state
143 /*----------------------------------------------------------------------*/
145 OpenGl_View::~OpenGl_View ()
147 ReleaseGlResources (NULL); // ensure ReleaseGlResources() was called within valid context
150 void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
152 OpenGl_Element::Destroy (theCtx, myTrihedron);
153 OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
155 if (!myTextureEnv.IsNull())
157 theCtx->DelayedRelease (myTextureEnv);
158 myTextureEnv.Nullify();
160 if (myBgTexture.TexId != 0)
162 glDeleteTextures (1, (GLuint*)&(myBgTexture.TexId));
163 myBgTexture.TexId = 0;
167 void OpenGl_View::SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
168 const Handle(Graphic3d_TextureEnv)& theTexture)
170 if (!myTextureEnv.IsNull())
172 theCtx->DelayedRelease (myTextureEnv);
173 myTextureEnv.Nullify();
176 if (theTexture.IsNull())
181 myTextureEnv = new OpenGl_Texture (theTexture->GetParams());
182 Handle(Image_PixMap) anImage = theTexture->GetImage();
183 if (!anImage.IsNull())
184 myTextureEnv->Init (theCtx, *anImage.operator->(), theTexture->Type());
187 myModificationState++;
191 void OpenGl_View::SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail theMode)
193 mySurfaceDetail = theMode;
196 myModificationState++;
200 /*----------------------------------------------------------------------*/
202 void OpenGl_View::SetBackfacing (const Standard_Integer theMode)
204 myBackfacing = theMode;
207 /*----------------------------------------------------------------------*/
210 void OpenGl_View::SetLights (const CALL_DEF_VIEWCONTEXT &AContext)
214 const int nb_lights = AContext.NbActiveLight;
217 const CALL_DEF_LIGHT *alight = &(AContext.ActiveLight[0]);
218 for ( ; i < nb_lights; i++, alight++ )
221 memset(&rep,0,sizeof(rep));
223 switch( alight->LightType )
225 case 0 : /* TOLS_AMBIENT */
226 rep.type = TLightAmbient;
227 rep.col.rgb[0] = alight->Color.r;
228 rep.col.rgb[1] = alight->Color.g;
229 rep.col.rgb[2] = alight->Color.b;
232 case 1 : /* TOLS_DIRECTIONAL */
233 rep.type = TLightDirectional;
234 rep.col.rgb[0] = alight->Color.r;
235 rep.col.rgb[1] = alight->Color.g;
236 rep.col.rgb[2] = alight->Color.b;
237 rep.dir[0] = alight->Direction.x;
238 rep.dir[1] = alight->Direction.y;
239 rep.dir[2] = alight->Direction.z;
242 case 2 : /* TOLS_POSITIONAL */
243 rep.type = TLightPositional;
244 rep.col.rgb[0] = alight->Color.r;
245 rep.col.rgb[1] = alight->Color.g;
246 rep.col.rgb[2] = alight->Color.b;
247 rep.pos[0] = alight->Position.x;
248 rep.pos[1] = alight->Position.y;
249 rep.pos[2] = alight->Position.z;
250 rep.atten[0] = alight->Attenuation[0];
251 rep.atten[1] = alight->Attenuation[1];
254 case 3 : /* TOLS_SPOT */
255 rep.type = TLightSpot;
256 rep.col.rgb[0] = alight->Color.r;
257 rep.col.rgb[1] = alight->Color.g;
258 rep.col.rgb[2] = alight->Color.b;
259 rep.pos[0] = alight->Position.x;
260 rep.pos[1] = alight->Position.y;
261 rep.pos[2] = alight->Position.z;
262 rep.dir[0] = alight->Direction.x;
263 rep.dir[1] = alight->Direction.y;
264 rep.dir[2] = alight->Direction.z;
265 rep.shine = alight->Concentration;
266 rep.atten[0] = alight->Attenuation[0];
267 rep.atten[1] = alight->Attenuation[1];
268 rep.angle = alight->Angle;
272 rep.HeadLight = alight->Headlight;
274 myLights.Append(rep);
277 myCurrLightSourceState = myStateCounter->Increment();
280 /*----------------------------------------------------------------------*/
282 //call_togl_setvisualisation
283 void OpenGl_View::SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext)
285 myVisualization = AContext.Visualization;
287 switch (AContext.Model)
289 case 1 : /* VISUAL3D_TOM_INTERP_COLOR */
290 case 3 : /* VISUAL3D_TOM_VERTEX */
291 myIntShadingMethod = TEL_SM_GOURAUD;
294 myIntShadingMethod = TEL_SM_FLAT;
299 /*----------------------------------------------------------------------*/
301 //call_togl_cliplimit
302 void OpenGl_View::SetClipLimit (const Graphic3d_CView& theCView)
305 (theCView.Context.ZClipBackPlane - theCView.Mapping.BackPlaneDistance) /
306 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
307 myZClip.Front.Limit =
308 (theCView.Context.ZClipFrontPlane - theCView.Mapping.BackPlaneDistance) /
309 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
310 if (myZClip.Back.Limit < 0.0f)
311 myZClip.Back.Limit = 0.0f;
312 if (myZClip.Front.Limit > 1.0f)
313 myZClip.Front.Limit = 1.0f;
314 if (myZClip.Back.Limit > myZClip.Front.Limit)
316 myZClip.Back.Limit = 0.0f;
317 myZClip.Front.Limit = 1.0f;
320 myZClip.Back.IsOn = (theCView.Context.BackZClipping != 0);
321 myZClip.Front.IsOn = (theCView.Context.FrontZClipping != 0);
324 /*----------------------------------------------------------------------*/
326 //call_togl_viewmapping
327 void OpenGl_View::SetMapping (const Handle(OpenGl_Display)& theGlDisplay,
328 const Graphic3d_CView& theCView)
330 const float ratio = theCView.DefWindow.dy / theCView.DefWindow.dx;
331 const float r_ratio = theCView.DefWindow.dx / theCView.DefWindow.dy;
333 TEL_VIEW_MAPPING Map;
335 Map.window.xmin = theCView.Mapping.WindowLimit.um;
336 Map.window.ymin = theCView.Mapping.WindowLimit.vm;
337 Map.window.xmax = theCView.Mapping.WindowLimit.uM;
338 Map.window.ymax = theCView.Mapping.WindowLimit.vM;
340 Map.viewport.xmin = 0.F;
341 Map.viewport.xmax = ( 1.F < r_ratio ? 1.F : r_ratio );
342 Map.viewport.ymin = 0.F;
343 Map.viewport.ymax = ( 1.F < ratio ? 1.F : ratio );
344 Map.viewport.zmin = 0.F;
345 Map.viewport.zmax = 1.F;
348 switch (theCView.Mapping.Projection)
351 Map.proj = TelPerspective;
354 Map.proj = TelParallel;
358 // projection reference point
359 Map.prp[0] = theCView.Mapping.ProjectionReferencePoint.x;
360 Map.prp[1] = theCView.Mapping.ProjectionReferencePoint.y;
361 Map.prp[2] = theCView.Mapping.ProjectionReferencePoint.z;
362 if (!theGlDisplay.IsNull() && !theGlDisplay->Walkthrough())
363 Map.prp[2] += theCView.Mapping.FrontPlaneDistance;
365 // view plane distance
366 Map.vpd = theCView.Mapping.ViewPlaneDistance;
368 // back plane distance
369 Map.bpd = theCView.Mapping.BackPlaneDistance;
371 // front plane distance
372 Map.fpd = theCView.Mapping.FrontPlaneDistance;
376 // use user-defined matrix
377 if (theCView.Mapping.IsCustomMatrix)
380 for( i = 0; i < 4; i++ )
381 for( j = 0; j < 4; j++ )
382 myMappingMatrix[i][j] = theCView.Mapping.ProjectionMatrix[i][j];
385 TelEvalViewMappingMatrix (theGlDisplay, &Map, &err_ind, myMappingMatrix);
390 myCurrViewMappingState = myStateCounter->Increment();
393 /*----------------------------------------------------------------------*/
395 //call_togl_vieworientation
396 void OpenGl_View::SetOrientation (const Graphic3d_CView& theCView)
401 Tfloat ScaleFactors[3];
403 Vrp[0] = theCView.Orientation.ViewReferencePoint.x;
404 Vrp[1] = theCView.Orientation.ViewReferencePoint.y;
405 Vrp[2] = theCView.Orientation.ViewReferencePoint.z;
407 Vpn[0] = theCView.Orientation.ViewReferencePlane.x;
408 Vpn[1] = theCView.Orientation.ViewReferencePlane.y;
409 Vpn[2] = theCView.Orientation.ViewReferencePlane.z;
411 Vup[0] = theCView.Orientation.ViewReferenceUp.x;
412 Vup[1] = theCView.Orientation.ViewReferenceUp.y;
413 Vup[2] = theCView.Orientation.ViewReferenceUp.z;
415 ScaleFactors[0] = theCView.Orientation.ViewScaleX;
416 ScaleFactors[1] = theCView.Orientation.ViewScaleY;
417 ScaleFactors[2] = theCView.Orientation.ViewScaleZ;
421 // use user-defined matrix
422 if (theCView.Orientation.IsCustomMatrix)
425 for( i = 0; i < 4; i++ )
426 for( j = 0; j < 4; j++ )
427 myOrientationMatrix[i][j] = theCView.Orientation.ModelViewMatrix[i][j];
431 TelEvalViewOrientationMatrix (Vrp, Vpn, Vup, ScaleFactors, &err_ind, myOrientationMatrix);
436 myExtra.vrp[0] = Vrp[0];
437 myExtra.vrp[1] = Vrp[1];
438 myExtra.vrp[2] = Vrp[2];
440 myExtra.vpn[0] = Vpn[0];
441 myExtra.vpn[1] = Vpn[1];
442 myExtra.vpn[2] = Vpn[2];
444 myExtra.vup[0] = Vup[0];
445 myExtra.vup[1] = Vup[1];
446 myExtra.vup[2] = Vup[2];
448 myExtra.scaleFactors[0] = ScaleFactors[0],
449 myExtra.scaleFactors[1] = ScaleFactors[1],
450 myExtra.scaleFactors[2] = ScaleFactors[2];
453 myCurrOrientationState = myStateCounter->Increment();
456 /*----------------------------------------------------------------------*/
458 void OpenGl_View::SetFog (const Graphic3d_CView& theCView,
459 const Standard_Boolean theFlag)
463 myFog.IsOn = Standard_False;
467 myFog.IsOn = Standard_True;
470 (theCView.Context.DepthFrontPlane - theCView.Mapping.BackPlaneDistance) /
471 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
474 (theCView.Context.DepthBackPlane - theCView.Mapping.BackPlaneDistance) /
475 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
477 if (myFog.Front < 0.F)
479 else if (myFog.Front > 1.F)
482 if (myFog.Back < 0.F)
484 else if (myFog.Back > 1.F)
487 if (myFog.Back > myFog.Front)
493 myFog.Color.rgb[0] = theCView.DefWindow.Background.r;
494 myFog.Color.rgb[1] = theCView.DefWindow.Background.g;
495 myFog.Color.rgb[2] = theCView.DefWindow.Background.b;
496 myFog.Color.rgb[3] = 1.0f;
500 /*----------------------------------------------------------------------*/
502 void OpenGl_View::TriedronDisplay (const Handle(OpenGl_Context)& theCtx,
503 const Aspect_TypeOfTriedronPosition thePosition,
504 const Quantity_NameOfColor theColor,
505 const Standard_Real theScale,
506 const Standard_Boolean theAsWireframe)
508 OpenGl_Element::Destroy (theCtx, myTrihedron);
509 myTrihedron = new OpenGl_Trihedron (thePosition, theColor, theScale, theAsWireframe);
512 /*----------------------------------------------------------------------*/
514 void OpenGl_View::TriedronErase (const Handle(OpenGl_Context)& theCtx)
516 OpenGl_Element::Destroy (theCtx, myTrihedron);
519 /*----------------------------------------------------------------------*/
521 void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
522 const Graphic3d_CGraduatedTrihedron& theData)
524 OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
525 myGraduatedTrihedron = new OpenGl_GraduatedTrihedron (theData);
528 /*----------------------------------------------------------------------*/
530 void OpenGl_View::GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx)
532 OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
535 /*----------------------------------------------------------------------*/
537 //transform_persistence_end
538 void OpenGl_View::EndTransformPersistence(const Handle(OpenGl_Context)& theCtx)
543 glMatrixMode (GL_PROJECTION);
545 glMatrixMode (GL_MODELVIEW);
547 myIsTransPers = Standard_False;
549 // Note: the approach of accessing OpenGl matrices is used now since the matrix
550 // manipulation are made with help of OpenGl methods. This might be replaced by
551 // direct computation of matrices by OCC subroutines.
552 Tmatrix3 aResultWorldView;
553 glGetFloatv (GL_MODELVIEW_MATRIX, *aResultWorldView);
555 Tmatrix3 aResultProjection;
556 glGetFloatv (GL_PROJECTION_MATRIX, *aResultProjection);
558 // Set OCCT state uniform variables
559 theCtx->ShaderManager()->RevertWorldViewStateTo (aResultWorldView);
560 theCtx->ShaderManager()->RevertProjectionStateTo (aResultProjection);
564 /*----------------------------------------------------------------------*/
566 //transform_persistence_begin
567 const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const Handle(OpenGl_Context)& theCtx,
568 const TEL_TRANSFORM_PERSISTENCE* theTransPers)
570 const TEL_TRANSFORM_PERSISTENCE* aTransPersPrev = myTransPers;
571 myTransPers = theTransPers;
572 if (theTransPers->mode == 0)
574 EndTransformPersistence (theCtx);
575 return aTransPersPrev;
579 GLdouble aModelMatrix[4][4];
580 GLdouble aProjMatrix[4][4];
581 glGetIntegerv (GL_VIEWPORT, aViewport);
582 glGetDoublev (GL_MODELVIEW_MATRIX, (GLdouble* )aModelMatrix);
583 glGetDoublev (GL_PROJECTION_MATRIX, (GLdouble *)aProjMatrix);
584 const GLdouble aViewportW = (GLdouble )aViewport[2];
585 const GLdouble aViewportH = (GLdouble )aViewport[3];
589 // pop matrix stack - it will be overridden later
590 glMatrixMode (GL_PROJECTION);
592 glMatrixMode (GL_MODELVIEW);
597 myIsTransPers = Standard_True;
600 // push matrices into stack and reset them
601 glMatrixMode (GL_MODELVIEW);
605 glMatrixMode (GL_PROJECTION);
609 // get the window's (fixed) coordinates for theTransPers->point before matrixes modifications
610 GLdouble aWinX = 0.0, aWinY = 0.0, aWinZ = 0.0;
611 if ((theTransPers->mode & TPF_PAN) != TPF_PAN)
613 gluProject (theTransPers->pointX, theTransPers->pointY, theTransPers->pointZ,
614 (GLdouble* )aModelMatrix, (GLdouble* )aProjMatrix, aViewport,
615 &aWinX, &aWinY, &aWinZ);
619 if ((theTransPers->mode & TPF_ZOOM)
620 || (theTransPers->mode == TPF_TRIEDRON))
622 // compute fixed-zoom multiplier
623 // actually function works ugly with TelPerspective!
624 const GLdouble aDet2 = 0.002 / (aViewportW > aViewportH ? aProjMatrix[1][1] : aProjMatrix[0][0]);
625 aProjMatrix[0][0] *= aDet2;
626 aProjMatrix[1][1] *= aDet2;
627 aProjMatrix[2][2] *= aDet2;
630 // prevent translation - annulate translate matrix
631 if ((theTransPers->mode & TPF_PAN)
632 || (theTransPers->mode == TPF_TRIEDRON))
634 aModelMatrix[3][0] = 0.0;
635 aModelMatrix[3][1] = 0.0;
636 aModelMatrix[3][2] = 0.0;
637 aProjMatrix [3][0] = 0.0;
638 aProjMatrix [3][1] = 0.0;
639 aProjMatrix [3][2] = 0.0;
642 // prevent scaling-on-axis
643 if (theTransPers->mode & TPF_ZOOM)
645 const double aScaleX = myExtra.scaleFactors[0];
646 const double aScaleY = myExtra.scaleFactors[1];
647 const double aScaleZ = myExtra.scaleFactors[2];
648 for (int i = 0; i < 3; ++i)
650 aModelMatrix[0][i] /= aScaleX;
651 aModelMatrix[1][i] /= aScaleY;
652 aModelMatrix[2][i] /= aScaleZ;
656 // prevent rotating - annulate rotate matrix
657 if (theTransPers->mode & TPF_ROTATE)
659 aModelMatrix[0][0] = 1.0;
660 aModelMatrix[1][1] = 1.0;
661 aModelMatrix[2][2] = 1.0;
663 aModelMatrix[1][0] = 0.0;
664 aModelMatrix[2][0] = 0.0;
665 aModelMatrix[0][1] = 0.0;
666 aModelMatrix[2][1] = 0.0;
667 aModelMatrix[0][2] = 0.0;
668 aModelMatrix[1][2] = 0.0;
671 // load computed matrices
672 glMatrixMode (GL_MODELVIEW);
673 glMultMatrixd ((GLdouble* )aModelMatrix);
675 glMatrixMode (GL_PROJECTION);
676 glMultMatrixd ((GLdouble* )aProjMatrix);
678 if (theTransPers->mode == TPF_TRIEDRON)
680 // move to the window corner
681 if (theTransPers->pointX != 0.0
682 && theTransPers->pointY != 0.0)
684 GLdouble aW1, aH1, aW2, aH2, aDummy;
685 glMatrixMode (GL_PROJECTION);
686 gluUnProject ( 0.5 * aViewportW, 0.5 * aViewportH, 0.0,
687 (GLdouble* )THE_IDENTITY_MATRIX, (GLdouble* )aProjMatrix, aViewport,
688 &aW1, &aH1, &aDummy);
689 gluUnProject (-0.5 * aViewportW, -0.5 * aViewportH, 0.0,
690 (GLdouble* )THE_IDENTITY_MATRIX, (GLdouble* )aProjMatrix, aViewport,
691 &aW2, &aH2, &aDummy);
692 GLdouble aMoveX = 0.5 * (aW1 - aW2 - theTransPers->pointZ);
693 GLdouble aMoveY = 0.5 * (aH1 - aH2 - theTransPers->pointZ);
694 aMoveX = (theTransPers->pointX > 0.0) ? aMoveX : -aMoveX;
695 aMoveY = (theTransPers->pointY > 0.0) ? aMoveY : -aMoveY;
696 glTranslated (aMoveX, aMoveY, 0.0);
699 else if ((theTransPers->mode & TPF_PAN) != TPF_PAN)
701 // move to thePoint using saved win-coordinates ('marker-behaviour')
702 GLdouble aMoveX, aMoveY, aMoveZ;
703 glGetDoublev (GL_MODELVIEW_MATRIX, (GLdouble* )aModelMatrix);
704 glGetDoublev (GL_PROJECTION_MATRIX, (GLdouble* )aProjMatrix);
705 gluUnProject (aWinX, aWinY, aWinZ,
706 (GLdouble* )aModelMatrix, (GLdouble* )aProjMatrix, aViewport,
707 &aMoveX, &aMoveY, &aMoveZ);
709 glMatrixMode (GL_MODELVIEW);
710 glTranslated (aMoveX, aMoveY, aMoveZ);
713 // Note: the approach of accessing OpenGl matrices is used now since the matrix
714 // manipulation are made with help of OpenGl methods. This might be replaced by
715 // direct computation of matrices by OCC subroutines.
716 Tmatrix3 aResultWorldView;
717 glGetFloatv (GL_MODELVIEW_MATRIX, *aResultWorldView);
719 Tmatrix3 aResultProjection;
720 glGetFloatv (GL_PROJECTION_MATRIX, *aResultProjection);
722 // Set OCCT state uniform variables
723 theCtx->ShaderManager()->UpdateWorldViewStateTo (aResultWorldView);
724 theCtx->ShaderManager()->UpdateProjectionStateTo (aResultProjection);
726 return aTransPersPrev;