mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
df9377619e | ||
|
f6d3cadd89 |
@@ -27,6 +27,8 @@
|
|||||||
#include <V3d_Viewer.hxx>
|
#include <V3d_Viewer.hxx>
|
||||||
#include <WNT_HIDSpaceMouse.hxx>
|
#include <WNT_HIDSpaceMouse.hxx>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : AIS_ViewController
|
// function : AIS_ViewController
|
||||||
// purpose :
|
// purpose :
|
||||||
@@ -2246,6 +2248,12 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
|
|||||||
myGL.Orientation.ToFitAll = false;
|
myGL.Orientation.ToFitAll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (theView->Viewer()->Grid()->IsActive()
|
||||||
|
&& theView->Viewer()->GridEcho())
|
||||||
|
{
|
||||||
|
theView->Viewer()->Grid()->Update();
|
||||||
|
}
|
||||||
|
|
||||||
if (myGL.IsNewGesture)
|
if (myGL.IsNewGesture)
|
||||||
{
|
{
|
||||||
if (myAnchorPointPrs1->HasInteractiveContext())
|
if (myAnchorPointPrs1->HasInteractiveContext())
|
||||||
|
@@ -87,6 +87,9 @@ public:
|
|||||||
//! Display the grid at screen.
|
//! Display the grid at screen.
|
||||||
Standard_EXPORT virtual void Display() = 0;
|
Standard_EXPORT virtual void Display() = 0;
|
||||||
|
|
||||||
|
//!
|
||||||
|
Standard_EXPORT virtual void Update() = 0;
|
||||||
|
|
||||||
//! Erase the grid from screen.
|
//! Erase the grid from screen.
|
||||||
Standard_EXPORT virtual void Erase() const = 0;
|
Standard_EXPORT virtual void Erase() const = 0;
|
||||||
|
|
||||||
|
@@ -27,31 +27,35 @@ Aspect_RectangularGrid::Aspect_RectangularGrid(
|
|||||||
const Standard_Real aFirstAngle,
|
const Standard_Real aFirstAngle,
|
||||||
const Standard_Real aSecondAngle,
|
const Standard_Real aSecondAngle,
|
||||||
const Standard_Real aRotationAngle)
|
const Standard_Real aRotationAngle)
|
||||||
:Aspect_Grid(anXOrigin,anYOrigin,aRotationAngle),myXStep(aXStep),myYStep(aYStep),myFirstAngle(aFirstAngle),mySecondAngle(aSecondAngle)
|
: Aspect_Grid (anXOrigin,anYOrigin,aRotationAngle),
|
||||||
|
myXStep (aXStep),
|
||||||
|
myYStep (aYStep),
|
||||||
|
myFirstAngle (aFirstAngle),
|
||||||
|
mySecondAngle (aSecondAngle)
|
||||||
{
|
{
|
||||||
Standard_NumericError_Raise_if (!CheckAngle (aFirstAngle, mySecondAngle),
|
Standard_NumericError_Raise_if (!CheckAngle (aFirstAngle, mySecondAngle),
|
||||||
"networks are parallel");
|
"networks are parallel");
|
||||||
|
Standard_NegativeValue_Raise_if (aXStep < 0.0, "invalid x step");
|
||||||
Standard_NegativeValue_Raise_if(aXStep < 0. , "invalid x step");
|
Standard_NegativeValue_Raise_if (aYStep < 0.0, "invalid y step");
|
||||||
Standard_NegativeValue_Raise_if(aYStep < 0. , "invalid y step");
|
Standard_NullValue_Raise_if (aXStep == 0.0, "invalid x step");
|
||||||
Standard_NullValue_Raise_if(aXStep == 0. , "invalid x step");
|
Standard_NullValue_Raise_if (aYStep == 0.0, "invalid y step");
|
||||||
Standard_NullValue_Raise_if(aYStep == 0. , "invalid y step");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Aspect_RectangularGrid::SetXStep(const Standard_Real aStep) {
|
void Aspect_RectangularGrid::SetXStep (const Standard_Real aStep)
|
||||||
Standard_NegativeValue_Raise_if(aStep < 0. , "invalid x step");
|
{
|
||||||
Standard_NullValue_Raise_if(aStep == 0. , "invalid y step");
|
Standard_NegativeValue_Raise_if (aStep < 0.0, "invalid x step");
|
||||||
|
Standard_NullValue_Raise_if (aStep == 0.0, "invalid y step");
|
||||||
myXStep = aStep;
|
myXStep = aStep;
|
||||||
Init();
|
Init();
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aspect_RectangularGrid::SetYStep(const Standard_Real aStep) {
|
void Aspect_RectangularGrid::SetYStep (const Standard_Real aStep)
|
||||||
Standard_NegativeValue_Raise_if(aStep < 0. , "invalid x step");
|
{
|
||||||
Standard_NullValue_Raise_if(aStep == 0. , "invalid y step");
|
Standard_NegativeValue_Raise_if (aStep < 0.0, "invalid x step");
|
||||||
|
Standard_NullValue_Raise_if (aStep == 0.0, "invalid y step");
|
||||||
myYStep = aStep;
|
myYStep = aStep;
|
||||||
Init();
|
Init();
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
@@ -73,15 +77,15 @@ void Aspect_RectangularGrid::SetGridValues(
|
|||||||
const Standard_Real theYOrigin,
|
const Standard_Real theYOrigin,
|
||||||
const Standard_Real theXStep,
|
const Standard_Real theXStep,
|
||||||
const Standard_Real theYStep,
|
const Standard_Real theYStep,
|
||||||
const Standard_Real theRotationAngle) {
|
const Standard_Real theRotationAngle)
|
||||||
|
{
|
||||||
myXOrigin = theXOrigin;
|
myXOrigin = theXOrigin;
|
||||||
myYOrigin = theYOrigin;
|
myYOrigin = theYOrigin;
|
||||||
Standard_NegativeValue_Raise_if(theXStep < 0. , "invalid x step");
|
Standard_NegativeValue_Raise_if (theXStep < 0.0, "invalid x step");
|
||||||
Standard_NullValue_Raise_if(theXStep == 0. , "invalid x step");
|
Standard_NullValue_Raise_if (theXStep == 0.0, "invalid x step");
|
||||||
myXStep = theXStep;
|
myXStep = theXStep;
|
||||||
Standard_NegativeValue_Raise_if(theYStep < 0. , "invalid y step");
|
Standard_NegativeValue_Raise_if (theYStep < 0.0, "invalid y step");
|
||||||
Standard_NullValue_Raise_if(theYStep == 0. , "invalid y step");
|
Standard_NullValue_Raise_if (theYStep == 0.0, "invalid y step");
|
||||||
myYStep = theYStep;
|
myYStep = theYStep;
|
||||||
myRotationAngle = theRotationAngle;
|
myRotationAngle = theRotationAngle;
|
||||||
Init();
|
Init();
|
||||||
@@ -91,7 +95,8 @@ void Aspect_RectangularGrid::SetGridValues(
|
|||||||
void Aspect_RectangularGrid::Compute (const Standard_Real X,
|
void Aspect_RectangularGrid::Compute (const Standard_Real X,
|
||||||
const Standard_Real Y,
|
const Standard_Real Y,
|
||||||
Standard_Real& gridX,
|
Standard_Real& gridX,
|
||||||
Standard_Real& gridY) const {
|
Standard_Real& gridY) const
|
||||||
|
{
|
||||||
Standard_Real D1 = b1 * X - a1 * Y - c1;
|
Standard_Real D1 = b1 * X - a1 * Y - c1;
|
||||||
Standard_Real D2 = b2 * X - a2 * Y - c2;
|
Standard_Real D2 = b2 * X - a2 * Y - c2;
|
||||||
Standard_Integer n1 = Standard_Integer (Abs (D1) / myXStep + 0.5);
|
Standard_Integer n1 = Standard_Integer (Abs (D1) / myXStep + 0.5);
|
||||||
@@ -103,24 +108,28 @@ void Aspect_RectangularGrid::Compute(const Standard_Real X,
|
|||||||
gridY = (offset2 * b1 - offset1 * b2) / Delta;
|
gridY = (offset2 * b1 - offset1 * b2) / Delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Real Aspect_RectangularGrid::XStep() const {
|
Standard_Real Aspect_RectangularGrid::XStep() const
|
||||||
|
{
|
||||||
return myXStep;
|
return myXStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Real Aspect_RectangularGrid::YStep() const {
|
Standard_Real Aspect_RectangularGrid::YStep() const
|
||||||
|
{
|
||||||
return myYStep;
|
return myYStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Real Aspect_RectangularGrid::FirstAngle() const {
|
Standard_Real Aspect_RectangularGrid::FirstAngle() const
|
||||||
|
{
|
||||||
return myFirstAngle;
|
return myFirstAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Real Aspect_RectangularGrid::SecondAngle() const {
|
Standard_Real Aspect_RectangularGrid::SecondAngle() const
|
||||||
|
{
|
||||||
return mySecondAngle;
|
return mySecondAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aspect_RectangularGrid::Init () {
|
void Aspect_RectangularGrid::Init()
|
||||||
|
{
|
||||||
//+zov Fixing CTS17856
|
//+zov Fixing CTS17856
|
||||||
// a1 = Cos (myFirstAngle + RotationAngle() );
|
// a1 = Cos (myFirstAngle + RotationAngle() );
|
||||||
// b1 = Sin (myFirstAngle + RotationAngle() );
|
// b1 = Sin (myFirstAngle + RotationAngle() );
|
||||||
@@ -132,28 +141,39 @@ void Aspect_RectangularGrid::Init () {
|
|||||||
|
|
||||||
Standard_Real angle1 = myFirstAngle + RotationAngle();
|
Standard_Real angle1 = myFirstAngle + RotationAngle();
|
||||||
Standard_Real angle2 = mySecondAngle + RotationAngle();
|
Standard_Real angle2 = mySecondAngle + RotationAngle();
|
||||||
if ( angle1 != 0. ) {
|
if (angle1 != 0.0)
|
||||||
|
{
|
||||||
a1 = -Sin (angle1);
|
a1 = -Sin (angle1);
|
||||||
b1 = Cos (angle1);
|
b1 = Cos (angle1);
|
||||||
c1 = XOrigin() * b1 - YOrigin() * a1;
|
c1 = XOrigin() * b1 - YOrigin() * a1;
|
||||||
} else {
|
}
|
||||||
a1 = 0.; b1 = 1.; c1 = XOrigin();
|
else
|
||||||
|
{
|
||||||
|
a1 = 0.0;
|
||||||
|
b1 = 1.0;
|
||||||
|
c1 = XOrigin();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( angle2 != 0. ) {
|
if (angle2 != 0.0)
|
||||||
angle2 += M_PI / 2.;
|
{
|
||||||
|
angle2 += M_PI / 2.0;
|
||||||
a2 = -Sin (angle2);
|
a2 = -Sin (angle2);
|
||||||
b2 = Cos (angle2);
|
b2 = Cos (angle2);
|
||||||
c2 = XOrigin() * b2 - YOrigin() * a2;
|
c2 = XOrigin() * b2 - YOrigin() * a2;
|
||||||
} else {
|
}
|
||||||
a2 = -1.; b2 = 0.; c2 = YOrigin();
|
else
|
||||||
|
{
|
||||||
|
a2 = -1.0;
|
||||||
|
b2 = 0.0;
|
||||||
|
c2 = YOrigin();
|
||||||
}
|
}
|
||||||
//-zov
|
//-zov
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Boolean Aspect_RectangularGrid::CheckAngle (const Standard_Real alpha,
|
Standard_Boolean Aspect_RectangularGrid::CheckAngle (const Standard_Real alpha,
|
||||||
const Standard_Real beta) const {
|
const Standard_Real beta) const
|
||||||
return (Abs( Sin(alpha) * Cos(beta + M_PI / 2.) - Cos(alpha) * Sin(beta + M_PI / 2.)) != 0) ;
|
{
|
||||||
|
return (Abs (Sin (alpha) * Cos (beta + M_PI / 2.0) - Cos (alpha) * Sin (beta + M_PI / 2.0)) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -2183,3 +2183,104 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getColoredQuadProgram()
|
|||||||
|
|
||||||
return aProgSrc;
|
return aProgSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getGridProgram() const
|
||||||
|
{
|
||||||
|
Handle(Graphic3d_ShaderProgram) aProgSrc = new Graphic3d_ShaderProgram();
|
||||||
|
|
||||||
|
Graphic3d_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||||
|
aStageInOuts.Append (Graphic3d_ShaderObject::ShaderVariable ("vec3 NearPoint", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||||
|
aStageInOuts.Append (Graphic3d_ShaderObject::ShaderVariable ("vec3 FarPoint", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||||
|
aStageInOuts.Append (Graphic3d_ShaderObject::ShaderVariable ("mat4 MVP", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||||
|
aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("float uZNear", Graphic3d_TOS_FRAGMENT));
|
||||||
|
aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("float uZFar", Graphic3d_TOS_FRAGMENT));
|
||||||
|
aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("bool uIsDrawAxis", Graphic3d_TOS_FRAGMENT));
|
||||||
|
|
||||||
|
TCollection_AsciiString aSrcVert = TCollection_AsciiString()
|
||||||
|
+ EOL"vec3 gridPlane[6] = vec3[] (vec3( 1, 1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0),"
|
||||||
|
EOL" vec3(-1, -1, 0), vec3( 1, 1, 0), vec3( 1, -1, 0));"
|
||||||
|
|
||||||
|
EOL"vec3 UnprojectPoint (float aX, float anY, float aZ)"
|
||||||
|
EOL"{"
|
||||||
|
EOL" vec4 anUnprojPnt = occModelWorldMatrixInverse * occWorldViewMatrixInverse * occProjectionMatrixInverse * vec4 (aX, anY, aZ, 1.0);"
|
||||||
|
EOL" return anUnprojPnt.xyz / anUnprojPnt.w;"
|
||||||
|
EOL"}"
|
||||||
|
|
||||||
|
EOL"void main()"
|
||||||
|
EOL"{"
|
||||||
|
EOL" vec3 aVertex = gridPlane[gl_VertexID];"
|
||||||
|
EOL" NearPoint = UnprojectPoint (aVertex.x, aVertex.y, 0.0);"
|
||||||
|
EOL" FarPoint = UnprojectPoint (aVertex.x, aVertex.y, 1.0);"
|
||||||
|
EOL" MVP = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix;"
|
||||||
|
EOL" gl_Position = vec4 (aVertex, 1.0);"
|
||||||
|
EOL"}";
|
||||||
|
|
||||||
|
TCollection_AsciiString aSrcFrag = TCollection_AsciiString()
|
||||||
|
+ EOL"vec4 grid (vec3 theFragPos3D, vec3 theColor, float theScale, bool theIsDrawAxis)"
|
||||||
|
EOL"{"
|
||||||
|
EOL" vec2 aCoord = theFragPos3D.xy * theScale;"
|
||||||
|
EOL" vec2 aDerivative = fwidth (aCoord);"
|
||||||
|
EOL" vec2 aGrid = abs (fract (aCoord - 0.5) - 0.5) / aDerivative;"
|
||||||
|
EOL" float aLine = min (aGrid.x, aGrid.y);"
|
||||||
|
EOL" float aMinY = min (aDerivative.y, 1);"
|
||||||
|
EOL" float aMinX = min (aDerivative.x, 1);"
|
||||||
|
EOL" vec4 aColor = vec4 (theColor, round (1.0 - min (aLine, 1.0)));"
|
||||||
|
EOL" if (uIsDrawAxis && theIsDrawAxis)"
|
||||||
|
EOL" {"
|
||||||
|
EOL" bool isYAxis = -aMinX < aCoord.x && aCoord.x < aMinX;"
|
||||||
|
EOL" bool isXAxis = -aMinY < aCoord.y && aCoord.y < aMinY;"
|
||||||
|
EOL" if (isXAxis && isYAxis) { aColor.xyz = vec3 (0.0, 0.0, 1.0); }"
|
||||||
|
EOL" else if (isXAxis) { aColor.xyz = vec3 (1.0, 0.0, 0.0); }"
|
||||||
|
EOL" else if (isYAxis) { aColor.xyz = vec3 (0.0, 1.0, 0.0); }"
|
||||||
|
EOL" }"
|
||||||
|
EOL" return aColor;"
|
||||||
|
EOL" }"
|
||||||
|
|
||||||
|
EOL"float computeDepth (vec3 thePos)"
|
||||||
|
EOL"{"
|
||||||
|
EOL" vec4 aClipSpacePos = MVP * vec4 (thePos, 1.0);"
|
||||||
|
EOL" return (aClipSpacePos.z / aClipSpacePos.w);"
|
||||||
|
EOL"}"
|
||||||
|
|
||||||
|
EOL"float computeLinearDepth (vec3 thePos)"
|
||||||
|
EOL"{"
|
||||||
|
EOL" float aClipSpaceDepth = computeDepth (thePos) * 2.0 - 1.0;"
|
||||||
|
EOL" float aLinearDepth = (2.0 * uZNear * uZFar) / (uZFar + uZNear - aClipSpaceDepth * (uZFar - uZNear));"
|
||||||
|
EOL" return aLinearDepth / uZFar;"
|
||||||
|
EOL"}"
|
||||||
|
|
||||||
|
EOL"void main()"
|
||||||
|
EOL"{"
|
||||||
|
EOL" float aParam = -NearPoint.z / (FarPoint.z - NearPoint.z);"
|
||||||
|
EOL" vec3 aFragPos3D = NearPoint + aParam * (FarPoint - NearPoint);"
|
||||||
|
EOL" float aLinearDepth = computeLinearDepth (aFragPos3D);"
|
||||||
|
// TODO : Compute scale
|
||||||
|
EOL" vec4 aBigGridColor = grid (aFragPos3D, vec3 (0.8), 0.01, true);"
|
||||||
|
EOL" vec4 aColor = aBigGridColor.a == 0.0"
|
||||||
|
EOL" ? grid (aFragPos3D, vec3 (0.2), 0.1, false)"
|
||||||
|
EOL" : aBigGridColor;"
|
||||||
|
EOL" float aDepth = computeDepth (aFragPos3D);"
|
||||||
|
EOL" float aFar = gl_DepthRange.far;"
|
||||||
|
EOL" float aNear = gl_DepthRange.near;"
|
||||||
|
EOL" aDepth = ((aFar - aNear) * aDepth + aNear + aFar) * 0.5;"
|
||||||
|
EOL" if (aColor.a == 0.0 || (-1.0 < aLinearDepth && aLinearDepth < 0.0))"
|
||||||
|
EOL" {"
|
||||||
|
EOL" discard;"
|
||||||
|
EOL" };"
|
||||||
|
// TODO : Get actual background color
|
||||||
|
EOL" vec4 aBackgroundColor = vec4 (0.0, 0.0, 0.0, 1.0);"
|
||||||
|
EOL" if (abs (aLinearDepth) > 1.0)"
|
||||||
|
EOL" {"
|
||||||
|
EOL" float anInterpVal = float (aLinearDepth > 0.0) - sign (aLinearDepth) * clamp (1.0 / (abs (aLinearDepth) - 1.0), 0.5, 1.0);"
|
||||||
|
EOL" aColor = mix (aColor, aBackgroundColor, anInterpVal);"
|
||||||
|
EOL" }"
|
||||||
|
EOL" gl_FragDepth = aDepth;"
|
||||||
|
EOL" occFragColor = aColor;"
|
||||||
|
EOL"}";
|
||||||
|
|
||||||
|
defaultGlslVersion (aProgSrc, "grid", 0);
|
||||||
|
aProgSrc->AttachShader (Graphic3d_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||||
|
aProgSrc->AttachShader (Graphic3d_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
||||||
|
|
||||||
|
return aProgSrc;
|
||||||
|
}
|
||||||
|
@@ -148,6 +148,9 @@ protected:
|
|||||||
//! Generates shader program to render correctly colored quad.
|
//! Generates shader program to render correctly colored quad.
|
||||||
Standard_EXPORT Handle(Graphic3d_ShaderProgram) getColoredQuadProgram() const;
|
Standard_EXPORT Handle(Graphic3d_ShaderProgram) getColoredQuadProgram() const;
|
||||||
|
|
||||||
|
//! Generates shader program to render grid.
|
||||||
|
Standard_EXPORT Handle(Graphic3d_ShaderProgram) getGridProgram() const;
|
||||||
|
|
||||||
//! Prepare GLSL source for IBL generation used in PBR pipeline.
|
//! Prepare GLSL source for IBL generation used in PBR pipeline.
|
||||||
Standard_EXPORT Handle(Graphic3d_ShaderProgram) getPBREnvBakingProgram (Standard_Integer theIndex) const;
|
Standard_EXPORT Handle(Graphic3d_ShaderProgram) getPBREnvBakingProgram (Standard_Integer theIndex) const;
|
||||||
|
|
||||||
|
@@ -1361,6 +1361,27 @@ Standard_Boolean OpenGl_ShaderManager::preparePBREnvBakingProgram (Standard_Inte
|
|||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : prepareGridProgram
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Standard_Boolean OpenGl_ShaderManager::prepareGridProgram()
|
||||||
|
{
|
||||||
|
Handle(Graphic3d_ShaderProgram) aProgramSrc = getGridProgram();
|
||||||
|
|
||||||
|
TCollection_AsciiString aKey;
|
||||||
|
if (!Create (aProgramSrc, aKey, myGridProgram))
|
||||||
|
{
|
||||||
|
myGridProgram = new OpenGl_ShaderProgram(); // just mark as invalid
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
myContext->BindProgram (myGridProgram);
|
||||||
|
myContext->BindProgram (Handle(OpenGl_ShaderProgram)());
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : GetBgCubeMapProgram
|
// function : GetBgCubeMapProgram
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@@ -225,6 +225,16 @@ public:
|
|||||||
return myContext->BindProgram (myPBREnvBakingProgram[theIndex]);
|
return myContext->BindProgram (myPBREnvBakingProgram[theIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Bind program for IBL maps generation in PBR pipeline.
|
||||||
|
Standard_Boolean BindGridProgram()
|
||||||
|
{
|
||||||
|
if (myGridProgram.IsNull())
|
||||||
|
{
|
||||||
|
prepareGridProgram();
|
||||||
|
}
|
||||||
|
return myContext->BindProgram (myGridProgram);
|
||||||
|
}
|
||||||
|
|
||||||
//! Generates shader program to render environment cubemap as background.
|
//! Generates shader program to render environment cubemap as background.
|
||||||
Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& GetBgCubeMapProgram();
|
Standard_EXPORT const Handle(Graphic3d_ShaderProgram)& GetBgCubeMapProgram();
|
||||||
|
|
||||||
@@ -709,6 +719,8 @@ protected:
|
|||||||
Standard_Boolean IsPbrAllowed() const { return myShadingModel == Graphic3d_TypeOfShadingModel_Pbr
|
Standard_Boolean IsPbrAllowed() const { return myShadingModel == Graphic3d_TypeOfShadingModel_Pbr
|
||||||
|| myShadingModel == Graphic3d_TypeOfShadingModel_PbrFacet; }
|
|| myShadingModel == Graphic3d_TypeOfShadingModel_PbrFacet; }
|
||||||
|
|
||||||
|
Standard_EXPORT Standard_Boolean prepareGridProgram();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Packed properties of light source
|
//! Packed properties of light source
|
||||||
@@ -776,6 +788,7 @@ protected:
|
|||||||
Handle(Graphic3d_ShaderProgram) myBgCubeMapProgram; //!< program for background cubemap rendering
|
Handle(Graphic3d_ShaderProgram) myBgCubeMapProgram; //!< program for background cubemap rendering
|
||||||
Handle(Graphic3d_ShaderProgram) myBgSkydomeProgram; //!< program for background cubemap rendering
|
Handle(Graphic3d_ShaderProgram) myBgSkydomeProgram; //!< program for background cubemap rendering
|
||||||
Handle(Graphic3d_ShaderProgram) myColoredQuadProgram; //!< program for correct quad rendering
|
Handle(Graphic3d_ShaderProgram) myColoredQuadProgram; //!< program for correct quad rendering
|
||||||
|
Handle(OpenGl_ShaderProgram) myGridProgram; //!< program for grid rendering
|
||||||
|
|
||||||
Handle(OpenGl_ShaderProgram) myStereoPrograms[Graphic3d_StereoMode_NB]; //!< standard stereo programs
|
Handle(OpenGl_ShaderProgram) myStereoPrograms[Graphic3d_StereoMode_NB]; //!< standard stereo programs
|
||||||
|
|
||||||
|
@@ -2433,6 +2433,12 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
|||||||
aContext->core11fwd->glDisable (GL_LIGHTING);
|
aContext->core11fwd->glDisable (GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ====================================
|
||||||
|
// Step 3: Redraw grid
|
||||||
|
// ====================================
|
||||||
|
|
||||||
|
renderGrid();
|
||||||
|
|
||||||
// =================================
|
// =================================
|
||||||
// Step 3: Redraw main plane
|
// Step 3: Redraw main plane
|
||||||
// =================================
|
// =================================
|
||||||
@@ -2525,6 +2531,35 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : renderGrid
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_View::renderGrid()
|
||||||
|
{
|
||||||
|
const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
|
||||||
|
|
||||||
|
aContext->ShaderManager()->UpdateModelWorldStateTo (aContext->ModelWorldState.Current());
|
||||||
|
aContext->ShaderManager()->UpdateProjectionStateTo (aContext->ProjectionState.Current());
|
||||||
|
aContext->ShaderManager()->UpdateWorldViewStateTo (aContext->WorldViewState.Current());
|
||||||
|
|
||||||
|
aContext->core11fwd->glEnable (GL_BLEND);
|
||||||
|
aContext->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
if (aContext->ShaderManager()->BindGridProgram())
|
||||||
|
{
|
||||||
|
const Handle(OpenGl_ShaderProgram)& aProg = aContext->ActiveProgram();
|
||||||
|
aProg->SetUniform (aContext, "uZNear", GLfloat (aContext->Camera()->ZNear()));
|
||||||
|
aProg->SetUniform (aContext, "uZFar", GLfloat (aContext->Camera()->ZFar()));
|
||||||
|
// TODO : add param to draw command
|
||||||
|
aProg->SetUniform (aContext, "uIsDrawAxis", GLboolean (true));
|
||||||
|
|
||||||
|
aContext->ShaderManager()->PushState (aContext->ActiveProgram());
|
||||||
|
aContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
|
||||||
|
aContext->BindProgram (NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : InvalidateBVHData
|
// function : InvalidateBVHData
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@@ -390,6 +390,9 @@ protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
|
|||||||
OpenGl_FrameBuffer* theOitAccumFbo,
|
OpenGl_FrameBuffer* theOitAccumFbo,
|
||||||
const Standard_Boolean theToDrawImmediate);
|
const Standard_Boolean theToDrawImmediate);
|
||||||
|
|
||||||
|
//! Renders grid
|
||||||
|
Standard_EXPORT void renderGrid();
|
||||||
|
|
||||||
//! Renders trihedron.
|
//! Renders trihedron.
|
||||||
void renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
|
void renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
|
||||||
|
|
||||||
|
@@ -91,7 +91,8 @@ V3d_CircularGrid::~V3d_CircularGrid()
|
|||||||
|
|
||||||
void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
|
void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
|
||||||
{
|
{
|
||||||
if( myColor != aColor || myTenthColor != aTenthColor ) {
|
if( myColor != aColor || myTenthColor != aTenthColor )
|
||||||
|
{
|
||||||
myColor = aColor;
|
myColor = aColor;
|
||||||
myTenthColor = aTenthColor;
|
myTenthColor = aTenthColor;
|
||||||
myCurAreDefined = Standard_False;
|
myCurAreDefined = Standard_False;
|
||||||
@@ -106,6 +107,11 @@ void V3d_CircularGrid::Display ()
|
|||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V3d_CircularGrid::Update()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
void V3d_CircularGrid::Erase() const
|
void V3d_CircularGrid::Erase() const
|
||||||
{
|
{
|
||||||
myStructure->Erase();
|
myStructure->Erase();
|
||||||
@@ -147,9 +153,11 @@ void V3d_CircularGrid::UpdateDisplay ()
|
|||||||
xdx != curxdx || xdy != curxdy || xdz != curxdz ||
|
xdx != curxdx || xdy != curxdy || xdz != curxdz ||
|
||||||
ydx != curydx || ydy != curydy || ydz != curydz ||
|
ydx != curydx || ydy != curydy || ydz != curydz ||
|
||||||
dx != curdx || dy != curdy || dz != curdz)
|
dx != curdx || dy != curdy || dz != curdz)
|
||||||
|
{
|
||||||
MakeTransform = Standard_True;
|
MakeTransform = Standard_True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (MakeTransform)
|
if (MakeTransform)
|
||||||
{
|
{
|
||||||
@@ -173,7 +181,8 @@ void V3d_CircularGrid::UpdateDisplay ()
|
|||||||
myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf));
|
myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf));
|
||||||
|
|
||||||
myCurAngle = RotationAngle();
|
myCurAngle = RotationAngle();
|
||||||
myCurXo = XOrigin (), myCurYo = YOrigin ();
|
myCurXo = XOrigin();
|
||||||
|
myCurYo = YOrigin();
|
||||||
myCurViewPlane = ThePlane;
|
myCurViewPlane = ThePlane;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,8 +211,7 @@ void V3d_CircularGrid::DefineLines ()
|
|||||||
|| myCurDrawMode != Aspect_GDM_Lines
|
|| myCurDrawMode != Aspect_GDM_Lines
|
||||||
|| aDivision != myCurDivi
|
|| aDivision != myCurDivi
|
||||||
|| aStep != myCurStep;
|
|| aStep != myCurStep;
|
||||||
if (!toUpdate
|
if (!toUpdate && !myToComputePrs)
|
||||||
&& !myToComputePrs)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -224,8 +232,9 @@ void V3d_CircularGrid::DefineLines ()
|
|||||||
|
|
||||||
myGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0));
|
myGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0));
|
||||||
Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments (2 * nbpnts);
|
Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments (2 * nbpnts);
|
||||||
const gp_Pnt p0(0., 0., -myOffSet);
|
const gp_Pnt p0 (0.0, 0.0, -myOffSet);
|
||||||
for (Standard_Integer i=1; i<=nbpnts; i++) {
|
for (Standard_Integer i = 1; i <= nbpnts; i++)
|
||||||
|
{
|
||||||
aPrims1->AddVertex (p0);
|
aPrims1->AddVertex (p0);
|
||||||
aPrims1->AddVertex (Cos (alpha * i) * myRadius, Sin (alpha * i) * myRadius, -myOffSet);
|
aPrims1->AddVertex (Cos (alpha * i) * myRadius, Sin (alpha * i) * myRadius, -myOffSet);
|
||||||
}
|
}
|
||||||
@@ -236,9 +245,11 @@ void V3d_CircularGrid::DefineLines ()
|
|||||||
alpha = M_PI / Division;
|
alpha = M_PI / Division;
|
||||||
Standard_Integer nblines = 0;
|
Standard_Integer nblines = 0;
|
||||||
TColgp_SequenceOfPnt aSeqLines, aSeqTenth;
|
TColgp_SequenceOfPnt aSeqLines, aSeqTenth;
|
||||||
for (Standard_Real r=aStep; r<=myRadius; r+=aStep, nblines++) {
|
for (Standard_Real r = aStep; r <= myRadius; r += aStep, nblines++)
|
||||||
|
{
|
||||||
const Standard_Boolean isTenth = (Modulus (nblines, 10) == 0);
|
const Standard_Boolean isTenth = (Modulus (nblines, 10) == 0);
|
||||||
for (Standard_Integer i=0; i<nbpnts; i++) {
|
for (Standard_Integer i = 0; i < nbpnts; i++)
|
||||||
|
{
|
||||||
const gp_Pnt pt (Cos (alpha * i) * r, Sin (alpha * i) * r, -myOffSet);
|
const gp_Pnt pt (Cos (alpha * i) * r, Sin (alpha * i) * r, -myOffSet);
|
||||||
(isTenth ? aSeqTenth : aSeqLines).Append (pt);
|
(isTenth ? aSeqTenth : aSeqLines).Append (pt);
|
||||||
}
|
}
|
||||||
@@ -249,11 +260,14 @@ void V3d_CircularGrid::DefineLines ()
|
|||||||
Standard_Integer n, np;
|
Standard_Integer n, np;
|
||||||
const Standard_Integer nbl = aSeqTenth.Length() / nbpnts;
|
const Standard_Integer nbl = aSeqTenth.Length() / nbpnts;
|
||||||
Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines (aSeqTenth.Length(), nbl);
|
Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines (aSeqTenth.Length(), nbl);
|
||||||
for (np = 1, n=0; n<nbl; n++) {
|
for (np = 1, n = 0; n < nbl; n++)
|
||||||
|
{
|
||||||
aPrims2->AddBound (nbpnts);
|
aPrims2->AddBound (nbpnts);
|
||||||
for (Standard_Integer i = 0; i < nbpnts; i++, np++)
|
for (Standard_Integer i = 0; i < nbpnts; i++, np++)
|
||||||
|
{
|
||||||
aPrims2->AddVertex (aSeqTenth (np));
|
aPrims2->AddVertex (aSeqTenth (np));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
myGroup->AddPrimitiveArray (aPrims2, Standard_False);
|
myGroup->AddPrimitiveArray (aPrims2, Standard_False);
|
||||||
}
|
}
|
||||||
if (aSeqLines.Length())
|
if (aSeqLines.Length())
|
||||||
@@ -262,16 +276,20 @@ void V3d_CircularGrid::DefineLines ()
|
|||||||
Standard_Integer n, np;
|
Standard_Integer n, np;
|
||||||
const Standard_Integer nbl = aSeqLines.Length() / nbpnts;
|
const Standard_Integer nbl = aSeqLines.Length() / nbpnts;
|
||||||
Handle(Graphic3d_ArrayOfPolylines) aPrims3 = new Graphic3d_ArrayOfPolylines (aSeqLines.Length(), nbl);
|
Handle(Graphic3d_ArrayOfPolylines) aPrims3 = new Graphic3d_ArrayOfPolylines (aSeqLines.Length(), nbl);
|
||||||
for (np = 1, n=0; n<nbl; n++) {
|
for (np = 1, n = 0; n < nbl; n++)
|
||||||
|
{
|
||||||
aPrims3->AddBound(nbpnts);
|
aPrims3->AddBound(nbpnts);
|
||||||
for (Standard_Integer i = 0; i < nbpnts; i++, np++)
|
for (Standard_Integer i = 0; i < nbpnts; i++, np++)
|
||||||
|
{
|
||||||
aPrims3->AddVertex (aSeqLines (np));
|
aPrims3->AddVertex (aSeqLines (np));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
myGroup->AddPrimitiveArray (aPrims3, Standard_False);
|
myGroup->AddPrimitiveArray (aPrims3, Standard_False);
|
||||||
}
|
}
|
||||||
|
|
||||||
myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
|
myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
|
||||||
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
|
myCurStep = aStep;
|
||||||
|
myCurDivi = (Standard_Integer) aDivision;
|
||||||
|
|
||||||
// update bounding box
|
// update bounding box
|
||||||
myStructure->CalculateBoundBox();
|
myStructure->CalculateBoundBox();
|
||||||
@@ -286,8 +304,7 @@ void V3d_CircularGrid::DefinePoints ()
|
|||||||
|| myCurDrawMode != Aspect_GDM_Points
|
|| myCurDrawMode != Aspect_GDM_Points
|
||||||
|| aDivision != myCurDivi
|
|| aDivision != myCurDivi
|
||||||
|| aStep != myCurStep;
|
|| aStep != myCurStep;
|
||||||
if (!toUpdate
|
if (!toUpdate && !myToComputePrs)
|
||||||
&& !myToComputePrs)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -303,34 +320,38 @@ void V3d_CircularGrid::DefinePoints ()
|
|||||||
Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d();
|
Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d();
|
||||||
MarkerAttrib->SetColor (myColor);
|
MarkerAttrib->SetColor (myColor);
|
||||||
MarkerAttrib->SetType (Aspect_TOM_POINT);
|
MarkerAttrib->SetType (Aspect_TOM_POINT);
|
||||||
MarkerAttrib->SetScale (3.);
|
MarkerAttrib->SetScale (3.0);
|
||||||
|
|
||||||
const Standard_Integer nbpnts = Standard_Integer (2 * aDivision);
|
const Standard_Integer nbpnts = Standard_Integer (2 * aDivision);
|
||||||
Standard_Real r, alpha = M_PI / aDivision;
|
Standard_Real alpha = M_PI / aDivision;
|
||||||
|
|
||||||
// diameters
|
// diameters
|
||||||
TColgp_SequenceOfPnt aSeqPnts;
|
TColgp_SequenceOfPnt aSeqPnts;
|
||||||
aSeqPnts.Append (gp_Pnt (0.0, 0.0, -myOffSet));
|
aSeqPnts.Append (gp_Pnt (0.0, 0.0, -myOffSet));
|
||||||
for (r=aStep; r<=myRadius; r+=aStep) {
|
for (Standard_Real r = aStep; r <= myRadius; r += aStep)
|
||||||
|
{
|
||||||
for (Standard_Integer i = 0; i < nbpnts; i++)
|
for (Standard_Integer i = 0; i < nbpnts; i++)
|
||||||
|
{
|
||||||
aSeqPnts.Append (gp_Pnt (Cos (alpha * i) * r, Sin (alpha * i) * r, -myOffSet));
|
aSeqPnts.Append (gp_Pnt (Cos (alpha * i) * r, Sin (alpha * i) * r, -myOffSet));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
myGroup->SetGroupPrimitivesAspect (MarkerAttrib);
|
myGroup->SetGroupPrimitivesAspect (MarkerAttrib);
|
||||||
if (aSeqPnts.Length())
|
if (aSeqPnts.Length())
|
||||||
{
|
{
|
||||||
Standard_Real X,Y,Z;
|
Standard_Real X,Y,Z;
|
||||||
const Standard_Integer nbv = aSeqPnts.Length();
|
const Standard_Integer nbv = aSeqPnts.Length();
|
||||||
Handle(Graphic3d_ArrayOfPoints) Cercle = new Graphic3d_ArrayOfPoints (nbv);
|
Handle(Graphic3d_ArrayOfPoints) aCircle = new Graphic3d_ArrayOfPoints (nbv);
|
||||||
for (Standard_Integer i = 1; i <= nbv; i++)
|
for (Standard_Integer i = 1; i <= nbv; i++)
|
||||||
{
|
{
|
||||||
aSeqPnts (i).Coord (X,Y,Z);
|
aSeqPnts (i).Coord (X,Y,Z);
|
||||||
Cercle->AddVertex (X,Y,Z);
|
aCircle->AddVertex (X,Y,Z);
|
||||||
}
|
}
|
||||||
myGroup->AddPrimitiveArray (Cercle, Standard_False);
|
myGroup->AddPrimitiveArray (aCircle, Standard_False);
|
||||||
}
|
}
|
||||||
myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
|
myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
|
||||||
|
|
||||||
myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
|
myCurStep = aStep;
|
||||||
|
myCurDivi = (Standard_Integer) aDivision;
|
||||||
|
|
||||||
// update bounding box
|
// update bounding box
|
||||||
myStructure->CalculateBoundBox();
|
myStructure->CalculateBoundBox();
|
||||||
@@ -345,19 +366,22 @@ void V3d_CircularGrid::GraphicValues (Standard_Real& theRadius, Standard_Real& t
|
|||||||
|
|
||||||
void V3d_CircularGrid::SetGraphicValues (const Standard_Real theRadius, const Standard_Real theOffSet)
|
void V3d_CircularGrid::SetGraphicValues (const Standard_Real theRadius, const Standard_Real theOffSet)
|
||||||
{
|
{
|
||||||
if (! myCurAreDefined) {
|
if (!myCurAreDefined)
|
||||||
|
{
|
||||||
myRadius = theRadius;
|
myRadius = theRadius;
|
||||||
myOffSet = theOffSet;
|
myOffSet = theOffSet;
|
||||||
}
|
}
|
||||||
if (myRadius != theRadius) {
|
if (myRadius != theRadius)
|
||||||
|
{
|
||||||
myRadius = theRadius;
|
myRadius = theRadius;
|
||||||
myCurAreDefined = Standard_False;
|
myCurAreDefined = Standard_False;
|
||||||
}
|
}
|
||||||
if (myOffSet != theOffSet) {
|
if (myOffSet != theOffSet)
|
||||||
|
{
|
||||||
myOffSet = theOffSet;
|
myOffSet = theOffSet;
|
||||||
myCurAreDefined = Standard_False;
|
myCurAreDefined = Standard_False;
|
||||||
}
|
}
|
||||||
if( !myCurAreDefined ) UpdateDisplay();
|
if (!myCurAreDefined) { UpdateDisplay(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -41,6 +41,8 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT void Display() Standard_OVERRIDE;
|
Standard_EXPORT void Display() Standard_OVERRIDE;
|
||||||
|
|
||||||
|
Standard_EXPORT void Update() Standard_OVERRIDE;
|
||||||
|
|
||||||
Standard_EXPORT void Erase() const Standard_OVERRIDE;
|
Standard_EXPORT void Erase() const Standard_OVERRIDE;
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsDisplayed() const Standard_OVERRIDE;
|
Standard_EXPORT Standard_Boolean IsDisplayed() const Standard_OVERRIDE;
|
||||||
|
@@ -91,7 +91,8 @@ V3d_RectangularGrid::~V3d_RectangularGrid()
|
|||||||
|
|
||||||
void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
|
void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
|
||||||
{
|
{
|
||||||
if( myColor != aColor || myTenthColor != aTenthColor ) {
|
if( myColor != aColor || myTenthColor != aTenthColor )
|
||||||
|
{
|
||||||
myColor = aColor;
|
myColor = aColor;
|
||||||
myTenthColor = aTenthColor;
|
myTenthColor = aTenthColor;
|
||||||
myCurAreDefined = Standard_False;
|
myCurAreDefined = Standard_False;
|
||||||
@@ -106,6 +107,12 @@ void V3d_RectangularGrid::Display ()
|
|||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V3d_RectangularGrid::Update()
|
||||||
|
{
|
||||||
|
SetXStep (XStep() + 1);
|
||||||
|
UpdateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
void V3d_RectangularGrid::Erase() const
|
void V3d_RectangularGrid::Erase() const
|
||||||
{
|
{
|
||||||
myStructure->Erase();
|
myStructure->Erase();
|
||||||
@@ -130,11 +137,17 @@ void V3d_RectangularGrid::UpdateDisplay ()
|
|||||||
ThePlane.YDirection().Coord (ydx, ydy, ydz);
|
ThePlane.YDirection().Coord (ydx, ydy, ydz);
|
||||||
ThePlane.Direction ().Coord (dx, dy, dz);
|
ThePlane.Direction ().Coord (dx, dy, dz);
|
||||||
if (!myCurAreDefined)
|
if (!myCurAreDefined)
|
||||||
|
{
|
||||||
MakeTransform = Standard_True;
|
MakeTransform = Standard_True;
|
||||||
else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (RotationAngle() != myCurAngle || XOrigin() != myCurXo || YOrigin() != myCurYo)
|
if (RotationAngle() != myCurAngle || XOrigin() != myCurXo || YOrigin() != myCurYo)
|
||||||
|
{
|
||||||
MakeTransform = Standard_True;
|
MakeTransform = Standard_True;
|
||||||
if (! MakeTransform) {
|
}
|
||||||
|
if (!MakeTransform)
|
||||||
|
{
|
||||||
Standard_Real curxl, curyl, curzl;
|
Standard_Real curxl, curyl, curzl;
|
||||||
Standard_Real curxdx, curxdy, curxdz;
|
Standard_Real curxdx, curxdy, curxdz;
|
||||||
Standard_Real curydx, curydy, curydz;
|
Standard_Real curydx, curydy, curydz;
|
||||||
@@ -147,9 +160,11 @@ void V3d_RectangularGrid::UpdateDisplay ()
|
|||||||
xdx != curxdx || xdy != curxdy || xdz != curxdz ||
|
xdx != curxdx || xdy != curxdy || xdz != curxdz ||
|
||||||
ydx != curydx || ydy != curydy || ydz != curydz ||
|
ydx != curydx || ydy != curydy || ydz != curydz ||
|
||||||
dx != curdx || dy != curdy || dz != curdz)
|
dx != curdx || dy != curdy || dz != curdz)
|
||||||
|
{
|
||||||
MakeTransform = Standard_True;
|
MakeTransform = Standard_True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (MakeTransform) {
|
if (MakeTransform) {
|
||||||
const Standard_Real CosAlpha = Cos (RotationAngle ());
|
const Standard_Real CosAlpha = Cos (RotationAngle ());
|
||||||
@@ -172,7 +187,8 @@ void V3d_RectangularGrid::UpdateDisplay ()
|
|||||||
myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf));
|
myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf));
|
||||||
|
|
||||||
myCurAngle = RotationAngle();
|
myCurAngle = RotationAngle();
|
||||||
myCurXo = XOrigin (), myCurYo = YOrigin ();
|
myCurXo = XOrigin();
|
||||||
|
myCurYo = YOrigin();
|
||||||
myCurViewPlane = ThePlane;
|
myCurViewPlane = ThePlane;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,8 +217,7 @@ void V3d_RectangularGrid::DefineLines ()
|
|||||||
|| myCurDrawMode != Aspect_GDM_Lines
|
|| myCurDrawMode != Aspect_GDM_Lines
|
||||||
|| aXStep != myCurXStep
|
|| aXStep != myCurXStep
|
||||||
|| aYStep != myCurYStep;
|
|| aYStep != myCurYStep;
|
||||||
if (!toUpdate
|
if (!toUpdate && !myToComputePrs)
|
||||||
&& !myToComputePrs)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -221,8 +236,8 @@ void V3d_RectangularGrid::DefineLines ()
|
|||||||
TColgp_SequenceOfPnt aSeqLines, aSeqTenth;
|
TColgp_SequenceOfPnt aSeqLines, aSeqTenth;
|
||||||
|
|
||||||
// verticals
|
// verticals
|
||||||
aSeqTenth.Append(gp_Pnt(0., -myYSize, -zl));
|
aSeqTenth.Append (gp_Pnt (0.0, -myYSize, -zl));
|
||||||
aSeqTenth.Append(gp_Pnt(0., myYSize, -zl));
|
aSeqTenth.Append (gp_Pnt (0.0, myYSize, -zl));
|
||||||
for (nblines = 1, xl = aXStep; xl < myXSize; xl += aXStep, nblines++)
|
for (nblines = 1, xl = aXStep; xl < myXSize; xl += aXStep, nblines++)
|
||||||
{
|
{
|
||||||
TColgp_SequenceOfPnt &aSeq = (Modulus (nblines, 10) != 0) ? aSeqLines : aSeqTenth;
|
TColgp_SequenceOfPnt &aSeq = (Modulus (nblines, 10) != 0) ? aSeqLines : aSeqTenth;
|
||||||
@@ -233,8 +248,8 @@ void V3d_RectangularGrid::DefineLines ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// horizontals
|
// horizontals
|
||||||
aSeqTenth.Append(gp_Pnt(-myXSize, 0., -zl));
|
aSeqTenth.Append (gp_Pnt (-myXSize, 0.0, -zl));
|
||||||
aSeqTenth.Append(gp_Pnt( myXSize, 0., -zl));
|
aSeqTenth.Append (gp_Pnt ( myXSize, 0.0, -zl));
|
||||||
for (nblines = 1, yl = aYStep; yl < myYSize; yl += aYStep, nblines++)
|
for (nblines = 1, yl = aYStep; yl < myYSize; yl += aYStep, nblines++)
|
||||||
{
|
{
|
||||||
TColgp_SequenceOfPnt &aSeq = (Modulus (nblines, 10) != 0) ? aSeqLines : aSeqTenth;
|
TColgp_SequenceOfPnt &aSeq = (Modulus (nblines, 10) != 0) ? aSeqLines : aSeqTenth;
|
||||||
@@ -250,9 +265,10 @@ void V3d_RectangularGrid::DefineLines ()
|
|||||||
myGroup->SetPrimitivesAspect (aLineAspect);
|
myGroup->SetPrimitivesAspect (aLineAspect);
|
||||||
const Standard_Integer nbv = aSeqLines.Length();
|
const Standard_Integer nbv = aSeqLines.Length();
|
||||||
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (nbv);
|
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (nbv);
|
||||||
Standard_Integer n = 1;
|
for (Standard_Integer n = 1; n <= nbv; n++)
|
||||||
while (n<=nbv)
|
{
|
||||||
aPrims->AddVertex(aSeqLines(n++));
|
aPrims->AddVertex (aSeqLines (n));
|
||||||
|
}
|
||||||
myGroup->AddPrimitiveArray (aPrims, Standard_False);
|
myGroup->AddPrimitiveArray (aPrims, Standard_False);
|
||||||
}
|
}
|
||||||
if (aSeqTenth.Length())
|
if (aSeqTenth.Length())
|
||||||
@@ -261,14 +277,16 @@ void V3d_RectangularGrid::DefineLines ()
|
|||||||
myGroup->SetPrimitivesAspect (aLineAspect);
|
myGroup->SetPrimitivesAspect (aLineAspect);
|
||||||
const Standard_Integer nbv = aSeqTenth.Length();
|
const Standard_Integer nbv = aSeqTenth.Length();
|
||||||
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (nbv);
|
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (nbv);
|
||||||
Standard_Integer n = 1;
|
for (Standard_Integer n = 1; n <= nbv; n++)
|
||||||
while (n<=nbv)
|
{
|
||||||
aPrims->AddVertex(aSeqTenth(n++));
|
aPrims->AddVertex (aSeqTenth (n));
|
||||||
|
}
|
||||||
myGroup->AddPrimitiveArray (aPrims, Standard_False);
|
myGroup->AddPrimitiveArray (aPrims, Standard_False);
|
||||||
}
|
}
|
||||||
|
|
||||||
myGroup->SetMinMaxValues (-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
|
myGroup->SetMinMaxValues (-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
|
||||||
myCurXStep = aXStep, myCurYStep = aYStep;
|
myCurXStep = aXStep;
|
||||||
|
myCurYStep = aYStep;
|
||||||
|
|
||||||
// update bounding box
|
// update bounding box
|
||||||
myStructure->CalculateBoundBox();
|
myStructure->CalculateBoundBox();
|
||||||
@@ -300,10 +318,12 @@ void V3d_RectangularGrid::DefinePoints ()
|
|||||||
// horizontals
|
// horizontals
|
||||||
Standard_Real xl, yl;
|
Standard_Real xl, yl;
|
||||||
TColgp_SequenceOfPnt aSeqPnts;
|
TColgp_SequenceOfPnt aSeqPnts;
|
||||||
for (xl = 0.0; xl <= myXSize; xl += aXStep) {
|
for (xl = 0.0; xl <= myXSize; xl += aXStep)
|
||||||
|
{
|
||||||
aSeqPnts.Append (gp_Pnt ( xl, 0.0, -myOffSet));
|
aSeqPnts.Append (gp_Pnt ( xl, 0.0, -myOffSet));
|
||||||
aSeqPnts.Append (gp_Pnt (-xl, 0.0, -myOffSet));
|
aSeqPnts.Append (gp_Pnt (-xl, 0.0, -myOffSet));
|
||||||
for (yl = aYStep; yl <= myYSize; yl += aYStep) {
|
for (yl = aYStep; yl <= myYSize; yl += aYStep)
|
||||||
|
{
|
||||||
aSeqPnts.Append (gp_Pnt ( xl, yl, -myOffSet));
|
aSeqPnts.Append (gp_Pnt ( xl, yl, -myOffSet));
|
||||||
aSeqPnts.Append (gp_Pnt ( xl, -yl, -myOffSet));
|
aSeqPnts.Append (gp_Pnt ( xl, -yl, -myOffSet));
|
||||||
aSeqPnts.Append (gp_Pnt (-xl, yl, -myOffSet));
|
aSeqPnts.Append (gp_Pnt (-xl, yl, -myOffSet));
|
||||||
@@ -328,7 +348,8 @@ void V3d_RectangularGrid::DefinePoints ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
myGroup->SetMinMaxValues (-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
|
myGroup->SetMinMaxValues (-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
|
||||||
myCurXStep = aXStep, myCurYStep = aYStep;
|
myCurXStep = aXStep;
|
||||||
|
myCurYStep = aYStep;
|
||||||
|
|
||||||
// update bounding box
|
// update bounding box
|
||||||
myStructure->CalculateBoundBox();
|
myStructure->CalculateBoundBox();
|
||||||
@@ -344,24 +365,28 @@ void V3d_RectangularGrid::GraphicValues (Standard_Real& theXSize, Standard_Real&
|
|||||||
|
|
||||||
void V3d_RectangularGrid::SetGraphicValues (const Standard_Real theXSize, const Standard_Real theYSize, const Standard_Real theOffSet)
|
void V3d_RectangularGrid::SetGraphicValues (const Standard_Real theXSize, const Standard_Real theYSize, const Standard_Real theOffSet)
|
||||||
{
|
{
|
||||||
if (! myCurAreDefined) {
|
if (! myCurAreDefined)
|
||||||
|
{
|
||||||
myXSize = theXSize;
|
myXSize = theXSize;
|
||||||
myYSize = theYSize;
|
myYSize = theYSize;
|
||||||
myOffSet = theOffSet;
|
myOffSet = theOffSet;
|
||||||
}
|
}
|
||||||
if (myXSize != theXSize) {
|
if (myXSize != theXSize)
|
||||||
|
{
|
||||||
myXSize = theXSize;
|
myXSize = theXSize;
|
||||||
myCurAreDefined = Standard_False;
|
myCurAreDefined = Standard_False;
|
||||||
}
|
}
|
||||||
if (myYSize != theYSize) {
|
if (myYSize != theYSize)
|
||||||
|
{
|
||||||
myYSize = theYSize;
|
myYSize = theYSize;
|
||||||
myCurAreDefined = Standard_False;
|
myCurAreDefined = Standard_False;
|
||||||
}
|
}
|
||||||
if (myOffSet != theOffSet) {
|
if (myOffSet != theOffSet)
|
||||||
|
{
|
||||||
myOffSet = theOffSet;
|
myOffSet = theOffSet;
|
||||||
myCurAreDefined = Standard_False;
|
myCurAreDefined = Standard_False;
|
||||||
}
|
}
|
||||||
if( !myCurAreDefined ) UpdateDisplay();
|
if (!myCurAreDefined) { UpdateDisplay(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -40,6 +40,8 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT virtual void Display() Standard_OVERRIDE;
|
Standard_EXPORT virtual void Display() Standard_OVERRIDE;
|
||||||
|
|
||||||
|
Standard_EXPORT virtual void Update() Standard_OVERRIDE;
|
||||||
|
|
||||||
Standard_EXPORT virtual void Erase() const Standard_OVERRIDE;
|
Standard_EXPORT virtual void Erase() const Standard_OVERRIDE;
|
||||||
|
|
||||||
Standard_EXPORT virtual Standard_Boolean IsDisplayed() const Standard_OVERRIDE;
|
Standard_EXPORT virtual Standard_Boolean IsDisplayed() const Standard_OVERRIDE;
|
||||||
|
Reference in New Issue
Block a user