#include <Graphic3d_Group.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_Structure.hxx>
+#include <Graphic3d_TransformPersScaledAbove.hxx>
#include <Poly_Triangulation.hxx>
#include <Precision.hxx>
#include <Prs3d_DatumAspect.hxx>
return Abs(X-Y)<=Precision::Confusion();
}
+//=======================================================================
+//function : SetMinimumSize
+//purpose :
+//=======================================================================
+void AIS_Plane::SetMinimumSize (const Standard_Real theValue)
+{
+ if (theValue <= 0)
+ {
+ UnsetMinimumSize();
+ return;
+ }
+ Standard_Real aX, anY;
+ Size (aX, anY);
+ SetTransformPersistence (new Graphic3d_TransformPersScaledAbove (Min (aX, anY) / theValue, myCenter));
+}
+
+//=======================================================================
+//function : UnsetMinimumSize
+//purpose :
+//=======================================================================
+void AIS_Plane::UnsetMinimumSize()
+{
+ SetTransformPersistence (NULL);
+}
+
+//=======================================================================
+//function : HasMinimumSize
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_Plane::HasMinimumSize() const
+{
+ return !Handle(Graphic3d_TransformPersScaledAbove)::DownCast (TransformPersistence()).IsNull();
+}
+
//=======================================================================
//function : SetColor
//purpose :
Standard_Boolean HasOwnSize() const { return myHasOwnSize; }
+ //! Sets transform persistence for zoom with value of minimum size
+ Standard_EXPORT void SetMinimumSize (const Standard_Real theValue);
+
+ //! Unsets transform persistence zoom
+ Standard_EXPORT void UnsetMinimumSize();
+
+ //! Returns true if transform persistence for zoom is set
+ Standard_EXPORT Standard_Boolean HasMinimumSize() const;
+
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 7; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
Graphic3d_ToneMappingMethod.hxx
Graphic3d_TransformPers.hxx
Graphic3d_TransformPers.cxx
+Graphic3d_TransformPersScaledAbove.hxx
+Graphic3d_TransformPersScaledAbove.cxx
Graphic3d_TransformUtils.hxx
Graphic3d_TransModeFlags.hxx
Graphic3d_TypeOfAnswer.hxx
public:
+ //! Find scale value based on the camera position and view dimensions
+ //! @param theCamera [in] camera definition
+ //! @param theViewportWidth [in] the width of viewport.
+ //! @param theViewportHeight [in] the height of viewport.
+ virtual Standard_Real persistentScale (const Handle(Graphic3d_Camera)& theCamera,
+ const Standard_Integer /*theViewportWidth*/,
+ const Standard_Integer theViewportHeight) const
+ {
+ // use total size when tiling is active
+ const Standard_Integer aVPSizeY = theCamera->Tile().IsValid() ? theCamera->Tile().TotalSize.y() : theViewportHeight;
+
+ gp_Vec aVecToEye (theCamera->Direction());
+ gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ));
+ const Standard_Real aFocus = aVecToObj.Dot (aVecToEye);
+ const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
+ return Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
+ }
+
//! Apply transformation to bounding box of presentation.
//! @param theCamera [in] camera definition
//! @param theProjection [in] the projection transformation matrix.
if ((myMode & Graphic3d_TMF_ZoomPers) != 0)
{
// lock zooming
- gp_Vec aVecToEye (theCamera->Direction());
- gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ));
- const Standard_Real aFocus = aVecToObj.Dot (aVecToEye);
- const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
- const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
+ Standard_Real aScale = persistentScale (theCamera, theViewportWidth, theViewportHeight);
Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
}
theWorldView.ConvertFrom (aWorldView);
--- /dev/null
+// Copyright (c) 2021 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <Graphic3d_TransformPersScaledAbove.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_TransformPersScaledAbove, Graphic3d_TransformPers)
+
+// =======================================================================
+// function : Graphic3d_TransformPersScaledAbove
+// purpose :
+// =======================================================================
+Graphic3d_TransformPersScaledAbove::Graphic3d_TransformPersScaledAbove (const Standard_Real theScale,
+ const gp_Pnt& thePnt)
+: Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, thePnt),
+ myScale (theScale)
+{
+}
+
+// =======================================================================
+// function : persistentScale
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_TransformPersScaledAbove::persistentScale (const Handle(Graphic3d_Camera)& theCamera,
+ const Standard_Integer theViewportWidth,
+ const Standard_Integer theViewportHeight) const
+{
+ Standard_Real aScale = base_type::persistentScale (theCamera, theViewportWidth, theViewportHeight);
+ if (aScale < myScale)
+ {
+ // do not apply zoom persistent, the model is zoomed
+ return myScale;
+ }
+ return aScale;
+}
--- /dev/null
+// Copyright (c) 2021 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Graphic3d_TransformPersScaledAbove_HeaderFile
+#define _Graphic3d_TransformPersScaledAbove_HeaderFile
+
+#include <Graphic3d_TransformPers.hxx>
+
+DEFINE_STANDARD_HANDLE(Graphic3d_TransformPersScaledAbove, Graphic3d_TransformPers)
+
+//! Transformation Zoom persistence with the above boundary of scale.
+//! This persistence works only when the camera scale value is below the scale value of this persistence.
+//! Otherwise, no persistence is applied.
+class Graphic3d_TransformPersScaledAbove : public Graphic3d_TransformPers
+{
+public:
+ //! Create a Zoom transformation persistence with an anchor 3D point and a scale value
+ Standard_EXPORT Graphic3d_TransformPersScaledAbove (const Standard_Real theScale,
+ const gp_Pnt& thePnt);
+ //! Destructor
+ virtual ~Graphic3d_TransformPersScaledAbove() {}
+
+ //! Find scale value based on the camera position and view dimensions
+ //! If the camera scale value less than the persistence scale, zoom persistence is not applied.
+ //! @param theCamera [in] camera definition
+ //! @param theViewportWidth [in] the width of viewport.
+ //! @param theViewportHeight [in] the height of viewport.
+ Standard_EXPORT virtual Standard_Real persistentScale (const Handle(Graphic3d_Camera)& theCamera,
+ const Standard_Integer theViewportWidth,
+ const Standard_Integer theViewportHeight) const Standard_OVERRIDE;
+
+public:
+
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_TransformPersScaledAbove, Graphic3d_TransformPers)
+
+private:
+ Standard_Real myScale; //!< scale bound value
+};
+
+#endif
Standard_Real aSizeX = 0.0;
Standard_Real aSizeY = 0.0;
+ Standard_Boolean aHasMinSize = aPlane->HasMinimumSize();
+ Standard_Real aMinSizeY = 0.0;
aPlane->Size (aSizeX, aSizeY);
Standard_Boolean isUpdate = Standard_True;
{
aSizeY = aPValue.RealValue();
}
+ else if (aPName.IsEqual ("MINSIZE"))
+ {
+ aHasMinSize = Standard_True;
+ aMinSizeY = aPValue.RealValue();
+ }
}
else if (anArg.IsEqual ("NOUPDATE"))
{
aPlane->SetComponent (new Geom_Plane (aCenterPnt, aDirection));
aPlane->SetSize (aSizeX, aSizeY);
+ if (aHasMinSize)
+ {
+ aPlane->SetMinimumSize (aMinSizeY);
+ }
+ else if (aPlane->HasMinimumSize())
+ {
+ aPlane->UnsetMinimumSize();
+ }
+
aContextAIS->Update (aPlane, isUpdate);
return 0;
" [x=center_x y=center_y z=center_z]"
" [dx=dir_x dy=dir_y dz=dir_z]"
" [sx=size_x sy=size_y]"
+ " [minsize=value]"
" [noupdate]\n"
" - changes parameters of the plane:\n"
" - x y z - center\n"
--- /dev/null
+puts "============"
+puts "CR32091: Visualization - possibility to redefine Graphic3d_TransformPers"
+puts "============"
+puts ""
+
+pload VISUALIZATION MODELING
+vinit
+vclear
+
+vtrihedron t1
+box b1 500 500 500
+vdisplay b1 -dispmode 1
+
+vpoint p1 0 0 0
+vpoint p2 1 0 0
+vpoint p3 0 1 0
+
+vplane pl1 p1 p2 p3 0
+vfit
+
+vchangeplane pl1 sx=100 sy=100 minsize=100
+vupdate pl1
+vfit
+vdump ${imagedir}/${casename}_0.png
+
+vzoom 8
+vpan 1100 600
+vdump ${imagedir}/${casename}_1.png
+
+vfit
+vzoom 0.2
+vdump ${imagedir}/${casename}_2.png