#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_GraphicDriver.hxx>
+#include <Graphic3d_TransformUtils.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Workspace.hxx>
#include <Precision.hxx>
// =======================================================================
void OpenGl_Trihedron::resetTransformations (const Handle(OpenGl_Workspace)& theWorkspace) const
{
- const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
- const Handle(OpenGl_View)& aView = theWorkspace->ActiveView();
- GLdouble anU = 1.0;
- GLdouble aV = 1.0;
- if (aView->Height() < aView->Width())
+ const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+ const Handle(Graphic3d_Camera)& aCamera = theWorkspace->View()->Camera();
+ double anU = 1.0;
+ double aV = 1.0;
+ if (aCamera->ViewDimensions().X() < aCamera->ViewDimensions().Y())
{
- aV = aView->Width() / aView->Height();
+ aV = aCamera->ViewDimensions().Y() / aCamera->ViewDimensions().X();
}
else
{
- anU = aView->Height() / aView->Width();
+ anU = aCamera->ViewDimensions().X() / aCamera->ViewDimensions().Y();
}
// Reading the transformation matrices and projection of sight
{
case Aspect_TOTP_LEFT_LOWER:
{
- OpenGl_Utils::Translate (aProjMatrix,
+ Graphic3d_TransformUtils::Translate (aProjMatrix,
-0.5 * anU + myScale, -0.5 * aV + myScale, 0.0);
break;
}
case Aspect_TOTP_LEFT_UPPER:
{
- OpenGl_Utils::Translate (aProjMatrix,
+ Graphic3d_TransformUtils::Translate (aProjMatrix,
-0.5 * anU + myScale, 0.5 * aV - myScale - myScale / 3.0, 0.0);
break;
}
case Aspect_TOTP_RIGHT_LOWER:
{
- OpenGl_Utils::Translate (aProjMatrix,
+ Graphic3d_TransformUtils::Translate (aProjMatrix,
0.5 * anU - myScale - myScale / 3.0, -0.5 * aV + myScale, 0.0);
break;
}
case Aspect_TOTP_RIGHT_UPPER:
{
- OpenGl_Utils::Translate (aProjMatrix,
+ Graphic3d_TransformUtils::Translate (aProjMatrix,
0.5 * anU - myScale - myScale / 3.0, 0.5 * aV - myScale - myScale / 3.0, 0.0);
break;
}
OpenGl_AspectFace anAspectY;
OpenGl_AspectFace anAspectZ;
OpenGl_AspectLine anAspectLine;
- memcpy (anAspectX.ChangeIntFront().matcol.rgb, myXColor.GetData(), sizeof (TEL_COLOUR));
- memcpy (anAspectY.ChangeIntFront().matcol.rgb, myYColor.GetData(), sizeof (TEL_COLOUR));
- memcpy (anAspectZ.ChangeIntFront().matcol.rgb, myZColor.GetData(), sizeof (TEL_COLOUR));
+ anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb()));
+ anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb()));
+ anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb()));
+
OpenGl_Mat4d aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
OpenGl_Mat4d aModelViewX (aModelMatrix);
OpenGl_Mat4d aModelViewZ (aModelMatrix);
// Set line aspect
- const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->AspectLine (Standard_True);
- CALL_DEF_CONTEXTLINE aLineAspect = {1, 1, { 1.F, 1.F, 1.F }, aCurrentAspectLine->Type(), aCurrentAspectLine->Width()};
- aLineAspect.Color.r = myZColor.r();
- aLineAspect.Color.g = myZColor.g();
- aLineAspect.Color.b = myZColor.b();
- anAspectLine.SetAspect (aLineAspect);
+ const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->ApplyAspectLine();
+ Handle(Graphic3d_AspectLine3d) anAspectLine3d = new Graphic3d_AspectLine3d (Quantity_Color(), aCurrentAspectLine->Aspect()->Type(), aCurrentAspectLine->Aspect()->Width());
+ anAspectLine.SetAspect (anAspectLine3d);
// Disable depth test and face culling
GLboolean wasDepthMaskEnabled = GL_FALSE;
// Z axis
const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace(&anAspectZ);
+ anAspectLine3d->SetColor (Quantity_Color (myZColor.rgb()));
theWorkspace->SetAspectLine (&anAspectLine);
myLine.Render (theWorkspace);
- OpenGl_Utils::Translate (aModelViewZ, 0.0, 0.0, aLineLength);
+ Graphic3d_TransformUtils::Translate (aModelViewZ, 0.0, 0.0, aLineLength);
aContext->WorldViewState.SetCurrent<Standard_Real>(aModelViewZ);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
// X axis
theWorkspace->SetAspectFace (&anAspectX);
- OpenGl_Utils::Rotate (aModelViewX, 90.0, 0.0, aScale, 0.0);
+ Graphic3d_TransformUtils::Rotate (aModelViewX, 90.0, 0.0, aScale, 0.0);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
- aLineAspect.Color.r = myXColor.r();
- aLineAspect.Color.g = myXColor.g();
- aLineAspect.Color.b = myXColor.b();
- anAspectLine.SetAspect (aLineAspect);
+ anAspectLine3d->SetColor (Quantity_Color (myXColor.rgb()));
theWorkspace->SetAspectLine (&anAspectLine);
myLine.Render (theWorkspace);
- OpenGl_Utils::Translate (aModelViewX, 0.0, 0.0, aLineLength);
+ Graphic3d_TransformUtils::Translate (aModelViewX, 0.0, 0.0, aLineLength);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
// Y axis
theWorkspace->SetAspectFace (&anAspectY);
- OpenGl_Utils::Rotate (aModelViewY, -90.0, aScale, 0.0, 0.0);
+ Graphic3d_TransformUtils::Rotate (aModelViewY, -90.0, aScale, 0.0, 0.0);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
- aLineAspect.Color.r = myYColor.r();
- aLineAspect.Color.g = myYColor.g();
- aLineAspect.Color.b = myYColor.b();
- anAspectLine.SetAspect (aLineAspect);
+ anAspectLine3d->SetColor (Quantity_Color (myYColor.rgb()));
theWorkspace->SetAspectLine (&anAspectLine);
myLine.Render (theWorkspace);
- OpenGl_Utils::Translate (aModelViewY, 0.0, 0.0, aLineLength);
+ Graphic3d_TransformUtils::Translate (aModelViewY, 0.0, 0.0, aLineLength);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
const GLdouble aScale = myScale * myRatio;
- const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
- const TEL_COLOUR& aLineColor = anAspectLine->Color();
+ const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
+ const OpenGl_Vec4& aLineColor = anAspectLine->Aspect()->ColorRGBA();
// Create the trihedron
const Standard_Real THE_CYLINDER_LENGTH = 0.75;
OpenGl_AspectFace anAspectX;
OpenGl_AspectFace anAspectY;
OpenGl_AspectFace anAspectZ;
- memcpy (anAspectX.ChangeIntFront().matcol.rgb, myXColor.GetData(), sizeof (TEL_COLOUR));
- memcpy (anAspectY.ChangeIntFront().matcol.rgb, myYColor.GetData(), sizeof (TEL_COLOUR));
- memcpy (anAspectZ.ChangeIntFront().matcol.rgb, myZColor.GetData(), sizeof (TEL_COLOUR));
- memcpy (anAspectC.ChangeIntFront().matcol.rgb, aLineColor.rgb, sizeof (TEL_COLOUR));
+ anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb()));
+ anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb()));
+ anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb()));
+ anAspectC.Aspect()->SetInteriorColor (Quantity_Color (aLineColor.rgb()));
OpenGl_Mat4d aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
// Z axis
theWorkspace->SetAspectFace (&anAspectZ);
myCylinder.Render (theWorkspace);
- OpenGl_Utils::Translate (aModelViewZ, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
+ Graphic3d_TransformUtils::Translate (aModelViewZ, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewZ);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
// X axis
theWorkspace->SetAspectFace (&anAspectX);
- OpenGl_Utils::Rotate (aModelViewX, 90.0, aTriedronAxeY[0], aTriedronAxeY[1], aTriedronAxeY[2]);
+ Graphic3d_TransformUtils::Rotate (aModelViewX, 90.0, aTriedronAxeY[0], aTriedronAxeY[1], aTriedronAxeY[2]);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
myCylinder.Render (theWorkspace);
- OpenGl_Utils::Translate (aModelViewX, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
+ Graphic3d_TransformUtils::Translate (aModelViewX, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
// Y axis
theWorkspace->SetAspectFace (&anAspectY);
- OpenGl_Utils::Rotate (aModelViewY, -90.0, aTriedronAxeX[0], aTriedronAxeX[1], aTriedronAxeX[2]);
+ Graphic3d_TransformUtils::Rotate (aModelViewY, -90.0, aTriedronAxeX[0], aTriedronAxeX[1], aTriedronAxeX[2]);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
myCylinder.Render (theWorkspace);
- OpenGl_Utils::Translate (aModelViewY, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
+ Graphic3d_TransformUtils::Translate (aModelViewY, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
aContext->ApplyWorldViewMatrix();
myDisk.Render (theWorkspace);
myLine (NULL), // do not register arrays UID - trihedron is not intended to be drawn by Ray Tracing engine
myCircle (NULL)
{
- const TEL_COLOUR aWhiteColor = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
- myAspectLine.ChangeColor() = aWhiteColor;
- myAspectText.ChangeColor() = aWhiteColor;
- myAspectText.ChangeFontName() = "Courier";
+ myAspectLine.SetAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
+ myAspectText.Aspect()->SetColor (Quantity_NOC_WHITE);
+ myAspectText.Aspect()->SetFont ("Courier");
}
// =======================================================================
// =======================================================================
void OpenGl_Trihedron::SetLabelsColor (const Quantity_Color& theColor)
{
- myAspectText.ChangeColor().rgb[0] = float(theColor.Red());
- myAspectText.ChangeColor().rgb[1] = float(theColor.Green());
- myAspectText.ChangeColor().rgb[2] = float(theColor.Blue());
+ myAspectText.Aspect()->SetColor (theColor);
}
// =======================================================================
}
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
- theWorkspace->ActiveView()->EndTransformPersistence (theWorkspace->GetGlContext());
+
theWorkspace->GetGlContext()->ApplyModelViewMatrix();
if (myIsWireframe)