mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bfed908c8f |
@@ -45,6 +45,7 @@ void Graphic3d_TransformPers::DumpJson (Standard_OStream& theOStream, Standard_I
|
|||||||
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
|
||||||
|
|
||||||
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMode)
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMode)
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZoomPersScale)
|
||||||
|
|
||||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myParams.Params3d)
|
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myParams.Params3d)
|
||||||
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myParams.Params2d)
|
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myParams.Params2d)
|
||||||
|
@@ -62,7 +62,8 @@ public:
|
|||||||
|
|
||||||
//! Set transformation persistence.
|
//! Set transformation persistence.
|
||||||
Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode)
|
Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode)
|
||||||
: myMode (theMode)
|
: myMode (theMode),
|
||||||
|
myZoomPersScale(1.0)
|
||||||
{
|
{
|
||||||
if (IsZoomOrRotate (theMode))
|
if (IsZoomOrRotate (theMode))
|
||||||
{
|
{
|
||||||
@@ -87,11 +88,24 @@ public:
|
|||||||
//! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
|
//! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
|
||||||
Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
|
Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
|
||||||
const gp_Pnt& thePnt)
|
const gp_Pnt& thePnt)
|
||||||
: myMode (Graphic3d_TMF_None)
|
: myMode (Graphic3d_TMF_None),
|
||||||
|
myZoomPersScale(1.0)
|
||||||
{
|
{
|
||||||
SetPersistence (theMode, thePnt);
|
SetPersistence (theMode, thePnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Set Zoom/Rotate transformation persistence with an anchor 3D point and a scaling factor for zoom persistence.
|
||||||
|
//! Anchor point defines the origin of Local Coordinate system within World Coordinate system.
|
||||||
|
//! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
|
||||||
|
Graphic3d_TransformPers(const Graphic3d_TransModeFlags theMode,
|
||||||
|
const gp_Pnt& thePnt,
|
||||||
|
const Standard_Real theZoomPersScale)
|
||||||
|
: myMode(Graphic3d_TMF_None),
|
||||||
|
myZoomPersScale(1.0)
|
||||||
|
{
|
||||||
|
SetPersistence(theMode, thePnt, theZoomPersScale);
|
||||||
|
}
|
||||||
|
|
||||||
//! Set 2d/trihedron transformation persistence with a corner and 2D offset.
|
//! Set 2d/trihedron transformation persistence with a corner and 2D offset.
|
||||||
//! 2D offset defines the origin of Local Coordinate system as projection of 2D point on screen plane into World Coordinate system.
|
//! 2D offset defines the origin of Local Coordinate system as projection of 2D point on screen plane into World Coordinate system.
|
||||||
//! Throws an exception if persistence mode is not Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d.
|
//! Throws an exception if persistence mode is not Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d.
|
||||||
@@ -99,7 +113,8 @@ public:
|
|||||||
Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
|
Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
|
||||||
const Aspect_TypeOfTriedronPosition theCorner,
|
const Aspect_TypeOfTriedronPosition theCorner,
|
||||||
const Graphic3d_Vec2i& theOffset = Graphic3d_Vec2i (0, 0))
|
const Graphic3d_Vec2i& theOffset = Graphic3d_Vec2i (0, 0))
|
||||||
: myMode (Graphic3d_TMF_None)
|
: myMode (Graphic3d_TMF_None),
|
||||||
|
myZoomPersScale(1.0)
|
||||||
{
|
{
|
||||||
SetPersistence (theMode, theCorner, theOffset);
|
SetPersistence (theMode, theCorner, theOffset);
|
||||||
}
|
}
|
||||||
@@ -116,6 +131,9 @@ public:
|
|||||||
//! Transformation persistence mode flags.
|
//! Transformation persistence mode flags.
|
||||||
Graphic3d_TransModeFlags Flags() const { return myMode; }
|
Graphic3d_TransModeFlags Flags() const { return myMode; }
|
||||||
|
|
||||||
|
//! Zoom persistence scale value.
|
||||||
|
Standard_Real ZoomPersScale() const { return myZoomPersScale; }
|
||||||
|
|
||||||
//! Set Zoom/Rotate transformation persistence with an anchor 3D point.
|
//! Set Zoom/Rotate transformation persistence with an anchor 3D point.
|
||||||
//! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
|
//! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
|
||||||
void SetPersistence (const Graphic3d_TransModeFlags theMode,
|
void SetPersistence (const Graphic3d_TransModeFlags theMode,
|
||||||
@@ -132,6 +150,24 @@ public:
|
|||||||
myParams.Params3d.PntZ = thePnt.Z();
|
myParams.Params3d.PntZ = thePnt.Z();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Set Zoom/Rotate transformation persistence with an anchor 3D point.
|
||||||
|
//! Throws an exception if persistence mode is not Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers.
|
||||||
|
void SetPersistence(const Graphic3d_TransModeFlags theMode,
|
||||||
|
const gp_Pnt& thePnt,
|
||||||
|
const Standard_Real theZoomPersScale)
|
||||||
|
{
|
||||||
|
if (!IsZoomOrRotate(theMode))
|
||||||
|
{
|
||||||
|
throw Standard_ProgramError("Graphic3d_TransformPers::SetPersistence(), wrong persistence mode.");
|
||||||
|
}
|
||||||
|
|
||||||
|
myMode = theMode;
|
||||||
|
myParams.Params3d.PntX = thePnt.X();
|
||||||
|
myParams.Params3d.PntY = thePnt.Y();
|
||||||
|
myParams.Params3d.PntZ = thePnt.Z();
|
||||||
|
myZoomPersScale = theZoomPersScale;
|
||||||
|
}
|
||||||
|
|
||||||
//! Set 2d/trihedron transformation persistence with a corner and 2D offset.
|
//! Set 2d/trihedron transformation persistence with a corner and 2D offset.
|
||||||
//! Throws an exception if persistence mode is not Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d.
|
//! Throws an exception if persistence mode is not Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d.
|
||||||
void SetPersistence (const Graphic3d_TransModeFlags theMode,
|
void SetPersistence (const Graphic3d_TransModeFlags theMode,
|
||||||
@@ -175,6 +211,17 @@ public:
|
|||||||
myParams.Params3d.PntZ = thePnt.Z();
|
myParams.Params3d.PntZ = thePnt.Z();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Set the scaling factor for zoom transformation persistence.
|
||||||
|
void SetZoomPersScale(const Standard_Real theZoomPersScale)
|
||||||
|
{
|
||||||
|
if (!IsZoomOrRotate())
|
||||||
|
{
|
||||||
|
throw Standard_ProgramError("Graphic3d_TransformPers::SetZoomPersScale(), wrong persistence mode.");
|
||||||
|
}
|
||||||
|
|
||||||
|
myZoomPersScale = theZoomPersScale;
|
||||||
|
}
|
||||||
|
|
||||||
//! Return the corner for 2d/trihedron transformation persistence.
|
//! Return the corner for 2d/trihedron transformation persistence.
|
||||||
Aspect_TypeOfTriedronPosition Corner2d() const
|
Aspect_TypeOfTriedronPosition Corner2d() const
|
||||||
{
|
{
|
||||||
@@ -238,7 +285,8 @@ public:
|
|||||||
gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ));
|
gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ));
|
||||||
const Standard_Real aFocus = aVecToObj.Dot (aVecToEye);
|
const Standard_Real aFocus = aVecToObj.Dot (aVecToEye);
|
||||||
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
|
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
|
||||||
return Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
|
//return Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
|
||||||
|
return myZoomPersScale > 0 ? Abs(aViewDim.Y()) / Standard_Real(aVPSizeY) * myZoomPersScale : Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Apply transformation to bounding box of presentation.
|
//! Apply transformation to bounding box of presentation.
|
||||||
@@ -332,6 +380,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
Graphic3d_TransModeFlags myMode; //!< Transformation persistence mode flags
|
Graphic3d_TransModeFlags myMode; //!< Transformation persistence mode flags
|
||||||
|
Standard_Real myZoomPersScale; //!< Scale factor for zoom persistence mode
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
PersParams3d Params3d;
|
PersParams3d Params3d;
|
||||||
@@ -409,17 +458,6 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
|
NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
|
||||||
|
|
||||||
//Adjust the camera axial scale for trihedron behaviour
|
|
||||||
gp_XYZ anAxialScale = theCamera->AxialScale();
|
|
||||||
Standard_Real anAxialX = anAxialScale.X();
|
|
||||||
Standard_Real anAxialY = anAxialScale.Y();
|
|
||||||
Standard_Real anAxialZ = anAxialScale.Z();
|
|
||||||
if (anAxialX > 0.0 && anAxialY > 0.0 && anAxialZ > 0.0)
|
|
||||||
{
|
|
||||||
Graphic3d_TransformUtils::Scale (aWorldView, 1.0 / anAxialX, 1.0 / anAxialY, 1.0 / anAxialZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphic3d_TransformUtils::Translate (aWorldView, aCenter.X(), aCenter.Y(), aCenter.Z());
|
Graphic3d_TransformUtils::Translate (aWorldView, aCenter.X(), aCenter.Y(), aCenter.Z());
|
||||||
Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
|
Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
|
||||||
theWorldView.ConvertFrom (aWorldView);
|
theWorldView.ConvertFrom (aWorldView);
|
||||||
|
@@ -5100,6 +5100,26 @@ static int VDisplay2 (Draw_Interpretor& theDI,
|
|||||||
aTrsfPers = new Graphic3d_TransformPers (aTrsfPers->Mode(), Aspect_TypeOfTriedronPosition (aCorner), Graphic3d_Vec2i (aZ.IntegerValue()));
|
aTrsfPers = new Graphic3d_TransformPers (aTrsfPers->Mode(), Aspect_TypeOfTriedronPosition (aCorner), Graphic3d_Vec2i (aZ.IntegerValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (aNameCase == "-trsfperszoom")
|
||||||
|
{
|
||||||
|
if (anArgIter + 1 >= theArgNb
|
||||||
|
|| aTrsfPers.IsNull())
|
||||||
|
{
|
||||||
|
Message::SendFail() << "Error: wrong syntax at " << aName << ".";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TCollection_AsciiString aZoomScaleFactor(theArgVec[++anArgIter]);
|
||||||
|
if (!aZoomScaleFactor.IsRealValue(Standard_True))
|
||||||
|
{
|
||||||
|
Message::SendFail() << "Error: wrong syntax at " << aName << ".";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (aTrsfPers->IsZoomOrRotate())
|
||||||
|
{
|
||||||
|
aTrsfPers->SetZoomPersScale(aZoomScaleFactor.RealValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (aNameCase == "-layer"
|
else if (aNameCase == "-layer"
|
||||||
|| aNameCase == "-zlayer")
|
|| aNameCase == "-zlayer")
|
||||||
{
|
{
|
||||||
|
@@ -1,46 +0,0 @@
|
|||||||
puts "========"
|
|
||||||
puts "0027832: Visualization - Scaled zbuffer trihedron"
|
|
||||||
puts "========"
|
|
||||||
puts ""
|
|
||||||
|
|
||||||
pload MODELING VISUALIZATION
|
|
||||||
vinit
|
|
||||||
box b 10 10 10
|
|
||||||
vdisplay b
|
|
||||||
vfit
|
|
||||||
vsetdispmode 1
|
|
||||||
vzbufftrihedron -on
|
|
||||||
#draw initial picture of box without visual scale
|
|
||||||
vdump $imagedir/${casename}_unscaled.png
|
|
||||||
|
|
||||||
#draw picture of box after visual scale
|
|
||||||
#and zoomed out
|
|
||||||
vscale 1 3 10
|
|
||||||
vzoom 0.99
|
|
||||||
|
|
||||||
set color_1 [vreadpixel 55 360 -rgb -name]
|
|
||||||
set color_2 [vreadpixel 50 350 -rgb -name]
|
|
||||||
set color_3 [vreadpixel 55 355 -rgb -name]
|
|
||||||
|
|
||||||
if {$color_1 != "RED3"} {
|
|
||||||
puts "ERROR: trihedron does not maintain position"
|
|
||||||
puts " additional investigation is needed"
|
|
||||||
puts " expected color is: RED3"
|
|
||||||
puts " current color is: $color_1"
|
|
||||||
}
|
|
||||||
|
|
||||||
if {$color_2 != "BLUE3"} {
|
|
||||||
puts "ERROR: trihedron does not maintain position"
|
|
||||||
puts " additional investigation is needed"
|
|
||||||
puts " expected color is: BLUE3"
|
|
||||||
puts " current color is: $color_2"
|
|
||||||
}
|
|
||||||
|
|
||||||
if {$color_3 != "GREEN3"} {
|
|
||||||
puts "ERROR: trihedron does not maintain position"
|
|
||||||
puts " additional investigation is needed"
|
|
||||||
puts " expected color is: GREEN3"
|
|
||||||
puts " current color is: $color_3"
|
|
||||||
}
|
|
||||||
|
|
||||||
vdump $imagedir/${casename}_scaled.png
|
|
23
tests/v3d/trsf/bug32135
Normal file
23
tests/v3d/trsf/bug32135
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "0032135: Visualization - possibility to redefine zoom persistent scale compute in Graphic3d_TransformPers"
|
||||||
|
puts "========"
|
||||||
|
|
||||||
|
pload ALL
|
||||||
|
vclear
|
||||||
|
vinit
|
||||||
|
box b 10 10 10
|
||||||
|
#display box with zoompersistence and a predefined scale
|
||||||
|
#test if zoom changes the box position
|
||||||
|
vdisplay b -dispmode 1 -trsfPers zoom
|
||||||
|
vzoom 5
|
||||||
|
if { [vreadpixel 210 200 -rgb -name] != "DARKGOLDENROD" } { puts "Error" }
|
||||||
|
if { [vreadpixel 210 210 -rgb -name] != "BLACK" } { puts "Error" }
|
||||||
|
|
||||||
|
vdump ${imagedir}/${casename}_1.png
|
||||||
|
|
||||||
|
#display box with zoom persistence but with a bigger scale
|
||||||
|
vzoom 0.2
|
||||||
|
vdisplay b -dispmode 1 -trsfPers zoom -trsfperszoom 5.0
|
||||||
|
if { [vreadpixel 230 215 -rgb -name] != "DARKGOLDENROD" } { puts "Error" }
|
||||||
|
|
||||||
|
vdump ${imagedir}/${casename}_2.png
|
Reference in New Issue
Block a user