1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_View.hxx>
18 #include <Aspect_RenderingContext.hxx>
19 #include <Aspect_Window.hxx>
20 #include <Graphic3d_AspectFillArea3d.hxx>
21 #include <Graphic3d_Texture2Dmanual.hxx>
22 #include <Graphic3d_TextureEnv.hxx>
23 #include <Graphic3d_Mat4d.hxx>
24 #include <NCollection_Mat4.hxx>
25 #include <OpenGl_Context.hxx>
26 #include <OpenGl_FrameBuffer.hxx>
27 #include <OpenGl_GlCore11.hxx>
28 #include <OpenGl_GraduatedTrihedron.hxx>
29 #include <OpenGl_GraphicDriver.hxx>
30 #include <OpenGl_ShaderManager.hxx>
31 #include <OpenGl_Texture.hxx>
32 #include <OpenGl_Window.hxx>
33 #include <OpenGl_Workspace.hxx>
34 #include <Standard_CLocaleSentry.hxx>
36 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_View,Graphic3d_CView)
42 // =======================================================================
43 // function : Constructor
45 // =======================================================================
46 OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
47 const Handle(OpenGl_GraphicDriver)& theDriver,
48 const Handle(OpenGl_Caps)& theCaps,
49 Standard_Boolean& theDeviceLostFlag,
50 OpenGl_StateCounter* theCounter)
51 : Graphic3d_CView (theMgr),
52 myDriver (theDriver.operator->()),
54 myDeviceLostFlag (theDeviceLostFlag),
55 myWasRedrawnGL (Standard_False),
56 myCulling (Standard_True),
57 myShadingModel (Graphic3d_TOSM_FACET),
58 myBackfacing (Graphic3d_TOBM_AUTOMATIC),
59 myBgColor (Quantity_NOC_BLACK),
60 myCamera (new Graphic3d_Camera()),
61 myUseGLLight (Standard_True),
62 myToShowGradTrihedron (false),
63 myStateCounter (theCounter),
64 myLastLightSourceState (0, 0),
65 myFboColorFormat (GL_RGBA8),
66 myFboDepthFormat (GL_DEPTH24_STENCIL8),
67 myToFlipOutput (Standard_False),
69 myHasFboBlit (Standard_True),
70 myToDisableMSAA (Standard_False),
71 myTransientDrawToFront (Standard_True),
72 myBackBufferRestored (Standard_False),
73 myIsImmediateDrawn (Standard_False),
74 myTextureParams (new OpenGl_AspectFace()),
75 myBgGradientArray (new OpenGl_BackgroundArray (Graphic3d_TOB_GRADIENT)),
76 myBgTextureArray (new OpenGl_BackgroundArray (Graphic3d_TOB_TEXTURE)),
77 // ray-tracing fields initialization
78 myRaytraceInitStatus (OpenGl_RT_NONE),
79 myIsRaytraceDataValid (Standard_False),
80 myIsRaytraceWarnTextures (Standard_False),
81 myToUpdateEnvironmentMap (Standard_False),
82 myRaytraceLayerListState (0)
84 myWorkspace = new OpenGl_Workspace (this, NULL);
87 aLight.Type = Graphic3d_TOLS_AMBIENT;
88 aLight.IsHeadlight = Standard_False;
89 aLight.Color.r() = 1.;
90 aLight.Color.g() = 1.;
91 aLight.Color.b() = 1.;
92 myNoShadingLight.Append (aLight);
94 myCurrLightSourceState = myStateCounter->Increment();
95 myMainSceneFbos[0] = new OpenGl_FrameBuffer();
96 myMainSceneFbos[1] = new OpenGl_FrameBuffer();
97 myImmediateSceneFbos[0] = new OpenGl_FrameBuffer();
98 myImmediateSceneFbos[1] = new OpenGl_FrameBuffer();
99 myOpenGlFBO = new OpenGl_FrameBuffer();
100 myOpenGlFBO2 = new OpenGl_FrameBuffer();
101 myRaytraceFBO1[0] = new OpenGl_FrameBuffer();
102 myRaytraceFBO1[1] = new OpenGl_FrameBuffer();
103 myRaytraceFBO2[0] = new OpenGl_FrameBuffer();
104 myRaytraceFBO2[1] = new OpenGl_FrameBuffer();
107 // =======================================================================
108 // function : Destructor
110 // =======================================================================
111 OpenGl_View::~OpenGl_View()
113 ReleaseGlResources (NULL); // ensure ReleaseGlResources() was called within valid context
114 OpenGl_Element::Destroy (NULL, myBgGradientArray);
115 OpenGl_Element::Destroy (NULL, myBgTextureArray);
116 OpenGl_Element::Destroy (NULL, myTextureParams);
119 // =======================================================================
120 // function : ReleaseGlResources
122 // =======================================================================
123 void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
125 myGraduatedTrihedron.Release (theCtx.operator->());
127 if (!myTextureEnv.IsNull())
129 theCtx->DelayedRelease (myTextureEnv);
130 myTextureEnv.Nullify();
133 if (myTextureParams != NULL)
135 myTextureParams->Release (theCtx.operator->());
137 if (myBgGradientArray != NULL)
139 myBgGradientArray->Release (theCtx.operator->());
141 if (myBgTextureArray != NULL)
143 myBgTextureArray->Release (theCtx.operator->());
146 myMainSceneFbos[0] ->Release (theCtx.operator->());
147 myMainSceneFbos[1] ->Release (theCtx.operator->());
148 myImmediateSceneFbos[0]->Release (theCtx.operator->());
149 myImmediateSceneFbos[1]->Release (theCtx.operator->());
150 myOpenGlFBO ->Release (theCtx.operator->());
151 myOpenGlFBO2 ->Release (theCtx.operator->());
152 myFullScreenQuad .Release (theCtx.operator->());
153 myFullScreenQuadFlip .Release (theCtx.operator->());
155 releaseRaytraceResources (theCtx);
158 // =======================================================================
161 // =======================================================================
162 void OpenGl_View::Remove()
169 myDriver->RemoveView (this);
172 Graphic3d_CView::Remove();
175 // =======================================================================
176 // function : SetTextureEnv
178 // =======================================================================
179 void OpenGl_View::SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv)
181 Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
182 if (!aCtx.IsNull() && !myTextureEnv.IsNull())
184 aCtx->DelayedRelease (myTextureEnv);
187 myToUpdateEnvironmentMap = Standard_True;
188 myTextureEnvData = theTextureEnv;
189 myTextureEnv.Nullify();
190 initTextureEnv (aCtx);
193 // =======================================================================
194 // function : initTextureEnv
196 // =======================================================================
197 void OpenGl_View::initTextureEnv (const Handle(OpenGl_Context)& theContext)
199 if (myTextureEnvData.IsNull()
200 || theContext.IsNull()
201 || !theContext->MakeCurrent())
206 myTextureEnv = new OpenGl_Texture (myTextureEnvData->GetParams());
207 Handle(Image_PixMap) anImage = myTextureEnvData->GetImage();
208 if (!anImage.IsNull())
210 myTextureEnv->Init (theContext, *anImage.operator->(), myTextureEnvData->Type());
214 // =======================================================================
215 // function : SetImmediateModeDrawToFront
217 // =======================================================================
218 Standard_Boolean OpenGl_View::SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer)
220 const Standard_Boolean aPrevMode = myTransientDrawToFront;
221 myTransientDrawToFront = theDrawToFrontBuffer;
225 // =======================================================================
226 // function : SetWindow
228 // =======================================================================
229 void OpenGl_View::SetWindow (const Handle(Aspect_Window)& theWindow,
230 const Aspect_RenderingContext theContext)
232 myWindow = myDriver->CreateRenderWindow (theWindow, theContext);
233 Standard_ASSERT_RAISE (!myWindow.IsNull(),
234 "OpenGl_View::SetWindow, "
235 "Failed to create OpenGl window.");
237 myWorkspace = new OpenGl_Workspace (this, myWindow);
238 myWorldViewProjState.Reset();
239 myToUpdateEnvironmentMap = Standard_True;
240 myHasFboBlit = Standard_True;
243 // Environment texture resource does not support lazy initialization.
244 initTextureEnv (myWorkspace->GetGlContext());
247 // =======================================================================
248 // function : Resized
250 // =======================================================================
251 void OpenGl_View::Resized()
253 if (myWindow.IsNull())
259 // =======================================================================
260 // function : SetMinMaxValuesCallback
262 // =======================================================================
263 static void SetMinMaxValuesCallback (Graphic3d_CView* theView)
265 OpenGl_View* aView = dynamic_cast<OpenGl_View*>(theView);
269 Bnd_Box aBox = theView->MinMaxValues();
272 gp_Pnt aMin = aBox.CornerMin();
273 gp_Pnt aMax = aBox.CornerMax();
275 Graphic3d_Vec3 aMinVec ((Standard_ShortReal )aMin.X(), (Standard_ShortReal )aMin.Y(), (Standard_ShortReal )aMin.Z());
276 Graphic3d_Vec3 aMaxVec ((Standard_ShortReal )aMax.X(), (Standard_ShortReal )aMax.Y(), (Standard_ShortReal )aMax.Z());
277 aView->GraduatedTrihedronMinMaxValues (aMinVec, aMaxVec);
281 // =======================================================================
282 // function : GraduatedTrihedronDisplay
284 // =======================================================================
285 void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData)
287 myGTrihedronData = theTrihedronData;
288 myGTrihedronData.PtrView = this;
289 myGTrihedronData.CubicAxesCallback = SetMinMaxValuesCallback;
290 myGraduatedTrihedron.SetValues (myGTrihedronData);
291 myToShowGradTrihedron = true;
294 // =======================================================================
295 // function : GraduatedTrihedronErase
297 // =======================================================================
298 void OpenGl_View::GraduatedTrihedronErase()
300 myGTrihedronData.PtrView = NULL;
301 myGraduatedTrihedron.Release (myWorkspace->GetGlContext().operator->());
302 myToShowGradTrihedron = false;
305 // =======================================================================
306 // function : GraduatedTrihedronMinMaxValues
308 // =======================================================================
309 void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
311 myGraduatedTrihedron.SetMinMax (theMin, theMax);
314 // =======================================================================
315 // function : BufferDump
317 // =======================================================================
318 Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType)
320 return myWorkspace->BufferDump (myFBO, theImage, theBufferType);
323 // =======================================================================
324 // function : Background
326 // =======================================================================
327 Aspect_Background OpenGl_View::Background() const
329 return Aspect_Background (myBgColor.GetRGB());
332 // =======================================================================
333 // function : SetBackground
335 // =======================================================================
336 void OpenGl_View::SetBackground (const Aspect_Background& theBackground)
338 myBgColor.SetRGB (theBackground.Color());
341 // =======================================================================
342 // function : GradientBackground
344 // =======================================================================
345 Aspect_GradientBackground OpenGl_View::GradientBackground() const
347 Quantity_Color aColor1, aColor2;
348 aColor1.SetValues (myBgGradientArray->GradientColor (0).r(),
349 myBgGradientArray->GradientColor (0).g(),
350 myBgGradientArray->GradientColor (0).b(), Quantity_TOC_RGB);
351 aColor2.SetValues (myBgGradientArray->GradientColor (1).r(),
352 myBgGradientArray->GradientColor (1).g(),
353 myBgGradientArray->GradientColor (1).b(), Quantity_TOC_RGB);
354 return Aspect_GradientBackground (aColor1, aColor2, myBgGradientArray->GradientFillMethod());
357 // =======================================================================
358 // function : SetGradientBackground
360 // =======================================================================
361 void OpenGl_View::SetGradientBackground (const Aspect_GradientBackground& theBackground)
363 Quantity_Color aColor1, aColor2;
364 theBackground.Colors (aColor1, aColor2);
365 myBgGradientArray->SetGradientParameters (aColor1, aColor2, theBackground.BgGradientFillMethod());
368 // =======================================================================
369 // function : SetBackgroundImage
371 // =======================================================================
372 void OpenGl_View::SetBackgroundImage (const TCollection_AsciiString& theFilePath)
374 // Prepare aspect for texture storage
375 myBackgroundImagePath = theFilePath;
376 Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
377 Handle(Graphic3d_Texture2Dmanual) aTextureMap = new Graphic3d_Texture2Dmanual (TCollection_AsciiString (theFilePath));
378 aTextureMap->EnableRepeat();
379 aTextureMap->DisableModulate();
380 aTextureMap->GetParams()->SetGenMode (Graphic3d_TOTM_MANUAL,
381 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f),
382 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
383 anAspect->SetTextureMap (aTextureMap);
384 anAspect->SetInteriorStyle (Aspect_IS_SOLID);
385 anAspect->SetSuppressBackFaces (false);
386 // Enable texture mapping
387 if (aTextureMap->IsDone())
389 anAspect->SetTextureMapOn();
393 anAspect->SetTextureMapOff();
397 // Set texture parameters
398 myTextureParams->SetAspect (anAspect);
401 // =======================================================================
402 // function : BackgroundImageStyle
404 // =======================================================================
405 Aspect_FillMethod OpenGl_View::BackgroundImageStyle() const
407 return myBgTextureArray->TextureFillMethod();
410 // =======================================================================
411 // function : SetBackgroundImageStyle
413 // =======================================================================
414 void OpenGl_View::SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle)
416 myBgTextureArray->SetTextureFillMethod (theFillStyle);
419 //=======================================================================
420 //function : AddZLayer
422 //=======================================================================
423 void OpenGl_View::AddZLayer (const Graphic3d_ZLayerId theLayerId)
425 myZLayers.AddLayer (theLayerId);
428 //=======================================================================
429 //function : RemoveZLayer
431 //=======================================================================
432 void OpenGl_View::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
434 myZLayers.RemoveLayer (theLayerId);
437 //=======================================================================
438 //function : SetZLayerSettings
440 //=======================================================================
441 void OpenGl_View::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
442 const Graphic3d_ZLayerSettings& theSettings)
444 myZLayers.SetLayerSettings (theLayerId, theSettings);
447 //=======================================================================
448 //function : ZLayerMax
450 //=======================================================================
451 Standard_Integer OpenGl_View::ZLayerMax() const
453 Standard_Integer aLayerMax = Graphic3d_ZLayerId_Default;
454 for (OpenGl_LayerSeqIds::Iterator aMapIt(myZLayers.LayerIDs()); aMapIt.More(); aMapIt.Next())
456 aLayerMax = Max (aLayerMax, aMapIt.Value());
462 //=======================================================================
463 //function : InvalidateZLayerBoundingBox
465 //=======================================================================
466 void OpenGl_View::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const
468 if (myZLayers.LayerIDs().IsBound (theLayerId))
470 myZLayers.Layer (theLayerId).InvalidateBoundingBox();
474 for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId < ZLayerMax(); ++aLayerId)
476 if (myZLayers.LayerIDs().IsBound (aLayerId))
478 const OpenGl_Layer& aLayer = myZLayers.Layer (aLayerId);
479 if (aLayer.NbOfTransformPersistenceObjects() > 0)
481 aLayer.InvalidateBoundingBox();
488 //=======================================================================
489 //function : ZLayerBoundingBox
491 //=======================================================================
492 Graphic3d_BndBox4f OpenGl_View::ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
493 const Handle(Graphic3d_Camera)& theCamera,
494 const Standard_Integer theWindowWidth,
495 const Standard_Integer theWindowHeight,
496 const Standard_Boolean theToIncludeAuxiliary) const
498 Graphic3d_BndBox4f aBox;
499 if (myZLayers.LayerIDs().IsBound (theLayerId))
501 aBox = myZLayers.Layer (theLayerId).BoundingBox (Identification(),
505 theToIncludeAuxiliary);
508 // add bounding box of gradient/texture background for proper Z-fit
509 if (theToIncludeAuxiliary
510 && theLayerId == Graphic3d_ZLayerId_BotOSD
511 && (myBgTextureArray->IsDefined()
512 || myBgGradientArray->IsDefined()))
514 // Background is drawn using 2D transformation persistence
515 // (e.g. it is actually placed in 3D coordinates within active camera position).
516 // We add here full-screen plane with 2D transformation persistence
517 // for simplicity (myBgTextureArray might define a little bit different options
518 // but it is updated within ::Render())
519 const Graphic3d_Mat4& aProjectionMat = theCamera->ProjectionMatrixF();
520 const Graphic3d_Mat4& aWorldViewMat = theCamera->OrientationMatrixF();
521 Graphic3d_BndBox4f aBox2d (Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f),
522 Graphic3d_Vec4 (float(theWindowWidth), float(theWindowHeight), 0.0f, 0.0f));
524 Graphic3d_TransformPers aTrsfPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER);
525 aTrsfPers.Apply (theCamera,
531 aBox.Combine (aBox2d);
537 //=======================================================================
538 //function : considerZoomPersistenceObjects
540 //=======================================================================
541 Standard_Real OpenGl_View::considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
542 const Handle(Graphic3d_Camera)& theCamera,
543 const Standard_Integer theWindowWidth,
544 const Standard_Integer theWindowHeight) const
546 if (myZLayers.LayerIDs().IsBound (theLayerId))
548 return myZLayers.Layer (theLayerId).considerZoomPersistenceObjects (Identification(),
557 //=======================================================================
560 //=======================================================================
561 Handle(Standard_Transient) OpenGl_View::FBO() const
563 return Handle(Standard_Transient)(myFBO);
566 //=======================================================================
569 //=======================================================================
570 void OpenGl_View::SetFBO (const Handle(Standard_Transient)& theFbo)
572 myFBO = Handle(OpenGl_FrameBuffer)::DownCast (theFbo);
575 //=======================================================================
576 //function : FBOCreate
578 //=======================================================================
579 Handle(Standard_Transient) OpenGl_View::FBOCreate (const Standard_Integer theWidth,
580 const Standard_Integer theHeight)
582 return myWorkspace->FBOCreate (theWidth, theHeight);
585 //=======================================================================
586 //function : FBORelease
588 //=======================================================================
589 void OpenGl_View::FBORelease (Handle(Standard_Transient)& theFbo)
591 Handle(OpenGl_FrameBuffer) aFrameBuffer = Handle(OpenGl_FrameBuffer)::DownCast (theFbo);
592 if (aFrameBuffer.IsNull())
597 myWorkspace->FBORelease (aFrameBuffer);
601 //=======================================================================
602 //function : FBOGetDimensions
604 //=======================================================================
605 void OpenGl_View::FBOGetDimensions (const Handle(Standard_Transient)& theFbo,
606 Standard_Integer& theWidth,
607 Standard_Integer& theHeight,
608 Standard_Integer& theWidthMax,
609 Standard_Integer& theHeightMax)
611 const Handle(OpenGl_FrameBuffer) aFrameBuffer = Handle(OpenGl_FrameBuffer)::DownCast (theFbo);
612 if (aFrameBuffer.IsNull())
617 theWidth = aFrameBuffer->GetVPSizeX(); // current viewport size
618 theHeight = aFrameBuffer->GetVPSizeY();
619 theWidthMax = aFrameBuffer->GetSizeX(); // texture size
620 theHeightMax = aFrameBuffer->GetSizeY();
623 //=======================================================================
624 //function : FBOChangeViewport
626 //=======================================================================
627 void OpenGl_View::FBOChangeViewport (const Handle(Standard_Transient)& theFbo,
628 const Standard_Integer theWidth,
629 const Standard_Integer theHeight)
631 const Handle(OpenGl_FrameBuffer) aFrameBuffer = Handle(OpenGl_FrameBuffer)::DownCast (theFbo);
632 if (aFrameBuffer.IsNull())
637 aFrameBuffer->ChangeViewport (theWidth, theHeight);
640 // =======================================================================
643 // =======================================================================
645 Standard_Boolean OpenGl_View::Export (const Standard_CString theFileName,
646 const Graphic3d_ExportFormat theFormat,
647 const Graphic3d_SortType theSortType)
649 // gl2psBeginPage() will call OpenGL functions
650 // so we should activate correct GL context before redraw scene call
651 if (!myWorkspace->Activate())
653 return Standard_False;
656 Standard_Integer aFormat = -1;
657 Standard_Integer aSortType = Graphic3d_ST_BSP_Tree;
660 case Graphic3d_EF_PostScript:
663 case Graphic3d_EF_EnhPostScript:
666 case Graphic3d_EF_TEX:
669 case Graphic3d_EF_PDF:
672 case Graphic3d_EF_SVG:
675 case Graphic3d_EF_PGF:
678 case Graphic3d_EF_EMF:
679 //aFormat = GL2PS_EMF;
680 aFormat = GL2PS_PGF + 1; // 6
683 // unsupported format
684 return Standard_False;
689 case Graphic3d_ST_Simple:
690 aSortType = GL2PS_SIMPLE_SORT;
692 case Graphic3d_ST_BSP_Tree:
693 aSortType = GL2PS_BSP_SORT;
700 aViewport[2] = myWindow->Width();
701 aViewport[3] = myWindow->Height();
703 GLint aBufferSize = 1024 * 1024;
704 GLint anErrCode = GL2PS_SUCCESS;
706 // gl2ps uses standard write functions and do not check locale
707 Standard_CLocaleSentry aLocaleSentry;
709 while (aBufferSize > 0)
711 // current patch for EMF support in gl2ps uses WinAPI functions to create file
712 FILE* aFileH = (theFormat != Graphic3d_EF_EMF) ? fopen (theFileName, "wb") : NULL;
713 anErrCode = gl2psBeginPage ("", "", aViewport, aFormat, aSortType,
714 GL2PS_DRAW_BACKGROUND | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT/* | GL2PS_SIMPLE_LINE_OFFSET*/,
716 0, 0, 0, aBufferSize, aFileH, theFileName);
717 if (anErrCode != GL2PS_SUCCESS)
719 // initialization failed
726 anErrCode = gl2psEndPage();
730 if (anErrCode == GL2PS_OVERFLOW)
735 return anErrCode == GL2PS_SUCCESS;
738 Standard_Boolean OpenGl_View::Export (const Standard_CString /*theFileName*/,
739 const Graphic3d_ExportFormat /*theFormat*/,
740 const Graphic3d_SortType /*theSortType*/)
742 return Standard_False;
746 //=======================================================================
747 //function : displayStructure
749 //=======================================================================
750 void OpenGl_View::displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
751 const Standard_Integer thePriority)
753 const OpenGl_Structure* aStruct = reinterpret_cast<const OpenGl_Structure*> (theStructure.operator->());
754 const Graphic3d_ZLayerId aZLayer = aStruct->ZLayer();
755 myZLayers.AddStructure (aStruct, aZLayer, thePriority);
758 //=======================================================================
759 //function : eraseStructure
761 //=======================================================================
762 void OpenGl_View::eraseStructure (const Handle(Graphic3d_CStructure)& theStructure)
764 const OpenGl_Structure* aStruct = reinterpret_cast<const OpenGl_Structure*> (theStructure.operator->());
765 myZLayers.RemoveStructure (aStruct);
768 //=======================================================================
769 //function : changeZLayer
771 //=======================================================================
772 void OpenGl_View::changeZLayer (const Handle(Graphic3d_CStructure)& theStructure,
773 const Graphic3d_ZLayerId theNewLayerId)
775 const Graphic3d_ZLayerId anOldLayer = theStructure->ZLayer();
776 const OpenGl_Structure* aStruct = reinterpret_cast<const OpenGl_Structure*> (theStructure.operator->());
777 myZLayers.ChangeLayer (aStruct, anOldLayer, theNewLayerId);
778 Update (Aspect_TOU_WAIT, anOldLayer);
779 Update (Aspect_TOU_WAIT, theNewLayerId);
782 //=======================================================================
783 //function : changePriority
785 //=======================================================================
786 void OpenGl_View::changePriority (const Handle(Graphic3d_CStructure)& theStructure,
787 const Standard_Integer theNewPriority)
789 const Graphic3d_ZLayerId aLayerId = theStructure->ZLayer();
790 const OpenGl_Structure* aStruct = reinterpret_cast<const OpenGl_Structure*> (theStructure.operator->());
791 myZLayers.ChangePriority (aStruct, aLayerId, theNewPriority);
794 //=======================================================================
795 //function : DiagnosticInformation
797 //=======================================================================
798 void OpenGl_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
799 Graphic3d_DiagnosticInfo theFlags) const
801 Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
802 if (!myWorkspace->Activate()
808 aCtx->DiagnosticInformation (theDict, theFlags);
809 if ((theFlags & Graphic3d_DiagnosticInfo_FrameBuffer) != 0)
811 TCollection_AsciiString aResRatio (myRenderParams.ResolutionRatio());
812 theDict.ChangeFromIndex (theDict.Add ("ResolutionRatio", aResRatio)) = aResRatio;