aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
aContext->ApplyModelViewMatrix();
- thePlane->Primitives().Render (theWorkspace);
+ thePlane->Primitives()->Render (theWorkspace);
aContext->ModelWorldState.Pop();
aContext->ApplyModelViewMatrix();
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;
}
// purpose :
// =======================================================================
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
-: myPrimitives (NULL),
+: myPrimitives (new OpenGl_PrimitiveArray(NULL)),
myOrientation (OpenGl_IdentityMatrix),
myAspect (NULL),
myPlaneRoot (thePlane),
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);
}
}
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;
}
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:
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.
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();
}
// =======================================================================
// =======================================================================
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);
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;
{
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);
}
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);
}
}
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();
aCtx->VirtualViewport()[2], aCtx->VirtualViewport()[3]);
}
aCtx->ApplyModelViewMatrix();
- myCountersText.Render (theWorkspace);
+ myCountersText->Render (theWorkspace);
aCtx->WorldViewState.Pop();
}
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();
}
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:
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
};
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();
}
// =======================================================================
myAxes[0].Release (theCtx);
myAxes[1].Release (theCtx);
myAxes[2].Release (theCtx);
- myLabelValues.Release (theCtx);
+ myLabelValues->Release (theCtx);
}
// =======================================================================
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));
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());
}
// =======================================================================
// 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,
Graphic3d_TransformUtils::Translate (aMat, theXt, theYt, theZt);
aContext->WorldViewState.SetCurrent (aMat);
aContext->ApplyWorldViewMatrix();
- theLine.Render (theWorkspace);
+ theLine->Render (theWorkspace);
}
// =======================================================================
Graphic3d_TransformUtils::Translate (aMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
aContext->WorldViewState.SetCurrent (aMat);
aContext->ApplyWorldViewMatrix();
- anAxis.Line.Render (theWorkspace);
+ anAxis.Line->Render (theWorkspace);
}
}
}
{
const Axis& anAxis = myAxes[theIndex];
- theWorkspace->SetAspectLine (&anAxis.LineAspect);
+ theWorkspace->SetAspectLine (anAxis.LineAspect);
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
// Reset transformations
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;
aContext->WorldViewState.SetCurrent (aModelMat);
aContext->ApplyWorldViewMatrix();
- anAxis.Line.Render (theWorkspace);
+ anAxis.Line->Render (theWorkspace);
}
// =======================================================================
if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
{
- theWorkspace->SetAspectLine (&myGridLineAspect);
+ theWorkspace->SetAspectLine (myGridLineAspect);
OpenGl_Mat4 aModelMat (theMat);
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();
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);
}
}
}
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())
{
if (myData.ToDrawGrid())
{
- theWorkspace->SetAspectLine (&myGridLineAspect);
+ theWorkspace->SetAspectLine (myGridLineAspect);
// render grid edges
if (anAxesState & XOO_XYO)
// =======================================================================
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);
}
// =======================================================================
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;
}
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());
}
// =======================================================================
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());
}
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());
}
// =======================================================================
// =======================================================================
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);
}
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:
//! @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,
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:
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);
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)
// =======================================================================
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,
// use highlight color or colors from aspect
render (aCtx,
- *aTextAspect,
+ aTextAspect,
theWorkspace->TextColor(),
theWorkspace->TextSubtitleColor(),
aCtx->Resolution());
// 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);
}
// 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;
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
- Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
+ Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
}
else
{
else
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
- Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
+ Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect->Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
}
- if (!theTextAspect.Aspect()->GetTextZoomable())
+ if (!theTextAspect->Aspect()->GetTextZoomable())
{
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
}
// 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()
// 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;
// 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)
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))
{
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();
{
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);
{
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);
// 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();
// 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
myWinX, myWinY, myWinZ);
// compute scale factor for constant text height
- if (theTextAspect.Aspect()->GetTextZoomable())
+ if (theTextAspect->Aspect()->GetTextZoomable())
{
myExportHeight = aPointSize;
}
// 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);
const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
// extra drawings
- switch (theTextAspect.Aspect()->DisplayType())
+ switch (theTextAspect->Aspect()->DisplayType())
{
case Aspect_TODT_BLEND:
{
}
#endif
- if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
+ if (theTextAspect->Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
{
glDisable (GL_BLEND);
if (!myIs2d)
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);
//! 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,
//! 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:
//! 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;
myRaytraceFBO1[1] = new OpenGl_FrameBuffer();
myRaytraceFBO2[0] = new OpenGl_FrameBuffer();
myRaytraceFBO2[1] = new OpenGl_FrameBuffer();
+
+ myGraduatedTrihedron = new OpenGl_GraduatedTrihedron();
+ myFrameStatsPrs = new OpenGl_FrameStatsPrs();
}
// =======================================================================
// =======================================================================
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())
{
myGTrihedronData = theTrihedronData;
myGTrihedronData.PtrView = this;
myGTrihedronData.CubicAxesCallback = SetMinMaxValuesCallback;
- myGraduatedTrihedron.SetValues (myGTrihedronData);
+ myGraduatedTrihedron->SetValues (myGTrihedronData);
myToShowGradTrihedron = true;
}
void OpenGl_View::GraduatedTrihedronErase()
{
myGTrihedronData.PtrView = NULL;
- myGraduatedTrihedron.Release (myWorkspace->GetGlContext().operator->());
+ myGraduatedTrihedron->Release (myWorkspace->GetGlContext().operator->());
myToShowGradTrihedron = false;
}
// =======================================================================
void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax)
{
- myGraduatedTrihedron.SetMinMax (theMin, theMax);
+ myGraduatedTrihedron->SetMinMax (theMin, theMax);
}
// =======================================================================
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);
//! 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;
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);
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,
// 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)
{
{
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)();
{
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)();
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
}
{
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);
}
{
if (myToShowGradTrihedron)
{
- myGraduatedTrihedron.Render (theWorkspace);
+ myGraduatedTrihedron->Render (theWorkspace);
}
}
if (myRenderParams.ToShowStats
&& myRenderParams.CollectedStats != Graphic3d_RenderingParams::PerfCounters_NONE)
{
- myFrameStatsPrs.Update (myWorkspace);
- myFrameStatsPrs.Render (myWorkspace);
+ myFrameStatsPrs->Update (myWorkspace);
+ myFrameStatsPrs->Render (myWorkspace);
}
}
// 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;
}
// =======================================================================
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()