From de110ed8b2cd45652c409552a4b96aa41e7c45e3 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 22 Feb 2019 19:56:30 +0300 Subject: [PATCH] 0030491: Visualization - OpenGl_Element inherits Standard_Transient # moving direct objects into Handles --- src/OpenGl/OpenGl_CappingAlgo.cxx | 4 +- src/OpenGl/OpenGl_CappingPlaneResource.cxx | 6 +- src/OpenGl/OpenGl_CappingPlaneResource.hxx | 4 +- src/OpenGl/OpenGl_FrameStatsPrs.cxx | 45 +++++---- src/OpenGl/OpenGl_FrameStatsPrs.hxx | 8 +- src/OpenGl/OpenGl_GraduatedTrihedron.cxx | 104 +++++++++++---------- src/OpenGl/OpenGl_GraduatedTrihedron.hxx | 20 ++-- src/OpenGl/OpenGl_GraphicDriver.cxx | 4 +- src/OpenGl/OpenGl_PrimitiveArray.cxx | 4 +- src/OpenGl/OpenGl_Text.cxx | 54 +++++------ src/OpenGl/OpenGl_Text.hxx | 18 ++-- src/OpenGl/OpenGl_View.cxx | 13 ++- src/OpenGl/OpenGl_View.hxx | 10 +- src/OpenGl/OpenGl_View_Raytrace.cxx | 22 ++--- src/OpenGl/OpenGl_View_Redraw.cxx | 10 +- src/OpenGl/OpenGl_Workspace.cxx | 16 +--- src/OpenGl/OpenGl_Workspace.hxx | 8 +- 17 files changed, 180 insertions(+), 170 deletions(-) diff --git a/src/OpenGl/OpenGl_CappingAlgo.cxx b/src/OpenGl/OpenGl_CappingAlgo.cxx index 274aea5385..29a207e448 100755 --- a/src/OpenGl/OpenGl_CappingAlgo.cxx +++ b/src/OpenGl/OpenGl_CappingAlgo.cxx @@ -72,7 +72,7 @@ namespace aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat)); aContext->ApplyModelViewMatrix(); - thePlane->Primitives().Render (theWorkspace); + thePlane->Primitives()->Render (theWorkspace); aContext->ModelWorldState.Pop(); aContext->ApplyModelViewMatrix(); @@ -108,7 +108,7 @@ namespace thePlane->Update (aContext, !anObjAspectFace.IsNull() ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)()); theWorkspace->SetAspectFace (thePlane->AspectFace()); theWorkspace->SetRenderFilter (aPrevFilter); - if (!theWorkspace->ShouldRender (&thePlane->Primitives())) + if (!theWorkspace->ShouldRender (thePlane->Primitives())) { continue; } diff --git a/src/OpenGl/OpenGl_CappingPlaneResource.cxx b/src/OpenGl/OpenGl_CappingPlaneResource.cxx index f961d375c2..19d7c22c24 100755 --- a/src/OpenGl/OpenGl_CappingPlaneResource.cxx +++ b/src/OpenGl/OpenGl_CappingPlaneResource.cxx @@ -63,7 +63,7 @@ namespace // purpose : // ======================================================================= OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane) -: myPrimitives (NULL), +: myPrimitives (new OpenGl_PrimitiveArray(NULL)), myOrientation (OpenGl_IdentityMatrix), myAspect (NULL), myPlaneRoot (thePlane), @@ -82,7 +82,7 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d if (anAttribs->Init (12, anAttribInfo, 3)) { memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS)); - myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL); + myPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL); } } @@ -113,7 +113,7 @@ void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& , void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext) { OpenGl_Element::Destroy (theContext, myAspect); - myPrimitives.Release (theContext); + myPrimitives->Release (theContext); myEquationMod = (unsigned int )-1; myAspectMod = (unsigned int )-1; } diff --git a/src/OpenGl/OpenGl_CappingPlaneResource.hxx b/src/OpenGl/OpenGl_CappingPlaneResource.hxx index 4145cd231e..b7e150ebd1 100755 --- a/src/OpenGl/OpenGl_CappingPlaneResource.hxx +++ b/src/OpenGl/OpenGl_CappingPlaneResource.hxx @@ -67,7 +67,7 @@ public: inline const OpenGl_Matrix* Orientation() const { return &myOrientation; } //! @return primitive array of vertices to render infinite plane. - inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; } + inline const Handle(OpenGl_PrimitiveArray)& Primitives() const { return myPrimitives; } private: @@ -79,7 +79,7 @@ private: private: - OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering + Handle(OpenGl_PrimitiveArray) myPrimitives; //!< vertices and texture coordinates for rendering OpenGl_Matrix myOrientation; //!< plane transformation matrix. Handle(OpenGl_AspectFace) myAspect; //!< capping face aspect. Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure. diff --git a/src/OpenGl/OpenGl_FrameStatsPrs.cxx b/src/OpenGl/OpenGl_FrameStatsPrs.cxx index e6a8a0f71c..849873ec10 100644 --- a/src/OpenGl/OpenGl_FrameStatsPrs.cxx +++ b/src/OpenGl/OpenGl_FrameStatsPrs.cxx @@ -52,7 +52,11 @@ OpenGl_FrameStatsPrs::OpenGl_FrameStatsPrs() myChartIndices (new OpenGl_IndexBuffer()), myChartLines (new OpenGl_VertexBuffer()) { - // + myCountersText = new OpenGl_Text(); + myTextAspect = new OpenGl_AspectText(); + myChartLabels[0] = new OpenGl_Text(); + myChartLabels[1] = new OpenGl_Text(); + myChartLabels[2] = new OpenGl_Text(); } // ======================================================================= @@ -70,10 +74,10 @@ OpenGl_FrameStatsPrs::~OpenGl_FrameStatsPrs() // ======================================================================= void OpenGl_FrameStatsPrs::Release (OpenGl_Context* theCtx) { - myCountersText.Release (theCtx); - myChartLabels[0].Release (theCtx); - myChartLabels[1].Release (theCtx); - myChartLabels[2].Release (theCtx); + myCountersText->Release (theCtx); + myChartLabels[0]->Release (theCtx); + myChartLabels[1]->Release (theCtx); + myChartLabels[2]->Release (theCtx); myChartVertices->Release (theCtx); myChartIndices->Release (theCtx); myChartLines->Release (theCtx); @@ -90,7 +94,7 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace) const Graphic3d_RenderingParams& aRendParams = theWorkspace->View()->RenderingParams(); myCountersTrsfPers = theWorkspace->View()->RenderingParams().StatsPosition; myChartTrsfPers = theWorkspace->View()->RenderingParams().ChartPosition; - myTextAspect.SetAspect (aRendParams.StatsTextAspect); + myTextAspect->SetAspect (aRendParams.StatsTextAspect); // adjust text alignment depending on corner OpenGl_TextParam aParams; @@ -113,21 +117,21 @@ void OpenGl_FrameStatsPrs::Update (const Handle(OpenGl_Workspace)& theWorkspace) { aParams.VAlign = Graphic3d_VTA_BOTTOM; } - if (aParams.Height != myCountersText.FormatParams().Height - || aParams.HAlign != myCountersText.FormatParams().HAlign - || aParams.VAlign != myCountersText.FormatParams().VAlign) + if (aParams.Height != myCountersText->FormatParams().Height + || aParams.HAlign != myCountersText->FormatParams().HAlign + || aParams.VAlign != myCountersText->FormatParams().VAlign) { - myCountersText.Release (aCtx.operator->()); + myCountersText->Release (aCtx.operator->()); } if (!aStats->IsFrameUpdated (myStatsPrev) - && !myCountersText.Text().IsEmpty()) + && !myCountersText->Text().IsEmpty()) { return; } TCollection_AsciiString aText = aStats->FormatStats (aRendParams.CollectedStats); - myCountersText.Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams); + myCountersText->Init (aCtx, aText.ToCString(), OpenGl_Vec3 (0.0f, 0.0f, 0.0f), aParams); updateChart (theWorkspace); } @@ -343,9 +347,9 @@ void OpenGl_FrameStatsPrs::updateChart (const Handle(OpenGl_Workspace)& theWorks const float aLabX = aParams.HAlign == Graphic3d_HTA_RIGHT ? float(anOffset.x()) : float(anOffset.x() + aCharSize.x()); - myChartLabels[0].Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams); - myChartLabels[1].Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams); - myChartLabels[2].Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams); + myChartLabels[0]->Init (aCtx, aLabels[isTopDown ? 0 : 2].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y()), 0.0f), aParams); + myChartLabels[1]->Init (aCtx, aLabels[isTopDown ? 1 : 1].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y() / 2), 0.0f), aParams); + myChartLabels[2]->Init (aCtx, aLabels[isTopDown ? 2 : 0].ToCString(), OpenGl_Vec3 (aLabX, float(anOffset.y() - aBinSize.y()), 0.0f), aParams); } } @@ -363,7 +367,8 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) glDepthMask (GL_FALSE); } - const Handle(OpenGl_AspectText)& aTextAspectBack = theWorkspace->SetAspectText (&myTextAspect); + const Handle(OpenGl_AspectText)& aTextAspectBack = theWorkspace->AspectText(); + theWorkspace->SetAspectText (myTextAspect); aCtx->ModelWorldState.Push(); aCtx->ModelWorldState.ChangeCurrent().InitIdentity(); @@ -378,7 +383,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) aCtx->VirtualViewport()[2], aCtx->VirtualViewport()[3]); } aCtx->ApplyModelViewMatrix(); - myCountersText.Render (theWorkspace); + myCountersText->Render (theWorkspace); aCtx->WorldViewState.Pop(); } @@ -421,9 +426,9 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_COLOR); myChartLines->unbindAttribute (aCtx, Graphic3d_TOA_POS); - myChartLabels[0].Render (theWorkspace); - myChartLabels[1].Render (theWorkspace); - myChartLabels[2].Render (theWorkspace); + myChartLabels[0]->Render (theWorkspace); + myChartLabels[1]->Render (theWorkspace); + myChartLabels[2]->Render (theWorkspace); aCtx->WorldViewState.Pop(); } diff --git a/src/OpenGl/OpenGl_FrameStatsPrs.hxx b/src/OpenGl/OpenGl_FrameStatsPrs.hxx index 04ba8b292d..16508b4e4a 100644 --- a/src/OpenGl/OpenGl_FrameStatsPrs.hxx +++ b/src/OpenGl/OpenGl_FrameStatsPrs.hxx @@ -44,7 +44,7 @@ public: Standard_EXPORT void Update (const Handle(OpenGl_Workspace)& theWorkspace); //! Assign text aspect. - void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect.SetAspect (theAspect); } + void SetTextAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect->SetAspect (theAspect); } protected: @@ -55,14 +55,14 @@ protected: Handle(OpenGl_FrameStats) myStatsPrev; //!< currently displayed stats Handle(Graphic3d_TransformPers) myCountersTrsfPers; //!< transformation persistence for counters presentation - OpenGl_Text myCountersText; //!< counters presentation - OpenGl_AspectText myTextAspect; //!< text aspect + Handle(OpenGl_Text) myCountersText; //!< counters presentation + Handle(OpenGl_AspectText) myTextAspect; //!< text aspect Handle(Graphic3d_TransformPers) myChartTrsfPers; //!< transformation persistence for chart presentation Handle(Graphic3d_ArrayOfTriangles) myChartArray; //!< array of chart triangles Handle(OpenGl_VertexBuffer) myChartVertices; //!< VBO with chart triangles Handle(OpenGl_IndexBuffer) myChartIndices; //!< VBO with chart triangle indexes Handle(OpenGl_VertexBuffer) myChartLines; //!< array of chart lines - OpenGl_Text myChartLabels[3]; //!< chart labels + Handle(OpenGl_Text) myChartLabels[3]; //!< chart labels }; diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx index db4279298b..1e420435f3 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx @@ -51,7 +51,11 @@ OpenGl_GraduatedTrihedron::OpenGl_GraduatedTrihedron() myMax (100.0f, 100.0f, 100.0f), myIsInitialized (Standard_False) { - // + myGridLineAspect = new OpenGl_AspectLine(); + + myLabelValues = new OpenGl_Text(); + myAspectLabels = new OpenGl_AspectText(); + myAspectValues = new OpenGl_AspectText(); } // ======================================================================= @@ -82,7 +86,7 @@ void OpenGl_GraduatedTrihedron::Release (OpenGl_Context* theCtx) myAxes[0].Release (theCtx); myAxes[1].Release (theCtx); myAxes[2].Release (theCtx); - myLabelValues.Release (theCtx); + myLabelValues->Release (theCtx); } // ======================================================================= @@ -94,7 +98,7 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t myAxes[0].Release (theCtx.operator->()); myAxes[1].Release (theCtx.operator->()); myAxes[2].Release (theCtx.operator->()); - myLabelValues.Release (theCtx.operator->()); + myLabelValues->Release (theCtx.operator->()); // Initialize text label parameters for x, y, and z axes myAxes[0] = Axis (myData.XAxisAspect(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f)); @@ -107,19 +111,19 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t myAxes[2].InitArrow (theCtx, myData.ArrowsLength(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f)); for (Standard_Integer anIt = 0; anIt < 3; ++anIt) { - myAxes[anIt].Label.SetFontSize (theCtx, myData.NamesSize()); + myAxes[anIt].Label->SetFontSize (theCtx, myData.NamesSize()); } - myLabelValues.SetFontSize (theCtx, myData.ValuesSize()); + myLabelValues->SetFontSize (theCtx, myData.ValuesSize()); - myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect()); - myAspectLabels.Aspect()->SetFont (myData.NamesFont()); + myAspectLabels->Aspect()->SetTextFontAspect (myData.NamesFontAspect()); + myAspectLabels->Aspect()->SetFont (myData.NamesFont()); - myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect()); - myAspectValues.Aspect()->SetFont (myData.ValuesFont()); + myAspectValues->Aspect()->SetTextFontAspect (myData.ValuesFontAspect()); + myAspectValues->Aspect()->SetFont (myData.ValuesFont()); // Grid aspect - myGridLineAspect.Aspect()->SetColor (myData.GridColor()); + myGridLineAspect->Aspect()->SetColor (myData.GridColor()); } // ======================================================================= @@ -328,7 +332,7 @@ Standard_ExtCharacter OpenGl_GraduatedTrihedron::getGridAxes (const Standard_Sho // function : renderLine // purpose : // ======================================================================= -void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray& theLine, +void OpenGl_GraduatedTrihedron::renderLine (const Handle(OpenGl_PrimitiveArray)& theLine, const Handle(OpenGl_Workspace)& theWorkspace, const OpenGl_Mat4& theMat, const Standard_ShortReal theXt, @@ -340,7 +344,7 @@ void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray& theL Graphic3d_TransformUtils::Translate (aMat, theXt, theYt, theZt); aContext->WorldViewState.SetCurrent (aMat); aContext->ApplyWorldViewMatrix(); - theLine.Render (theWorkspace); + theLine->Render (theWorkspace); } // ======================================================================= @@ -387,7 +391,7 @@ void OpenGl_GraduatedTrihedron::renderGridPlane (const Handle(OpenGl_Workspace)& Graphic3d_TransformUtils::Translate (aMat, aStepVec.x(), aStepVec.y(), aStepVec.z()); aContext->WorldViewState.SetCurrent (aMat); aContext->ApplyWorldViewMatrix(); - anAxis.Line.Render (theWorkspace); + anAxis.Line->Render (theWorkspace); } } } @@ -402,7 +406,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW { const Axis& anAxis = myAxes[theIndex]; - theWorkspace->SetAspectLine (&anAxis.LineAspect); + theWorkspace->SetAspectLine (anAxis.LineAspect); const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext(); // Reset transformations @@ -424,7 +428,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW aContext->ModelWorldState.SetCurrent (aTransMode.Compute (theWorkspace->View()->Camera(), aProjection, aWorldView, aWidth, aHeight)); aContext->ApplyModelViewMatrix(); - anAxis.Arrow.Render (theWorkspace); + anAxis.Arrow->Render (theWorkspace); // Get current Model-View and Projection states OpenGl_Mat4 aModelMat; @@ -459,7 +463,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW aContext->WorldViewState.SetCurrent (aModelMat); aContext->ApplyWorldViewMatrix(); - anAxis.Line.Render (theWorkspace); + anAxis.Line->Render (theWorkspace); } // ======================================================================= @@ -489,7 +493,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0) { - theWorkspace->SetAspectLine (&myGridLineAspect); + theWorkspace->SetAspectLine (myGridLineAspect); OpenGl_Mat4 aModelMat (theMat); @@ -502,7 +506,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp OpenGl_Vec3 aStepVec = anAxis.Direction * aStep; for (Standard_Integer anIter = 0; anIter <= aCurAspect.TickmarksNumber(); ++anIter) { - anAxis.Tickmark.Render (theWorkspace); + anAxis.Tickmark->Render (theWorkspace); Graphic3d_TransformUtils::Translate (aModelMat, aStepVec.x(), aStepVec.y(), aStepVec.z()); aContext->WorldViewState.SetCurrent (aModelMat); aContext->ApplyWorldViewMatrix(); @@ -519,24 +523,24 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset)); - myAspectLabels.Aspect()->SetColor (anAxis.NameColor); - theWorkspace->SetAspectText (&myAspectLabels); - anAxis.Label.SetPosition (aMiddle); - anAxis.Label.Render (theWorkspace); + myAspectLabels->Aspect()->SetColor (anAxis.NameColor); + theWorkspace->SetAspectText (myAspectLabels); + anAxis.Label->SetPosition (aMiddle); + anAxis.Label->Render (theWorkspace); } if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0) { - myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color()); - theWorkspace->SetAspectText (&myAspectValues); + myAspectValues->Aspect()->SetColor (anAxis.LineAspect->Aspect()->Color()); + theWorkspace->SetAspectText (myAspectValues); Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength(); for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarksNumber(); ++anIt) { sprintf (aTextValue, "%g", theGridAxes.Ticks[theIndex].GetData()[theIndex] + anIt * aStep); OpenGl_Vec3 aPos (theGridAxes.Ticks[theIndex] + anAxis.Direction* (Standard_ShortReal) (anIt * aStep) + aDir * (Standard_ShortReal) (theDpix * anOffset)); - myLabelValues.Init (theWorkspace->GetGlContext(), aTextValue, aPos); - myLabelValues.Render (theWorkspace); + myLabelValues->Init (theWorkspace->GetGlContext(), aTextValue, aPos); + myLabelValues->Render (theWorkspace); } } } @@ -561,9 +565,9 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks if (myData.CubicAxesCallback) { myData.CubicAxesCallback (myData.PtrView); - if (!myAxes[0].Line.IsInitialized() - || !myAxes[1].Line.IsInitialized() - || !myAxes[2].Line.IsInitialized() + if (!myAxes[0].Line->IsInitialized() + || !myAxes[1].Line->IsInitialized() + || !myAxes[2].Line->IsInitialized() || OpenGl_Vec3 (anOldMin - myMin).Modulus() > Precision::Confusion() || OpenGl_Vec3 (anOldMax - myMax).Modulus() > Precision::Confusion()) { @@ -620,7 +624,7 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks if (myData.ToDrawGrid()) { - theWorkspace->SetAspectLine (&myGridLineAspect); + theWorkspace->SetAspectLine (myGridLineAspect); // render grid edges if (anAxesState & XOO_XYO) @@ -715,14 +719,16 @@ void OpenGl_GraduatedTrihedron::SetMinMax (const OpenGl_Vec3& theMin, const Open // ======================================================================= OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect, const OpenGl_Vec3& theDirection) -: Direction (theDirection), - Label (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS), - Tickmark (NULL), - Line (NULL), - Arrow (NULL) +: Direction (theDirection) { NameColor = theAspect.NameColor(); - LineAspect.Aspect()->SetColor (theAspect.Color()); + LineAspect = new OpenGl_AspectLine(); + LineAspect->Aspect()->SetColor (theAspect.Color()); + + Label = new OpenGl_Text(NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS); + Tickmark = new OpenGl_PrimitiveArray (NULL); + Line = new OpenGl_PrimitiveArray (NULL); + Arrow = new OpenGl_PrimitiveArray (NULL); } // ======================================================================= @@ -745,9 +751,9 @@ OpenGl_GraduatedTrihedron::Axis& OpenGl_GraduatedTrihedron::Axis::operator= (con LineAspect = theOther.LineAspect; Label = theOther.Label; - Line .InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Line.Indices(), theOther.Line.Attributes(), theOther.Line.Bounds()); - Tickmark.InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Tickmark.Indices(), theOther.Tickmark.Attributes(), theOther.Tickmark.Bounds()); - Arrow .InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow.Indices(), theOther.Arrow.Attributes(), theOther.Arrow.Bounds()); + Line ->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Line->Indices(), theOther.Line->Attributes(), theOther.Line->Bounds()); + Tickmark->InitBuffers (NULL, Graphic3d_TOPA_SEGMENTS, theOther.Tickmark->Indices(), theOther.Tickmark->Attributes(), theOther.Tickmark->Bounds()); + Arrow ->InitBuffers (NULL, Graphic3d_TOPA_POLYLINES, theOther.Arrow->Indices(), theOther.Arrow->Attributes(), theOther.Arrow->Bounds()); return *this; } @@ -782,8 +788,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitArrow (const Handle(OpenGl_Context)& t anArray->AddVertex (aPoint3); anArray->AddVertex (aPoint1); - Arrow.InitBuffers (theContext, Graphic3d_TOPA_POLYLINES, - anArray->Indices(), anArray->Attributes(), anArray->Bounds()); + Arrow->InitBuffers (theContext, Graphic3d_TOPA_POLYLINES, + anArray->Indices(), anArray->Attributes(), anArray->Bounds()); } // ======================================================================= @@ -797,8 +803,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitTickmark (const Handle(OpenGl_Context) Handle(Graphic3d_ArrayOfSegments) anArray = new Graphic3d_ArrayOfSegments (2); anArray->AddVertex (0.0f, 0.0f, 0.0f); anArray->AddVertex (theDir); - Tickmark.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS, - anArray->Indices(), anArray->Attributes(), anArray->Bounds()); + Tickmark->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS, + anArray->Indices(), anArray->Attributes(), anArray->Bounds()); } @@ -814,8 +820,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th anArray->AddVertex (0.0f, 0.0f, 0.0f); anArray->AddVertex (theDir); - Line.InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS, - anArray->Indices(), anArray->Attributes(), anArray->Bounds()); + Line->InitBuffers (theContext, Graphic3d_TOPA_SEGMENTS, + anArray->Indices(), anArray->Attributes(), anArray->Bounds()); } // ======================================================================= @@ -824,8 +830,8 @@ void OpenGl_GraduatedTrihedron::Axis::InitLine (const Handle(OpenGl_Context)& th // ======================================================================= void OpenGl_GraduatedTrihedron::Axis::Release (OpenGl_Context* theCtx) { - Label .Release (theCtx); - Tickmark.Release (theCtx); - Line .Release (theCtx); - Arrow .Release (theCtx); + Label ->Release (theCtx); + Tickmark->Release (theCtx); + Line ->Release (theCtx); + Arrow ->Release (theCtx); } diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx index ea9f6bd6ab..cf33b3f76d 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx @@ -71,11 +71,11 @@ private: OpenGl_Vec3 Direction; Quantity_Color NameColor; - OpenGl_AspectLine LineAspect; - mutable OpenGl_Text Label; - mutable OpenGl_PrimitiveArray Tickmark; - mutable OpenGl_PrimitiveArray Line; - mutable OpenGl_PrimitiveArray Arrow; + Handle(OpenGl_AspectLine) LineAspect; + mutable Handle(OpenGl_Text) Label; + mutable Handle(OpenGl_PrimitiveArray) Tickmark; + mutable Handle(OpenGl_PrimitiveArray) Line; + mutable Handle(OpenGl_PrimitiveArray) Arrow; public: @@ -166,7 +166,7 @@ private: //! @param thaTx the X for vector of translation //! @param thaTy the Y for vector of translation //! @param thaTz the Z for vector of translation - void renderLine (const OpenGl_PrimitiveArray& theLine, + void renderLine (const Handle(OpenGl_PrimitiveArray)& theLine, const Handle(OpenGl_Workspace)& theWorkspace, const OpenGl_Mat4& theMat, const Standard_ShortReal theXt, @@ -216,13 +216,13 @@ protected: mutable Axis myAxes[3]; //!< Axes for trihedron mutable Graphic3d_GraduatedTrihedron myData; - mutable OpenGl_AspectLine myGridLineAspect; //!< Color grid properties + mutable Handle(OpenGl_AspectLine) myGridLineAspect; //!< Color grid properties protected: //! @name Labels properties - mutable OpenGl_Text myLabelValues; - mutable OpenGl_AspectText myAspectLabels; - mutable OpenGl_AspectText myAspectValues; + mutable Handle(OpenGl_Text) myLabelValues; + mutable Handle(OpenGl_AspectText) myAspectLabels; + mutable Handle(OpenGl_AspectText) myAspectValues; private: diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index ee2ea156c1..280b0b06d4 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -560,8 +560,8 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView, const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight; OpenGl_TextParam aTextParam; aTextParam.Height = (int )aHeight; - OpenGl_AspectText aTextAspect; - aTextAspect.Aspect()->SetSpace (0.3); + Handle(OpenGl_AspectText) aTextAspect = new OpenGl_AspectText(); + aTextAspect->Aspect()->SetSpace (0.3); TCollection_ExtendedString anExtText = theText; NCollection_String aText (anExtText.ToExtString()); OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent); diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index f0ffc320f9..dd01cf9d9d 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -505,7 +505,9 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo return; } - const Handle(OpenGl_AspectLine) anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge()); + const Handle(OpenGl_AspectLine) anAspectLineOld = theWorkspace->AspectLine(); + theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge()); + const Handle(OpenGl_AspectLine) anAspect = theWorkspace->ApplyAspectLine(); #if !defined(GL_ES_VERSION_2_0) diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index aea8b5002e..862ab8293b 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -289,7 +289,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx) // ======================================================================= void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx, const NCollection_String& theText, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_TextParam& theParams, const unsigned int theResolution, Standard_ShortReal& theWidth, @@ -369,7 +369,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const // use highlight color or colors from aspect render (aCtx, - *aTextAspect, + aTextAspect, theWorkspace->TextColor(), theWorkspace->TextSubtitleColor(), aCtx->Resolution()); @@ -392,12 +392,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const // purpose : // ======================================================================= void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const unsigned int theResolution) const { render (theCtx, theTextAspect, - theTextAspect.Aspect()->ColorRGBA(), - theTextAspect.Aspect()->ColorSubTitleRGBA(), + theTextAspect->Aspect()->ColorRGBA(), + theTextAspect->Aspect()->ColorSubTitleRGBA(), theResolution); } @@ -406,7 +406,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx, // purpose : // ======================================================================= void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_Vec3 theDVec) const { OpenGl_Mat4d aModViewMat; @@ -424,7 +424,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx, { Graphic3d_TransformUtils::Translate (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f); Graphic3d_TransformUtils::Scale (aModViewMat, 1.f, -1.f, 1.f); - Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f); + Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.f, 0.f, 1.f); } else { @@ -466,10 +466,10 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx, else { Graphic3d_TransformUtils::Translate (aModViewMat, anObjX, anObjY, anObjZ); - Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0); + Graphic3d_TransformUtils::Rotate (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.0, 0.0, 1.0); } - if (!theTextAspect.Aspect()->GetTextZoomable()) + if (!theTextAspect->Aspect()->GetTextZoomable()) { Graphic3d_TransformUtils::Scale (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight); } @@ -506,7 +506,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx, // purpose : // ======================================================================= void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect) const + const Handle(OpenGl_AspectText)& theTextAspect) const { (void )theTextAspect; if (myVertsVbo.Length() != myTextures.Length() @@ -537,14 +537,14 @@ void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx, // function : FontKey // purpose : // ======================================================================= -TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect, +TCollection_AsciiString OpenGl_Text::FontKey (const Handle(OpenGl_AspectText)& theAspect, const Standard_Integer theHeight, const unsigned int theResolution) { - const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined - ? theAspect.Aspect()->GetTextFontAspect() + const Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined + ? theAspect->Aspect()->GetTextFontAspect() : Font_FA_Regular; - return theAspect.Aspect()->Font() + return theAspect->Aspect()->Font() + TCollection_AsciiString(":") + Standard_Integer(anAspect) + TCollection_AsciiString(":") + Standard_Integer(theResolution) + TCollection_AsciiString(":") + theHeight; @@ -555,7 +555,7 @@ TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect // purpose : // ======================================================================= Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theAspect, + const Handle(OpenGl_AspectText)& theAspect, const Standard_Integer theHeight, const unsigned int theResolution, const TCollection_AsciiString theKey) @@ -569,9 +569,9 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, if (!theCtx->GetResource (theKey, aFont)) { Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance(); - const TCollection_AsciiString& aFontName = theAspect.Aspect()->Font(); - Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined - ? theAspect.Aspect()->GetTextFontAspect() + const TCollection_AsciiString& aFontName = theAspect->Aspect()->Font(); + Font_FontAspect anAspect = theAspect->Aspect()->GetTextFontAspect() != Font_FA_Undefined + ? theAspect->Aspect()->GetTextFontAspect() : Font_FA_Regular; Handle(Font_FTFont) aFontFt; if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect)) @@ -585,7 +585,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, { TCollection_ExtendedString aMsg; aMsg += "Font '"; - aMsg += theAspect.Aspect()->Font(); + aMsg += theAspect->Aspect()->Font(); aMsg += "' - initialization of GL resources has failed!"; theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg); aFontFt.Nullify(); @@ -597,7 +597,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, { TCollection_ExtendedString aMsg; aMsg += "Font '"; - aMsg += theAspect.Aspect()->Font(); + aMsg += theAspect->Aspect()->Font(); aMsg += "' is broken or has incompatible format! File path: "; aMsg += aRequestedFont->FontPathAny (anAspect); theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg); @@ -609,7 +609,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, { TCollection_ExtendedString aMsg; aMsg += "Font '"; - aMsg += theAspect.Aspect()->Font(); + aMsg += theAspect->Aspect()->Font(); aMsg += "' is not found in the system!"; theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg); aFont = new OpenGl_Font (aFontFt, theKey); @@ -625,7 +625,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, // purpose : // ======================================================================= void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_Vec4& theColorSubs) const { Handle(OpenGl_ShaderProgram) aPrevProgram = theCtx->ActiveProgram(); @@ -676,7 +676,7 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx, // purpose : // ======================================================================= void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_Vec4& theColorText, const OpenGl_Vec4& theColorSubs, const unsigned int theResolution) const @@ -749,7 +749,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, myWinX, myWinY, myWinZ); // compute scale factor for constant text height - if (theTextAspect.Aspect()->GetTextZoomable()) + if (theTextAspect->Aspect()->GetTextZoomable()) { myExportHeight = aPointSize; } @@ -780,7 +780,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, // setup depth test const bool hasDepthTest = !myIs2d - && theTextAspect.Aspect()->Style() != Aspect_TOST_ANNOTATION; + && theTextAspect->Aspect()->Style() != Aspect_TOST_ANNOTATION; if (!hasDepthTest) { glDisable (GL_DEPTH_TEST); @@ -811,7 +811,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false); // extra drawings - switch (theTextAspect.Aspect()->DisplayType()) + switch (theTextAspect->Aspect()->DisplayType()) { case Aspect_TODT_BLEND: { @@ -874,7 +874,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, } #endif - if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION) + if (theTextAspect->Aspect()->DisplayType() == Aspect_TODT_DIMENSION) { glDisable (GL_BLEND); if (!myIs2d) diff --git a/src/OpenGl/OpenGl_Text.hxx b/src/OpenGl/OpenGl_Text.hxx index 09b9e5acf2..0af140c823 100755 --- a/src/OpenGl/OpenGl_Text.hxx +++ b/src/OpenGl/OpenGl_Text.hxx @@ -83,13 +83,13 @@ public: //! @name methods for compatibility with layers Standard_EXPORT OpenGl_Text(); //! Create key for shared resource - Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_AspectText& theAspect, + Standard_EXPORT static TCollection_AsciiString FontKey (const Handle(OpenGl_AspectText)& theAspect, const Standard_Integer theHeight, const unsigned int theResolution); //! Find shared resource for specified font or initialize new one Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theAspect, + const Handle(OpenGl_AspectText)& theAspect, const Standard_Integer theHeight, const unsigned int theResolution, const TCollection_AsciiString theKey); @@ -97,7 +97,7 @@ public: //! @name methods for compatibility with layers //! Compute text width Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx, const NCollection_String& theText, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_TextParam& theParams, const unsigned int theResolution, Standard_ShortReal& theWidth, @@ -112,8 +112,8 @@ public: //! @name methods for compatibility with layers //! Perform rendering Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, - const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const; + const Handle(OpenGl_AspectText)& theTextAspect, + const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const; protected: @@ -127,21 +127,21 @@ private: //! Setup matrix. void setupMatrix (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_Vec3 theDVec) const; //! Draw arrays of vertices. void drawText (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect) const; + const Handle(OpenGl_AspectText)& theTextAspect) const; //! Draw rectangle from bounding text box. void drawRect (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_Vec4& theColorSubs) const; //! Main rendering code void render (const Handle(OpenGl_Context)& theCtx, - const OpenGl_AspectText& theTextAspect, + const Handle(OpenGl_AspectText)& theTextAspect, const OpenGl_Vec4& theColorText, const OpenGl_Vec4& theColorSubs, const unsigned int theResolution) const; diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index 7cb26b309d..c8bafe1cc3 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -110,6 +110,9 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr, myRaytraceFBO1[1] = new OpenGl_FrameBuffer(); myRaytraceFBO2[0] = new OpenGl_FrameBuffer(); myRaytraceFBO2[1] = new OpenGl_FrameBuffer(); + + myGraduatedTrihedron = new OpenGl_GraduatedTrihedron(); + myFrameStatsPrs = new OpenGl_FrameStatsPrs(); } // ======================================================================= @@ -130,8 +133,8 @@ OpenGl_View::~OpenGl_View() // ======================================================================= void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx) { - myGraduatedTrihedron.Release (theCtx.operator->()); - myFrameStatsPrs.Release (theCtx.operator->()); + myGraduatedTrihedron->Release (theCtx.operator->()); + myFrameStatsPrs->Release (theCtx.operator->()); if (!myTextureEnv.IsNull()) { @@ -333,7 +336,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& myGTrihedronData = theTrihedronData; myGTrihedronData.PtrView = this; myGTrihedronData.CubicAxesCallback = SetMinMaxValuesCallback; - myGraduatedTrihedron.SetValues (myGTrihedronData); + myGraduatedTrihedron->SetValues (myGTrihedronData); myToShowGradTrihedron = true; } @@ -344,7 +347,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& void OpenGl_View::GraduatedTrihedronErase() { myGTrihedronData.PtrView = NULL; - myGraduatedTrihedron.Release (myWorkspace->GetGlContext().operator->()); + myGraduatedTrihedron->Release (myWorkspace->GetGlContext().operator->()); myToShowGradTrihedron = false; } @@ -354,7 +357,7 @@ void OpenGl_View::GraduatedTrihedronErase() // ======================================================================= void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) { - myGraduatedTrihedron.SetMinMax (theMin, theMax); + myGraduatedTrihedron->SetMinMax (theMin, theMax); } // ======================================================================= diff --git a/src/OpenGl/OpenGl_View.hxx b/src/OpenGl/OpenGl_View.hxx index 029f2a1eca..69a2820950 100644 --- a/src/OpenGl/OpenGl_View.hxx +++ b/src/OpenGl/OpenGl_View.hxx @@ -297,7 +297,7 @@ public: const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; } //! Change graduated trihedron. - OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; } + const Handle(OpenGl_GraduatedTrihedron)& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; } void SetTextureEnv (const Handle(OpenGl_Context)& theCtx, const Handle(Graphic3d_TextureEnv)& theTexture); @@ -486,8 +486,8 @@ protected: //! Is needed for selection of overlapping objects and storage of the current view volume OpenGl_BVHTreeSelector myBVHSelector; - OpenGl_GraduatedTrihedron myGraduatedTrihedron; - OpenGl_FrameStatsPrs myFrameStatsPrs; + Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron; + Handle(OpenGl_FrameStatsPrs) myFrameStatsPrs; Handle(OpenGl_TextureSet) myTextureEnv; @@ -780,7 +780,7 @@ protected: //! @name methods related to ray-tracing const Handle(OpenGl_Context)& theGlContext); //! Adds OpenGL primitive array to ray-traced scene geometry. - Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray) theArray, + Handle(OpenGl_TriangleSet) addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray, const Standard_Integer theMatID, const OpenGl_Mat4* theTrans); @@ -789,7 +789,7 @@ protected: //! @name methods related to ray-tracing const Standard_Integer theMatID, const Standard_Integer theCount, const Standard_Integer theOffset, - const OpenGl_PrimitiveArray& theArray); + const Handle(OpenGl_PrimitiveArray)& theArray); //! Adds OpenGL triangle array to ray-traced scene geometry. Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet, diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index 93e35a8580..242415f2e5 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -584,7 +584,7 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure* // function : addRaytracePrimitiveArray // purpose : Adds OpenGL primitive array to ray-traced scene geometry // ======================================================================= -Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray) theArray, +Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle(OpenGl_PrimitiveArray)& theArray, const Standard_Integer theMaterial, const OpenGl_Mat4* theTransform) { @@ -704,7 +704,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle( { const Standard_Integer aVertNum = aBounds->Bounds[aBound]; - if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, *theArray)) + if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, aBoundStart, theArray)) { aSet.Nullify(); return Handle(OpenGl_TriangleSet)(); @@ -717,7 +717,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const Handle( { const Standard_Integer aVertNum = !anIndices.IsNull() ? anIndices->NbElements : anAttribs->NbElements; - if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, *theArray)) + if (!addRaytraceVertexIndices (*aSet, theMaterial, aVertNum, 0, theArray)) { aSet.Nullify(); return Handle(OpenGl_TriangleSet)(); @@ -741,17 +741,17 @@ Standard_Boolean OpenGl_View::addRaytraceVertexIndices (OpenGl_TriangleSet& const Standard_Integer theMatID, const Standard_Integer theCount, const Standard_Integer theOffset, - const OpenGl_PrimitiveArray& theArray) + const Handle(OpenGl_PrimitiveArray)& theArray) { - switch (theArray.DrawMode()) + switch (theArray->DrawMode()) { - case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); - case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); - case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); + case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray->Indices()); + case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray->Indices()); + case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray->Indices()); #if !defined(GL_ES_VERSION_2_0) - case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); - case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); - case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); + case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray->Indices()); + case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray->Indices()); + case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray->Indices()); #endif } diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index 7acfdb795d..4229f43586 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -125,7 +125,9 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace) { aCtx->core11fwd->glDisable (GL_BLEND); - const Handle(OpenGl_AspectFace) anOldAspectFace = theWorkspace->SetAspectFace (myTextureParams); + const Handle(OpenGl_AspectFace) anOldAspectFace = theWorkspace->AspectFace(); + theWorkspace->SetAspectFace (myTextureParams); + myBgTextureArray->Render (theWorkspace); theWorkspace->SetAspectFace (anOldAspectFace); } @@ -1161,7 +1163,7 @@ void OpenGl_View::renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace) { if (myToShowGradTrihedron) { - myGraduatedTrihedron.Render (theWorkspace); + myGraduatedTrihedron->Render (theWorkspace); } } @@ -1174,8 +1176,8 @@ void OpenGl_View::renderFrameStats() if (myRenderParams.ToShowStats && myRenderParams.CollectedStats != Graphic3d_RenderingParams::PerfCounters_NONE) { - myFrameStatsPrs.Update (myWorkspace); - myFrameStatsPrs.Render (myWorkspace); + myFrameStatsPrs->Update (myWorkspace); + myFrameStatsPrs->Render (myWorkspace); } } diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 7c5abcb6b2..7aef16b969 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -253,44 +253,36 @@ Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic // function : SetAspectLine // purpose : // ======================================================================= -const Handle(OpenGl_AspectLine) OpenGl_Workspace::SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect) +void OpenGl_Workspace::SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect) { - Handle(OpenGl_AspectLine) aPrevAspectLine = myAspectLineSet; myAspectLineSet = theAspect; - return aPrevAspectLine; } // ======================================================================= // function : SetAspectFace // purpose : // ======================================================================= -const Handle(OpenGl_AspectFace) OpenGl_Workspace::SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect) +void OpenGl_Workspace::SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect) { - Handle(OpenGl_AspectFace) aPrevAspectFace = myAspectFaceSet; myAspectFaceSet = theAspect; - return aPrevAspectFace; } // ======================================================================= // function : SetAspectMarker // purpose : // ======================================================================= -const Handle(OpenGl_AspectMarker) OpenGl_Workspace::SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect) +void OpenGl_Workspace::SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect) { - Handle(OpenGl_AspectMarker) aPrevAspectMarker = myAspectMarkerSet; myAspectMarkerSet = theAspect; - return aPrevAspectMarker; } // ======================================================================= // function : SetAspectText // purpose : // ======================================================================= -const Handle(OpenGl_AspectText) OpenGl_Workspace::SetAspectText (const Handle(OpenGl_AspectText)& theAspect) +void OpenGl_Workspace::SetAspectText (const Handle(OpenGl_AspectText)& theAspect) { - Handle(OpenGl_AspectText) aPrevAspectText = myAspectTextSet; myAspectTextSet = theAspect; - return aPrevAspectText; } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index d059102195..c7c741f623 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -175,16 +175,16 @@ public: const Handle(OpenGl_AspectText)& AspectText() const { return myAspectTextSet; } //! Assign new line aspect (will be applied within ApplyAspectLine()). - Standard_EXPORT const Handle(OpenGl_AspectLine) SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect); + Standard_EXPORT void SetAspectLine (const Handle(OpenGl_AspectLine)& theAspect); //! Assign new face aspect (will be applied within ApplyAspectFace()). - Standard_EXPORT const Handle(OpenGl_AspectFace) SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect); + Standard_EXPORT void SetAspectFace (const Handle(OpenGl_AspectFace)& theAspect); //! Assign new marker aspect (will be applied within ApplyAspectMarker()). - Standard_EXPORT const Handle(OpenGl_AspectMarker) SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect); + Standard_EXPORT void SetAspectMarker (const Handle(OpenGl_AspectMarker)& theAspect); //! Assign new text aspect (will be applied within ApplyAspectText()). - Standard_EXPORT const Handle(OpenGl_AspectText) SetAspectText (const Handle(OpenGl_AspectText)& theAspect); + Standard_EXPORT void SetAspectText (const Handle(OpenGl_AspectText)& theAspect); //! Apply line aspect. //! @return aspect set by SetAspectLine() -- 2.39.5