@subsection upgrade_710_trsfpers Transformation persistence
-The behavior of transformation persistence flags Graphic3d_TMF_ZoomPers and Graphic3d_TMF_TriedronPers have been changed to be consistent with textured fixed-size 2D text.
+The behavior of transformation persistence flags *Graphic3d_TMF_ZoomPers* and *Graphic3d_TMF_TriedronPers* have been changed to be consistent with textured fixed-size 2D text.
Object with these flags is considered to be defined in pixel units, and presentation is no more scaled depending on view height.
Applications that need to scale such objects depending on viewport size should update them manually.
+Flags *Graphic3d_TMF_PanPers* and *Graphic3d_TMF_FullPers* has been removed.
+*Graphic3d_TMF_TriedronPers* or *Graphic3d_TMF_2d* can be used instead depending on context.
+
+*Graphic3d_TransModeFlags* is not an integer bitmask anymore - enumeration values should be specified instead.
+Several transformation persistence methods in PrsMgr_PresentableObject have been marked deprecated.
+Transformation persistence should be defined using directly Graphic3d_TransformPers constructor and passed by a handle, not value.
+
@subsection upgrade_710_removed Removed features
The following obsolete features have been removed:
myCurZoom (0.0),
myRect (new AIS_RubberBand (Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.0) )
{
- myRect->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0));
+ myRect->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
if (myRect->ZLayer() != Graphic3d_ZLayerId_TopOSD)
{
myRect->SetZLayer (Graphic3d_ZLayerId_TopOSD);
Handle(Graphic3d_AspectLine3d) aLineAspect =
new Graphic3d_AspectLine3d(Quantity_NOC_ANTIQUEWHITE, Aspect_TOL_SOLID,2);
if( HasPresentation() )
- aSelectionPrs->SetTransformPersistence( Presentation()->TransformPersistenceMode(), Presentation()->TransformPersistencePoint() );
+ aSelectionPrs->SetTransformPersistence (Presentation()->TransformPersistence());
Standard_Integer aLength = theOwners.Length();
Handle (SelectMgr_EntityOwner) anOwner;
Handle( Prs3d_Presentation ) aHighlightPrs;
aHighlightPrs = GetHilightPresentation( thePM );
if( HasPresentation() )
- aHighlightPrs->SetTransformPersistence( Presentation()->TransformPersistenceMode(), Presentation()->TransformPersistencePoint() );
+ aHighlightPrs->SetTransformPersistence (Presentation()->TransformPersistence());
if(theOwner.IsNull())
return;
aHighlightPrs->Clear();
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
- const Graphic3d_TransModeFlags& theFlag,
- const gp_Pnt& thePoint)
+ const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- theObject->SetTransformPersistence (theFlag, thePoint);
-
+ theObject->SetTransformPersistence (theTrsfPers);
if (!myObjects.IsBound (theObject))
{
return;
Standard_EXPORT void Status (const Handle(AIS_InteractiveObject)& anObj, TCollection_ExtendedString& astatus) const;
//! Sets transform persistence.
- Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj,
- const Graphic3d_TransModeFlags& theFlag,
- const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0));
+ Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers);
+
+ Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
+ void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj,
+ const Graphic3d_TransModeFlags& theFlag,
+ const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
+ {
+ SetTransformPersistence (theObj, Graphic3d_TransformPers::FromDeprecatedParams (theFlag, thePoint));
+ }
//! Updates the current viewer, the viewer in Neutral Point.
//! Objects selected when there is no open local context
if (myIsZoomPersistentMode)
{
- if (!(GetTransformPersistenceMode () == Graphic3d_TMF_ZoomPers
- && GetTransformPersistencePoint().IsEqual (myPosition.Location(), 0.)))
+ if (TransformPersistence().IsNull()
+ || TransformPersistence()->Mode() != Graphic3d_TMF_ZoomPers
+ || !TransformPersistence()->AnchorPoint().IsEqual (myPosition.Location(), 0.0))
{
- setTransformPersistence (Graphic3d_TMF_ZoomPers, myPosition.Location());
+ setTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, myPosition.Location()));
}
}
}
if (!theToEnable)
{
- setTransformPersistence (Graphic3d_TMF_None, gp::Origin());
+ setTransformPersistence (Handle(Graphic3d_TransformPers)());
}
updateTransformation();
//=======================================================================
//function : SetTransformPersistence
-//purpose :
+//purpose :
//=======================================================================
-void AIS_Manipulator::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag, const gp_Pnt& thePoint)
+void AIS_Manipulator::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
Standard_ASSERT_RETURN (!myIsZoomPersistentMode,
"AIS_Manipulator::SetTransformPersistence: "
- "Custom settings are not supported by this class in ZoomPersistence mode",);
+ "Custom settings are not allowed by this class in ZoomPersistence mode",);
- setTransformPersistence (theFlag, thePoint);
+ setTransformPersistence (theTrsfPers);
}
//=======================================================================
//function : setTransformPersistence
//purpose :
//=======================================================================
-void AIS_Manipulator::setTransformPersistence (const Graphic3d_TransModeFlags& theFlag, const gp_Pnt& thePoint)
+void AIS_Manipulator::setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- AIS_InteractiveObject::SetTransformPersistence (theFlag, thePoint);
+ AIS_InteractiveObject::SetTransformPersistence (theTrsfPers);
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
- myAxes[anIt].SetTransformPersistence (theFlag, thePoint);
+ myAxes[anIt].SetTransformPersistence (theTrsfPers);
}
}
anAspectAx->SetColor (myAxes[anIt].Color());
aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect());
myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx);
- myAxes[anIt].SetTransformPersistence (GetTransformPersistenceMode(),
- GetTransformPersistencePoint());
+ myAxes[anIt].SetTransformPersistence (TransformPersistence());
}
updateTransformation();
//! silently does nothing in release mode.
//! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
//! when enabling zoom persistence.
- Standard_EXPORT virtual void SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag, const gp_Pnt& thePoint) Standard_OVERRIDE;
+ Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
//! Redefines local transformation management method to inform user of inproper use.
//! @warning this interactive object does not support setting custom local transformation,
Standard_EXPORT void adjustSize (const Bnd_Box& theBox);
- Standard_EXPORT void setTransformPersistence (const Graphic3d_TransModeFlags& theFlag, const gp_Pnt& thePoint);
+ Standard_EXPORT void setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
protected: //! @name Auxilliary classes to fill presentation with proper primitives
const gp_Ax1& Position() const { return myPosition; }
- void SetTransformPersistence (const Graphic3d_TransModeFlags& theFlags, const gp_Pnt& thePoint)
+ void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
if (!myHighlightTranslator.IsNull())
{
- myHighlightTranslator->SetTransformPersistence (theFlags, thePoint);
+ myHighlightTranslator->SetTransformPersistence (theTrsfPers);
}
if (!myHighlightScaler.IsNull())
{
- myHighlightScaler->SetTransformPersistence (theFlags, thePoint);
+ myHighlightScaler->SetTransformPersistence (theTrsfPers);
}
if (!myHighlightRotator.IsNull())
{
- myHighlightRotator->SetTransformPersistence (theFlags, thePoint);
+ myHighlightRotator->SetTransformPersistence (theTrsfPers);
}
}
- Graphic3d_TransModeFlags GetTransformPersistenceMode() const { return myHighlightTranslator->TransformPersistenceMode(); }
-
- gp_Pnt GetTransformPersistencePoint() const { return myHighlightTranslator->TransformPersistencePoint(); }
-
void Transform (const Handle(Geom_Transformation)& theTransformation)
{
if (!myHighlightTranslator.IsNull())
//=======================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theTransformation,
- const Graphic3d_TransModeFlags& theTrsfPersFlag,
- const gp_Pnt& theTrsfPersPoint)
+ const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
if (myAssemblyOwner.IsNull())
myAssemblyOwner = new SelectMgr_EntityOwner (this);
}
anObjectToAdd->SetLocalTransformation (theTransformation);
- if (theTrsfPersFlag != Graphic3d_TMF_None)
+ if (!theTrsfPers.IsNull())
{
- anObjectToAdd->SetTransformPersistence (theTrsfPersFlag, theTrsfPersPoint);
+ anObjectToAdd->SetTransformPersistence (theTrsfPers);
}
AddChild (anObjectToAdd);
return anObjectToAdd;
//=======================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
{
- return Connect (theAnotherObj, theAnotherObj->LocalTransformation(),
- theAnotherObj->GetTransformPersistenceMode(),
- theAnotherObj->GetTransformPersistencePoint());
+ return Connect (theAnotherObj, theAnotherObj->LocalTransformation(), theAnotherObj->TransformPersistence());
}
//=======================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theTransformation)
{
- return Connect (theAnotherObj, theTransformation,
- theAnotherObj->GetTransformPersistenceMode(),
- theAnotherObj->GetTransformPersistencePoint());
+ return Connect (theAnotherObj, theTransformation, theAnotherObj->TransformPersistence());
}
//=======================================================================
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Locates instance in theLocation and applies specified transformation persistence mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
- Standard_EXPORT virtual Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive, const gp_Trsf& theLocation, const Graphic3d_TransModeFlags& theTrsfPersFlag, const gp_Pnt& theTrsfPersPoint);
+ Standard_EXPORT virtual Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive,
+ const gp_Trsf& theLocation,
+ const Handle(Graphic3d_TransformPers)& theTrsfPers);
+
+ Standard_DEPRECATED("This method is deprecated - Connect() taking Graphic3d_TransformPers should be called instead")
+ Handle(AIS_InteractiveObject) Connect (const Handle(AIS_InteractiveObject)& theInteractive,
+ const gp_Trsf& theLocation,
+ const Graphic3d_TransModeFlags& theTrsfPersFlag,
+ const gp_Pnt& theTrsfPersPoint)
+ {
+ return Connect (theInteractive, theLocation, Graphic3d_TransformPers::FromDeprecatedParams (theTrsfPersFlag, theTrsfPersPoint));
+ }
Standard_EXPORT virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE;
myDrawer->ShadingAspect()->SetTransparency (1.0);
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
- SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0));
+ SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
SetZLayer (Graphic3d_ZLayerId_TopOSD);
}
myDrawer->ShadingAspect()->SetTransparency (1.0);
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
- SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0));
+ SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
SetZLayer (Graphic3d_ZLayerId_TopOSD);
}
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myDrawer->ShadingAspect()->SetTransparency (theTransparency);
- SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0));
+ SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
SetZLayer (Graphic3d_ZLayerId_TopOSD);
}
aCenterOfLabel.ChangeCoord() -= myOrientation3D.XDirection().XYZ() * aWidth * 0.5;
}
- if (!anAsp->Aspect()->GetTextZoomable())
+ if (!anAsp->Aspect()->GetTextZoomable()
+ && (TransformPersistence().IsNull()
+ || TransformPersistence()->Mode() == Graphic3d_TMF_ZoomPers))
{
anAsp->Aspect()->SetTextZoomable (Standard_True);
- SetTransformPersistence (GetTransformPersistenceMode() | Graphic3d_TMF_ZoomPers, aPosition);
+ SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, aPosition));
aPosition = gp::Origin();
}
#ifndef _Aspect_TypeOfTriedronPosition_HeaderFile
#define _Aspect_TypeOfTriedronPosition_HeaderFile
-//! Definition of the Triedron position in the views
-//!
-//! TOTP_CENTER at the center of the view
-//! TOTP_LEFT_LOWER at the left lower corner
-//! TOTP_LEFT_UPPER at the left upper corner
-//! TOTP_RIGHT_LOWER at the right lower corner
-//! TOTP_RIGHT_UPPER at the right upper corner
-//! TOTP_01 to TOTP_10 not yet implemented.
+//! Definition of the Trihedron position in the views.
+//! It is defined as a bitmask to simplify handling vertical and horizontal alignment independently.
enum Aspect_TypeOfTriedronPosition
{
-Aspect_TOTP_CENTER,
-Aspect_TOTP_LEFT_LOWER,
-Aspect_TOTP_LEFT_UPPER,
-Aspect_TOTP_RIGHT_LOWER,
-Aspect_TOTP_RIGHT_UPPER,
-Aspect_TOTP_01,
-Aspect_TOTP_02,
-Aspect_TOTP_03,
-Aspect_TOTP_04,
-Aspect_TOTP_05,
-Aspect_TOTP_06,
-Aspect_TOTP_07,
-Aspect_TOTP_08,
-Aspect_TOTP_09,
-Aspect_TOTP_10
+ Aspect_TOTP_CENTER = 0x0000, //!< at the center of the view
+ Aspect_TOTP_TOP = 0x0001, //!< at the middle of the top side
+ Aspect_TOTP_BOTTOM = 0x0002, //!< at the middle of the bottom side
+ Aspect_TOTP_LEFT = 0x0004, //!< at the middle of the left side
+ Aspect_TOTP_RIGHT = 0x0008, //!< at the middle of the right side
+ Aspect_TOTP_LEFT_LOWER = Aspect_TOTP_BOTTOM
+ | Aspect_TOTP_LEFT, //!< at the left lower corner
+ Aspect_TOTP_LEFT_UPPER = Aspect_TOTP_TOP
+ | Aspect_TOTP_LEFT, //!< at the left upper corner
+ Aspect_TOTP_RIGHT_LOWER = Aspect_TOTP_BOTTOM
+ | Aspect_TOTP_RIGHT, //!< at the right lower corner
+ Aspect_TOTP_RIGHT_UPPER = Aspect_TOTP_TOP
+ | Aspect_TOTP_RIGHT, //!< at the right upper corner
+
};
#endif // _Aspect_TypeOfTriedronPosition_HeaderFile
Graphic3d_StereoMode.hxx
Graphic3d_Structure.cxx
Graphic3d_Structure.hxx
-Graphic3d_Structure.lxx
Graphic3d_Structure.pxx
Graphic3d_StructureDefinitionError.hxx
Graphic3d_StructureManager.cxx
Graphic3d_TextureRoot.hxx
Graphic3d_TransformError.hxx
Graphic3d_TransformPers.hxx
+Graphic3d_TransformPers.cxx
Graphic3d_TransformUtils.hxx
Graphic3d_TransModeFlags.hxx
Graphic3d_TypeOfAnswer.hxx
return myGroups;
}
+ //! Return transformation persistence.
+ const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
+
+ //! Set transformation persistence.
+ void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
+
//! @return associated clip planes
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
{
unsigned IsMutable : 1;
unsigned Is2dText : 1;
- Graphic3d_TransformPers TransformPersistence;
-
protected:
//! Create empty structure.
Handle(Graphic3d_GraphicDriver) myGraphicDriver;
Graphic3d_SequenceOfGroup myGroups;
Graphic3d_BndBox4f myBndBox;
+ Handle(Graphic3d_TransformPers) myTrsfPers;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
public:
}
// "FitAll" operation ignores object with transform persistence parameter
- if (aStructure->TransformPersistence().Flags != Graphic3d_TMF_None)
+ if (!aStructure->TransformPersistence().IsNull())
{
// Panning and 2d persistence apply changes to projection or/and its translation components.
// It makes them incompatible with z-fitting algorithm. Ignored by now.
- if (!theToIgnoreInfiniteFlag ||
- (aStructure->TransformPersistence().Flags & Graphic3d_TMF_2d) ||
- (aStructure->TransformPersistence().Flags & Graphic3d_TMF_PanPers) ||
- (aStructure->TransformPersistence().Flags & Graphic3d_TMF_TriedronPers))
+ if (!theToIgnoreInfiniteFlag
+ || aStructure->TransformPersistence()->IsTrihedronOr2d())
{
continue;
}
continue;
}
- if (aStructure->TransformPersistence().Flags != Graphic3d_TMF_None)
+ if (!aStructure->TransformPersistence().IsNull())
{
const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix();
- aStructure->TransformPersistence().Apply (aCamera, aProjectionMat, aWorldViewMat, aWinWidth, aWinHeight, aBox);
+ aStructure->TransformPersistence()->Apply (aCamera, aProjectionMat, aWorldViewMat, aWinWidth, aWinHeight, aBox);
}
// To prevent float overflow at camera parameters calculation and further
myAxialScale (1.0, 1.0, 1.0),
myProjType (Projection_Orthographic),
myFOVy (45.0),
+ myFOVyTan (Tan (DTR_HALF * 45.0)),
myZNear (DEFAULT_ZNEAR),
myZFar (DEFAULT_ZFAR),
myAspect (1.0),
case Projection_MonoLeftEye :
case Projection_MonoRightEye :
{
- Standard_Real aDistance = theScale * 0.5 / Tan(DTR_HALF * myFOVy);
+ Standard_Real aDistance = theScale * 0.5 / myFOVyTan;
SetDistance (aDistance);
}
// case Projection_MonoLeftEye :
// case Projection_MonoRightEye :
default :
- return Distance() * 2.0 * Tan (DTR_HALF * myFOVy);
+ return Distance() * 2.0 * myFOVyTan;
}
}
}
myFOVy = theFOVy;
+ myFOVyTan = Tan(DTR_HALF * myFOVy);
InvalidateProjection();
}
gp_XYZ Graphic3d_Camera::ViewDimensions (const Standard_Real theZValue) const
{
// view plane dimensions
- Standard_Real aSize = IsOrthographic() ? myScale : (2.0 * theZValue * Tan (DTR_HALF * myFOVy));
+ Standard_Real aSize = IsOrthographic() ? myScale : (2.0 * theZValue * myFOVyTan);
Standard_Real aSizeX, aSizeY;
if (myAspect > 1.0)
{
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::OrientationMatrix() const
{
- return *UpdateOrientation (myMatricesD).Orientation;
+ return UpdateOrientation (myMatricesD).Orientation;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::OrientationMatrixF() const
{
- return *UpdateOrientation (myMatricesF).Orientation;
+ return UpdateOrientation (myMatricesF).Orientation;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionMatrix() const
{
- return *UpdateProjection (myMatricesD).MProjection;
+ return UpdateProjection (myMatricesD).MProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionMatrixF() const
{
- return *UpdateProjection (myMatricesF).MProjection;
+ return UpdateProjection (myMatricesF).MProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoLeft() const
{
- return *UpdateProjection (myMatricesD).LProjection;
+ return UpdateProjection (myMatricesD).LProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoLeftF() const
{
- return *UpdateProjection (myMatricesF).LProjection;
+ return UpdateProjection (myMatricesF).LProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoRight() const
{
- return *UpdateProjection (myMatricesD).RProjection;
+ return UpdateProjection (myMatricesD).RProjection;
}
// =======================================================================
// =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoRightF() const
{
- return *UpdateProjection (myMatricesF).RProjection;
+ return UpdateProjection (myMatricesF).RProjection;
}
// =======================================================================
}
else
{
- aDXHalf = aZNear * Elem_t (Tan (DTR_HALF * myFOVy));
- aDYHalf = aZNear * Elem_t (Tan (DTR_HALF * myFOVy));
+ aDXHalf = aZNear * Elem_t (myFOVyTan);
+ aDYHalf = aZNear * Elem_t (myFOVyTan);
}
if (anAspect > 1.0)
switch (myProjType)
{
case Projection_Orthographic :
- OrthoProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection);
+ OrthoProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
break;
case Projection_Perspective :
- PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection);
+ PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
break;
case Projection_MonoLeftEye :
{
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
- Standard_True, *theMatrices.MProjection);
- *theMatrices.LProjection = *theMatrices.MProjection;
+ Standard_True, theMatrices.MProjection);
+ theMatrices.LProjection = theMatrices.MProjection;
break;
}
{
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
- Standard_False, *theMatrices.MProjection);
- *theMatrices.RProjection = *theMatrices.MProjection;
+ Standard_False, theMatrices.MProjection);
+ theMatrices.RProjection = theMatrices.MProjection;
break;
}
case Projection_Stereo :
{
- PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection);
+ PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
Standard_True,
- *theMatrices.LProjection);
+ theMatrices.LProjection);
StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus,
Standard_False,
- *theMatrices.RProjection);
+ theMatrices.RProjection);
break;
}
}
static_cast<Elem_t> (myAxialScale.Y()),
static_cast<Elem_t> (myAxialScale.Z()));
- LookOrientation (anEye, aCenter, anUp, anAxialScale, *theMatrices.Orientation);
+ LookOrientation (anEye, aCenter, anUp, anAxialScale, theMatrices.Orientation);
return theMatrices; // for inline accessors
}
#include <Graphic3d_Vec3.hxx>
#include <Graphic3d_WorldViewProjState.hxx>
-#include <NCollection_Handle.hxx>
-
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
template<typename Elem_t>
struct TransformMatrices
{
+
+ //! Default constructor.
+ TransformMatrices() : myIsOrientationValid (Standard_False), myIsProjectionValid (Standard_False) {}
+
+ //! Initialize orientation.
void InitOrientation()
{
- Orientation = new NCollection_Mat4<Elem_t>();
+ myIsOrientationValid = Standard_True;
+ Orientation.InitIdentity();
}
+ //! Initialize projection.
void InitProjection()
{
- MProjection = new NCollection_Mat4<Elem_t>();
- LProjection = new NCollection_Mat4<Elem_t>();
- RProjection = new NCollection_Mat4<Elem_t>();
+ myIsProjectionValid = Standard_True;
+ MProjection.InitIdentity();
+ LProjection.InitIdentity();
+ RProjection.InitIdentity();
}
- void ResetOrientation()
- {
- Orientation.Nullify();
- }
+ //! Invalidate orientation.
+ void ResetOrientation() { myIsOrientationValid = Standard_False; }
- void ResetProjection()
- {
- MProjection.Nullify();
- LProjection.Nullify();
- RProjection.Nullify();
- }
+ //! Invalidate projection.
+ void ResetProjection() { myIsProjectionValid = Standard_False; }
- Standard_Boolean IsOrientationValid()
- {
- return !Orientation.IsNull();
- }
+ //! Return true if Orientation was not invalidated.
+ Standard_Boolean IsOrientationValid() const { return myIsOrientationValid; }
- Standard_Boolean IsProjectionValid()
- {
- return !MProjection.IsNull() &&
- !LProjection.IsNull() &&
- !RProjection.IsNull();
- }
+ //! Return true if Projection was not invalidated.
+ Standard_Boolean IsProjectionValid() const { return myIsProjectionValid; }
+
+ public:
+
+ NCollection_Mat4<Elem_t> Orientation;
+ NCollection_Mat4<Elem_t> MProjection;
+ NCollection_Mat4<Elem_t> LProjection;
+ NCollection_Mat4<Elem_t> RProjection;
+
+ private:
+
+ Standard_Boolean myIsOrientationValid;
+ Standard_Boolean myIsProjectionValid;
- NCollection_Handle< NCollection_Mat4<Elem_t> > Orientation;
- NCollection_Handle< NCollection_Mat4<Elem_t> > MProjection;
- NCollection_Handle< NCollection_Mat4<Elem_t> > LProjection;
- NCollection_Handle< NCollection_Mat4<Elem_t> > RProjection;
};
public:
Projection myProjType; //!< Projection type used for rendering.
Standard_Real myFOVy; //!< Field Of View in y axis.
+ Standard_Real myFOVyTan; //!< Field Of View as Tan(DTR_HALF * myFOVy)
Standard_Real myZNear; //!< Distance to near clipping plane.
Standard_Real myZFar; //!< Distance to far clipping plane.
Standard_Real myAspect; //!< Width to height display ratio.
//function : SetTransformPersistence
//purpose :
//=============================================================================
-void Graphic3d_Structure::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag)
+void Graphic3d_Structure::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- SetTransformPersistence (theFlag, gp_Pnt (0.0, 0.0, 0.0));
-}
-
-//=============================================================================
-//function : SetTransformPersistence
-//purpose :
-//=============================================================================
-void Graphic3d_Structure::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag,
- const gp_Pnt& thePoint)
-{
- if (IsDeleted()) return;
-
- myCStructure->TransformPersistence.Flags = theFlag;
- myCStructure->TransformPersistence.Point.x() = thePoint.X();
- myCStructure->TransformPersistence.Point.y() = thePoint.Y();
- myCStructure->TransformPersistence.Point.z() = thePoint.Z();
-}
-
-//=============================================================================
-//function : TransformPersistenceMode
-//purpose :
-//=============================================================================
-Graphic3d_TransModeFlags Graphic3d_Structure::TransformPersistenceMode() const
-{
- return myCStructure->TransformPersistence.Flags;
-}
+ if (IsDeleted())
+ {
+ return;
+ }
-//=============================================================================
-//function : TransformPersistencePoint
-//purpose :
-//=============================================================================
-gp_Pnt Graphic3d_Structure::TransformPersistencePoint() const
-{
- gp_Pnt aPnt (0.0, 0.0, 0.0);
- aPnt.SetX (myCStructure->TransformPersistence.Point.x());
- aPnt.SetY (myCStructure->TransformPersistence.Point.y());
- aPnt.SetZ (myCStructure->TransformPersistence.Point.z());
- return aPnt;
+ myCStructure->SetTransformPersistence (theTrsfPers);
}
//=============================================================================
//! Returns the transformation associated with
//! the structure <me>.
Standard_EXPORT void Transform (TColStd_Array2OfReal& AMatrix) const;
-
- //! Modifies the current modelling transform persistence (pan, zoom or rotate)
- Standard_EXPORT void SetTransformPersistence (const Graphic3d_TransModeFlags& AFlag, const gp_Pnt& APoint);
-
- Standard_EXPORT void SetTransformPersistence (const Graphic3d_TransModeFlags& AFlag);
-
- //! Get the current modelling transform persistence (pan, zoom or rotate)
- Standard_EXPORT Graphic3d_TransModeFlags TransformPersistenceMode() const;
-
- //! Get the current point of relative modelling transform persistence
- Standard_EXPORT gp_Pnt TransformPersistencePoint() const;
+
+ //! Modifies the current transform persistence (pan, zoom or rotate)
+ Standard_EXPORT void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! @return transform persistence of the presentable object.
- const Graphic3d_TransformPers& TransformPersistence() const;
+ const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myCStructure->TransformPersistence(); }
//! Sets if the structure location has mutable nature (content or location will be changed regularly).
Standard_EXPORT void SetMutable (const Standard_Boolean theIsMutable);
Standard_EXPORT static Graphic3d_Vertex Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vertex& Coord);
//! Returns the low-level structure
- const Handle(Graphic3d_CStructure)& CStructure() const;
+ const Handle(Graphic3d_CStructure)& CStructure() const { return myCStructure; }
friend class Graphic3d_Group;
Standard_Address myOwner;
Graphic3d_TypeOfStructure myVisual;
-
};
-
-#include <Graphic3d_Structure.lxx>
-
-
-
-
-
#endif // _Graphic3d_Structure_HeaderFile
+++ /dev/null
-// Created on: 2014-03-23
-// Created by: Kirill Gavrilov
-// Copyright (c) 2014 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.
-
-// =======================================================================
-// function : CStructure
-// purpose : Returns the low-level structure
-// =======================================================================
-inline const Handle(Graphic3d_CStructure)& Graphic3d_Structure::CStructure() const
-{
- return myCStructure;
-}
-
-// =======================================================================
-// function : TransformPersistence
-// purpose :
-// =======================================================================
-inline const Graphic3d_TransformPers& Graphic3d_Structure::TransformPersistence() const
-{
- return myCStructure->TransformPersistence;
-}
#ifndef Graphic3d_TRANS_MODE_FLAGS_HXX
#define Graphic3d_TRANS_MODE_FLAGS_HXX
-typedef Standard_Integer Graphic3d_TransModeFlags;
-
-enum {
- Graphic3d_TMF_None = 0x0000,
- Graphic3d_TMF_PanPers = 0x0001,
- Graphic3d_TMF_ZoomPers = 0x0002,
- Graphic3d_TMF_RotatePers = 0x0008,
- Graphic3d_TMF_TriedronPers = 0x0020,
- Graphic3d_TMF_2d = 0x0040,
- Graphic3d_TMF_FullPers = Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers
+//! Transform Persistence Mode defining whether to lock in object position, rotation and / or zooming relative to camera position.
+enum Graphic3d_TransModeFlags
+{
+ Graphic3d_TMF_None = 0x0000, //!< no persistence attributes (normal 3D object)
+ Graphic3d_TMF_ZoomPers = 0x0002, //!< object does not resize
+ Graphic3d_TMF_RotatePers = 0x0008, //!< object does not rotate;
+ Graphic3d_TMF_TriedronPers = 0x0020, //!< object behaves like trihedron - it is fixed at the corner of view and does not resizing (but rotating)
+ Graphic3d_TMF_2d = 0x0040, //!< object is defined in 2D screen coordinates (pixels) and does not resize, pan and rotate
+ Graphic3d_TMF_ZoomRotatePers = Graphic3d_TMF_ZoomPers
+ | Graphic3d_TMF_RotatePers //!< object doesn't resize and rotate
};
-
#endif
--- /dev/null
+// Copyright (c) 2016 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_TransformPers.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_TransformPers, Standard_Transient)
+
+// =======================================================================
+// function : FromDeprecatedParams
+// purpose :
+// =======================================================================
+Handle(Graphic3d_TransformPers) Graphic3d_TransformPers::FromDeprecatedParams (Graphic3d_TransModeFlags theFlag,
+ const gp_Pnt& thePoint)
+{
+ Handle(Graphic3d_TransformPers) aTrsfPers;
+ if (Graphic3d_TransformPers::IsZoomOrRotate (theFlag))
+ {
+ aTrsfPers = new Graphic3d_TransformPers (theFlag, thePoint);
+ }
+ else if (Graphic3d_TransformPers::IsTrihedronOr2d (theFlag))
+ {
+ Standard_Integer aCorner = Aspect_TOTP_CENTER;
+ const Graphic3d_Vec2i anOffset (Standard_Integer(thePoint.Z()), Standard_Integer(thePoint.Z()));
+ if (thePoint.X() > 0.0)
+ {
+ aCorner |= Aspect_TOTP_RIGHT;
+ }
+ else if (thePoint.X() < 0.0)
+ {
+ aCorner |= Aspect_TOTP_LEFT;
+ }
+ if (thePoint.Y() > 0.0)
+ {
+ aCorner |= Aspect_TOTP_TOP;
+ }
+ else if (thePoint.Y() < 0.0)
+ {
+ aCorner |= Aspect_TOTP_BOTTOM;
+ }
+ aTrsfPers = new Graphic3d_TransformPers (theFlag, Aspect_TypeOfTriedronPosition(aCorner), anOffset);
+ }
+ return aTrsfPers;
+}
#ifndef _Graphic3d_TransformPers_HeaderFile
#define _Graphic3d_TransformPers_HeaderFile
+#include <Aspect_TypeOfTriedronPosition.hxx>
#include <Bnd_Box.hxx>
#include <BVH_Box.hxx>
#include <Graphic3d_Camera.hxx>
#include <Graphic3d_TransformUtils.hxx>
#include <Graphic3d_TransModeFlags.hxx>
+#include <Graphic3d_Vec.hxx>
#include <NCollection_Mat4.hxx>
-#include <NCollection_Vec4.hxx>
+
+DEFINE_STANDARD_HANDLE(Graphic3d_TransformPers, Standard_Transient)
//! Class for keeping and computing transformation persistence.
-class Graphic3d_TransformPers
+//! Note that instance of this class can not define
+//! no transformation persistence Graphic3d_TMF_None - NULL handle should be used for this purpose.
+class Graphic3d_TransformPers : public Standard_Transient
{
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_TransformPers, Standard_Transient)
public:
- DEFINE_STANDARD_ALLOC
+ //! Return true if specified mode is zoom/rotate transformation persistence.
+ static Standard_Boolean IsZoomOrRotate (Graphic3d_TransModeFlags theMode)
+ {
+ return (theMode & (Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers)) != 0;
+ }
+
+ //! Return true if specified mode is 2d/trihedron transformation persistence.
+ static Standard_Boolean IsTrihedronOr2d (Graphic3d_TransModeFlags theMode)
+ {
+ return (theMode & (Graphic3d_TMF_TriedronPers | Graphic3d_TMF_2d)) != 0;
+ }
- //! Default constructor.
- Graphic3d_TransformPers()
- : Flags (Graphic3d_TMF_None),
- Point (0.0, 0.0, 0.0) {}
+ //! Create Graphic3d_TransformPers instance from deprecated parameters set
+ //! decoding 2D corner + offset parameters from 3D point.
+ Standard_EXPORT static Handle(Graphic3d_TransformPers) FromDeprecatedParams (Graphic3d_TransModeFlags theFlag,
+ const gp_Pnt& thePoint);
+
+public:
+
+ //! Set transformation persistence.
+ Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode)
+ : myMode (theMode)
+ {
+ if (IsZoomOrRotate (theMode))
+ {
+ SetPersistence (theMode, gp_Pnt(0.0, 0.0, 0.0));
+ }
+ else if (IsTrihedronOr2d (theMode))
+ {
+ SetPersistence (theMode, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (0, 0));
+ }
+ else
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::SetPersistence(), wrong persistence mode.");
+ }
+ }
+
+ //! 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.
+ Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
+ const gp_Pnt& thePnt)
+ : myMode (Graphic3d_TMF_None)
+ {
+ SetPersistence (theMode, thePnt);
+ }
+
+ //! 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.
+ //! The offset is a positive displacement from the view corner in pixels.
+ Graphic3d_TransformPers (const Graphic3d_TransModeFlags theMode,
+ const Aspect_TypeOfTriedronPosition theCorner,
+ const Graphic3d_Vec2i& theOffset = Graphic3d_Vec2i (0, 0))
+ : myMode (Graphic3d_TMF_None)
+ {
+ SetPersistence (theMode, theCorner, theOffset);
+ }
+
+ //! Return true for Graphic3d_TMF_ZoomPers, Graphic3d_TMF_ZoomRotatePers or Graphic3d_TMF_RotatePers modes.
+ Standard_Boolean IsZoomOrRotate() const { return IsZoomOrRotate (myMode); }
+
+ //! Return true for Graphic3d_TMF_TriedronPers and Graphic3d_TMF_2d modes.
+ Standard_Boolean IsTrihedronOr2d() const { return IsTrihedronOr2d (myMode); }
//! Transformation persistence mode flags.
- Graphic3d_TransModeFlags Flags;
+ Graphic3d_TransModeFlags Mode() const { return myMode; }
- //! Reference point for transformation.
- Graphic3d_Vec3d Point;
+ //! Transformation persistence mode flags.
+ Graphic3d_TransModeFlags Flags() const { return myMode; }
+
+ //! 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)
+ {
+ if (!IsZoomOrRotate (theMode))
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::SetPersistence(), wrong persistence mode.");
+ }
+
+ myMode = theMode;
+ myParams.Params3d.PntX = thePnt.X();
+ myParams.Params3d.PntY = thePnt.Y();
+ myParams.Params3d.PntZ = thePnt.Z();
+ }
+
+ //! 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.
+ void SetPersistence (const Graphic3d_TransModeFlags theMode,
+ const Aspect_TypeOfTriedronPosition theCorner,
+ const Graphic3d_Vec2i& theOffset)
+ {
+ if (!IsTrihedronOr2d (theMode))
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::SetPersistence(), wrong persistence mode.");
+ }
+
+ myMode = theMode;
+ myParams.Params2d.Corner = theCorner;
+ myParams.Params2d.OffsetX = theOffset.x();
+ myParams.Params2d.OffsetY = theOffset.y();
+ }
+
+public:
+
+ //! Return the anchor point for zoom/rotate transformation persistence.
+ gp_Pnt AnchorPoint() const
+ {
+ if (!IsZoomOrRotate())
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::AnchorPoint(), wrong persistence mode.");
+ }
+
+ return gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ);
+ }
+
+ //! Set the anchor point for zoom/rotate transformation persistence.
+ void SetAnchorPoint (const gp_Pnt& thePnt)
+ {
+ if (!IsZoomOrRotate())
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::SetAnchorPoint(), wrong persistence mode.");
+ }
+
+ myParams.Params3d.PntX = thePnt.X();
+ myParams.Params3d.PntY = thePnt.Y();
+ myParams.Params3d.PntZ = thePnt.Z();
+ }
+
+ //! Return the corner for 2d/trihedron transformation persistence.
+ Aspect_TypeOfTriedronPosition Corner2d() const
+ {
+ if (!IsTrihedronOr2d())
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::Corner2d(), wrong persistence mode.");
+ }
+
+ return myParams.Params2d.Corner;
+ }
+
+ //! Set the corner for 2d/trihedron transformation persistence.
+ void SetCorner2d (const Aspect_TypeOfTriedronPosition thePos)
+ {
+ if (!IsTrihedronOr2d())
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::SetCorner2d(), wrong persistence mode.");
+ }
+
+ myParams.Params2d.Corner = thePos;
+ }
+
+ //! Return the offset from the corner for 2d/trihedron transformation persistence.
+ Graphic3d_Vec2i Offset2d() const
+ {
+ if (!IsTrihedronOr2d())
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::Offset2d(), wrong persistence mode.");
+ }
+
+ return Graphic3d_Vec2i (myParams.Params2d.OffsetX, myParams.Params2d.OffsetY);
+ }
+
+ //! Set the offset from the corner for 2d/trihedron transformation persistence.
+ void SetOffset2d (const Graphic3d_Vec2i& theOffset)
+ {
+ if (!IsTrihedronOr2d())
+ {
+ Standard_ProgramError::Raise ("Graphic3d_TransformPers::SetOffset2d(), wrong persistence mode.");
+ }
+
+ myParams.Params2d.OffsetX = theOffset.x();
+ myParams.Params2d.OffsetY = theOffset.y();
+ }
public:
//! @param theViewportHeight viewport height
template<class T>
void Apply (const Handle(Graphic3d_Camera)& theCamera,
- NCollection_Mat4<T>& theProjection,
+ const NCollection_Mat4<T>& theProjection,
NCollection_Mat4<T>& theWorldView,
const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const;
- //! Return true if transformation persistence alters projection matrix.
- bool AltersProjectionMatrix() const
+private:
+
+ //! 3D anchor point for zoom/rotate transformation persistence.
+ struct PersParams3d
{
- return (Flags & Graphic3d_TMF_PanPers) != 0;
- }
+ Standard_Real PntX;
+ Standard_Real PntY;
+ Standard_Real PntZ;
+ };
+
+ //! 2d/trihedron transformation persistence parameters.
+ struct PersParams2d
+ {
+ Standard_Integer OffsetX;
+ Standard_Integer OffsetY;
+ Aspect_TypeOfTriedronPosition Corner;
+ };
+
+private:
+
+ Graphic3d_TransModeFlags myMode; //!< Transformation persistence mode flags
+ union
+ {
+ PersParams3d Params3d;
+ PersParams2d Params2d;
+ } myParams;
};
// =======================================================================
template<class T>
void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
- NCollection_Mat4<T>& theProjection,
+ const NCollection_Mat4<T>& theProjection,
NCollection_Mat4<T>& theWorldView,
const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const
{
(void )theViewportWidth;
- if (Flags == Graphic3d_TMF_None
+ (void )theProjection;
+ if (myMode == Graphic3d_TMF_None
|| theViewportHeight == 0)
{
return;
}
+ // use total size when tiling is active
const Standard_Integer aVPSizeY = theCamera->Tile().IsValid() ? theCamera->Tile().TotalSize.y() : theViewportHeight;
- if (Flags == Graphic3d_TMF_TriedronPers)
+
+ // a small enough jitter compensation offset
+ // to avoid image dragging within single pixel in corner cases
+ const Standard_Real aJitterComp = 0.001;
+ if (myMode == Graphic3d_TMF_TriedronPers)
{
// reset Z focus for trihedron persistence
const Standard_Real aFocus = theCamera->IsOrthographic()
// scale factor to pixels
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
-
- // offset from the corner
- const Standard_Real anOffset = Point.z() * aScale;
-
const gp_Dir aForward (theCamera->Center().XYZ() - theCamera->Eye().XYZ());
gp_XYZ aCenter = theCamera->Center().XYZ() + aForward.XYZ() * (aFocus - theCamera->Distance());
- if (Point.x() != 0.0)
+ if ((myParams.Params2d.Corner & (Aspect_TOTP_LEFT | Aspect_TOTP_RIGHT)) != 0)
{
- const gp_Dir aSide = aForward.Crossed (theCamera->Up());
- if (Point.x() > 0.0)
+ const Standard_Real anOffsetX = (Standard_Real(myParams.Params2d.OffsetX) + aJitterComp) * aScale;
+ const gp_Dir aSide = aForward.Crossed (theCamera->Up());
+ const gp_XYZ aDeltaX = aSide.XYZ() * (Abs(aViewDim.X()) * 0.5 - anOffsetX);
+ if ((myParams.Params2d.Corner & Aspect_TOTP_RIGHT) != 0)
{
- aCenter += aSide.XYZ() * (Abs(aViewDim.X()) * 0.5 - anOffset);
+ aCenter += aDeltaX;
}
else
{
- aCenter -= aSide.XYZ() * (Abs(aViewDim.X()) * 0.5 - anOffset);
+ aCenter -= aDeltaX;
}
}
- if (Point.y() != 0.0)
+ if ((myParams.Params2d.Corner & (Aspect_TOTP_TOP | Aspect_TOTP_BOTTOM)) != 0)
{
- if (Point.y() > 0.0)
+ const Standard_Real anOffsetY = (Standard_Real(myParams.Params2d.OffsetY) + aJitterComp) * aScale;
+ const gp_XYZ aDeltaY = theCamera->Up().XYZ() * (Abs(aViewDim.Y()) * 0.5 - anOffsetY);
+ if ((myParams.Params2d.Corner & Aspect_TOTP_TOP) != 0)
{
- aCenter += theCamera->Up().XYZ() * (Abs(aViewDim.Y()) * 0.5 - anOffset);
+ aCenter += aDeltaY;
}
else
{
- aCenter -= theCamera->Up().XYZ() * (Abs(aViewDim.Y()) * 0.5 - anOffset);
+ aCenter -= aDeltaY;
}
}
- Graphic3d_TransformUtils::Translate (theWorldView, T(aCenter.X()), T(aCenter.Y()), T(aCenter.Z()));
- Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
+ NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
+ Graphic3d_TransformUtils::Translate (aWorldView, aCenter.X(), aCenter.Y(), aCenter.Z());
+ Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
+ theWorldView.ConvertFrom (aWorldView);
return;
}
- else if (Flags == Graphic3d_TMF_2d)
+ else if (myMode == Graphic3d_TMF_2d)
{
const Standard_Real aFocus = theCamera->IsOrthographic()
? theCamera->Distance()
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
gp_XYZ aCenter (0.0, 0.0, -aFocus);
- if (Point.x() != 0.0)
+ if ((myParams.Params2d.Corner & (Aspect_TOTP_LEFT | Aspect_TOTP_RIGHT)) != 0)
{
- aCenter.SetX (-aViewDim.X() * 0.5 + Point.z() * aScale);
- if (Point.x() > 0.0)
+ aCenter.SetX (-aViewDim.X() * 0.5 + (Standard_Real(myParams.Params2d.OffsetX) + aJitterComp) * aScale);
+ if ((myParams.Params2d.Corner & Aspect_TOTP_RIGHT) != 0)
{
aCenter.SetX (-aCenter.X());
}
}
- if (Point.y() != 0.0)
+ if ((myParams.Params2d.Corner & (Aspect_TOTP_TOP | Aspect_TOTP_BOTTOM)) != 0)
{
- aCenter.SetY (-aViewDim.Y() * 0.5 + Point.z() * aScale);
- if (Point.y() > 0.0)
+ aCenter.SetY (-aViewDim.Y() * 0.5 + (Standard_Real(myParams.Params2d.OffsetY) + aJitterComp) * aScale);
+ if ((myParams.Params2d.Corner & Aspect_TOTP_TOP) != 0)
{
aCenter.SetY (-aCenter.Y());
}
Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
return;
}
-
+ else
{
// Compute reference point for transformation in untransformed projection space.
- NCollection_Vec4<T> aRefPoint (static_cast<T> (Point.x()),
- static_cast<T> (Point.y()),
- static_cast<T> (Point.z()),
+ NCollection_Vec4<T> aRefPoint (static_cast<T> (myParams.Params3d.PntX),
+ static_cast<T> (myParams.Params3d.PntY),
+ static_cast<T> (myParams.Params3d.PntZ),
static_cast<T> (1.0));
- NCollection_Vec4<T> aRefPointProj;
- if ((Flags & Graphic3d_TMF_PanPers) != Graphic3d_TMF_PanPers)
- {
- aRefPointProj = theProjection * (theWorldView * aRefPoint);
- aRefPointProj /= aRefPointProj.w();
- }
-
- // Prevent zooming.
- if ((Flags & Graphic3d_TMF_ZoomPers) != 0)
- {
- const T aSize = static_cast<T> (1.0);
- const Standard_Integer aViewport[4] = { 0, 0, theViewportHeight, theViewportHeight };
- NCollection_Mat4<T> aWorldView;
- aWorldView.InitIdentity();
-
- NCollection_Vec3<T> aWinCoordsRefPoint;
- Graphic3d_TransformUtils::Project (static_cast<T> (Point.x()),
- static_cast<T> (Point.y()),
- static_cast<T> (Point.z()),
- theWorldView, theProjection, aViewport,
- aWinCoordsRefPoint.x(), aWinCoordsRefPoint.y(), aWinCoordsRefPoint.z());
-
- NCollection_Vec3<T> anUnProj1;
- Graphic3d_TransformUtils::UnProject (aWinCoordsRefPoint.x(), aWinCoordsRefPoint.y(), aWinCoordsRefPoint.z(),
- aWorldView, theProjection, aViewport,
- anUnProj1.x(), anUnProj1.y(), anUnProj1.z());
-
- NCollection_Vec3<T> anUnProj2;
- Graphic3d_TransformUtils::UnProject (aWinCoordsRefPoint.x(), aWinCoordsRefPoint.y() + aSize, aWinCoordsRefPoint.z(),
- aWorldView, theProjection, aViewport,
- anUnProj2.x(), anUnProj2.y(), anUnProj2.z());
-
- const T aScale = (anUnProj2.y() - anUnProj1.y()) / aSize;
-
- Graphic3d_TransformUtils::Scale (theWorldView, aScale, aScale, aScale);
- }
-
- // Prevent translation by nullifying translation component.
- if ((Flags & Graphic3d_TMF_PanPers) != 0)
- {
- theWorldView .SetValue (0, 3, static_cast<T> (0.0));
- theWorldView .SetValue (1, 3, static_cast<T> (0.0));
- theWorldView .SetValue (2, 3, static_cast<T> (0.0));
- theProjection.SetValue (0, 3, static_cast<T> (0.0));
- theProjection.SetValue (1, 3, static_cast<T> (0.0));
- theProjection.SetValue (2, 3, static_cast<T> (0.0));
- }
- // Prevent rotation by nullifying rotation component.
- if (Flags & Graphic3d_TMF_RotatePers)
+ Graphic3d_TransformUtils::Translate<T> (theWorldView, aRefPoint.x(), aRefPoint.y(), aRefPoint.z());
+ if ((myMode & Graphic3d_TMF_RotatePers) != 0)
{
- theWorldView.SetValue (0, 0, static_cast<T> (1.0));
- theWorldView.SetValue (1, 0, static_cast<T> (0.0));
- theWorldView.SetValue (2, 0, static_cast<T> (0.0));
-
- theWorldView.SetValue (0, 1, static_cast<T> (0.0));
- theWorldView.SetValue (1, 1, static_cast<T> (1.0));
- theWorldView.SetValue (2, 1, static_cast<T> (0.0));
-
- theWorldView.SetValue (0, 2, static_cast<T> (0.0));
- theWorldView.SetValue (1, 2, static_cast<T> (0.0));
- theWorldView.SetValue (2, 2, static_cast<T> (1.0));
+ // lock rotation by nullifying rotation component
+ theWorldView.SetValue (0, 0, static_cast<T> (1));
+ theWorldView.SetValue (1, 0, static_cast<T> (0));
+ theWorldView.SetValue (2, 0, static_cast<T> (0));
+
+ theWorldView.SetValue (0, 1, static_cast<T> (0));
+ theWorldView.SetValue (1, 1, static_cast<T> (1));
+ theWorldView.SetValue (2, 1, static_cast<T> (0));
+
+ theWorldView.SetValue (0, 2, static_cast<T> (0));
+ theWorldView.SetValue (1, 2, static_cast<T> (0));
+ theWorldView.SetValue (2, 2, static_cast<T> (1));
}
- if ((Flags & Graphic3d_TMF_PanPers) != Graphic3d_TMF_PanPers)
+ if ((myMode & Graphic3d_TMF_ZoomPers) != 0)
{
- NCollection_Mat4<T> anUnviewMat;
-
- if (!(theProjection * theWorldView).Inverted (anUnviewMat))
- {
- Standard_ProgramError::Raise ("Graphic3d_TransformPers::Apply, can not inverse world view projection matrix.");
- }
-
- // Move to reference point location in transformed view projection space.
- aRefPoint = anUnviewMat * aRefPointProj;
- aRefPoint /= aRefPoint.w();
-
- Graphic3d_TransformUtils::Translate<T> (theWorldView, aRefPoint.x(), aRefPoint.y(), aRefPoint.z());
+ // 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);
+ Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
}
+ return;
}
}
const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const
{
- if (Flags == Graphic3d_TMF_None)
+ if (myMode == Graphic3d_TMF_None)
{
return NCollection_Mat4<T>();
}
- NCollection_Mat4<T> aProjection (theProjection);
- NCollection_Mat4<T> aWorldView (theWorldView);
+ NCollection_Mat4<T> aWorldView (theWorldView);
NCollection_Mat4<T> anUnviewMat;
- if (AltersProjectionMatrix())
- {
- // destructive transformation persistence which directly modifies projection matrix
- if (!(theProjection * theWorldView).Inverted (anUnviewMat))
- {
- return NCollection_Mat4<T>();
- }
-
- Apply (theCamera, aProjection, aWorldView, theViewportWidth, theViewportHeight);
- return anUnviewMat * (aProjection * aWorldView);
- }
-
if (!theWorldView.Inverted (anUnviewMat))
{
return NCollection_Mat4<T>();
// compute only world-view matrix difference to avoid floating point instability
// caused by projection matrix modifications outside of this algorithm (e.g. by Z-fit)
- Apply (theCamera, aProjection, aWorldView, theViewportWidth, theViewportHeight);
+ Apply (theCamera, theProjection, aWorldView, theViewportWidth, theViewportHeight);
return anUnviewMat * aWorldView;
}
aSelectionPrs = GetSelectPresentation( thePM );
if( HasPresentation() )
- aSelectionPrs->SetTransformPersistence( Presentation()->TransformPersistenceMode(), Presentation()->TransformPersistencePoint() );
+ aSelectionPrs->SetTransformPersistence (Presentation()->TransformPersistence());
//----------------
// It is very important to call this parent method, because it check whether
//new functionality
if( HasPresentation() )
- aHilightPrs->SetTransformPersistence( Presentation()->TransformPersistenceMode(), Presentation()->TransformPersistencePoint() );
+ aHilightPrs->SetTransformPersistence (Presentation()->TransformPersistence());
//----------------
const Standard_Boolean isMeshEntityOwner = Owner->IsKind ( STANDARD_TYPE ( MeshVS_MeshEntityOwner ) );
return true;
}
- // Converts NCollection_Mat4 with different element type.
+ //! Take values from NCollection_Mat4 with a different element type with type conversion.
template <typename Other_t>
- void Convert (const NCollection_Mat4<Other_t>& theOther)
+ void ConvertFrom (const NCollection_Mat4<Other_t>& theFrom)
{
for (int anIdx = 0; anIdx < 16; ++anIdx)
{
- myMat[anIdx] = static_cast<Element_t> (theOther.myMat[anIdx]);
+ myMat[anIdx] = static_cast<Element_t> (theFrom.myMat[anIdx]);
}
}
+ //! Take values from NCollection_Mat4 with a different element type with type conversion.
+ template <typename Other_t>
+ void Convert (const NCollection_Mat4<Other_t>& theFrom) { ConvertFrom (theFrom); }
+
//! Maps plain C array to matrix type.
static NCollection_Mat4<Element_t>& Map (Element_t* theData)
{
HBndBox4f aBoundingBox = new Graphic3d_BndBox4f;
*aBoundingBox = aStructure->BoundingBox();
- aStructure->TransformPersistence.Apply (theCamera, theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, *aBoundingBox);
+ if (!aStructure->TransformPersistence().IsNull())
+ {
+ aStructure->TransformPersistence()->Apply (theCamera, theProjectionMatrix, theWorldViewMatrix, theViewportWidth, theViewportHeight, *aBoundingBox);
+ }
myStructBoxes.Add (aBoundingBox);
}
// =======================================================================
OpenGl_BackgroundArray::OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground theType)
: OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_TRIANGLESTRIPS, NULL, NULL, NULL),
+ myTrsfPers (Graphic3d_TMF_2d, theType == Graphic3d_TOB_TEXTURE ? Aspect_TOTP_CENTER : Aspect_TOTP_LEFT_LOWER),
myType (theType),
myFillMethod (Aspect_FM_NONE),
myViewWidth (0),
myGradientParams.color1 = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 1.0f);
myGradientParams.color2 = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 1.0f);
myGradientParams.type = Aspect_GFM_NONE;
-
- myTrsfPers.Flags = Graphic3d_TMF_2d;
- if (myType == Graphic3d_TOB_TEXTURE)
- {
- myTrsfPers.Point.x() = 0.0;
- myTrsfPers.Point.y() = 0.0;
- }
- else
- {
- myTrsfPers.Point.x() = -1.0;
- myTrsfPers.Point.y() = -1.0;
- }
}
// =======================================================================
// Render arrow
OpenGl_Vec3 anArrowVec = myMin + anAxis.Direction * (myMax - myMin);
- Graphic3d_TransformPers aTransMode;
- aTransMode.Flags = Graphic3d_TMF_ZoomPers;
- aTransMode.Point.x() = anArrowVec.x();
- aTransMode.Point.y() = anArrowVec.y();
- aTransMode.Point.z() = anArrowVec.z();
-
+ 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();
}
else if (!isForChangePriority)
{
- if (theStruct->TransformPersistence.Flags == Graphic3d_TMF_None)
+ if (theStruct->TransformPersistence().IsNull())
{
myBVHPrimitives.Add (theStruct);
}
// "FitAll" operation ignores object with transform persistence parameter
// but adds transform persistence point in a bounding box of layer (only zoom pers. objects).
- if (aStructure->TransformPersistence.Flags != Graphic3d_TMF_None)
+ if (!aStructure->TransformPersistence().IsNull())
{
if (!theToIncludeAuxiliary
- && (aStructure->TransformPersistence.Flags & Graphic3d_TMF_ZoomPers) != 0)
+ && aStructure->TransformPersistence()->IsZoomOrRotate())
{
- BVH_Vec4f aTPPoint (static_cast<float> (aStructure->TransformPersistence.Point.x()),
- static_cast<float> (aStructure->TransformPersistence.Point.y()),
- static_cast<float> (aStructure->TransformPersistence.Point.z()),
+ const gp_Pnt anAnchor = aStructure->TransformPersistence()->AnchorPoint();
+ BVH_Vec4f aTPPoint (static_cast<float> (anAnchor.X()),
+ static_cast<float> (anAnchor.Y()),
+ static_cast<float> (anAnchor.Z()),
1.0f);
myBoundingBox[aBoxId].Combine (aTPPoint);
// Panning and 2d persistence apply changes to projection or/and its translation components.
// It makes them incompatible with z-fitting algorithm. Ignored by now.
else if (!theToIncludeAuxiliary
- || (aStructure->TransformPersistence.Flags & (Graphic3d_TMF_2d | Graphic3d_TMF_PanPers | Graphic3d_TMF_TriedronPers)) != 0)
+ || aStructure->TransformPersistence()->IsTrihedronOr2d())
{
continue;
}
aBox = centerOfinfiniteBndBox (aBox);
}
- if (aStructure->TransformPersistence.Flags != Graphic3d_TMF_None)
+ if (!aStructure->TransformPersistence().IsNull())
{
- aStructure->TransformPersistence.Apply (theCamera,
- aProjectionMat,
- aWorldViewMat,
- theWindowWidth,
- theWindowHeight,
- aBox);
+ aStructure->TransformPersistence()->Apply (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
}
// skip too big boxes to prevent float overflow at camera parameters calculation
{
continue;
}
- else if ((aStructure->TransformPersistence.Flags & (Graphic3d_TMF_TriedronPers | Graphic3d_TMF_2d)) == 0)
+ else if (aStructure->TransformPersistence().IsNull()
+ || !aStructure->TransformPersistence()->IsTrihedronOr2d())
{
continue;
}
continue;
}
- aStructure->TransformPersistence.Apply (theCamera,
- aProjectionMat,
- aWorldViewMat,
- theWindowWidth,
- theWindowHeight,
- aBox);
+ aStructure->TransformPersistence()->Apply (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
if (!isInfiniteBndBox (aBox))
{
aResBox.Combine (aBox);
{
OpenGl_Structure* aStructure = const_cast<OpenGl_Structure*> (aStructures.FindKey (aStructIdx));
if (!aStructure->IsVisible (theViewId)
- || (aStructure->TransformPersistence.Flags & Graphic3d_TMF_ZoomPers) == 0)
+ || aStructure->TransformPersistence().IsNull()
+ || !aStructure->TransformPersistence()->IsZoomOrRotate())
{
continue;
}
continue;
}
- aStructure->TransformPersistence.Apply (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
+ aStructure->TransformPersistence()->Apply (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
const BVH_Vec4f& aCornerMin = aBox.CornerMin();
const BVH_Vec4f& aCornerMax = aBox.CornerMax();
continue;
}
- const gp_Pnt aTPPoint (aStructure->TransformPersistence.Point.x(),
- aStructure->TransformPersistence.Point.y(),
- aStructure->TransformPersistence.Point.z());
+ const gp_Pnt aTPPoint = aStructure->TransformPersistence()->AnchorPoint();
gp_Pnt aConvertedTPPoint = theCamera->Project (aTPPoint);
aConvertedTPPoint.SetZ (0.0);
aStruct->MarkAsNotCulled();
myAlwaysRenderedMap.Add (aStruct);
}
- else if (aStruct->TransformPersistence.Flags == Graphic3d_TMF_None)
+ else if (aStruct->TransformPersistence().IsNull())
{
myBVHPrimitives.Add (aStruct);
}
}
#endif
- if (TransformPersistence.Flags)
+ if (!myTrsfPers.IsNull())
{
- OpenGl_Mat4 aProjection = aCtx->ProjectionState.Current();
- OpenGl_Mat4 aWorldView = aCtx->WorldViewState.Current();
- TransformPersistence.Apply (theWorkspace->View()->Camera(), aProjection, aWorldView,
- aCtx->Viewport()[2], aCtx->Viewport()[3]);
+ OpenGl_Mat4 aWorldView = aCtx->WorldViewState.Current();
+ myTrsfPers->Apply (theWorkspace->View()->Camera(), aCtx->ProjectionState.Current(), aWorldView,
+ aCtx->Viewport()[2], aCtx->Viewport()[3]);
- aCtx->ProjectionState.Push();
aCtx->WorldViewState.Push();
- aCtx->ProjectionState.SetCurrent (aProjection);
aCtx->WorldViewState.SetCurrent (aWorldView);
- aCtx->ApplyProjectionMatrix();
#if !defined(GL_ES_VERSION_2_0)
if (!aCtx->IsGlNormalizeEnabled()
if (aCtx->Clipping().IsClippingOrCappingOn())
{
const Graphic3d_BndBox4f& aBBox = BoundingBox();
- if (TransformPersistence.Flags == Graphic3d_TMF_TriedronPers
- || TransformPersistence.Flags == Graphic3d_TMF_2d
+ if ((!myTrsfPers.IsNull() && myTrsfPers->IsTrihedronOr2d())
|| (!myClipPlanes.IsNull() && myClipPlanes->ToOverrideGlobal()))
{
aCtx->ChangeClipping().DisableGlobal (aCtx);
// Set of clipping planes that do not intersect the structure,
// and thus can be disabled to improve rendering performance
if (aBBox.IsValid()
- && TransformPersistence.Flags == Graphic3d_TMF_None)
+ && myTrsfPers.IsNull())
{
for (OpenGl_ClippingIterator aPlaneIt (aCtx->Clipping()); aPlaneIt.More(); aPlaneIt.Next())
{
// Restore local transformation
aCtx->ModelWorldState.Pop();
aCtx->SetGlNormalizeEnabled (anOldGlNormalize);
- if (TransformPersistence.Flags)
+ if (!myTrsfPers.IsNull())
{
- aCtx->ProjectionState.Pop();
aCtx->WorldViewState.Pop();
- aCtx->ApplyProjectionMatrix();
}
// Restore highlight color
|| IsForHighlight
|| IsMutable
|| Is2dText
- || (TransformPersistence.Flags & Graphic3d_TMF_2d) != 0
- || (TransformPersistence.Flags & Graphic3d_TMF_PanPers) != 0
- || (TransformPersistence.Flags & Graphic3d_TMF_TriedronPers) != 0;
+ || (!myTrsfPers.IsNull() && myTrsfPers->IsTrihedronOr2d());
}
//! This method releases GL resources without actual elements destruction.
UpdateTransformation();
myInstancedStructure = const_cast<OpenGl_Structure*> (myParent->InstancedStructure());
- TransformPersistence = myParent->TransformPersistence;
+ myTrsfPers = myParent->TransformPersistence();
// reuse instanced structure API
myInstancedStructure = myParent.operator->();
Graphic3d_BndBox4f aBox2d (Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f),
Graphic3d_Vec4 (float(theWindowWidth), float(theWindowHeight), 0.0f, 0.0f));
- Graphic3d_TransformPers aTrsfPers;
- aTrsfPers.Flags = Graphic3d_TMF_2d;
- aTrsfPers.Point = Graphic3d_Vec3d(-1.0, -1.0, 0.0);
+ Graphic3d_TransformPers aTrsfPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER);
aTrsfPers.Apply (theCamera,
aProjectionMat,
aWorldViewMat,
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <PrsMgr_PresentableObject.hxx>
#include <Geom_Transformation.hxx>
#include <gp_Pnt.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx>
#include <PrsMgr_ModedPresentation.hxx>
-#include <PrsMgr_PresentableObject.hxx>
#include <PrsMgr_Presentation.hxx>
#include <PrsMgr_PresentationManager.hxx>
#include <Standard_NotImplemented.hxx>
Compute (thePrsMgr, aStruct3d, theMode);
UpdateTransformation (aStruct3d);
aStruct3d->SetClipPlanes (myClipPlanes);
- aStruct3d->SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint());
+ aStruct3d->SetTransformPersistence (TransformPersistence());
}
//=======================================================================
//function : SetTransformPersistence
//purpose :
//=======================================================================
-void PrsMgr_PresentableObject::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag,
- const gp_Pnt& thePoint)
+void PrsMgr_PresentableObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- myTransformPersistence.Flags = theFlag;
- myTransformPersistence.Point.x() = thePoint.X();
- myTransformPersistence.Point.y() = thePoint.Y();
- myTransformPersistence.Point.z() = thePoint.Z();
+ myTransformPersistence = theTrsfPers;
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
if (!aPrs3d.IsNull()
&& !aPrs3d->Presentation().IsNull())
{
- aPrs3d->Presentation()->SetTransformPersistence (theFlag, thePoint);
+ aPrs3d->Presentation()->SetTransformPersistence (myTransformPersistence);
aPrs3d->Presentation()->ReCompute();
}
}
//=======================================================================
//function : GetTransformPersistence
-//purpose :
-//=======================================================================
-Graphic3d_TransModeFlags PrsMgr_PresentableObject::GetTransformPersistenceMode() const
-{
- return myTransformPersistence.Flags;
-}
-
-//=======================================================================
-//function : GetTransformPersistence
-//purpose :
+//purpose :
//=======================================================================
gp_Pnt PrsMgr_PresentableObject::GetTransformPersistencePoint() const
{
- return gp_Pnt (myTransformPersistence.Point.x(),
- myTransformPersistence.Point.y(),
- myTransformPersistence.Point.z());
+ if (myTransformPersistence.IsNull())
+ {
+ return gp_Pnt();
+ }
+ else if (myTransformPersistence->IsZoomOrRotate())
+ {
+ return myTransformPersistence->AnchorPoint();
+ }
+ else if (!myTransformPersistence->IsTrihedronOr2d())
+ {
+ return gp_Pnt();
+ }
+
+ Standard_Real anX = 0.0;
+ if ((myTransformPersistence->Corner2d() & Aspect_TOTP_RIGHT) != 0)
+ {
+ anX = 1.0;
+ }
+ else if ((myTransformPersistence->Corner2d() & Aspect_TOTP_LEFT) != 0)
+ {
+ anX = -1.0;
+ }
+
+ Standard_Real anY = 0.0;
+ if ((myTransformPersistence->Corner2d() & Aspect_TOTP_TOP) != 0)
+ {
+ anY = 1.0;
+ }
+ else if ((myTransformPersistence->Corner2d() & Aspect_TOTP_BOTTOM) != 0)
+ {
+ anY = -1.0;
+ }
+
+ return gp_Pnt (anX, anY, myTransformPersistence->Offset2d().x());
}
//=======================================================================
//! Returns information on whether the object accepts display in HLR mode or not.
PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; }
+ //! @return transform persistence of the presentable object.
+ const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTransformPersistence; }
+
+ //! Sets up Transform Persistence for this object.
+ Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
+
//! Sets up Transform Persistence Mode for this object.
//! This function used to lock in object position, rotation and / or zooming relative to camera position.
- //! Object will be drawn in the origin setted by APoint parameter (except Graphic3d_TMF_TriedronPers flag
- //! - see description later). aFlag should be:
+ //! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag
+ //! - see description later). theMode should be:
//! - Graphic3d_TMF_None - no persistence attributes (reset);
- //! - Graphic3d_TMF_PanPers - object doesn't move;
//! - Graphic3d_TMF_ZoomPers - object doesn't resize;
//! - Graphic3d_TMF_RotatePers - object doesn't rotate;
- //! - Graphic3d_TMF_FullPers - pan, zoom and rotate transform persistence;
- //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron;
- //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers);
- //! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_RotatePers);
- //! - combination (Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers).
- //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected APoint coordinates X and Y means:
+ //! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate;
+ //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
+ //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron.
+ //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means:
//! - X = 0.0, Y = 0.0 - center of view window;
//! - X > 0.0, Y > 0.0 - right upper corner of view window;
//! - X > 0.0, Y < 0.0 - right lower corner of view window;
//! - X < 0.0, Y > 0.0 - left upper corner of view window;
//! - X < 0.0, Y < 0.0 - left lower corner of view window.
//! And Z coordinate defines the gap from border of view window (except center position).
- Standard_EXPORT virtual void SetTransformPersistence (const Graphic3d_TransModeFlags& aFlag, const gp_Pnt& APoint = gp_Pnt (0.0, 0.0, 0.0));
+ Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
+ void SetTransformPersistence (const Graphic3d_TransModeFlags theMode, const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0))
+ {
+ SetTransformPersistence (Graphic3d_TransformPers::FromDeprecatedParams (theMode, thePoint));
+ }
//! Gets Transform Persistence Mode for this object
- Standard_EXPORT Graphic3d_TransModeFlags GetTransformPersistenceMode() const;
-
+ Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
+ Graphic3d_TransModeFlags GetTransformPersistenceMode() const
+ {
+ return myTransformPersistence.IsNull()
+ ? Graphic3d_TMF_None
+ : myTransformPersistence->Mode();
+ }
+
//! Gets point of transform persistence for this object
+ Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
- //! @return transform persistence of the presentable object.
- const Graphic3d_TransformPers& TransformPersistence() const { return myTransformPersistence; }
-
Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
//! flags the Prs of mode <AMode> to be Updated.
private:
- Graphic3d_TransformPers myTransformPersistence;
+ Handle(Graphic3d_TransformPers) myTransformPersistence;
PrsMgr_PresentableObjectPointer myParent;
gp_Trsf myLocalTransformation;
gp_Trsf myTransformation;
{
aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD);
}
- if (aCS->GetTransformPersistenceMode() != Graphic3d_TMF_2d)
+ if (aCS->TransformPersistence().IsNull()
+ || aCS->TransformPersistence()->Mode() != Graphic3d_TMF_2d)
{
- aContext->SetTransformPersistence (aCS, Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
+ aContext->SetTransformPersistence (aCS, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
}
Standard_Integer aWinWidth, aWinHeight;
V->Window()->Size (aWinWidth, aWinHeight);
//function : GetHilightPresentation
//purpose :
//=======================================================================
-Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation( const Handle(PrsMgr_PresentationManager3d)& TheMgr )
+Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
{
- if( myHilightPrs.IsNull() && !TheMgr.IsNull() )
- {
- myHilightPrs = new Prs3d_Presentation( TheMgr->StructureManager() );
- myHilightPrs->SetTransformPersistence( GetTransformPersistenceMode(),
- GetTransformPersistencePoint() );
- }
+ if (myHilightPrs.IsNull() && !theMgr.IsNull())
+ {
+ myHilightPrs = new Prs3d_Presentation (theMgr->StructureManager());
+ myHilightPrs->SetTransformPersistence (TransformPersistence());
+ }
return myHilightPrs;
}
//function : GetSelectPresentation
//purpose :
//=======================================================================
-Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation( const Handle(PrsMgr_PresentationManager3d)& TheMgr )
+Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
{
- if( mySelectionPrs.IsNull() && !TheMgr.IsNull() ) {
- mySelectionPrs = new Prs3d_Presentation( TheMgr->StructureManager() );
- mySelectionPrs->SetTransformPersistence( GetTransformPersistenceMode(),
- GetTransformPersistencePoint() );
+ if (mySelectionPrs.IsNull() && !theMgr.IsNull())
+ {
+ mySelectionPrs = new Prs3d_Presentation (theMgr->StructureManager());
+ mySelectionPrs->SetTransformPersistence (TransformPersistence());
}
+
return mySelectionPrs;
}
Bnd_Box aBoundingBox;
anObject->BoundingBox (aBoundingBox);
- if (aBoundingBox.IsVoid())
+ if (aBoundingBox.IsVoid()
+ || anObject->TransformPersistence().IsNull())
{
myBoundings.Add (new Select3D_HBndBox3d());
}
else
{
- anObject->TransformPersistence().Apply (
- theCamera, theProjectionMat, theWorldViewMat, theWidth, theHeight, aBoundingBox);
+ anObject->TransformPersistence()->Apply (theCamera, theProjectionMat, theWorldViewMat, theWidth, theHeight, aBoundingBox);
const gp_Pnt aMin = aBoundingBox.CornerMin();
const gp_Pnt aMax = aBoundingBox.CornerMax();
//! Returns an appropriate subset of theObject given depending on its persistence type.
Standard_Integer appropriateSubset (const Handle(SelectMgr_SelectableObject)& theObject)
{
- if (!theObject->TransformPersistence().Flags)
+ if (theObject->TransformPersistence().IsNull())
{
return SelectMgr_SelectableObjectSet::BVHSubset_3d;
}
- else if (theObject->TransformPersistence().Flags & Graphic3d_TMF_2d)
+ else if (theObject->TransformPersistence()->Mode() == Graphic3d_TMF_2d)
{
return SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent;
}
if (!anOwner.IsNull())
{
aSelectable = anOwner->Selectable();
- if (aSelectable->TransformPersistence().Flags == Graphic3d_TMF_TriedronPers
- || aSelectable->TransformPersistence().Flags == Graphic3d_TMF_2d
+ if ((!aSelectable->TransformPersistence().IsNull() && aSelectable->TransformPersistence()->IsTrihedronOr2d())
|| (!aSelectable->ClipPlanes().IsNull() && aSelectable->ClipPlanes()->ToOverrideGlobal()))
{
theMgr.SetViewClippingEnabled (Standard_False);
gp_GTrsf aInversedTrsf;
- if (theObject->HasTransformation() || theObject->TransformPersistence().Flags)
+ if (theObject->HasTransformation() || !theObject->TransformPersistence().IsNull())
{
- if (!theObject->TransformPersistence().Flags)
+ if (theObject->TransformPersistence().IsNull())
{
aInversedTrsf = theObject->InversedTransformation();
}
else
{
gp_GTrsf aTPers;
- Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute (
- theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
+ Graphic3d_Mat4d aMat = theObject->TransformPersistence()->Compute (theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
aTPers.SetValue (1, 1, aMat.GetValue (0, 0));
aTPers.SetValue (1, 2, aMat.GetValue (0, 1));
if (!aSel.IsNull())
{
myPrsSh->SetZLayer (aSel->ZLayer());
- myPrsSh->SetTransformPersistence (aSel->GetTransformPersistenceMode(), aSel->GetTransformPersistencePoint());
+ myPrsSh->SetTransformPersistence (aSel->TransformPersistence());
}
// highlight and set layer
if (!aSel.IsNull())
{
myPrsSh->SetZLayer (aSel->ZLayer());
- myPrsSh->SetTransformPersistence (aSel->GetTransformPersistenceMode(), aSel->GetTransformPersistencePoint());
+ myPrsSh->SetTransformPersistence (aSel->TransformPersistence());
}
// highlight with color and set layer
{
if (anObj->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
{
- computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Graphic3d_TransformPers());
+ computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Handle(Graphic3d_TransformPers)());
}
}
Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager());
- computeSensitivePrs (aStruct, theSel, theTrsf, Graphic3d_TransformPers());
+ computeSensitivePrs (aStruct, theSel, theTrsf, Handle(Graphic3d_TransformPers)());
myStructs.Append (aStruct);
myStructs.Last()->SetDisplayPriority (10);
void StdSelect_ViewerSelector3d::computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc,
- const Graphic3d_TransformPers& theTransPers)
+ const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- theStructure->SetTransformPersistence (theTransPers.Flags, gp_Pnt (theTransPers.Point.x(),
- theTransPers.Point.y(),
- theTransPers.Point.z()));
+ theStructure->SetTransformPersistence (theTrsfPers);
Handle(Graphic3d_Group) aSensGroup = theStructure->NewGroup();
Standard_EXPORT void computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc,
- const Graphic3d_TransformPers& theTransPers);
+ const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Update z-layers order map.
Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView);
}
// skip transformation-persistent objects
- if (aStruct->TransformPersistence().Flags != Graphic3d_TMF_None)
+ if (!aStruct->TransformPersistence().IsNull())
{
continue;
}
//! Auxiliary method to parse transformation persistence flags
inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFlagString,
- Standard_Integer& theFlags)
+ Graphic3d_TransModeFlags& theFlags)
{
- if (theFlagString == "pan")
+ if (theFlagString == "zoom")
{
- theFlags |= Graphic3d_TMF_PanPers;
- }
- else if (theFlagString == "zoom")
- {
- theFlags |= Graphic3d_TMF_ZoomPers;
+ theFlags = Graphic3d_TMF_ZoomPers;
}
else if (theFlagString == "rotate")
{
- theFlags |= Graphic3d_TMF_RotatePers;
+ theFlags = Graphic3d_TMF_RotatePers;
}
- else if (theFlagString == "trihedron")
+ else if (theFlagString == "zoomrotate")
{
- theFlags = Graphic3d_TMF_TriedronPers;
+ theFlags = Graphic3d_TMF_ZoomRotatePers;
}
- else if (theFlagString == "full")
+ else if (theFlagString == "trihedron"
+ || theFlagString == "triedron")
{
- theFlags = Graphic3d_TMF_FullPers;
+ theFlags = Graphic3d_TMF_TriedronPers;
}
else if (theFlagString == "none")
{
return Standard_True;
}
+//! Auxiliary method to parse transformation persistence flags
+inline Standard_Boolean parseTrsfPersCorner (const TCollection_AsciiString& theString,
+ Aspect_TypeOfTriedronPosition& theCorner)
+{
+ TCollection_AsciiString aString (theString);
+ aString.LowerCase();
+ if (aString == "center")
+ {
+ theCorner = Aspect_TOTP_CENTER;
+ }
+ else if (aString == "top"
+ || aString == "upper")
+ {
+ theCorner = Aspect_TOTP_TOP;
+ }
+ else if (aString == "bottom"
+ || aString == "lower")
+ {
+ theCorner = Aspect_TOTP_BOTTOM;
+ }
+ else if (aString == "left")
+ {
+ theCorner = Aspect_TOTP_LEFT;
+ }
+ else if (aString == "right")
+ {
+ theCorner = Aspect_TOTP_RIGHT;
+ }
+ else if (aString == "topleft"
+ || aString == "leftupper"
+ || aString == "upperleft")
+ {
+ theCorner = Aspect_TOTP_LEFT_UPPER;
+ }
+ else if (aString == "bottomleft"
+ || aString == "leftlower"
+ || aString == "lowerleft")
+ {
+ theCorner = Aspect_TOTP_LEFT_LOWER;
+ }
+ else if (aString == "topright"
+ || aString == "rightupper"
+ || aString == "upperright")
+ {
+ theCorner = Aspect_TOTP_RIGHT_UPPER;
+ }
+ else if (aString == "bottomright"
+ || aString == "lowerright"
+ || aString == "rightlower")
+ {
+ theCorner = Aspect_TOTP_RIGHT_LOWER;
+ }
+ else
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
//==============================================================================
//function : VDisplay2
//author : ege
Standard_Integer anObjDispMode = -2;
Standard_Integer anObjHighMode = -2;
Standard_Boolean toSetTrsfPers = Standard_False;
- Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
- gp_Pnt aTPPosition;
+ Handle(Graphic3d_TransformPers) aTrsfPers;
TColStd_SequenceOfAsciiString aNamesOfDisplayIO;
AIS_DisplayStatus aDispStatus = AIS_DS_None;
Standard_Integer toDisplayInView = Standard_False;
else if (aNameCase == "-3d")
{
toSetTrsfPers = Standard_True;
- aTrsfPersFlags = Graphic3d_TMF_None;
+ aTrsfPers.Nullify();
}
- else if (aNameCase == "-2d")
+ else if (aNameCase == "-2d"
+ || aNameCase == "-trihedron"
+ || aNameCase == "-triedron")
{
toSetTrsfPers = Standard_True;
- aTrsfPersFlags = Graphic3d_TMF_2d;
+ aTrsfPers = new Graphic3d_TransformPers (aNameCase == "-2d" ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
+
+ if (anArgIter + 1 < theArgNb)
+ {
+ Aspect_TypeOfTriedronPosition aCorner = Aspect_TOTP_CENTER;
+ if (parseTrsfPersCorner (theArgVec[anArgIter + 1], aCorner))
+ {
+ ++anArgIter;
+ aTrsfPers->SetCorner2d (aCorner);
+
+ if (anArgIter + 2 < theArgNb)
+ {
+ TCollection_AsciiString anX (theArgVec[anArgIter + 1]);
+ TCollection_AsciiString anY (theArgVec[anArgIter + 2]);
+ if (anX.IsIntegerValue()
+ && anY.IsIntegerValue())
+ {
+ anArgIter += 2;
+ aTrsfPers->SetOffset2d (Graphic3d_Vec2i (anX.IntegerValue(), anY.IntegerValue()));
+ }
+ }
+ }
+ }
}
else if (aNameCase == "-trsfpers"
|| aNameCase == "-pers")
{
- if (++anArgIter >= theArgNb)
+ if (++anArgIter >= theArgNb
+ || !aTrsfPers.IsNull())
{
std::cerr << "Error: wrong syntax at " << aName << ".\n";
return 1;
}
toSetTrsfPers = Standard_True;
- aTrsfPersFlags = Graphic3d_TMF_None;
+ Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
TCollection_AsciiString aPersFlags (theArgVec [anArgIter]);
aPersFlags.LowerCase();
- for (Standard_Integer aParserPos = aPersFlags.Search ("|");; aParserPos = aPersFlags.Search ("|"))
+ if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
{
- if (aParserPos == -1)
- {
- if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
- {
- std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
- return 1;
- }
- break;
- }
+ std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
+ return 1;
+ }
- TCollection_AsciiString anOtherFlags = aPersFlags.Split (aParserPos - 1);
- if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
- {
- std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
- return 1;
- }
- aPersFlags = anOtherFlags;
+ if (aTrsfPersFlags == Graphic3d_TMF_TriedronPers)
+ {
+ aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
+ }
+ else if (aTrsfPersFlags != Graphic3d_TMF_None)
+ {
+ aTrsfPers = new Graphic3d_TransformPers (aTrsfPersFlags, gp_Pnt());
}
}
else if (aNameCase == "-trsfperspos"
|| aNameCase == "-perspos")
{
- if (anArgIter + 2 >= theArgNb)
+ if (anArgIter + 2 >= theArgNb
+ || aTrsfPers.IsNull())
{
std::cerr << "Error: wrong syntax at " << aName << ".\n";
return 1;
TCollection_AsciiString aX (theArgVec[++anArgIter]);
TCollection_AsciiString aY (theArgVec[++anArgIter]);
TCollection_AsciiString aZ = "0";
- if (!aX.IsIntegerValue()
- || !aY.IsIntegerValue())
+ if (!aX.IsRealValue()
+ || !aY.IsRealValue())
{
std::cerr << "Error: wrong syntax at " << aName << ".\n";
return 1;
if (anArgIter + 1 < theArgNb)
{
TCollection_AsciiString aTemp = theArgVec[anArgIter + 1];
- if (aTemp.IsIntegerValue())
+ if (aTemp.IsRealValue())
{
aZ = aTemp;
++anArgIter;
}
}
- aTPPosition.SetCoord (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue());
+
+ const gp_Pnt aPnt (aX.RealValue(), aY.RealValue(), aZ.RealValue());
+ if (aTrsfPers->IsZoomOrRotate())
+ {
+ aTrsfPers->SetAnchorPoint (aPnt);
+ }
+ else if (aTrsfPers->IsTrihedronOr2d())
+ {
+ aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (aTrsfPers->Mode(), aPnt);
+ }
}
else if (aNameCase == "-layer")
{
}
if (toSetTrsfPers)
{
- aCtx->SetTransformPersistence (aShape, aTrsfPersFlags, aTPPosition);
+ aCtx->SetTransformPersistence (aShape, aTrsfPers);
}
if (anObjDispMode != -2)
{
}
if (toSetTrsfPers)
{
- aCtx->SetTransformPersistence (aShape, aTrsfPersFlags, aTPPosition);
+ aCtx->SetTransformPersistence (aShape, aTrsfPers);
}
if (anObjDispMode != -2)
{
theCommands.Add("vdisplay",
"vdisplay [-noupdate|-update] [-local] [-mutable] [-neutral]"
- "\n\t\t: [-trsfPers {pan|zoom|rotate|trihedron|full|none}=none] [-trsfPersPos X Y [Z]] [-3d|-2d]"
+ "\n\t\t: [-trsfPers {zoom|rotate|zoomRotate|none}=none]"
+ "\n\t\t: [-trsfPersPos X Y [Z]] [-3d]"
+ "\n\t\t: [-2d|-trihedron [{top|bottom|left|right|topLeft"
+ "\n\t\t: |topRight|bottomLeft|bottomRight}"
+ "\n\t\t: [offsetX offsetY]]]"
"\n\t\t: [-dispMode mode] [-highMode mode]"
"\n\t\t: [-layer index] [-top|-topmost|-overlay|-underlay]"
"\n\t\t: [-redisplay]"
"\n\t\t: Option -local enables displaying of objects in local"
"\n\t\t: selection context. Local selection context will be opened"
"\n\t\t: if there is not any."
- "\n\t\t: -noupdate suppresses viewer redraw call."
- "\n\t\t: -mutable enables optimizations for mutable objects."
- "\n\t\t: -neutral draws objects in main viewer."
- "\n\t\t: -layer sets z-layer for objects. It can use -overlay|-underlay|-top|-topmost instead of -layer index for the default z-layers."
- "\n\t\t: -top draws objects on top of main presentations but below topmost."
- "\n\t\t: -topmost draws in overlay for 3D presentations with independent Depth."
- "\n\t\t: -overlay draws objects in overlay for 2D presentations (On-Screen-Display)."
- "\n\t\t: -underlay draws objects in underlay for 2D presentations (On-Screen-Display)."
- "\n\t\t: -selectable|-noselect controls selection of objects."
- "\n\t\t: -trsfPers sets a transform persistence flags. Flag 'full' is pan, zoom and rotate."
- "\n\t\t: -trsfPersPos sets an anchor point for transform persistence."
- "\n\t\t: -2d displays object in screen coordinates (DY looks up)."
- "\n\t\t: -dispmode sets display mode for objects."
- "\n\t\t: -highmode sets hilight mode for objects."
- "\n\t\t: -redisplay recomputes presentation of objects.",
+ "\n\t\t: -noupdate Suppresses viewer redraw call."
+ "\n\t\t: -mutable Enables optimizations for mutable objects."
+ "\n\t\t: -neutral Draws objects in main viewer."
+ "\n\t\t: -layer Sets z-layer for objects."
+ "\n\t\t: Alternatively -overlay|-underlay|-top|-topmost"
+ "\n\t\t: options can be used for the default z-layers."
+ "\n\t\t: -top Draws object on top of main presentations"
+ "\n\t\t: but below topmost."
+ "\n\t\t: -topmost Draws in overlay for 3D presentations."
+ "\n\t\t: with independent Depth."
+ "\n\t\t: -overlay Draws objects in overlay for 2D presentations."
+ "\n\t\t: (On-Screen-Display)"
+ "\n\t\t: -underlay Draws objects in underlay for 2D presentations."
+ "\n\t\t: (On-Screen-Display)"
+ "\n\t\t: -selectable|-noselect Controls selection of objects."
+ "\n\t\t: -trsfPers Sets a transform persistence flags."
+ "\n\t\t: -trsfPersPos Sets an anchor point for transform persistence."
+ "\n\t\t: -2d Displays object in screen coordinates."
+ "\n\t\t: (DY looks up)"
+ "\n\t\t: -dispmode Sets display mode for objects."
+ "\n\t\t: -highmode Sets hilight mode for objects."
+ "\n\t\t: -redisplay Recomputes presentation of objects.",
__FILE__, VDisplay2, group);
theCommands.Add ("vupdate",
#include <TColStd_HArray1OfAsciiString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
-#if defined(_MSC_VER)
-# define _CRT_SECURE_NO_DEPRECATE
-# pragma warning (disable:4996)
-#endif
-
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
const Handle(AIS_InteractiveObject)& theAISObj,
aTextPrs->SetText (aText);
- Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
- gp_Pnt aTPPosition;
+ Handle(Graphic3d_TransformPers) aTrsfPers;
Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL;
-
Standard_Boolean aHasPlane = Standard_False;
gp_Dir aNormal;
gp_Dir aDirection;
}
else if (aParam == "-2d")
{
- aTrsfPersFlags = Graphic3d_TMF_2d;
+ aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_2d);
}
else if (aParam == "-trsfperspos"
|| aParam == "-perspos")
++anArgIt;
}
}
- aTPPosition.SetCoord (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue());
+
+ aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (Graphic3d_TMF_2d, gp_Pnt (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue()));
}
else
{
aTextPrs->SetDisplayType (aDisplayType);
- if (aTrsfPersFlags != Graphic3d_TMF_None)
+ if (!aTrsfPers.IsNull())
{
- aContext->SetTransformPersistence (aTextPrs, aTrsfPersFlags, aTPPosition);
+ aContext->SetTransformPersistence (aTextPrs, aTrsfPers);
aTextPrs->SetZLayer(Graphic3d_ZLayerId_TopOSD);
if (aTextPrs->Position().Z() != 0)
{
aTextPrs->SetPosition (gp_Pnt(aTextPrs->Position().X(), aTextPrs->Position().Y(), 0));
}
}
- else if (aTrsfPersFlags != aTextPrs->TransformPersistence().Flags)
+ else if (!aTextPrs->TransformPersistence().IsNull())
{
- aContext->SetTransformPersistence (aTextPrs, aTrsfPersFlags);
+ aContext->SetTransformPersistence (aTextPrs, Handle(Graphic3d_TransformPers)());
}
ViewerTest::Display (aName, aTextPrs, Standard_False);
return 0;
{
aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD);
}
- if (aCS->GetTransformPersistenceMode() != Graphic3d_TMF_2d)
+ if (aCS->TransformPersistence().IsNull()
+ || aCS->TransformPersistence()->Mode() != Graphic3d_TMF_2d)
{
- aContext->SetTransformPersistence (aCS, Graphic3d_TMF_2d, gp_Pnt (-1.0, -1.0, 0.0));
+ aContext->SetTransformPersistence (aCS, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
}
Standard_Real aMinRange = aCS->GetMin();
aLineType, aWidth,
aTransparency);
- aContext->SetTransformPersistence (aLine, Graphic3d_TMF_2d, gp_Pnt (-1.0, -1.0, 0.0));
+ aContext->SetTransformPersistence (aLine, new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER));
aLine->SetZLayer (Graphic3d_ZLayerId_TopOSD);
aLine->SetToUpdate();
aContext->Display (aLine, Standard_True);
box b2 10 20 30
ttranslate b2 50 50 0
vinit
-vdisplay b1 -trsfPers trihedron
+vdisplay b1 -trihedron center
vdisplay b2
vfit
# display polyline in overlay
text2brep tcc "Center" -font SansFont -height 30
-vdisplay tcc -2d -osd
+vdisplay tcc -2d center -osd
polyline lcc -50 -50 0 -50 50 0 50 50 0 50 0 0 0 -50 0 -50 -50 0
-vdisplay lcc -2d -overlay
+vdisplay lcc -2d center -overlay
# display polyline in overlay in the bottom left corner of the view
text2brep tbl "Bottom-Left" -font SansFont -height 30
-vdisplay tbl -2d -trsfPersPos -1 -1 5 -osd
+vdisplay tbl -2d bottomLeft 5 5 -osd
polyline lbl 0 0 0 0 100 0 100 100 0 100 50 0 50 0 0 0 0 0
-vdisplay lbl -2d -trsfPersPos -1 -1 3 -overlay
+vdisplay lbl -2d bottomLeft 3 3 -overlay
# display polyline in overlay in the top left corner of the view
text2brep ttl "Top-Left" -font SansFont -height 30 -pos -27 0 0
-vdisplay ttl -2d -trsfPersPos -1 1 30 -osd
+vdisplay ttl -2d topLeft 30 30 -osd
polyline ltl 0 -100 0 0 0 0 100 0 0 100 -50 0 50 -100 0 0 -100 0
-vdisplay ltl -2d -trsfPersPos -1 1 3 -overlay
+vdisplay ltl -2d topLeft 3 3 -overlay
# display polyline in overlay in the top right corner of the view
text2brep ttr "Top-Right" -font SansFont -height 30 -pos -100 0 0
-vdisplay ttr -2d -trsfPersPos 1 1 30 -osd
+vdisplay ttr -2d topRight 30 30 -osd
polyline ltr -100 -100 0 -100 0 0 0 0 0 0 -50 0 -50 -100 0 -100 -100 0
-vdisplay ltr -2d -trsfPersPos 1 1 3 -overlay
+vdisplay ltr -2d topRight 3 3 -overlay
# display polyline in overlay in the bottom right corner of the view
text2brep tbr "Bottom-Right" -font SansFont -height 30 -pos -165 0 0
-vdisplay tbr -2d -trsfPersPos 1 -1 5 -osd
+vdisplay tbr -2d bottomRight 5 5 -osd
polyline lbr -100 0 0 -100 100 0 0 100 0 0 50 0 -50 0 0 -100 0 0
-vdisplay lbr -2d -trsfPersPos 1 -1 3 -overlay
+vdisplay lbr -2d bottomRight 3 3 -overlay
vdump ${imagedir}/${casename}.png
vaxo
text2brep tcc "Center" -font SansFont -height 30
-vdisplay tcc -2d -underlay
+vdisplay tcc -2d center -underlay
polyline lcc -50 -50 0 -50 50 0 50 50 0 50 0 0 0 -50 0 -50 -50 0
-vdisplay lcc -2d -underlay
+vdisplay lcc -2d center -underlay
text2brep tbl "Bottom-Left" -font SansFont -height 30
-vdisplay tbl -2d -trsfPersPos -1 -1 5 -underlay
+vdisplay tbl -2d bottomLeft 5 5 -underlay
polyline lbl 0 0 0 0 100 0 100 100 0 100 50 0 50 0 0 0 0 0
-vdisplay lbl -2d -trsfPersPos -1 -1 3 -underlay
+vdisplay lbl -2d bottomLeft 3 3 -underlay
text2brep ttl "Top-Left" -font SansFont -height 30 -pos -27 0 0
-vdisplay ttl -2d -trsfPersPos -1 1 30 -underlay
+vdisplay ttl -2d topLeft 30 30 -underlay
polyline ltl 0 -100 0 0 0 0 100 0 0 100 -50 0 50 -100 0 0 -100 0
-vdisplay ltl -2d -trsfPersPos -1 1 3 -underlay
+vdisplay ltl -2d topLeft 3 3 -underlay
text2brep ttr "Top-Right" -font SansFont -height 30 -pos -100 0 0
-vdisplay ttr -2d -trsfPersPos 1 1 30 -underlay
+vdisplay ttr -2d topRight 30 30 -underlay
polyline ltr -100 -100 0 -100 0 0 0 0 0 0 -50 0 -50 -100 0 -100 -100 0
-vdisplay ltr -2d -trsfPersPos 1 1 3 -underlay
+vdisplay ltr -2d topRight 3 3 -underlay
text2brep tbr "Bottom-Right" -font SansFont -height 30 -pos -165 0 0
-vdisplay tbr -2d -trsfPersPos 1 -1 5 -underlay
+vdisplay tbr -2d bottomRight 5 5 -underlay
polyline lbr -100 0 0 -100 100 0 0 100 0 0 50 0 -50 0 0 -100 0 0
-vdisplay lbr -2d -trsfPersPos 1 -1 3 -underlay
+vdisplay lbr -2d bottomRight 3 3 -underlay
box b 1 2 3
vdisplay b
vtrihedron tri
vpan 50 50
-box b1 25 25 25
-box b2 25 25 25
-box b3 100 100 100
-box b4 100 100 100
-box b5 100 100 100
+box bz1 25 25 25
+box bz2 25 25 25
+box br 100 100 100
+box bzr 50 25 20
+box bt 100 100 100
# 1) Zoom persistence
-vpoint p1 200 200 200
+vpoint pz 200 200 200
-vdisplay b1 -dispMode 1 -highMode 1 -trsfPers zoom -trsfPersPos 200 200 200
-vdisplay b2 -dispMode 1 -highMode 1 -trsfPers zoom -trsfPersPos 200 200 200
-vsetlocation b2 -25 -25 -25
+vdisplay bz1 -dispMode 1 -highMode 1 -trsfPers zoom -trsfPersPos 200 200 200
+vdisplay bz2 -dispMode 1 -highMode 1 -trsfPers zoom -trsfPersPos 200 200 200
+vsetlocation bz2 -25 -25 -25
vselect 0 0
vselect 387 77
# 2) Rotate persistence
-vdisplay b3 -dispMode 1 -highMode 1 -trsfPers rotate -trsfPersPos -200 -200 -200
-vsetmaterial b3 PLASTIC
+vpoint pr -200 -200 -200
+vdisplay br -dispMode 1 -highMode 1 -trsfPers rotate -trsfPersPos -200 -200 -200
+vsetmaterial br PLASTIC
vselect 0 0
vselect 160 200
if { [vreadpixel 160 180 rgb name] != "WHITE" } { puts "Error picking rotate persistence object" }
vselect 130 230 190 170
if { [vreadpixel 160 180 rgb name] != "WHITE" } { puts "Error selecting rotate persistence object" }
-# 3) Pan persistence
+# 3) Zoom + Rotate persistence
-vdisplay b4 -dispMode 1 -highMode 1 -trsfPers pan
+vpoint pzr -200 100 0
+vdisplay bzr -dispMode 1 -highMode 1 -trsfPers zoomRotate -trsfPersPos -200 100 0
+
+vsetmaterial bzr PLASTIC
vselect 0 0
-vselect 233 188
-if { [vreadpixel 233 188 rgb name] != "GRAY66" } { puts "Error picking pan persistence object" }
+vselect 250 90
+if { [vreadpixel 250 90 rgb name] != "WHITE" } { puts "Error picking zoom-rotate persistence object" }
vselect 0 0
-vselect 200 230 270 140
-if { [vreadpixel 233 188 rgb name] != "GRAY66" } { puts "Error selecting pan persistence object" }
+vselect 200 70 286 110
+if { [vreadpixel 250 90 rgb name] != "WHITE" } { puts "Error selecting zoom-rotate persistence object" }
# 4) Trihedron persistence
-vdisplay b5 -dispMode 1 -highMode 1 -trsfPers trihedron -trsfPersPos -1 -1 62
+vdisplay bt -dispMode 1 -highMode 1 -trsfPers trihedron -trsfPersPos -1 -1 62
vselect 0 0
vselect 132 300
if { [vreadpixel 132 300 rgb name] != "GRAY66" } { puts "Error picking trihedron persistence object" }
box box_zoom 100 100 100
vdisplay box3d -dispMode 1 -highMode 0
-vdisplay box2d -dispMode 1 -highMode 1 -2d
-vdisplay box2d_pos -dispMode 1 -highMode 1 -2d -trsfPersPos -1 -1
-vdisplay box2d_loc -dispMode 1 -highMode 1 -2d
+vdisplay box2d -dispMode 1 -highMode 1 -2d center
+vdisplay box2d_pos -dispMode 1 -highMode 1 -2d bottomLeft
+vdisplay box2d_loc -dispMode 1 -highMode 1 -2d center
vdisplay box_zoom -dispMode 1 -highMode 0 -trsfPers zoom
vdisplay box2d
vsetlocation box2d_loc 100 0 0
vzlayer enable 1 depthclear
vtrihedron trh
-vdisplay -noupdate trh -layer 1 -trsfPers trihedron -trsfPersPos 1 1 100
+vdisplay -noupdate trh -layer 1 -trihedron topRight 100 100
text2brep tcc "Center" -font $aLabelFont -height 30 -pos -40 0 0
-vdisplay -noupdate tcc -2d -layer 1 -dispMode 1
+vdisplay -noupdate tcc -2d center -layer 1 -dispMode 1
polyline lcc -50 -50 0 -50 50 0 50 50 0 50 0 0 0 -50 0 -50 -50 0
-vdisplay -noupdate lcc -2d -layer 1
+vdisplay -noupdate lcc -2d center -layer 1
vsetwidth -noupdate lcc 2
text2brep tbl "Bottom-Left" -font $aLabelFont -height 30 -pos 0 3 5
-vdisplay -noupdate tbl -2d -layer 1 -trsfPersPos -1 -1 -dispMode 1
+vdisplay -noupdate tbl -2d bottomLeft -layer 1 -dispMode 1
polyline lbl 0 0 0 0 100 0 100 100 0 100 50 0 50 0 0 0 0 0
-vdisplay -noupdate lbl -2d -layer 1 -trsfPersPos -1 -1
+vdisplay -noupdate lbl -2d bottomLeft -layer 1
vsetwidth -noupdate lbl 2
text2brep ttl "Top-Left" -font $aLabelFont -height 30 -pos 0 -30 0
-vdisplay -noupdate ttl -2d -layer 1 -trsfPersPos -1 1 -dispMode 1
+vdisplay -noupdate ttl -2d topLeft -layer 1 -dispMode 1
polyline ltl 0 -100 0 0 0 0 100 0 0 100 -50 0 50 -100 0 0 -100 0
-vdisplay -noupdate ltl -2d -layer 1 -trsfPersPos -1 1
+vdisplay -noupdate ltl -2d topLeft -layer 1
vsetwidth -noupdate ltl 2
text2brep ttr "Top-Right" -font $aLabelFont -height 30 -pos -130 -30 0
-vdisplay -noupdate ttr -2d -layer 1 -trsfPersPos 1 1 -dispMode 1
+vdisplay -noupdate ttr -2d topRight -layer 1 -dispMode 1
polyline ltr -100 -100 0 -100 0 0 0 0 0 0 -50 0 -50 -100 0 -100 -100 0
-vdisplay -noupdate ltr -2d -layer 1 -trsfPersPos 1 1
+vdisplay -noupdate ltr -2d topRight -layer 1
vsetwidth -noupdate ltr 2
text2brep tbr "Bottom-Right" -font $aLabelFont -height 30 -pos -180 3 0
-vdisplay -noupdate tbr -2d -layer 1 -trsfPersPos 1 -1 -dispMode 1
+vdisplay -noupdate tbr -2d bottomRight -layer 1 -dispMode 1
polyline lbr -100 0 0 -100 100 0 0 100 0 0 50 0 -50 0 0 -100 0 0
-vdisplay -noupdate lbr -2d -layer 1 -trsfPersPos 1 -1
+vdisplay -noupdate lbr -2d bottomRight -layer 1
vsetwidth -noupdate lbr 2
vdrawtext t2 "Label" -pos 1 0 1 -font $aLabelFont