// commercial license or contractual agreement.
#include <OpenGl_GlCore11.hxx>
-#include <OpenGl_Utils.hxx>
-#include <InterfaceGraphic_Graphic3d.hxx>
-#include <InterfaceGraphic_Aspect.hxx>
-#include <InterfaceGraphic_Visual3d.hxx>
-
-#ifndef _WIN32
- #include <string.h>
-#endif
#include <OpenGl_GraduatedTrihedron.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
+#include <Graphic3d_TransformPers.hxx>
+#include <Graphic3d_TransformUtils.hxx>
#include <gp_Ax3.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_Utils.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_View.hxx>
-#include <OpenGl_Cylinder.hxx>
#include <Precision.hxx>
+#ifndef _WIN32
+ #include <string.h>
+#endif
+
+namespace
+{
+ static const OpenGl_TextParam THE_LABEL_PARAMS =
+ {
+ 16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
+ };
+}
+
// =======================================================================
// function : Constructor
// purpose :
// =======================================================================
-OpenGl_GraduatedTrihedron::OpenGl_GraduatedTrihedron (const Graphic3d_GraduatedTrihedron& theData)
+OpenGl_GraduatedTrihedron::OpenGl_GraduatedTrihedron()
: myMin (0.0f, 0.0f, 0.0f),
myMax (100.0f, 100.0f, 100.0f),
- myData (theData)
+ myIsInitialized (Standard_False)
{
- // Initialize text label parameters for x, y, and z axes
- myAxes[0] = Axis (myData.XAxisAspect(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
- myAxes[1] = Axis (myData.YAxisAspect(), OpenGl_Vec3 (0.0f, 1.0f, 0.0f));
- myAxes[2] = Axis (myData.ZAxisAspect(), OpenGl_Vec3 (0.0f, 0.0f, 1.0f));
-
- // Initialize constant primitives: text, arrows.
-
- myAxes[0].InitArrow (NULL, myData.ArrowLength(), OpenGl_Vec3 (0.0f, 0.0f, 1.0f));
-
- myAxes[1].InitArrow (NULL, myData.ArrowLength(), OpenGl_Vec3 (0.0f, 0.0f, 1.0f));
-
- myAxes[2].InitArrow (NULL, myData.ArrowLength(), OpenGl_Vec3 (1.0f, 0.0f, 0.0f));
-
- for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
- {
- myAxes[anIt].Label.SetFontSize (NULL, theData.NamesSize());
- }
-
- myLabelValues.SetFontSize (NULL, theData.ValuesSize());
-
- myAspectLabels.SetFontAspect (theData.NamesFontAspect());
- myAspectLabels.ChangeFontName() = theData.NamesFont();
-
- myAspectValues.SetFontAspect (theData.ValuesFontAspect());
- myAspectValues.ChangeFontName() = theData.ValuesFont();
+ //
+}
- // Grid aspect
- Graphic3d_CAspectLine anAspect;
- anAspect.IsDef = 1;
- anAspect.IsSet = 1;
- anAspect.Width = 1.0f;
- anAspect.LineType = Aspect_TOL_SOLID;
- anAspect.Color.r = (Standard_ShortReal) theData.GridColor().Red();
- anAspect.Color.g = (Standard_ShortReal) theData.GridColor().Green();
- anAspect.Color.b = (Standard_ShortReal) theData.GridColor().Blue();
- myGridLineAspect.SetAspect (anAspect);
+// =======================================================================
+// function : SetValues
+// purpose :
+// =======================================================================
+void OpenGl_GraduatedTrihedron::SetValues (const Graphic3d_GraduatedTrihedron& theData)
+{
+ myData = theData;
+ myIsInitialized = Standard_False;
}
// =======================================================================
myLabelValues.Release (theCtx);
}
+// =======================================================================
+// function : initResources
+// purpose :
+// =======================================================================
+void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& theCtx) const
+{
+ myAxes[0].Release (theCtx.operator->());
+ myAxes[1].Release (theCtx.operator->());
+ myAxes[2].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[1] = Axis (myData.YAxisAspect(), OpenGl_Vec3 (0.0f, 1.0f, 0.0f));
+ myAxes[2] = Axis (myData.ZAxisAspect(), OpenGl_Vec3 (0.0f, 0.0f, 1.0f));
+
+ // Initialize constant primitives: text, arrows.
+ myAxes[0].InitArrow (theCtx, myData.ArrowsLength(), OpenGl_Vec3 (0.0f, 0.0f, 1.0f));
+ myAxes[1].InitArrow (theCtx, myData.ArrowsLength(), OpenGl_Vec3 (0.0f, 0.0f, 1.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());
+ }
+
+ myLabelValues.SetFontSize (theCtx, myData.ValuesSize());
+
+ myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect());
+ myAspectLabels.Aspect()->SetTextFont (!myData.NamesFont().IsEmpty()
+ ? new TCollection_HAsciiString (myData.NamesFont())
+ : Handle(TCollection_HAsciiString )());
+
+ myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
+ myAspectValues.Aspect()->SetTextFont (!myData.ValuesFont().IsEmpty()
+ ? new TCollection_HAsciiString (myData.ValuesFont())
+ : Handle(TCollection_HAsciiString )());
+
+ // Grid aspect
+ myGridLineAspect.Aspect()->SetColor (myData.GridColor());
+}
+
// =======================================================================
// method : getNormal
// purpose : Normal of the view (not normalized!)
Standard_ShortReal OpenGl_GraduatedTrihedron::getNormal (const Handle(OpenGl_Context)& theContext,
OpenGl_Vec3& theNormal) const
{
- GLint aViewport[4] = {};
- glGetIntegerv(GL_VIEWPORT, aViewport);
+ const Standard_Integer* aViewport = theContext->Viewport();
OpenGl_Mat4 aModelMatrix;
OpenGl_Mat4 aProjMatrix;
aProjMatrix .Convert (theContext->ProjectionState.Current());
OpenGl_Vec3 aPoint1, aPoint2, aPoint3;
- OpenGl_Utils::UnProject<Standard_ShortReal> ((Standard_ShortReal) aViewport[0],
- (Standard_ShortReal) aViewport[1],
- 0.0f,
- aModelMatrix, aProjMatrix, aViewport,
- aPoint1.x(), aPoint1.y(), aPoint1.z());
-
- OpenGl_Utils::UnProject<Standard_ShortReal> ((Standard_ShortReal) (aViewport[0] + aViewport[2]),
- (Standard_ShortReal) aViewport[1],
- 0.0f,
- aModelMatrix, aProjMatrix, aViewport,
- aPoint2.x(), aPoint2.y(), aPoint2.z());
-
- OpenGl_Utils::UnProject<Standard_ShortReal> ((Standard_ShortReal) aViewport[0],
- (Standard_ShortReal) (aViewport[1] + aViewport[3]),
- 0.0f,
- aModelMatrix, aProjMatrix, aViewport,
- aPoint3.x(), aPoint3.y(), aPoint3.z());
+ Graphic3d_TransformUtils::UnProject<Standard_ShortReal> ((Standard_ShortReal) aViewport[0],
+ (Standard_ShortReal) aViewport[1],
+ 0.0f,
+ aModelMatrix, aProjMatrix, aViewport,
+ aPoint1.x(), aPoint1.y(), aPoint1.z());
+
+ Graphic3d_TransformUtils::UnProject<Standard_ShortReal> ((Standard_ShortReal) (aViewport[0] + aViewport[2]),
+ (Standard_ShortReal) aViewport[1],
+ 0.0f,
+ aModelMatrix, aProjMatrix, aViewport,
+ aPoint2.x(), aPoint2.y(), aPoint2.z());
+
+ Graphic3d_TransformUtils::UnProject<Standard_ShortReal> ((Standard_ShortReal) aViewport[0],
+ (Standard_ShortReal) (aViewport[1] + aViewport[3]),
+ 0.0f,
+ aModelMatrix, aProjMatrix, aViewport,
+ aPoint3.x(), aPoint3.y(), aPoint3.z());
const OpenGl_Vec3 aD1 = aPoint3 - aPoint1;
const OpenGl_Vec3 aD2 = aPoint2 - aPoint1;
// function : renderLine
// purpose :
// =======================================================================
-void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray* theLine,
+void OpenGl_GraduatedTrihedron::renderLine (const OpenGl_PrimitiveArray& theLine,
const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Mat4& theMat,
const Standard_ShortReal theXt,
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
OpenGl_Mat4 aMat (theMat);
- OpenGl_Utils::Translate (aMat, theXt, theYt, theZt);
+ Graphic3d_TransformUtils::Translate (aMat, theXt, theYt, theZt);
aContext->WorldViewState.SetCurrent (aMat);
aContext->ApplyWorldViewMatrix();
- theLine->Render (theWorkspace);
+ theLine.Render (theWorkspace);
}
// =======================================================================
OpenGl_Mat4& theMat) const
{
const Graphic3d_AxisAspect& aCurAspect = myData.AxisAspect (theIndex);
- if (aCurAspect.TickmarkNumber() <= 0)
+ if (aCurAspect.TickmarksNumber() <= 0)
{
return;
}
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
Standard_ShortReal aStep = theGridAxes.Axes[theIndex].GetData()[theIndex]
- * (myMax.GetData()[theIndex] - myMin.GetData()[theIndex]) / aCurAspect.TickmarkNumber();
+ * (myMax.GetData()[theIndex] - myMin.GetData()[theIndex]) / aCurAspect.TickmarksNumber();
// NOTE:
- // Get two other axes directions and draw lines Axis.TickmarkNumber times.
+ // Get two other axes directions and draw lines Axis.TickmarksNumber times.
// Combining together from three axes, these lines will make a grid.
for (Standard_Integer anIter = 1; anIter <= 2; ++anIter)
{
aStart.ChangeData()[anIndex] = myMin.GetData()[anIndex];
}
- OpenGl_Utils::Translate (aMat, aStart.x(), aStart.y(), aStart.z());
+ Graphic3d_TransformUtils::Translate (aMat, aStart.x(), aStart.y(), aStart.z());
aContext->WorldViewState.SetCurrent (aMat);
aContext->ApplyWorldViewMatrix();
const OpenGl_Vec3 aStepVec (myAxes[theIndex].Direction * aStep);
- for (Standard_Integer anIt = myData.ToDrawAxes() ? 1 : 0; anIt < aCurAspect.TickmarkNumber(); ++anIt)
+ for (Standard_Integer anIt = myData.ToDrawAxes() ? 1 : 0; anIt < aCurAspect.TickmarksNumber(); ++anIt)
{
- OpenGl_Utils::Translate (aMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
+ 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->SetAspects (&anAxis.LineAspect);
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
// Reset transformations
aContext->ApplyWorldViewMatrix();
// Render arrow
-
- TEL_TRANSFORM_PERSISTENCE aTransMode;
- aTransMode.mode = Graphic3d_TMF_ZoomPers;
OpenGl_Vec3 anArrowVec = myMin + anAxis.Direction * (myMax - myMin);
- aTransMode.pointX = anArrowVec.x();
- aTransMode.pointY = anArrowVec.y();
- aTransMode.pointZ = anArrowVec.z();
- theWorkspace->ActiveView()->BeginTransformPersistence (aContext, &aTransMode);
+ Graphic3d_TransformPers aTransMode (Graphic3d_TMF_ZoomPers, gp_Pnt (Standard_Real(anArrowVec.x()),
+ Standard_Real(anArrowVec.y()),
+ Standard_Real(anArrowVec.z())));
+ const OpenGl_Mat4& aProjection = aContext->ProjectionState.Current();
+ const OpenGl_Mat4& aWorldView = aContext->WorldViewState.Current();
+ const Standard_Integer aWidth = theWorkspace->Width();
+ const Standard_Integer aHeight = theWorkspace->Height();
- // NOTE:
- // OpenGl_View applies Transform Persistence only in Projection Matrix.
// Take into account Transform Persistence
+ aContext->ModelWorldState.SetCurrent (aTransMode.Compute (theWorkspace->View()->Camera(), aProjection, aWorldView, aWidth, aHeight));
aContext->ApplyModelViewMatrix();
+ anAxis.Arrow.Render (theWorkspace);
+
// Get current Model-View and Projection states
OpenGl_Mat4 aModelMat;
OpenGl_Mat4 aProjMat;
- GLint aViewport[4];
- aContext->core11fwd->glGetIntegerv (GL_VIEWPORT, aViewport);
- aModelMat.Convert (aContext->ModelWorldState.Current() * aContext->WorldViewState.Current());
+ aModelMat.Convert (aContext->WorldViewState.Current() * aContext->ModelWorldState.Current());
aProjMat .Convert (aContext->ProjectionState.Current());
- // Get the window's (fixed) coordinates for before matrixes modifications
- OpenGl_Vec3 aEndPoint = -anAxis.Direction * myData.ArrowLength();
+ // Get the window's (fixed) coordinates for before matrices modifications
+ OpenGl_Vec3 aEndPoint = -anAxis.Direction * myData.ArrowsLength();
OpenGl_Vec3 aWinPoint;
- OpenGl_Utils::Project<Standard_ShortReal> (aEndPoint.x(), aEndPoint.y(), aEndPoint.z(),
- aModelMat, aProjMat, aViewport,
- aWinPoint.x(), aWinPoint.y(), aWinPoint.z());
- anAxis.Arrow->Render (theWorkspace);
- theWorkspace->ActiveView()->EndTransformPersistence (aContext);
-
- // Get current Model-View and Projection states after the end of Transform Persistence
- aModelMat.Convert (aContext->ModelWorldState.Current() * aContext->WorldViewState.Current());
+ Graphic3d_TransformUtils::Project<Standard_ShortReal> (aEndPoint.x(), aEndPoint.y(), aEndPoint.z(),
+ aModelMat, aProjMat, aContext->Viewport(),
+ aWinPoint.x(), aWinPoint.y(), aWinPoint.z());
+
+ aContext->ModelWorldState.SetIdentity();
+ aModelMat.Convert (aContext->WorldViewState.Current());
aProjMat .Convert (aContext->ProjectionState.Current());
// Get start point of zoom persistent arrow
OpenGl_Vec3 anArrowStart;
- OpenGl_Utils::UnProject<Standard_ShortReal> (aWinPoint.x(), aWinPoint.y(), aWinPoint.z(),
- aModelMat, aProjMat, aViewport,
- anArrowStart.x(), anArrowStart.y(), anArrowStart.z());
+ Graphic3d_TransformUtils::UnProject<Standard_ShortReal> (aWinPoint.x(), aWinPoint.y(), aWinPoint.z(),
+ aModelMat, aProjMat, aContext->Viewport(),
+ anArrowStart.x(), anArrowStart.y(), anArrowStart.z());
// Render axis line
-
aModelMat = theMat;
- OpenGl_Utils::Translate (aModelMat, myMin.x(), myMin.y(), myMin.z());
+ Graphic3d_TransformUtils::Translate (aModelMat, myMin.x(), myMin.y(), myMin.z());
Standard_ShortReal aScaleFactor = ( (anArrowStart - myMin)*anAxis.Direction ).Modulus()
/ (anAxis.Direction * (myMax - myMin) ).Modulus();
OpenGl_Vec3 aScaleAxes = anAxis.Direction * aScaleFactor;
- OpenGl_Utils::Scale (aModelMat, aScaleAxes.x(), aScaleAxes.y(), aScaleAxes.z());
+ Graphic3d_TransformUtils::Scale (aModelMat, aScaleAxes.x(), aScaleAxes.y(), aScaleAxes.z());
aContext->WorldViewState.SetCurrent (aModelMat);
aContext->ApplyWorldViewMatrix();
- anAxis.Line->Render (theWorkspace);
+ anAxis.Line.Render (theWorkspace);
}
// =======================================================================
const Axis& anAxis = myAxes[theIndex];
const OpenGl_Vec3 aSizeVec (myMax - myMin);
Standard_ShortReal aStep = theGridAxes.Axes[theIndex].GetData()[theIndex]
- * (myMax.GetData()[theIndex] - myMin.GetData()[theIndex]) / aCurAspect.TickmarkNumber();
+ * (myMax.GetData()[theIndex] - myMin.GetData()[theIndex]) / aCurAspect.TickmarksNumber();
OpenGl_Vec3 aDir = (theGridAxes.Ticks[theIndex] - theGridAxes.Origin).Normalized();
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
- if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarkNumber() > 0)
+ if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
{
- theWorkspace->SetAspectLine (&myGridLineAspect);
+ theWorkspace->SetAspects (&myGridLineAspect);
OpenGl_Mat4 aModelMat (theMat);
- anAxis.InitTickmark (aContext, aDir * (Standard_ShortReal) aCurAspect.TickmarkLength() * theDpix);
- OpenGl_Utils::Translate (aModelMat, theGridAxes.Ticks[theIndex].x(),
- theGridAxes.Ticks[theIndex].y(),
- theGridAxes.Ticks[theIndex].z());
+ anAxis.InitTickmark (aContext, aDir * (Standard_ShortReal) aCurAspect.TickmarksLength() * theDpix);
+ Graphic3d_TransformUtils::Translate (aModelMat, theGridAxes.Ticks[theIndex].x(),
+ theGridAxes.Ticks[theIndex].y(),
+ theGridAxes.Ticks[theIndex].z());
aContext->WorldViewState.SetCurrent (aModelMat);
aContext->ApplyWorldViewMatrix();
OpenGl_Vec3 aStepVec = anAxis.Direction * aStep;
- for (Standard_Integer anIter = 0; anIter <= aCurAspect.TickmarkNumber(); ++anIter)
+ for (Standard_Integer anIter = 0; anIter <= aCurAspect.TickmarksNumber(); ++anIter)
{
- anAxis.Tickmark->Render (theWorkspace);
- OpenGl_Utils::Translate (aModelMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
+ anAxis.Tickmark.Render (theWorkspace);
+ Graphic3d_TransformUtils::Translate (aModelMat, aStepVec.x(), aStepVec.y(), aStepVec.z());
aContext->WorldViewState.SetCurrent (aModelMat);
aContext->ApplyWorldViewMatrix();
}
if (aCurAspect.ToDrawName())
{
- Standard_Real anOffset = aCurAspect.NameOffset() + aCurAspect.TickmarkLength();
+ Standard_Real anOffset = aCurAspect.NameOffset() + aCurAspect.TickmarksLength();
OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset));
- myAspectLabels.ChangeColor() = anAxis.NameColor;
- theWorkspace->SetAspectText (&myAspectLabels);
+ myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
+ theWorkspace->SetAspects (&myAspectLabels);
anAxis.Label.SetPosition (aMiddle);
anAxis.Label.Render (theWorkspace);
}
- if (aCurAspect.ToDrawValues() && aCurAspect.TickmarkNumber() > 0)
+ if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0)
{
- myAspectValues.ChangeColor() = anAxis.LineAspect.Color();
- theWorkspace->SetAspectText (&myAspectValues);
- Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarkLength();
+ myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color());
+ theWorkspace->SetAspects (&myAspectValues);
+ Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength();
- for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarkNumber(); ++anIt)
+ 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));
void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+ if (!myIsInitialized)
+ {
+ initGlResources (theWorkspace->GetGlContext());
+ myIsInitialized = Standard_True;
+ }
// Update boundary box
OpenGl_Vec3 anOldMin = myMin;
if (myData.CubicAxesCallback)
{
- myData.CubicAxesCallback (myData.PtrVisual3dView);
- if (myAxes[0].Line == NULL || myAxes[1].Line == NULL || myAxes[2].Line == NULL
- || OpenGl_Vec3 (anOldMin - myMin).Modulus() > Precision::Confusion()
- || OpenGl_Vec3 (anOldMax - myMax).Modulus() > Precision::Confusion())
+ myData.CubicAxesCallback (myData.PtrView);
+ 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())
{
- myAxes[0].InitLine (aContext, OpenGl_Vec3 (myMax.x() - myMin.x(), 0.0f, 0.0f));
- myAxes[1].InitLine (aContext, OpenGl_Vec3 (0.0f, myMax.y() - myMin.y(), 0.0f));
- myAxes[2].InitLine (aContext, OpenGl_Vec3 (0.0f, 0.0f, myMax.z() - myMin.z()));
+ myAxes[0].InitLine (aContext, OpenGl_Vec3 (myMax.x() - myMin.x(), 0.0f, 0.0f));
+ myAxes[1].InitLine (aContext, OpenGl_Vec3 (0.0f, myMax.y() - myMin.y(), 0.0f));
+ myAxes[2].InitLine (aContext, OpenGl_Vec3 (0.0f, 0.0f, myMax.z() - myMin.z()));
}
}
Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
// Remember current aspects
- const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine (Standard_False);
- const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText (Standard_False);
+ const OpenGl_Aspects* anOldAspectLine = theWorkspace->Aspects();
OpenGl_Mat4 aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
if (myData.ToDrawGrid())
{
- theWorkspace->SetAspectLine (&myGridLineAspect);
+ theWorkspace->SetAspects (&myGridLineAspect);
// render grid edges
if (anAxesState & XOO_XYO)
renderTickmarkLabels (theWorkspace, aModelMatrix, anIter, aGridAxes, aDpix);
}
- theWorkspace->SetAspectLine (anOldAspectLine);
- theWorkspace->SetAspectText (anOldAspectText);
+ theWorkspace->SetAspects (anOldAspectLine);
aContext->WorldViewState.Pop();
aContext->ApplyWorldViewMatrix();
// =======================================================================
// method : OpenGl_GraduatedTrihedron::Axis constructor
-// purpose :
+// purpose :
// =======================================================================
OpenGl_GraduatedTrihedron::Axis::Axis (const Graphic3d_AxisAspect& theAspect,
- const OpenGl_Vec3& theDirection)
+ const OpenGl_Vec3& theDirection)
: Direction (theDirection),
- Label (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(),
- Direction, THE_LABEL_PARAMS)
+ Label (NCollection_String ((Standard_Utf16Char* )theAspect.Name().ToExtString()).ToCString(), theDirection, THE_LABEL_PARAMS),
+ Tickmark (NULL),
+ Line (NULL),
+ Arrow (NULL)
{
- NameColor.rgb[0] = (Standard_ShortReal) theAspect.NameColor().Red();
- NameColor.rgb[1] = (Standard_ShortReal) theAspect.NameColor().Green();
- NameColor.rgb[2] = (Standard_ShortReal) theAspect.NameColor().Blue();
- NameColor.rgb[3] = 1.0f;
-
- // Fill aspect
- Graphic3d_CAspectLine anAspect;
- anAspect.IsDef = 1;
- anAspect.IsSet = 1;
- anAspect.Width = 1.0f;
- anAspect.LineType = Aspect_TOL_SOLID;
- anAspect.Color.r = (Standard_ShortReal) theAspect.Color().Red();
- anAspect.Color.g = (Standard_ShortReal) theAspect.Color().Green();
- anAspect.Color.b = (Standard_ShortReal) theAspect.Color().Blue();
- LineAspect.SetAspect (anAspect);
-
- // Create primitives
- Line = new OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_SEGMENTS, NULL, NULL, NULL);
- Tickmark = new OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_SEGMENTS, NULL, NULL, NULL);
- Arrow = new OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_POLYLINES, NULL, NULL, NULL);
+ NameColor = theAspect.NameColor();
+ LineAspect.Aspect()->SetColor (theAspect.Color());
}
// =======================================================================
-// method : OpenGl_GraduatedTrihedron::Axis operator =
-// purpose :
+// method : OpenGl_GraduatedTrihedron::Axis::~Axis
+// purpose :
// =======================================================================
-OpenGl_GraduatedTrihedron::Axis&
- OpenGl_GraduatedTrihedron::Axis::operator= (const Axis& theOther)
+OpenGl_GraduatedTrihedron::Axis::~Axis()
{
- Direction = theOther.Direction;
- NameColor = theOther.NameColor;
+ //
+}
+
+// =======================================================================
+// method : OpenGl_GraduatedTrihedron::Axis operator=
+// purpose :
+// =======================================================================
+OpenGl_GraduatedTrihedron::Axis& OpenGl_GraduatedTrihedron::Axis::operator= (const Axis& theOther)
+{
+ Direction = theOther.Direction;
+ NameColor = theOther.NameColor;
LineAspect = theOther.LineAspect;
- Label = theOther.Label;
+ 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;
}
// =======================================================================
// method : InitArrow
-// purpose :
+// purpose :
// =======================================================================
void OpenGl_GraduatedTrihedron::Axis::InitArrow (const Handle(OpenGl_Context)& theContext,
const Standard_ShortReal theLength,
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);
}