1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0027860: Visualization - clean up Transformation Persistence API

Graphic3d_Camera::TransformMatrices redundant NCollection_Handle usage
has been replaced with validity flags.

Graphic3d_TransModeFlags now defined as enumeration, not integer bit flags.
Graphic3d_TMF_PanPers and Graphic3d_TMF_FullPers have been removed.
Graphic3d_TMF_ZoomRotatePers has been introduced.

Graphic3d_TransformPers is now inherits Standard_Transient.
Graphic3d_TransformPers now defines dedicated constructors
for 3D persistence (zoom / rotate) and 2D persistence (2d / trihedron).
2D persistence now supports dedicated values for X and Y offsets.
The corner is now specified by enumeration Aspect_TypeOfTriedronPosition
instead of indirect interpretation of anchor point values.
Fixed handling of Graphic3d_TMF_ZoomRotatePers (combination of Graphic3d_TMF_RotatePers + Graphic3d_TMF_ZoomPers).

PrsMgr_PresentableObject, Graphic3d_CStructure now hold
Handle(Graphic3d_TransformPers) instead of a value.
Method ::SetTransformPersistence(), ::TransformPersistence()
now works with Handle(Graphic3d_TransformPers).
Old methods have been marked deprecated.
This commit is contained in:
kgv 2016-09-19 23:40:07 +03:00
parent 27ba9c6006
commit 778cd66786
53 changed files with 863 additions and 648 deletions

View File

@ -1034,10 +1034,17 @@ Thus the recommended way to generate vector image of a 3D model or scene is to u
@subsection upgrade_710_trsfpers Transformation persistence @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. 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. 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 @subsection upgrade_710_removed Removed features
The following obsolete features have been removed: The following obsolete features have been removed:

View File

@ -17,7 +17,7 @@ OCC_BaseView::OCC_BaseView()
myCurZoom (0.0), myCurZoom (0.0),
myRect (new AIS_RubberBand (Quantity_Color(Quantity_NOC_WHITE), Aspect_TOL_SOLID, 1.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) if (myRect->ZLayer() != Graphic3d_ZLayerId_TopOSD)
{ {
myRect->SetZLayer (Graphic3d_ZLayerId_TopOSD); myRect->SetZLayer (Graphic3d_ZLayerId_TopOSD);

View File

@ -267,7 +267,7 @@ void Sample2D_Face::HilightSelected
Handle(Graphic3d_AspectLine3d) aLineAspect = Handle(Graphic3d_AspectLine3d) aLineAspect =
new Graphic3d_AspectLine3d(Quantity_NOC_ANTIQUEWHITE, Aspect_TOL_SOLID,2); new Graphic3d_AspectLine3d(Quantity_NOC_ANTIQUEWHITE, Aspect_TOL_SOLID,2);
if( HasPresentation() ) if( HasPresentation() )
aSelectionPrs->SetTransformPersistence( Presentation()->TransformPersistenceMode(), Presentation()->TransformPersistencePoint() ); aSelectionPrs->SetTransformPersistence (Presentation()->TransformPersistence());
Standard_Integer aLength = theOwners.Length(); Standard_Integer aLength = theOwners.Length();
Handle (SelectMgr_EntityOwner) anOwner; Handle (SelectMgr_EntityOwner) anOwner;
@ -337,7 +337,7 @@ void Sample2D_Face::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationMana
Handle( Prs3d_Presentation ) aHighlightPrs; Handle( Prs3d_Presentation ) aHighlightPrs;
aHighlightPrs = GetHilightPresentation( thePM ); aHighlightPrs = GetHilightPresentation( thePM );
if( HasPresentation() ) if( HasPresentation() )
aHighlightPrs->SetTransformPersistence( Presentation()->TransformPersistenceMode(), Presentation()->TransformPersistencePoint() ); aHighlightPrs->SetTransformPersistence (Presentation()->TransformPersistence());
if(theOwner.IsNull()) if(theOwner.IsNull())
return; return;
aHighlightPrs->Clear(); aHighlightPrs->Clear();

View File

@ -2932,11 +2932,9 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject, void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
const Graphic3d_TransModeFlags& theFlag, const Handle(Graphic3d_TransformPers)& theTrsfPers)
const gp_Pnt& thePoint)
{ {
theObject->SetTransformPersistence (theFlag, thePoint); theObject->SetTransformPersistence (theTrsfPers);
if (!myObjects.IsBound (theObject)) if (!myObjects.IsBound (theObject))
{ {
return; return;

View File

@ -599,9 +599,16 @@ public:
Standard_EXPORT void Status (const Handle(AIS_InteractiveObject)& anObj, TCollection_ExtendedString& astatus) const; Standard_EXPORT void Status (const Handle(AIS_InteractiveObject)& anObj, TCollection_ExtendedString& astatus) const;
//! Sets transform persistence. //! Sets transform persistence.
Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj, 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 Graphic3d_TransModeFlags& theFlag,
const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0)); 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. //! Updates the current viewer, the viewer in Neutral Point.
//! Objects selected when there is no open local context //! Objects selected when there is no open local context

View File

@ -651,10 +651,11 @@ void AIS_Manipulator::updateTransformation()
if (myIsZoomPersistentMode) if (myIsZoomPersistentMode)
{ {
if (!(GetTransformPersistenceMode () == Graphic3d_TMF_ZoomPers if (TransformPersistence().IsNull()
&& GetTransformPersistencePoint().IsEqual (myPosition.Location(), 0.))) || 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()));
} }
} }
} }
@ -734,7 +735,7 @@ void AIS_Manipulator::SetZoomPersistence (const Standard_Boolean theToEnable)
if (!theToEnable) if (!theToEnable)
{ {
setTransformPersistence (Graphic3d_TMF_None, gp::Origin()); setTransformPersistence (Handle(Graphic3d_TransformPers)());
} }
updateTransformation(); updateTransformation();
@ -744,26 +745,26 @@ void AIS_Manipulator::SetZoomPersistence (const Standard_Boolean theToEnable)
//function : SetTransformPersistence //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, Standard_ASSERT_RETURN (!myIsZoomPersistentMode,
"AIS_Manipulator::SetTransformPersistence: " "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 //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)
{ {
AIS_InteractiveObject::SetTransformPersistence (theFlag, thePoint); AIS_InteractiveObject::SetTransformPersistence (theTrsfPers);
for (Standard_Integer anIt = 0; anIt < 3; ++anIt) for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{ {
myAxes[anIt].SetTransformPersistence (theFlag, thePoint); myAxes[anIt].SetTransformPersistence (theTrsfPers);
} }
} }
@ -814,8 +815,7 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager3d)& thePr
anAspectAx->SetColor (myAxes[anIt].Color()); anAspectAx->SetColor (myAxes[anIt].Color());
aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect()); aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect());
myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx); myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx);
myAxes[anIt].SetTransformPersistence (GetTransformPersistenceMode(), myAxes[anIt].SetTransformPersistence (TransformPersistence());
GetTransformPersistencePoint());
} }
updateTransformation(); updateTransformation();

View File

@ -250,7 +250,7 @@ public: //! @name Configuration of graphical transformations
//! silently does nothing in release mode. //! silently does nothing in release mode.
//! @warning revise use of AdjustSize argument of of \sa AttachToObjects method //! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
//! when enabling zoom persistence. //! 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. //! Redefines local transformation management method to inform user of inproper use.
//! @warning this interactive object does not support setting custom local transformation, //! @warning this interactive object does not support setting custom local transformation,
@ -347,7 +347,7 @@ protected:
Standard_EXPORT void adjustSize (const Bnd_Box& theBox); 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 protected: //! @name Auxilliary classes to fill presentation with proper primitives
@ -489,28 +489,24 @@ protected: //! @name Auxilliary classes to fill presentation with proper primiti
const gp_Ax1& Position() const { return myPosition; } 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()) if (!myHighlightTranslator.IsNull())
{ {
myHighlightTranslator->SetTransformPersistence (theFlags, thePoint); myHighlightTranslator->SetTransformPersistence (theTrsfPers);
} }
if (!myHighlightScaler.IsNull()) if (!myHighlightScaler.IsNull())
{ {
myHighlightScaler->SetTransformPersistence (theFlags, thePoint); myHighlightScaler->SetTransformPersistence (theTrsfPers);
} }
if (!myHighlightRotator.IsNull()) 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) void Transform (const Handle(Geom_Transformation)& theTransformation)
{ {
if (!myHighlightTranslator.IsNull()) if (!myHighlightTranslator.IsNull())

View File

@ -195,8 +195,7 @@ Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
//======================================================================= //=======================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theTransformation, const gp_Trsf& theTransformation,
const Graphic3d_TransModeFlags& theTrsfPersFlag, const Handle(Graphic3d_TransformPers)& theTrsfPers)
const gp_Pnt& theTrsfPersPoint)
{ {
if (myAssemblyOwner.IsNull()) if (myAssemblyOwner.IsNull())
myAssemblyOwner = new SelectMgr_EntityOwner (this); myAssemblyOwner = new SelectMgr_EntityOwner (this);
@ -234,9 +233,9 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const H
} }
anObjectToAdd->SetLocalTransformation (theTransformation); anObjectToAdd->SetLocalTransformation (theTransformation);
if (theTrsfPersFlag != Graphic3d_TMF_None) if (!theTrsfPers.IsNull())
{ {
anObjectToAdd->SetTransformPersistence (theTrsfPersFlag, theTrsfPersPoint); anObjectToAdd->SetTransformPersistence (theTrsfPers);
} }
AddChild (anObjectToAdd); AddChild (anObjectToAdd);
return anObjectToAdd; return anObjectToAdd;
@ -248,9 +247,7 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const H
//======================================================================= //=======================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj)
{ {
return Connect (theAnotherObj, theAnotherObj->LocalTransformation(), return Connect (theAnotherObj, theAnotherObj->LocalTransformation(), theAnotherObj->TransformPersistence());
theAnotherObj->GetTransformPersistenceMode(),
theAnotherObj->GetTransformPersistencePoint());
} }
//======================================================================= //=======================================================================
@ -260,9 +257,7 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const H
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theTransformation) const gp_Trsf& theTransformation)
{ {
return Connect (theAnotherObj, theTransformation, return Connect (theAnotherObj, theTransformation, theAnotherObj->TransformPersistence());
theAnotherObj->GetTransformPersistenceMode(),
theAnotherObj->GetTransformPersistencePoint());
} }
//======================================================================= //=======================================================================

View File

@ -66,7 +66,18 @@ public:
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference. //! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Locates instance in theLocation and applies specified transformation persistence mode. //! Locates instance in theLocation and applies specified transformation persistence mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive) //! @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; Standard_EXPORT virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE;

View File

@ -47,7 +47,7 @@ AIS_RubberBand::AIS_RubberBand()
myDrawer->ShadingAspect()->SetTransparency (1.0); myDrawer->ShadingAspect()->SetTransparency (1.0);
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE); 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); SetZLayer (Graphic3d_ZLayerId_TopOSD);
} }
@ -66,7 +66,7 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
myDrawer->ShadingAspect()->SetTransparency (1.0); myDrawer->ShadingAspect()->SetTransparency (1.0);
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE); 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); SetZLayer (Graphic3d_ZLayerId_TopOSD);
} }
@ -87,7 +87,7 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID); myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myDrawer->ShadingAspect()->SetTransparency (theTransparency); 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); SetZLayer (Graphic3d_ZLayerId_TopOSD);
} }

View File

@ -284,10 +284,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr
aCenterOfLabel.ChangeCoord() -= myOrientation3D.XDirection().XYZ() * aWidth * 0.5; 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); anAsp->Aspect()->SetTextZoomable (Standard_True);
SetTransformPersistence (GetTransformPersistenceMode() | Graphic3d_TMF_ZoomPers, aPosition); SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, aPosition));
aPosition = gp::Origin(); aPosition = gp::Origin();
} }

View File

@ -16,31 +16,24 @@
#ifndef _Aspect_TypeOfTriedronPosition_HeaderFile #ifndef _Aspect_TypeOfTriedronPosition_HeaderFile
#define _Aspect_TypeOfTriedronPosition_HeaderFile #define _Aspect_TypeOfTriedronPosition_HeaderFile
//! Definition of the Triedron position in the views //! Definition of the Trihedron position in the views.
//! //! It is defined as a bitmask to simplify handling vertical and horizontal alignment independently.
//! 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.
enum Aspect_TypeOfTriedronPosition enum Aspect_TypeOfTriedronPosition
{ {
Aspect_TOTP_CENTER, Aspect_TOTP_CENTER = 0x0000, //!< at the center of the view
Aspect_TOTP_LEFT_LOWER, Aspect_TOTP_TOP = 0x0001, //!< at the middle of the top side
Aspect_TOTP_LEFT_UPPER, Aspect_TOTP_BOTTOM = 0x0002, //!< at the middle of the bottom side
Aspect_TOTP_RIGHT_LOWER, Aspect_TOTP_LEFT = 0x0004, //!< at the middle of the left side
Aspect_TOTP_RIGHT_UPPER, Aspect_TOTP_RIGHT = 0x0008, //!< at the middle of the right side
Aspect_TOTP_01, Aspect_TOTP_LEFT_LOWER = Aspect_TOTP_BOTTOM
Aspect_TOTP_02, | Aspect_TOTP_LEFT, //!< at the left lower corner
Aspect_TOTP_03, Aspect_TOTP_LEFT_UPPER = Aspect_TOTP_TOP
Aspect_TOTP_04, | Aspect_TOTP_LEFT, //!< at the left upper corner
Aspect_TOTP_05, Aspect_TOTP_RIGHT_LOWER = Aspect_TOTP_BOTTOM
Aspect_TOTP_06, | Aspect_TOTP_RIGHT, //!< at the right lower corner
Aspect_TOTP_07, Aspect_TOTP_RIGHT_UPPER = Aspect_TOTP_TOP
Aspect_TOTP_08, | Aspect_TOTP_RIGHT, //!< at the right upper corner
Aspect_TOTP_09,
Aspect_TOTP_10
}; };
#endif // _Aspect_TypeOfTriedronPosition_HeaderFile #endif // _Aspect_TypeOfTriedronPosition_HeaderFile

View File

@ -98,7 +98,6 @@ Graphic3d_SortType.hxx
Graphic3d_StereoMode.hxx Graphic3d_StereoMode.hxx
Graphic3d_Structure.cxx Graphic3d_Structure.cxx
Graphic3d_Structure.hxx Graphic3d_Structure.hxx
Graphic3d_Structure.lxx
Graphic3d_Structure.pxx Graphic3d_Structure.pxx
Graphic3d_StructureDefinitionError.hxx Graphic3d_StructureDefinitionError.hxx
Graphic3d_StructureManager.cxx Graphic3d_StructureManager.cxx
@ -126,6 +125,7 @@ Graphic3d_TextureRoot.cxx
Graphic3d_TextureRoot.hxx Graphic3d_TextureRoot.hxx
Graphic3d_TransformError.hxx Graphic3d_TransformError.hxx
Graphic3d_TransformPers.hxx Graphic3d_TransformPers.hxx
Graphic3d_TransformPers.cxx
Graphic3d_TransformUtils.hxx Graphic3d_TransformUtils.hxx
Graphic3d_TransModeFlags.hxx Graphic3d_TransModeFlags.hxx
Graphic3d_TypeOfAnswer.hxx Graphic3d_TypeOfAnswer.hxx

View File

@ -46,6 +46,12 @@ public:
return myGroups; 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 //! @return associated clip planes
const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
{ {
@ -143,8 +149,6 @@ public:
unsigned IsMutable : 1; unsigned IsMutable : 1;
unsigned Is2dText : 1; unsigned Is2dText : 1;
Graphic3d_TransformPers TransformPersistence;
protected: protected:
//! Create empty structure. //! Create empty structure.
@ -155,6 +159,7 @@ protected:
Handle(Graphic3d_GraphicDriver) myGraphicDriver; Handle(Graphic3d_GraphicDriver) myGraphicDriver;
Graphic3d_SequenceOfGroup myGroups; Graphic3d_SequenceOfGroup myGroups;
Graphic3d_BndBox4f myBndBox; Graphic3d_BndBox4f myBndBox;
Handle(Graphic3d_TransformPers) myTrsfPers;
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes; Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
public: public:

View File

@ -530,14 +530,12 @@ Bnd_Box Graphic3d_CView::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
} }
// "FitAll" operation ignores object with transform persistence parameter // "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. // Panning and 2d persistence apply changes to projection or/and its translation components.
// It makes them incompatible with z-fitting algorithm. Ignored by now. // It makes them incompatible with z-fitting algorithm. Ignored by now.
if (!theToIgnoreInfiniteFlag || if (!theToIgnoreInfiniteFlag
(aStructure->TransformPersistence().Flags & Graphic3d_TMF_2d) || || aStructure->TransformPersistence()->IsTrihedronOr2d())
(aStructure->TransformPersistence().Flags & Graphic3d_TMF_PanPers) ||
(aStructure->TransformPersistence().Flags & Graphic3d_TMF_TriedronPers))
{ {
continue; continue;
} }
@ -550,11 +548,11 @@ Bnd_Box Graphic3d_CView::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
continue; continue;
} }
if (aStructure->TransformPersistence().Flags != Graphic3d_TMF_None) if (!aStructure->TransformPersistence().IsNull())
{ {
const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix(); const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix(); 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 // To prevent float overflow at camera parameters calculation and further

View File

@ -74,6 +74,7 @@ Graphic3d_Camera::Graphic3d_Camera()
myAxialScale (1.0, 1.0, 1.0), myAxialScale (1.0, 1.0, 1.0),
myProjType (Projection_Orthographic), myProjType (Projection_Orthographic),
myFOVy (45.0), myFOVy (45.0),
myFOVyTan (Tan (DTR_HALF * 45.0)),
myZNear (DEFAULT_ZNEAR), myZNear (DEFAULT_ZNEAR),
myZFar (DEFAULT_ZFAR), myZFar (DEFAULT_ZFAR),
myAspect (1.0), myAspect (1.0),
@ -271,7 +272,7 @@ void Graphic3d_Camera::SetScale (const Standard_Real theScale)
case Projection_MonoLeftEye : case Projection_MonoLeftEye :
case Projection_MonoRightEye : case Projection_MonoRightEye :
{ {
Standard_Real aDistance = theScale * 0.5 / Tan(DTR_HALF * myFOVy); Standard_Real aDistance = theScale * 0.5 / myFOVyTan;
SetDistance (aDistance); SetDistance (aDistance);
} }
@ -298,7 +299,7 @@ Standard_Real Graphic3d_Camera::Scale() const
// case Projection_MonoLeftEye : // case Projection_MonoLeftEye :
// case Projection_MonoRightEye : // case Projection_MonoRightEye :
default : default :
return Distance() * 2.0 * Tan (DTR_HALF * myFOVy); return Distance() * 2.0 * myFOVyTan;
} }
} }
@ -344,6 +345,7 @@ void Graphic3d_Camera::SetFOVy (const Standard_Real theFOVy)
} }
myFOVy = theFOVy; myFOVy = theFOVy;
myFOVyTan = Tan(DTR_HALF * myFOVy);
InvalidateProjection(); InvalidateProjection();
} }
@ -646,7 +648,7 @@ gp_Pnt Graphic3d_Camera::ConvertView2World (const gp_Pnt& thePnt) const
gp_XYZ Graphic3d_Camera::ViewDimensions (const Standard_Real theZValue) const gp_XYZ Graphic3d_Camera::ViewDimensions (const Standard_Real theZValue) const
{ {
// view plane dimensions // 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; Standard_Real aSizeX, aSizeY;
if (myAspect > 1.0) if (myAspect > 1.0)
{ {
@ -719,7 +721,7 @@ void Graphic3d_Camera::Frustum (gp_Pln& theLeft,
// ======================================================================= // =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::OrientationMatrix() const const Graphic3d_Mat4d& Graphic3d_Camera::OrientationMatrix() const
{ {
return *UpdateOrientation (myMatricesD).Orientation; return UpdateOrientation (myMatricesD).Orientation;
} }
// ======================================================================= // =======================================================================
@ -728,7 +730,7 @@ const Graphic3d_Mat4d& Graphic3d_Camera::OrientationMatrix() const
// ======================================================================= // =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::OrientationMatrixF() const const Graphic3d_Mat4& Graphic3d_Camera::OrientationMatrixF() const
{ {
return *UpdateOrientation (myMatricesF).Orientation; return UpdateOrientation (myMatricesF).Orientation;
} }
// ======================================================================= // =======================================================================
@ -737,7 +739,7 @@ const Graphic3d_Mat4& Graphic3d_Camera::OrientationMatrixF() const
// ======================================================================= // =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionMatrix() const const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionMatrix() const
{ {
return *UpdateProjection (myMatricesD).MProjection; return UpdateProjection (myMatricesD).MProjection;
} }
// ======================================================================= // =======================================================================
@ -746,7 +748,7 @@ const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionMatrix() const
// ======================================================================= // =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionMatrixF() const const Graphic3d_Mat4& Graphic3d_Camera::ProjectionMatrixF() const
{ {
return *UpdateProjection (myMatricesF).MProjection; return UpdateProjection (myMatricesF).MProjection;
} }
// ======================================================================= // =======================================================================
@ -755,7 +757,7 @@ const Graphic3d_Mat4& Graphic3d_Camera::ProjectionMatrixF() const
// ======================================================================= // =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoLeft() const const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoLeft() const
{ {
return *UpdateProjection (myMatricesD).LProjection; return UpdateProjection (myMatricesD).LProjection;
} }
// ======================================================================= // =======================================================================
@ -764,7 +766,7 @@ const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoLeft() const
// ======================================================================= // =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoLeftF() const const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoLeftF() const
{ {
return *UpdateProjection (myMatricesF).LProjection; return UpdateProjection (myMatricesF).LProjection;
} }
// ======================================================================= // =======================================================================
@ -773,7 +775,7 @@ const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoLeftF() const
// ======================================================================= // =======================================================================
const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoRight() const const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoRight() const
{ {
return *UpdateProjection (myMatricesD).RProjection; return UpdateProjection (myMatricesD).RProjection;
} }
// ======================================================================= // =======================================================================
@ -782,7 +784,7 @@ const Graphic3d_Mat4d& Graphic3d_Camera::ProjectionStereoRight() const
// ======================================================================= // =======================================================================
const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoRightF() const const Graphic3d_Mat4& Graphic3d_Camera::ProjectionStereoRightF() const
{ {
return *UpdateProjection (myMatricesF).RProjection; return UpdateProjection (myMatricesF).RProjection;
} }
// ======================================================================= // =======================================================================
@ -813,8 +815,8 @@ Graphic3d_Camera::TransformMatrices<Elem_t>&
} }
else else
{ {
aDXHalf = aZNear * Elem_t (Tan (DTR_HALF * myFOVy)); aDXHalf = aZNear * Elem_t (myFOVyTan);
aDYHalf = aZNear * Elem_t (Tan (DTR_HALF * myFOVy)); aDYHalf = aZNear * Elem_t (myFOVyTan);
} }
if (anAspect > 1.0) if (anAspect > 1.0)
@ -854,19 +856,19 @@ Graphic3d_Camera::TransformMatrices<Elem_t>&
switch (myProjType) switch (myProjType)
{ {
case Projection_Orthographic : case Projection_Orthographic :
OrthoProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection); OrthoProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
break; break;
case Projection_Perspective : case Projection_Perspective :
PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, *theMatrices.MProjection); PerspectiveProj (aLeft, aRight, aBot, aTop, aZNear, aZFar, theMatrices.MProjection);
break; break;
case Projection_MonoLeftEye : case Projection_MonoLeftEye :
{ {
StereoEyeProj (aLeft, aRight, aBot, aTop, StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus, aZNear, aZFar, aIOD, aFocus,
Standard_True, *theMatrices.MProjection); Standard_True, theMatrices.MProjection);
*theMatrices.LProjection = *theMatrices.MProjection; theMatrices.LProjection = theMatrices.MProjection;
break; break;
} }
@ -874,24 +876,24 @@ Graphic3d_Camera::TransformMatrices<Elem_t>&
{ {
StereoEyeProj (aLeft, aRight, aBot, aTop, StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus, aZNear, aZFar, aIOD, aFocus,
Standard_False, *theMatrices.MProjection); Standard_False, theMatrices.MProjection);
*theMatrices.RProjection = *theMatrices.MProjection; theMatrices.RProjection = theMatrices.MProjection;
break; break;
} }
case Projection_Stereo : 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, StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus, aZNear, aZFar, aIOD, aFocus,
Standard_True, Standard_True,
*theMatrices.LProjection); theMatrices.LProjection);
StereoEyeProj (aLeft, aRight, aBot, aTop, StereoEyeProj (aLeft, aRight, aBot, aTop,
aZNear, aZFar, aIOD, aFocus, aZNear, aZFar, aIOD, aFocus,
Standard_False, Standard_False,
*theMatrices.RProjection); theMatrices.RProjection);
break; break;
} }
} }
@ -930,7 +932,7 @@ Graphic3d_Camera::TransformMatrices<Elem_t>&
static_cast<Elem_t> (myAxialScale.Y()), static_cast<Elem_t> (myAxialScale.Y()),
static_cast<Elem_t> (myAxialScale.Z())); 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 return theMatrices; // for inline accessors
} }

View File

@ -22,8 +22,6 @@
#include <Graphic3d_Vec3.hxx> #include <Graphic3d_Vec3.hxx>
#include <Graphic3d_WorldViewProjState.hxx> #include <Graphic3d_WorldViewProjState.hxx>
#include <NCollection_Handle.hxx>
#include <gp_Dir.hxx> #include <gp_Dir.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
@ -45,46 +43,50 @@ private:
template<typename Elem_t> template<typename Elem_t>
struct TransformMatrices struct TransformMatrices
{ {
//! Default constructor.
TransformMatrices() : myIsOrientationValid (Standard_False), myIsProjectionValid (Standard_False) {}
//! Initialize orientation.
void InitOrientation() void InitOrientation()
{ {
Orientation = new NCollection_Mat4<Elem_t>(); myIsOrientationValid = Standard_True;
Orientation.InitIdentity();
} }
//! Initialize projection.
void InitProjection() void InitProjection()
{ {
MProjection = new NCollection_Mat4<Elem_t>(); myIsProjectionValid = Standard_True;
LProjection = new NCollection_Mat4<Elem_t>(); MProjection.InitIdentity();
RProjection = new NCollection_Mat4<Elem_t>(); LProjection.InitIdentity();
RProjection.InitIdentity();
} }
void ResetOrientation() //! Invalidate orientation.
{ void ResetOrientation() { myIsOrientationValid = Standard_False; }
Orientation.Nullify();
}
void ResetProjection() //! Invalidate projection.
{ void ResetProjection() { myIsProjectionValid = Standard_False; }
MProjection.Nullify();
LProjection.Nullify();
RProjection.Nullify();
}
Standard_Boolean IsOrientationValid() //! Return true if Orientation was not invalidated.
{ Standard_Boolean IsOrientationValid() const { return myIsOrientationValid; }
return !Orientation.IsNull();
}
Standard_Boolean IsProjectionValid() //! Return true if Projection was not invalidated.
{ Standard_Boolean IsProjectionValid() const { return myIsProjectionValid; }
return !MProjection.IsNull() &&
!LProjection.IsNull() && public:
!RProjection.IsNull();
} 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: public:
@ -637,6 +639,7 @@ private:
Projection myProjType; //!< Projection type used for rendering. Projection myProjType; //!< Projection type used for rendering.
Standard_Real myFOVy; //!< Field Of View in y axis. 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 myZNear; //!< Distance to near clipping plane.
Standard_Real myZFar; //!< Distance to far clipping plane. Standard_Real myZFar; //!< Distance to far clipping plane.
Standard_Real myAspect; //!< Width to height display ratio. Standard_Real myAspect; //!< Width to height display ratio.

View File

@ -1103,46 +1103,14 @@ Standard_Integer Graphic3d_Structure::Identification() const
//function : SetTransformPersistence //function : SetTransformPersistence
//purpose : //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)); if (IsDeleted())
} {
return;
}
//============================================================================= myCStructure->SetTransformPersistence (theTrsfPers);
//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;
}
//=============================================================================
//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;
} }
//============================================================================= //=============================================================================

View File

@ -378,19 +378,11 @@ public:
//! the structure <me>. //! the structure <me>.
Standard_EXPORT void Transform (TColStd_Array2OfReal& AMatrix) const; Standard_EXPORT void Transform (TColStd_Array2OfReal& AMatrix) const;
//! Modifies the current modelling transform persistence (pan, zoom or rotate) //! Modifies the current transform persistence (pan, zoom or rotate)
Standard_EXPORT void SetTransformPersistence (const Graphic3d_TransModeFlags& AFlag, const gp_Pnt& APoint); Standard_EXPORT void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
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;
//! @return transform persistence of the presentable object. //! @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). //! 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 void SetMutable (const Standard_Boolean theIsMutable);
@ -439,7 +431,7 @@ public:
Standard_EXPORT static Graphic3d_Vertex Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vertex& Coord); Standard_EXPORT static Graphic3d_Vertex Transforms (const TColStd_Array2OfReal& ATrsf, const Graphic3d_Vertex& Coord);
//! Returns the low-level structure //! Returns the low-level structure
const Handle(Graphic3d_CStructure)& CStructure() const; const Handle(Graphic3d_CStructure)& CStructure() const { return myCStructure; }
friend class Graphic3d_Group; friend class Graphic3d_Group;
@ -505,14 +497,6 @@ protected:
Standard_Address myOwner; Standard_Address myOwner;
Graphic3d_TypeOfStructure myVisual; Graphic3d_TypeOfStructure myVisual;
}; };
#include <Graphic3d_Structure.lxx>
#endif // _Graphic3d_Structure_HeaderFile #endif // _Graphic3d_Structure_HeaderFile

View File

@ -1,32 +0,0 @@
// 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;
}

View File

@ -16,17 +16,16 @@
#ifndef Graphic3d_TRANS_MODE_FLAGS_HXX #ifndef Graphic3d_TRANS_MODE_FLAGS_HXX
#define Graphic3d_TRANS_MODE_FLAGS_HXX #define Graphic3d_TRANS_MODE_FLAGS_HXX
typedef Standard_Integer Graphic3d_TransModeFlags; //! Transform Persistence Mode defining whether to lock in object position, rotation and / or zooming relative to camera position.
enum Graphic3d_TransModeFlags
enum { {
Graphic3d_TMF_None = 0x0000, Graphic3d_TMF_None = 0x0000, //!< no persistence attributes (normal 3D object)
Graphic3d_TMF_PanPers = 0x0001, Graphic3d_TMF_ZoomPers = 0x0002, //!< object does not resize
Graphic3d_TMF_ZoomPers = 0x0002, Graphic3d_TMF_RotatePers = 0x0008, //!< object does not rotate;
Graphic3d_TMF_RotatePers = 0x0008, Graphic3d_TMF_TriedronPers = 0x0020, //!< object behaves like trihedron - it is fixed at the corner of view and does not resizing (but rotating)
Graphic3d_TMF_TriedronPers = 0x0020, Graphic3d_TMF_2d = 0x0040, //!< object is defined in 2D screen coordinates (pixels) and does not resize, pan and rotate
Graphic3d_TMF_2d = 0x0040, Graphic3d_TMF_ZoomRotatePers = Graphic3d_TMF_ZoomPers
Graphic3d_TMF_FullPers = Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers | Graphic3d_TMF_RotatePers //!< object doesn't resize and rotate
}; };
#endif #endif

View File

@ -0,0 +1,53 @@
// 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;
}

View File

@ -16,31 +16,197 @@
#ifndef _Graphic3d_TransformPers_HeaderFile #ifndef _Graphic3d_TransformPers_HeaderFile
#define _Graphic3d_TransformPers_HeaderFile #define _Graphic3d_TransformPers_HeaderFile
#include <Aspect_TypeOfTriedronPosition.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <BVH_Box.hxx> #include <BVH_Box.hxx>
#include <Graphic3d_Camera.hxx> #include <Graphic3d_Camera.hxx>
#include <Graphic3d_TransformUtils.hxx> #include <Graphic3d_TransformUtils.hxx>
#include <Graphic3d_TransModeFlags.hxx> #include <Graphic3d_TransModeFlags.hxx>
#include <Graphic3d_Vec.hxx>
#include <NCollection_Mat4.hxx> #include <NCollection_Mat4.hxx>
#include <NCollection_Vec4.hxx>
DEFINE_STANDARD_HANDLE(Graphic3d_TransformPers, Standard_Transient)
//! Class for keeping and computing transformation persistence. //! 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: 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;
}
//! Default constructor. //! Return true if specified mode is 2d/trihedron transformation persistence.
Graphic3d_TransformPers() static Standard_Boolean IsTrihedronOr2d (Graphic3d_TransModeFlags theMode)
: Flags (Graphic3d_TMF_None), {
Point (0.0, 0.0, 0.0) {} return (theMode & (Graphic3d_TMF_TriedronPers | Graphic3d_TMF_2d)) != 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. //! Transformation persistence mode flags.
Graphic3d_TransModeFlags Flags; Graphic3d_TransModeFlags Mode() const { return myMode; }
//! Reference point for transformation. //! Transformation persistence mode flags.
Graphic3d_Vec3d Point; 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: public:
@ -98,16 +264,37 @@ public:
//! @param theViewportHeight viewport height //! @param theViewportHeight viewport height
template<class T> template<class T>
void Apply (const Handle(Graphic3d_Camera)& theCamera, void Apply (const Handle(Graphic3d_Camera)& theCamera,
NCollection_Mat4<T>& theProjection, const NCollection_Mat4<T>& theProjection,
NCollection_Mat4<T>& theWorldView, NCollection_Mat4<T>& theWorldView,
const Standard_Integer theViewportWidth, const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const; const Standard_Integer theViewportHeight) const;
//! Return true if transformation persistence alters projection matrix. private:
bool AltersProjectionMatrix() const
//! 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;
}; };
@ -117,20 +304,26 @@ public:
// ======================================================================= // =======================================================================
template<class T> template<class T>
void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera, void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
NCollection_Mat4<T>& theProjection, const NCollection_Mat4<T>& theProjection,
NCollection_Mat4<T>& theWorldView, NCollection_Mat4<T>& theWorldView,
const Standard_Integer theViewportWidth, const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const const Standard_Integer theViewportHeight) const
{ {
(void )theViewportWidth; (void )theViewportWidth;
if (Flags == Graphic3d_TMF_None (void )theProjection;
if (myMode == Graphic3d_TMF_None
|| theViewportHeight == 0) || theViewportHeight == 0)
{ {
return; return;
} }
// use total size when tiling is active
const Standard_Integer aVPSizeY = theCamera->Tile().IsValid() ? theCamera->Tile().TotalSize.y() : theViewportHeight; 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 // reset Z focus for trihedron persistence
const Standard_Real aFocus = theCamera->IsOrthographic() const Standard_Real aFocus = theCamera->IsOrthographic()
@ -142,41 +335,43 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
// scale factor to pixels // scale factor to pixels
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus); const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY); 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()); const gp_Dir aForward (theCamera->Center().XYZ() - theCamera->Eye().XYZ());
gp_XYZ aCenter = theCamera->Center().XYZ() + aForward.XYZ() * (aFocus - theCamera->Distance()); 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 Standard_Real anOffsetX = (Standard_Real(myParams.Params2d.OffsetX) + aJitterComp) * aScale;
const gp_Dir aSide = aForward.Crossed (theCamera->Up()); const gp_Dir aSide = aForward.Crossed (theCamera->Up());
if (Point.x() > 0.0) 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 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 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())); NCollection_Mat4<Standard_Real> aWorldView = theCamera->OrientationMatrix();
Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale)); Graphic3d_TransformUtils::Translate (aWorldView, aCenter.X(), aCenter.Y(), aCenter.Z());
Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale);
theWorldView.ConvertFrom (aWorldView);
return; return;
} }
else if (Flags == Graphic3d_TMF_2d) else if (myMode == Graphic3d_TMF_2d)
{ {
const Standard_Real aFocus = theCamera->IsOrthographic() const Standard_Real aFocus = theCamera->IsOrthographic()
? theCamera->Distance() ? theCamera->Distance()
@ -188,18 +383,18 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus); const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY); const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
gp_XYZ aCenter (0.0, 0.0, -aFocus); 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); aCenter.SetX (-aViewDim.X() * 0.5 + (Standard_Real(myParams.Params2d.OffsetX) + aJitterComp) * aScale);
if (Point.x() > 0.0) if ((myParams.Params2d.Corner & Aspect_TOTP_RIGHT) != 0)
{ {
aCenter.SetX (-aCenter.X()); 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); aCenter.SetY (-aViewDim.Y() * 0.5 + (Standard_Real(myParams.Params2d.OffsetY) + aJitterComp) * aScale);
if (Point.y() > 0.0) if ((myParams.Params2d.Corner & Aspect_TOTP_TOP) != 0)
{ {
aCenter.SetY (-aCenter.Y()); aCenter.SetY (-aCenter.Y());
} }
@ -210,92 +405,42 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera,
Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale)); Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
return; return;
} }
else
{ {
// Compute reference point for transformation in untransformed projection space. // Compute reference point for transformation in untransformed projection space.
NCollection_Vec4<T> aRefPoint (static_cast<T> (Point.x()), NCollection_Vec4<T> aRefPoint (static_cast<T> (myParams.Params3d.PntX),
static_cast<T> (Point.y()), static_cast<T> (myParams.Params3d.PntY),
static_cast<T> (Point.z()), static_cast<T> (myParams.Params3d.PntZ),
static_cast<T> (1.0)); 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)
{
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));
}
if ((Flags & Graphic3d_TMF_PanPers) != Graphic3d_TMF_PanPers)
{
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()); Graphic3d_TransformUtils::Translate<T> (theWorldView, aRefPoint.x(), aRefPoint.y(), aRefPoint.z());
if ((myMode & Graphic3d_TMF_RotatePers) != 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 ((myMode & Graphic3d_TMF_ZoomPers) != 0)
{
// lock zooming
gp_Vec aVecToEye (theCamera->Direction());
gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ));
const Standard_Real aFocus = aVecToObj.Dot (aVecToEye);
const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus);
const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY);
Graphic3d_TransformUtils::Scale (theWorldView, T(aScale), T(aScale), T(aScale));
}
return;
} }
} }
@ -384,26 +529,13 @@ NCollection_Mat4<T> Graphic3d_TransformPers::Compute (const Handle(Graphic3d_Cam
const Standard_Integer theViewportWidth, const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const const Standard_Integer theViewportHeight) const
{ {
if (Flags == Graphic3d_TMF_None) if (myMode == Graphic3d_TMF_None)
{ {
return NCollection_Mat4<T>(); return NCollection_Mat4<T>();
} }
NCollection_Mat4<T> aProjection (theProjection);
NCollection_Mat4<T> aWorldView (theWorldView); NCollection_Mat4<T> aWorldView (theWorldView);
NCollection_Mat4<T> anUnviewMat; 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)) if (!theWorldView.Inverted (anUnviewMat))
{ {
return NCollection_Mat4<T>(); return NCollection_Mat4<T>();
@ -411,7 +543,7 @@ NCollection_Mat4<T> Graphic3d_TransformPers::Compute (const Handle(Graphic3d_Cam
// compute only world-view matrix difference to avoid floating point instability // 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) // 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; return anUnviewMat * aWorldView;
} }

View File

@ -929,7 +929,7 @@ void MeshVS_Mesh::HilightSelected ( const Handle(PrsMgr_PresentationManager3d)&
aSelectionPrs = GetSelectPresentation( thePM ); aSelectionPrs = GetSelectPresentation( thePM );
if( HasPresentation() ) 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 // It is very important to call this parent method, because it check whether
@ -1083,7 +1083,7 @@ void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManage
//new functionality //new functionality
if( HasPresentation() ) if( HasPresentation() )
aHilightPrs->SetTransformPersistence( Presentation()->TransformPersistenceMode(), Presentation()->TransformPersistencePoint() ); aHilightPrs->SetTransformPersistence (Presentation()->TransformPersistence());
//---------------- //----------------
const Standard_Boolean isMeshEntityOwner = Owner->IsKind ( STANDARD_TYPE ( MeshVS_MeshEntityOwner ) ); const Standard_Boolean isMeshEntityOwner = Owner->IsKind ( STANDARD_TYPE ( MeshVS_MeshEntityOwner ) );

View File

@ -410,16 +410,20 @@ public:
return true; 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> 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) 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. //! Maps plain C array to matrix type.
static NCollection_Mat4<Element_t>& Map (Element_t* theData) static NCollection_Mat4<Element_t>& Map (Element_t* theData)
{ {

View File

@ -155,7 +155,10 @@ const NCollection_Handle<BVH_Tree<Standard_ShortReal, 4> >&
HBndBox4f aBoundingBox = new Graphic3d_BndBox4f; HBndBox4f aBoundingBox = new Graphic3d_BndBox4f;
*aBoundingBox = aStructure->BoundingBox(); *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); myStructBoxes.Add (aBoundingBox);
} }

View File

@ -27,6 +27,7 @@
// ======================================================================= // =======================================================================
OpenGl_BackgroundArray::OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground theType) OpenGl_BackgroundArray::OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground theType)
: OpenGl_PrimitiveArray (NULL, Graphic3d_TOPA_TRIANGLESTRIPS, NULL, NULL, NULL), : 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), myType (theType),
myFillMethod (Aspect_FM_NONE), myFillMethod (Aspect_FM_NONE),
myViewWidth (0), myViewWidth (0),
@ -41,18 +42,6 @@ OpenGl_BackgroundArray::OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground
myGradientParams.color1 = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 1.0f); 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.color2 = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 1.0f);
myGradientParams.type = Aspect_GFM_NONE; 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;
}
} }
// ======================================================================= // =======================================================================

View File

@ -411,12 +411,9 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
// Render arrow // Render arrow
OpenGl_Vec3 anArrowVec = myMin + anAxis.Direction * (myMax - myMin); OpenGl_Vec3 anArrowVec = myMin + anAxis.Direction * (myMax - myMin);
Graphic3d_TransformPers aTransMode; Graphic3d_TransformPers aTransMode (Graphic3d_TMF_ZoomPers, gp_Pnt (Standard_Real(anArrowVec.x()),
aTransMode.Flags = Graphic3d_TMF_ZoomPers; Standard_Real(anArrowVec.y()),
aTransMode.Point.x() = anArrowVec.x(); Standard_Real(anArrowVec.z())));
aTransMode.Point.y() = anArrowVec.y();
aTransMode.Point.z() = anArrowVec.z();
const OpenGl_Mat4& aProjection = aContext->ProjectionState.Current(); const OpenGl_Mat4& aProjection = aContext->ProjectionState.Current();
const OpenGl_Mat4& aWorldView = aContext->WorldViewState.Current(); const OpenGl_Mat4& aWorldView = aContext->WorldViewState.Current();
const Standard_Integer aWidth = theWorkspace->Width(); const Standard_Integer aWidth = theWorkspace->Width();

View File

@ -68,7 +68,7 @@ void OpenGl_Layer::Add (const OpenGl_Structure* theStruct,
} }
else if (!isForChangePriority) else if (!isForChangePriority)
{ {
if (theStruct->TransformPersistence.Flags == Graphic3d_TMF_None) if (theStruct->TransformPersistence().IsNull())
{ {
myBVHPrimitives.Add (theStruct); myBVHPrimitives.Add (theStruct);
} }
@ -198,14 +198,15 @@ Graphic3d_BndBox4f OpenGl_Layer::BoundingBox (const Standard_Integer th
// "FitAll" operation ignores object with transform persistence parameter // "FitAll" operation ignores object with transform persistence parameter
// but adds transform persistence point in a bounding box of layer (only zoom pers. objects). // 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 if (!theToIncludeAuxiliary
&& (aStructure->TransformPersistence.Flags & Graphic3d_TMF_ZoomPers) != 0) && aStructure->TransformPersistence()->IsZoomOrRotate())
{ {
BVH_Vec4f aTPPoint (static_cast<float> (aStructure->TransformPersistence.Point.x()), const gp_Pnt anAnchor = aStructure->TransformPersistence()->AnchorPoint();
static_cast<float> (aStructure->TransformPersistence.Point.y()), BVH_Vec4f aTPPoint (static_cast<float> (anAnchor.X()),
static_cast<float> (aStructure->TransformPersistence.Point.z()), static_cast<float> (anAnchor.Y()),
static_cast<float> (anAnchor.Z()),
1.0f); 1.0f);
myBoundingBox[aBoxId].Combine (aTPPoint); myBoundingBox[aBoxId].Combine (aTPPoint);
@ -214,7 +215,7 @@ Graphic3d_BndBox4f OpenGl_Layer::BoundingBox (const Standard_Integer th
// Panning and 2d persistence apply changes to projection or/and its translation components. // Panning and 2d persistence apply changes to projection or/and its translation components.
// It makes them incompatible with z-fitting algorithm. Ignored by now. // It makes them incompatible with z-fitting algorithm. Ignored by now.
else if (!theToIncludeAuxiliary else if (!theToIncludeAuxiliary
|| (aStructure->TransformPersistence.Flags & (Graphic3d_TMF_2d | Graphic3d_TMF_PanPers | Graphic3d_TMF_TriedronPers)) != 0) || aStructure->TransformPersistence()->IsTrihedronOr2d())
{ {
continue; continue;
} }
@ -233,14 +234,9 @@ Graphic3d_BndBox4f OpenGl_Layer::BoundingBox (const Standard_Integer th
aBox = centerOfinfiniteBndBox (aBox); aBox = centerOfinfiniteBndBox (aBox);
} }
if (aStructure->TransformPersistence.Flags != Graphic3d_TMF_None) if (!aStructure->TransformPersistence().IsNull())
{ {
aStructure->TransformPersistence.Apply (theCamera, aStructure->TransformPersistence()->Apply (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
aProjectionMat,
aWorldViewMat,
theWindowWidth,
theWindowHeight,
aBox);
} }
// skip too big boxes to prevent float overflow at camera parameters calculation // skip too big boxes to prevent float overflow at camera parameters calculation
@ -269,7 +265,8 @@ Graphic3d_BndBox4f OpenGl_Layer::BoundingBox (const Standard_Integer th
{ {
continue; continue;
} }
else if ((aStructure->TransformPersistence.Flags & (Graphic3d_TMF_TriedronPers | Graphic3d_TMF_2d)) == 0) else if (aStructure->TransformPersistence().IsNull()
|| !aStructure->TransformPersistence()->IsTrihedronOr2d())
{ {
continue; continue;
} }
@ -280,12 +277,7 @@ Graphic3d_BndBox4f OpenGl_Layer::BoundingBox (const Standard_Integer th
continue; continue;
} }
aStructure->TransformPersistence.Apply (theCamera, aStructure->TransformPersistence()->Apply (theCamera, aProjectionMat, aWorldViewMat, theWindowWidth, theWindowHeight, aBox);
aProjectionMat,
aWorldViewMat,
theWindowWidth,
theWindowHeight,
aBox);
if (!isInfiniteBndBox (aBox)) if (!isInfiniteBndBox (aBox))
{ {
aResBox.Combine (aBox); aResBox.Combine (aBox);
@ -321,7 +313,8 @@ Standard_Real OpenGl_Layer::considerZoomPersistenceObjects (const Standard_Integ
{ {
OpenGl_Structure* aStructure = const_cast<OpenGl_Structure*> (aStructures.FindKey (aStructIdx)); OpenGl_Structure* aStructure = const_cast<OpenGl_Structure*> (aStructures.FindKey (aStructIdx));
if (!aStructure->IsVisible (theViewId) if (!aStructure->IsVisible (theViewId)
|| (aStructure->TransformPersistence.Flags & Graphic3d_TMF_ZoomPers) == 0) || aStructure->TransformPersistence().IsNull()
|| !aStructure->TransformPersistence()->IsZoomOrRotate())
{ {
continue; continue;
} }
@ -332,7 +325,7 @@ Standard_Real OpenGl_Layer::considerZoomPersistenceObjects (const Standard_Integ
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& aCornerMin = aBox.CornerMin();
const BVH_Vec4f& aCornerMax = aBox.CornerMax(); const BVH_Vec4f& aCornerMax = aBox.CornerMax();
@ -372,9 +365,7 @@ Standard_Real OpenGl_Layer::considerZoomPersistenceObjects (const Standard_Integ
continue; continue;
} }
const gp_Pnt aTPPoint (aStructure->TransformPersistence.Point.x(), const gp_Pnt aTPPoint = aStructure->TransformPersistence()->AnchorPoint();
aStructure->TransformPersistence.Point.y(),
aStructure->TransformPersistence.Point.z());
gp_Pnt aConvertedTPPoint = theCamera->Project (aTPPoint); gp_Pnt aConvertedTPPoint = theCamera->Project (aTPPoint);
aConvertedTPPoint.SetZ (0.0); aConvertedTPPoint.SetZ (0.0);
@ -473,7 +464,7 @@ void OpenGl_Layer::updateBVH() const
aStruct->MarkAsNotCulled(); aStruct->MarkAsNotCulled();
myAlwaysRenderedMap.Add (aStruct); myAlwaysRenderedMap.Add (aStruct);
} }
else if (aStruct->TransformPersistence.Flags == Graphic3d_TMF_None) else if (aStruct->TransformPersistence().IsNull())
{ {
myBVHPrimitives.Add (aStruct); myBVHPrimitives.Add (aStruct);
} }

View File

@ -471,18 +471,14 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
} }
#endif #endif
if (TransformPersistence.Flags) if (!myTrsfPers.IsNull())
{ {
OpenGl_Mat4 aProjection = aCtx->ProjectionState.Current();
OpenGl_Mat4 aWorldView = aCtx->WorldViewState.Current(); OpenGl_Mat4 aWorldView = aCtx->WorldViewState.Current();
TransformPersistence.Apply (theWorkspace->View()->Camera(), aProjection, aWorldView, myTrsfPers->Apply (theWorkspace->View()->Camera(), aCtx->ProjectionState.Current(), aWorldView,
aCtx->Viewport()[2], aCtx->Viewport()[3]); aCtx->Viewport()[2], aCtx->Viewport()[3]);
aCtx->ProjectionState.Push();
aCtx->WorldViewState.Push(); aCtx->WorldViewState.Push();
aCtx->ProjectionState.SetCurrent (aProjection);
aCtx->WorldViewState.SetCurrent (aWorldView); aCtx->WorldViewState.SetCurrent (aWorldView);
aCtx->ApplyProjectionMatrix();
#if !defined(GL_ES_VERSION_2_0) #if !defined(GL_ES_VERSION_2_0)
if (!aCtx->IsGlNormalizeEnabled() if (!aCtx->IsGlNormalizeEnabled()
@ -526,8 +522,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
if (aCtx->Clipping().IsClippingOrCappingOn()) if (aCtx->Clipping().IsClippingOrCappingOn())
{ {
const Graphic3d_BndBox4f& aBBox = BoundingBox(); const Graphic3d_BndBox4f& aBBox = BoundingBox();
if (TransformPersistence.Flags == Graphic3d_TMF_TriedronPers if ((!myTrsfPers.IsNull() && myTrsfPers->IsTrihedronOr2d())
|| TransformPersistence.Flags == Graphic3d_TMF_2d
|| (!myClipPlanes.IsNull() && myClipPlanes->ToOverrideGlobal())) || (!myClipPlanes.IsNull() && myClipPlanes->ToOverrideGlobal()))
{ {
aCtx->ChangeClipping().DisableGlobal (aCtx); aCtx->ChangeClipping().DisableGlobal (aCtx);
@ -537,7 +532,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
// Set of clipping planes that do not intersect the structure, // Set of clipping planes that do not intersect the structure,
// and thus can be disabled to improve rendering performance // and thus can be disabled to improve rendering performance
if (aBBox.IsValid() if (aBBox.IsValid()
&& TransformPersistence.Flags == Graphic3d_TMF_None) && myTrsfPers.IsNull())
{ {
for (OpenGl_ClippingIterator aPlaneIt (aCtx->Clipping()); aPlaneIt.More(); aPlaneIt.Next()) for (OpenGl_ClippingIterator aPlaneIt (aCtx->Clipping()); aPlaneIt.More(); aPlaneIt.Next())
{ {
@ -617,11 +612,9 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
// Restore local transformation // Restore local transformation
aCtx->ModelWorldState.Pop(); aCtx->ModelWorldState.Pop();
aCtx->SetGlNormalizeEnabled (anOldGlNormalize); aCtx->SetGlNormalizeEnabled (anOldGlNormalize);
if (TransformPersistence.Flags) if (!myTrsfPers.IsNull())
{ {
aCtx->ProjectionState.Pop();
aCtx->WorldViewState.Pop(); aCtx->WorldViewState.Pop();
aCtx->ApplyProjectionMatrix();
} }
// Restore highlight color // Restore highlight color

View File

@ -145,9 +145,7 @@ public:
|| IsForHighlight || IsForHighlight
|| IsMutable || IsMutable
|| Is2dText || Is2dText
|| (TransformPersistence.Flags & Graphic3d_TMF_2d) != 0 || (!myTrsfPers.IsNull() && myTrsfPers->IsTrihedronOr2d());
|| (TransformPersistence.Flags & Graphic3d_TMF_PanPers) != 0
|| (TransformPersistence.Flags & Graphic3d_TMF_TriedronPers) != 0;
} }
//! This method releases GL resources without actual elements destruction. //! This method releases GL resources without actual elements destruction.

View File

@ -38,7 +38,7 @@ OpenGl_StructureShadow::OpenGl_StructureShadow (const Handle(Graphic3d_Structure
UpdateTransformation(); UpdateTransformation();
myInstancedStructure = const_cast<OpenGl_Structure*> (myParent->InstancedStructure()); myInstancedStructure = const_cast<OpenGl_Structure*> (myParent->InstancedStructure());
TransformPersistence = myParent->TransformPersistence; myTrsfPers = myParent->TransformPersistence();
// reuse instanced structure API // reuse instanced structure API
myInstancedStructure = myParent.operator->(); myInstancedStructure = myParent.operator->();

View File

@ -576,9 +576,7 @@ Graphic3d_BndBox4f OpenGl_View::ZLayerBoundingBox (const Graphic3d_ZLayerId
Graphic3d_BndBox4f aBox2d (Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f), Graphic3d_BndBox4f aBox2d (Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f),
Graphic3d_Vec4 (float(theWindowWidth), float(theWindowHeight), 0.0f, 0.0f)); Graphic3d_Vec4 (float(theWindowWidth), float(theWindowHeight), 0.0f, 0.0f));
Graphic3d_TransformPers aTrsfPers; Graphic3d_TransformPers aTrsfPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER);
aTrsfPers.Flags = Graphic3d_TMF_2d;
aTrsfPers.Point = Graphic3d_Vec3d(-1.0, -1.0, 0.0);
aTrsfPers.Apply (theCamera, aTrsfPers.Apply (theCamera,
aProjectionMat, aProjectionMat,
aWorldViewMat, aWorldViewMat,

View File

@ -14,6 +14,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <PrsMgr_PresentableObject.hxx>
#include <Geom_Transformation.hxx> #include <Geom_Transformation.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
@ -24,7 +25,6 @@
#include <Prs3d_Presentation.hxx> #include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx> #include <Prs3d_Projector.hxx>
#include <PrsMgr_ModedPresentation.hxx> #include <PrsMgr_ModedPresentation.hxx>
#include <PrsMgr_PresentableObject.hxx>
#include <PrsMgr_Presentation.hxx> #include <PrsMgr_Presentation.hxx>
#include <PrsMgr_PresentationManager.hxx> #include <PrsMgr_PresentationManager.hxx>
#include <Standard_NotImplemented.hxx> #include <Standard_NotImplemented.hxx>
@ -74,7 +74,7 @@ void PrsMgr_PresentableObject::Fill (const Handle(PrsMgr_PresentationManager)& t
Compute (thePrsMgr, aStruct3d, theMode); Compute (thePrsMgr, aStruct3d, theMode);
UpdateTransformation (aStruct3d); UpdateTransformation (aStruct3d);
aStruct3d->SetClipPlanes (myClipPlanes); aStruct3d->SetClipPlanes (myClipPlanes);
aStruct3d->SetTransformPersistence (GetTransformPersistenceMode(), GetTransformPersistencePoint()); aStruct3d->SetTransformPersistence (TransformPersistence());
} }
//======================================================================= //=======================================================================
@ -306,43 +306,61 @@ void PrsMgr_PresentableObject::UpdateTransformation(const Handle(Prs3d_Presentat
//function : SetTransformPersistence //function : SetTransformPersistence
//purpose : //purpose :
//======================================================================= //=======================================================================
void PrsMgr_PresentableObject::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag, void PrsMgr_PresentableObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
const gp_Pnt& thePoint)
{ {
myTransformPersistence.Flags = theFlag; myTransformPersistence = theTrsfPers;
myTransformPersistence.Point.x() = thePoint.X();
myTransformPersistence.Point.y() = thePoint.Y();
myTransformPersistence.Point.z() = thePoint.Z();
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
{ {
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation(); const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
if (!aPrs3d.IsNull() if (!aPrs3d.IsNull()
&& !aPrs3d->Presentation().IsNull()) && !aPrs3d->Presentation().IsNull())
{ {
aPrs3d->Presentation()->SetTransformPersistence (theFlag, thePoint); aPrs3d->Presentation()->SetTransformPersistence (myTransformPersistence);
aPrs3d->Presentation()->ReCompute(); aPrs3d->Presentation()->ReCompute();
} }
} }
} }
//=======================================================================
//function : GetTransformPersistence
//purpose :
//=======================================================================
Graphic3d_TransModeFlags PrsMgr_PresentableObject::GetTransformPersistenceMode() const
{
return myTransformPersistence.Flags;
}
//======================================================================= //=======================================================================
//function : GetTransformPersistence //function : GetTransformPersistence
//purpose : //purpose :
//======================================================================= //=======================================================================
gp_Pnt PrsMgr_PresentableObject::GetTransformPersistencePoint() const gp_Pnt PrsMgr_PresentableObject::GetTransformPersistencePoint() const
{ {
return gp_Pnt (myTransformPersistence.Point.x(), if (myTransformPersistence.IsNull())
myTransformPersistence.Point.y(), {
myTransformPersistence.Point.z()); 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());
} }
//======================================================================= //=======================================================================

View File

@ -78,37 +78,48 @@ public:
//! Returns information on whether the object accepts display in HLR mode or not. //! Returns information on whether the object accepts display in HLR mode or not.
PrsMgr_TypeOfPresentation3d TypeOfPresentation3d() const { return myTypeOfPresentation3d; } 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. //! Sets up Transform Persistence Mode for this object.
//! This function used to lock in object position, rotation and / or zooming relative to camera position. //! 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 //! Object will be drawn in the origin setted by thePoint parameter (except Graphic3d_TMF_TriedronPers flag
//! - see description later). aFlag should be: //! - see description later). theMode should be:
//! - Graphic3d_TMF_None - no persistence attributes (reset); //! - Graphic3d_TMF_None - no persistence attributes (reset);
//! - Graphic3d_TMF_PanPers - object doesn't move;
//! - Graphic3d_TMF_ZoomPers - object doesn't resize; //! - Graphic3d_TMF_ZoomPers - object doesn't resize;
//! - Graphic3d_TMF_RotatePers - object doesn't rotate; //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
//! - Graphic3d_TMF_FullPers - pan, zoom and rotate transform persistence; //! - Graphic3d_TMF_ZoomRotatePers - object doesn't resize and rotate;
//! - Graphic3d_TMF_TriedronPers - object behaves like trihedron; //! - Graphic3d_TMF_RotatePers - object doesn't rotate;
//! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_ZoomPers); //! - Graphic3d_TMF_TriedronPers - object behaves like trihedron.
//! - combination (Graphic3d_TMF_PanPers | Graphic3d_TMF_RotatePers); //! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected thePoint coordinates X and Y means:
//! - combination (Graphic3d_TMF_ZoomPers | Graphic3d_TMF_RotatePers).
//! If Graphic3d_TMF_TriedronPers or Graphic3d_TMF_2d persistence mode selected APoint coordinates X and Y means:
//! - X = 0.0, Y = 0.0 - center of view window; //! - 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 upper corner of view window;
//! - X > 0.0, Y < 0.0 - right lower 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 upper corner of view window;
//! - X < 0.0, Y < 0.0 - left lower 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). //! 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 //! 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 //! 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; 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); Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType);
//! flags the Prs of mode <AMode> to be Updated. //! flags the Prs of mode <AMode> to be Updated.
@ -289,7 +300,7 @@ protected:
private: private:
Graphic3d_TransformPers myTransformPersistence; Handle(Graphic3d_TransformPers) myTransformPersistence;
PrsMgr_PresentableObjectPointer myParent; PrsMgr_PresentableObjectPointer myParent;
gp_Trsf myLocalTransformation; gp_Trsf myLocalTransformation;
gp_Trsf myTransformation; gp_Trsf myTransformation;

View File

@ -4556,9 +4556,10 @@ static Standard_Integer OCC12584 (Draw_Interpretor& di, Standard_Integer argc, c
{ {
aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD); 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; Standard_Integer aWinWidth, aWinHeight;
V->Window()->Size (aWinWidth, aWinHeight); V->Window()->Size (aWinWidth, aWinHeight);

View File

@ -348,13 +348,12 @@ void SelectMgr_SelectableObject::SetAutoHilight ( const Standard_Boolean newAuto
//function : GetHilightPresentation //function : GetHilightPresentation
//purpose : //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() ) if (myHilightPrs.IsNull() && !theMgr.IsNull())
{ {
myHilightPrs = new Prs3d_Presentation( TheMgr->StructureManager() ); myHilightPrs = new Prs3d_Presentation (theMgr->StructureManager());
myHilightPrs->SetTransformPersistence( GetTransformPersistenceMode(), myHilightPrs->SetTransformPersistence (TransformPersistence());
GetTransformPersistencePoint() );
} }
return myHilightPrs; return myHilightPrs;
@ -365,13 +364,14 @@ Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation( c
//function : GetSelectPresentation //function : GetSelectPresentation
//purpose : //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() ) { if (mySelectionPrs.IsNull() && !theMgr.IsNull())
mySelectionPrs = new Prs3d_Presentation( TheMgr->StructureManager() ); {
mySelectionPrs->SetTransformPersistence( GetTransformPersistenceMode(), mySelectionPrs = new Prs3d_Presentation (theMgr->StructureManager());
GetTransformPersistencePoint() ); mySelectionPrs->SetTransformPersistence (TransformPersistence());
} }
return mySelectionPrs; return mySelectionPrs;
} }

View File

@ -125,14 +125,14 @@ namespace
Bnd_Box aBoundingBox; Bnd_Box aBoundingBox;
anObject->BoundingBox (aBoundingBox); anObject->BoundingBox (aBoundingBox);
if (aBoundingBox.IsVoid()) if (aBoundingBox.IsVoid()
|| anObject->TransformPersistence().IsNull())
{ {
myBoundings.Add (new Select3D_HBndBox3d()); myBoundings.Add (new Select3D_HBndBox3d());
} }
else else
{ {
anObject->TransformPersistence().Apply ( anObject->TransformPersistence()->Apply (theCamera, theProjectionMat, theWorldViewMat, theWidth, theHeight, aBoundingBox);
theCamera, theProjectionMat, theWorldViewMat, theWidth, theHeight, aBoundingBox);
const gp_Pnt aMin = aBoundingBox.CornerMin(); const gp_Pnt aMin = aBoundingBox.CornerMin();
const gp_Pnt aMax = aBoundingBox.CornerMax(); const gp_Pnt aMax = aBoundingBox.CornerMax();

View File

@ -184,11 +184,11 @@ private:
//! Returns an appropriate subset of theObject given depending on its persistence type. //! Returns an appropriate subset of theObject given depending on its persistence type.
Standard_Integer appropriateSubset (const Handle(SelectMgr_SelectableObject)& theObject) Standard_Integer appropriateSubset (const Handle(SelectMgr_SelectableObject)& theObject)
{ {
if (!theObject->TransformPersistence().Flags) if (theObject->TransformPersistence().IsNull())
{ {
return SelectMgr_SelectableObjectSet::BVHSubset_3d; 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; return SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent;
} }

View File

@ -171,8 +171,7 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
if (!anOwner.IsNull()) if (!anOwner.IsNull())
{ {
aSelectable = anOwner->Selectable(); aSelectable = anOwner->Selectable();
if (aSelectable->TransformPersistence().Flags == Graphic3d_TMF_TriedronPers if ((!aSelectable->TransformPersistence().IsNull() && aSelectable->TransformPersistence()->IsTrihedronOr2d())
|| aSelectable->TransformPersistence().Flags == Graphic3d_TMF_2d
|| (!aSelectable->ClipPlanes().IsNull() && aSelectable->ClipPlanes()->ToOverrideGlobal())) || (!aSelectable->ClipPlanes().IsNull() && aSelectable->ClipPlanes()->ToOverrideGlobal()))
{ {
theMgr.SetViewClippingEnabled (Standard_False); theMgr.SetViewClippingEnabled (Standard_False);
@ -289,17 +288,16 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
gp_GTrsf aInversedTrsf; 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(); aInversedTrsf = theObject->InversedTransformation();
} }
else else
{ {
gp_GTrsf aTPers; gp_GTrsf aTPers;
Graphic3d_Mat4d aMat = theObject->TransformPersistence().Compute ( Graphic3d_Mat4d aMat = theObject->TransformPersistence()->Compute (theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
aTPers.SetValue (1, 1, aMat.GetValue (0, 0)); aTPers.SetValue (1, 1, aMat.GetValue (0, 0));
aTPers.SetValue (1, 2, aMat.GetValue (0, 1)); aTPers.SetValue (1, 2, aMat.GetValue (0, 1));

View File

@ -114,7 +114,7 @@ void StdSelect_BRepOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
if (!aSel.IsNull()) if (!aSel.IsNull())
{ {
myPrsSh->SetZLayer (aSel->ZLayer()); myPrsSh->SetZLayer (aSel->ZLayer());
myPrsSh->SetTransformPersistence (aSel->GetTransformPersistenceMode(), aSel->GetTransformPersistencePoint()); myPrsSh->SetTransformPersistence (aSel->TransformPersistence());
} }
// highlight and set layer // highlight and set layer
@ -177,7 +177,7 @@ void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManag
if (!aSel.IsNull()) if (!aSel.IsNull())
{ {
myPrsSh->SetZLayer (aSel->ZLayer()); myPrsSh->SetZLayer (aSel->ZLayer());
myPrsSh->SetTransformPersistence (aSel->GetTransformPersistenceMode(), aSel->GetTransformPersistencePoint()); myPrsSh->SetTransformPersistence (aSel->TransformPersistence());
} }
// highlight with color and set layer // highlight with color and set layer

View File

@ -195,7 +195,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theVi
{ {
if (anObj->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated) if (anObj->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
{ {
computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Graphic3d_TransformPers()); computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Handle(Graphic3d_TransformPers)());
} }
} }
@ -247,7 +247,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(SelectMgr_Select
Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager()); 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.Append (aStruct);
myStructs.Last()->SetDisplayPriority (10); myStructs.Last()->SetDisplayPriority (10);
@ -263,11 +263,9 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(SelectMgr_Select
void StdSelect_ViewerSelector3d::computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure, void StdSelect_ViewerSelector3d::computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
const Handle(SelectMgr_Selection)& theSel, const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc, const gp_Trsf& theLoc,
const Graphic3d_TransformPers& theTransPers) const Handle(Graphic3d_TransformPers)& theTrsfPers)
{ {
theStructure->SetTransformPersistence (theTransPers.Flags, gp_Pnt (theTransPers.Point.x(), theStructure->SetTransformPersistence (theTrsfPers);
theTransPers.Point.y(),
theTransPers.Point.z()));
Handle(Graphic3d_Group) aSensGroup = theStructure->NewGroup(); Handle(Graphic3d_Group) aSensGroup = theStructure->NewGroup();

View File

@ -88,7 +88,7 @@ protected:
Standard_EXPORT void computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure, Standard_EXPORT void computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
const Handle(SelectMgr_Selection)& theSel, const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc, const gp_Trsf& theLoc,
const Graphic3d_TransformPers& theTransPers); const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Update z-layers order map. //! Update z-layers order map.
Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView); Standard_EXPORT void updateZLayers (const Handle(V3d_View)& theView);

View File

@ -2126,7 +2126,7 @@ void V3d_View::Gravity (Standard_Real& theX,
} }
// skip transformation-persistent objects // skip transformation-persistent objects
if (aStruct->TransformPersistence().Flags != Graphic3d_TMF_None) if (!aStruct->TransformPersistence().IsNull())
{ {
continue; continue;
} }

View File

@ -3385,28 +3385,25 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
//! Auxiliary method to parse transformation persistence flags //! Auxiliary method to parse transformation persistence flags
inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFlagString, inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFlagString,
Standard_Integer& theFlags) Graphic3d_TransModeFlags& theFlags)
{ {
if (theFlagString == "pan") if (theFlagString == "zoom")
{ {
theFlags |= Graphic3d_TMF_PanPers; theFlags = Graphic3d_TMF_ZoomPers;
}
else if (theFlagString == "zoom")
{
theFlags |= Graphic3d_TMF_ZoomPers;
} }
else if (theFlagString == "rotate") else if (theFlagString == "rotate")
{ {
theFlags |= Graphic3d_TMF_RotatePers; theFlags = Graphic3d_TMF_RotatePers;
} }
else if (theFlagString == "trihedron") else if (theFlagString == "zoomrotate")
{
theFlags = Graphic3d_TMF_ZoomRotatePers;
}
else if (theFlagString == "trihedron"
|| theFlagString == "triedron")
{ {
theFlags = Graphic3d_TMF_TriedronPers; theFlags = Graphic3d_TMF_TriedronPers;
} }
else if (theFlagString == "full")
{
theFlags = Graphic3d_TMF_FullPers;
}
else if (theFlagString == "none") else if (theFlagString == "none")
{ {
theFlags = Graphic3d_TMF_None; theFlags = Graphic3d_TMF_None;
@ -3419,6 +3416,66 @@ inline Standard_Boolean parseTrsfPersFlag (const TCollection_AsciiString& theFla
return Standard_True; 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 //function : VDisplay2
//author : ege //author : ege
@ -3451,8 +3508,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
Standard_Integer anObjDispMode = -2; Standard_Integer anObjDispMode = -2;
Standard_Integer anObjHighMode = -2; Standard_Integer anObjHighMode = -2;
Standard_Boolean toSetTrsfPers = Standard_False; Standard_Boolean toSetTrsfPers = Standard_False;
Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None; Handle(Graphic3d_TransformPers) aTrsfPers;
gp_Pnt aTPPosition;
TColStd_SequenceOfAsciiString aNamesOfDisplayIO; TColStd_SequenceOfAsciiString aNamesOfDisplayIO;
AIS_DisplayStatus aDispStatus = AIS_DS_None; AIS_DisplayStatus aDispStatus = AIS_DS_None;
Standard_Integer toDisplayInView = Standard_False; Standard_Integer toDisplayInView = Standard_False;
@ -3528,51 +3584,71 @@ static int VDisplay2 (Draw_Interpretor& theDI,
else if (aNameCase == "-3d") else if (aNameCase == "-3d")
{ {
toSetTrsfPers = Standard_True; toSetTrsfPers = Standard_True;
aTrsfPersFlags = Graphic3d_TMF_None; aTrsfPers.Nullify();
} }
else if (aNameCase == "-2d") else if (aNameCase == "-2d"
|| aNameCase == "-trihedron"
|| aNameCase == "-triedron")
{ {
toSetTrsfPers = Standard_True; 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" else if (aNameCase == "-trsfpers"
|| aNameCase == "-pers") || aNameCase == "-pers")
{ {
if (++anArgIter >= theArgNb) if (++anArgIter >= theArgNb
|| !aTrsfPers.IsNull())
{ {
std::cerr << "Error: wrong syntax at " << aName << ".\n"; std::cerr << "Error: wrong syntax at " << aName << ".\n";
return 1; return 1;
} }
toSetTrsfPers = Standard_True; toSetTrsfPers = Standard_True;
aTrsfPersFlags = Graphic3d_TMF_None; Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None;
TCollection_AsciiString aPersFlags (theArgVec [anArgIter]); TCollection_AsciiString aPersFlags (theArgVec [anArgIter]);
aPersFlags.LowerCase(); aPersFlags.LowerCase();
for (Standard_Integer aParserPos = aPersFlags.Search ("|");; aParserPos = aPersFlags.Search ("|"))
{
if (aParserPos == -1)
{
if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags)) if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
{ {
std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n"; std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n";
return 1; return 1;
} }
break;
}
TCollection_AsciiString anOtherFlags = aPersFlags.Split (aParserPos - 1); if (aTrsfPersFlags == Graphic3d_TMF_TriedronPers)
if (!parseTrsfPersFlag (aPersFlags, aTrsfPersFlags))
{ {
std::cerr << "Error: wrong transform persistence flags " << theArgVec [anArgIter] << ".\n"; aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER);
return 1;
} }
aPersFlags = anOtherFlags; else if (aTrsfPersFlags != Graphic3d_TMF_None)
{
aTrsfPers = new Graphic3d_TransformPers (aTrsfPersFlags, gp_Pnt());
} }
} }
else if (aNameCase == "-trsfperspos" else if (aNameCase == "-trsfperspos"
|| aNameCase == "-perspos") || aNameCase == "-perspos")
{ {
if (anArgIter + 2 >= theArgNb) if (anArgIter + 2 >= theArgNb
|| aTrsfPers.IsNull())
{ {
std::cerr << "Error: wrong syntax at " << aName << ".\n"; std::cerr << "Error: wrong syntax at " << aName << ".\n";
return 1; return 1;
@ -3581,8 +3657,8 @@ static int VDisplay2 (Draw_Interpretor& theDI,
TCollection_AsciiString aX (theArgVec[++anArgIter]); TCollection_AsciiString aX (theArgVec[++anArgIter]);
TCollection_AsciiString aY (theArgVec[++anArgIter]); TCollection_AsciiString aY (theArgVec[++anArgIter]);
TCollection_AsciiString aZ = "0"; TCollection_AsciiString aZ = "0";
if (!aX.IsIntegerValue() if (!aX.IsRealValue()
|| !aY.IsIntegerValue()) || !aY.IsRealValue())
{ {
std::cerr << "Error: wrong syntax at " << aName << ".\n"; std::cerr << "Error: wrong syntax at " << aName << ".\n";
return 1; return 1;
@ -3590,13 +3666,22 @@ static int VDisplay2 (Draw_Interpretor& theDI,
if (anArgIter + 1 < theArgNb) if (anArgIter + 1 < theArgNb)
{ {
TCollection_AsciiString aTemp = theArgVec[anArgIter + 1]; TCollection_AsciiString aTemp = theArgVec[anArgIter + 1];
if (aTemp.IsIntegerValue()) if (aTemp.IsRealValue())
{ {
aZ = aTemp; aZ = aTemp;
++anArgIter; ++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") else if (aNameCase == "-layer")
{ {
@ -3672,7 +3757,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
} }
if (toSetTrsfPers) if (toSetTrsfPers)
{ {
aCtx->SetTransformPersistence (aShape, aTrsfPersFlags, aTPPosition); aCtx->SetTransformPersistence (aShape, aTrsfPers);
} }
if (anObjDispMode != -2) if (anObjDispMode != -2)
{ {
@ -3726,7 +3811,7 @@ static int VDisplay2 (Draw_Interpretor& theDI,
} }
if (toSetTrsfPers) if (toSetTrsfPers)
{ {
aCtx->SetTransformPersistence (aShape, aTrsfPersFlags, aTPPosition); aCtx->SetTransformPersistence (aShape, aTrsfPers);
} }
if (anObjDispMode != -2) if (anObjDispMode != -2)
{ {
@ -5523,7 +5608,11 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
theCommands.Add("vdisplay", theCommands.Add("vdisplay",
"vdisplay [-noupdate|-update] [-local] [-mutable] [-neutral]" "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: [-dispMode mode] [-highMode mode]"
"\n\t\t: [-layer index] [-top|-topmost|-overlay|-underlay]" "\n\t\t: [-layer index] [-top|-topmost|-overlay|-underlay]"
"\n\t\t: [-redisplay]" "\n\t\t: [-redisplay]"
@ -5532,21 +5621,28 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
"\n\t\t: Option -local enables displaying of objects in local" "\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: selection context. Local selection context will be opened"
"\n\t\t: if there is not any." "\n\t\t: if there is not any."
"\n\t\t: -noupdate suppresses viewer redraw call." "\n\t\t: -noupdate Suppresses viewer redraw call."
"\n\t\t: -mutable enables optimizations for mutable objects." "\n\t\t: -mutable Enables optimizations for mutable objects."
"\n\t\t: -neutral draws objects in main viewer." "\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: -layer Sets z-layer for objects."
"\n\t\t: -top draws objects on top of main presentations but below topmost." "\n\t\t: Alternatively -overlay|-underlay|-top|-topmost"
"\n\t\t: -topmost draws in overlay for 3D presentations with independent Depth." "\n\t\t: options can be used for the default z-layers."
"\n\t\t: -overlay draws objects in overlay for 2D presentations (On-Screen-Display)." "\n\t\t: -top Draws object on top of main presentations"
"\n\t\t: -underlay draws objects in underlay for 2D presentations (On-Screen-Display)." "\n\t\t: but below topmost."
"\n\t\t: -selectable|-noselect controls selection of objects." "\n\t\t: -topmost Draws in overlay for 3D presentations."
"\n\t\t: -trsfPers sets a transform persistence flags. Flag 'full' is pan, zoom and rotate." "\n\t\t: with independent Depth."
"\n\t\t: -trsfPersPos sets an anchor point for transform persistence." "\n\t\t: -overlay Draws objects in overlay for 2D presentations."
"\n\t\t: -2d displays object in screen coordinates (DY looks up)." "\n\t\t: (On-Screen-Display)"
"\n\t\t: -dispmode sets display mode for objects." "\n\t\t: -underlay Draws objects in underlay for 2D presentations."
"\n\t\t: -highmode sets hilight mode for objects." "\n\t\t: (On-Screen-Display)"
"\n\t\t: -redisplay recomputes presentation of objects.", "\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); __FILE__, VDisplay2, group);
theCommands.Add ("vupdate", theCommands.Add ("vupdate",

View File

@ -139,11 +139,6 @@
#include <TColStd_HArray1OfAsciiString.hxx> #include <TColStd_HArray1OfAsciiString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx> #include <TColStd_HSequenceOfAsciiString.hxx>
#if defined(_MSC_VER)
# define _CRT_SECURE_NO_DEPRECATE
# pragma warning (disable:4996)
#endif
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName, extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
const Handle(AIS_InteractiveObject)& theAISObj, const Handle(AIS_InteractiveObject)& theAISObj,
@ -2508,11 +2503,9 @@ static int VDrawText (Draw_Interpretor& theDI,
aTextPrs->SetText (aText); aTextPrs->SetText (aText);
Graphic3d_TransModeFlags aTrsfPersFlags = Graphic3d_TMF_None; Handle(Graphic3d_TransformPers) aTrsfPers;
gp_Pnt aTPPosition;
Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL; Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL;
Standard_Boolean aHasPlane = Standard_False; Standard_Boolean aHasPlane = Standard_False;
gp_Dir aNormal; gp_Dir aNormal;
gp_Dir aDirection; gp_Dir aDirection;
@ -2799,7 +2792,7 @@ static int VDrawText (Draw_Interpretor& theDI,
} }
else if (aParam == "-2d") else if (aParam == "-2d")
{ {
aTrsfPersFlags = Graphic3d_TMF_2d; aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_2d);
} }
else if (aParam == "-trsfperspos" else if (aParam == "-trsfperspos"
|| aParam == "-perspos") || aParam == "-perspos")
@ -2828,7 +2821,8 @@ static int VDrawText (Draw_Interpretor& theDI,
++anArgIt; ++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 else
{ {
@ -2844,18 +2838,18 @@ static int VDrawText (Draw_Interpretor& theDI,
aTextPrs->SetDisplayType (aDisplayType); 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); aTextPrs->SetZLayer(Graphic3d_ZLayerId_TopOSD);
if (aTextPrs->Position().Z() != 0) if (aTextPrs->Position().Z() != 0)
{ {
aTextPrs->SetPosition (gp_Pnt(aTextPrs->Position().X(), aTextPrs->Position().Y(), 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); ViewerTest::Display (aName, aTextPrs, Standard_False);
return 0; return 0;

View File

@ -3478,9 +3478,10 @@ static int VColorScale (Draw_Interpretor& theDI,
{ {
aCS->SetZLayer (Graphic3d_ZLayerId_TopOSD); 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(); Standard_Real aMinRange = aCS->GetMin();
@ -4746,7 +4747,7 @@ static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char**
aLineType, aWidth, aLineType, aWidth,
aTransparency); 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->SetZLayer (Graphic3d_ZLayerId_TopOSD);
aLine->SetToUpdate(); aLine->SetToUpdate();
aContext->Display (aLine, Standard_True); aContext->Display (aLine, Standard_True);

View File

@ -10,7 +10,7 @@ box b1 10 20 30
box b2 10 20 30 box b2 10 20 30
ttranslate b2 50 50 0 ttranslate b2 50 50 0
vinit vinit
vdisplay b1 -trsfPers trihedron vdisplay b1 -trihedron center
vdisplay b2 vdisplay b2
vfit vfit

View File

@ -12,32 +12,32 @@ vaxo
# display polyline in overlay # display polyline in overlay
text2brep tcc "Center" -font SansFont -height 30 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 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 # display polyline in overlay in the bottom left corner of the view
text2brep tbl "Bottom-Left" -font SansFont -height 30 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 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 # display polyline in overlay in the top left corner of the view
text2brep ttl "Top-Left" -font SansFont -height 30 -pos -27 0 0 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 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 # display polyline in overlay in the top right corner of the view
text2brep ttr "Top-Right" -font SansFont -height 30 -pos -100 0 0 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 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 # display polyline in overlay in the bottom right corner of the view
text2brep tbr "Bottom-Right" -font SansFont -height 30 -pos -165 0 0 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 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 vdump ${imagedir}/${casename}.png

View File

@ -11,29 +11,29 @@ vclear
vaxo vaxo
text2brep tcc "Center" -font SansFont -height 30 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 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 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 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 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 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 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 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 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 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 box b 1 2 3
vdisplay b vdisplay b

View File

@ -13,18 +13,18 @@ vinit View1 w=409 h=409
vtrihedron tri vtrihedron tri
vpan 50 50 vpan 50 50
box b1 25 25 25 box bz1 25 25 25
box b2 25 25 25 box bz2 25 25 25
box b3 100 100 100 box br 100 100 100
box b4 100 100 100 box bzr 50 25 20
box b5 100 100 100 box bt 100 100 100
# 1) Zoom persistence # 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 bz1 -dispMode 1 -highMode 1 -trsfPers zoom -trsfPersPos 200 200 200
vdisplay b2 -dispMode 1 -highMode 1 -trsfPers zoom -trsfPersPos 200 200 200 vdisplay bz2 -dispMode 1 -highMode 1 -trsfPers zoom -trsfPersPos 200 200 200
vsetlocation b2 -25 -25 -25 vsetlocation bz2 -25 -25 -25
vselect 0 0 vselect 0 0
vselect 387 77 vselect 387 77
@ -36,8 +36,9 @@ if { [vreadpixel 387 77 rgb name] != "GRAY66" || [vreadpixel 352 96 rgb name] !=
# 2) Rotate persistence # 2) Rotate persistence
vdisplay b3 -dispMode 1 -highMode 1 -trsfPers rotate -trsfPersPos -200 -200 -200 vpoint pr -200 -200 -200
vsetmaterial b3 PLASTIC vdisplay br -dispMode 1 -highMode 1 -trsfPers rotate -trsfPersPos -200 -200 -200
vsetmaterial br PLASTIC
vselect 0 0 vselect 0 0
vselect 160 200 vselect 160 200
if { [vreadpixel 160 180 rgb name] != "WHITE" } { puts "Error picking rotate persistence object" } if { [vreadpixel 160 180 rgb name] != "WHITE" } { puts "Error picking rotate persistence object" }
@ -46,19 +47,22 @@ vselect 0 0
vselect 130 230 190 170 vselect 130 230 190 170
if { [vreadpixel 160 180 rgb name] != "WHITE" } { puts "Error selecting rotate persistence object" } 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 0 0
vselect 233 188 vselect 250 90
if { [vreadpixel 233 188 rgb name] != "GRAY66" } { puts "Error picking pan persistence object" } if { [vreadpixel 250 90 rgb name] != "WHITE" } { puts "Error picking zoom-rotate persistence object" }
vselect 0 0 vselect 0 0
vselect 200 230 270 140 vselect 200 70 286 110
if { [vreadpixel 233 188 rgb name] != "GRAY66" } { puts "Error selecting pan persistence object" } if { [vreadpixel 250 90 rgb name] != "WHITE" } { puts "Error selecting zoom-rotate persistence object" }
# 4) Trihedron persistence # 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 0 0
vselect 132 300 vselect 132 300
if { [vreadpixel 132 300 rgb name] != "GRAY66" } { puts "Error picking trihedron persistence object" } if { [vreadpixel 132 300 rgb name] != "GRAY66" } { puts "Error picking trihedron persistence object" }

View File

@ -22,9 +22,9 @@ box box2d_loc 100 100 1
box box_zoom 100 100 100 box box_zoom 100 100 100
vdisplay box3d -dispMode 1 -highMode 0 vdisplay box3d -dispMode 1 -highMode 0
vdisplay box2d -dispMode 1 -highMode 1 -2d vdisplay box2d -dispMode 1 -highMode 1 -2d center
vdisplay box2d_pos -dispMode 1 -highMode 1 -2d -trsfPersPos -1 -1 vdisplay box2d_pos -dispMode 1 -highMode 1 -2d bottomLeft
vdisplay box2d_loc -dispMode 1 -highMode 1 -2d vdisplay box2d_loc -dispMode 1 -highMode 1 -2d center
vdisplay box_zoom -dispMode 1 -highMode 0 -trsfPers zoom vdisplay box_zoom -dispMode 1 -highMode 0 -trsfPers zoom
vdisplay box2d vdisplay box2d
vsetlocation box2d_loc 100 0 0 vsetlocation box2d_loc 100 0 0

View File

@ -30,36 +30,36 @@ vzlayer add 1
vzlayer enable 1 depthclear vzlayer enable 1 depthclear
vtrihedron trh 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 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 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 vsetwidth -noupdate lcc 2
text2brep tbl "Bottom-Left" -font $aLabelFont -height 30 -pos 0 3 5 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 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 vsetwidth -noupdate lbl 2
text2brep ttl "Top-Left" -font $aLabelFont -height 30 -pos 0 -30 0 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 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 vsetwidth -noupdate ltl 2
text2brep ttr "Top-Right" -font $aLabelFont -height 30 -pos -130 -30 0 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 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 vsetwidth -noupdate ltr 2
text2brep tbr "Bottom-Right" -font $aLabelFont -height 30 -pos -180 3 0 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 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 vsetwidth -noupdate lbr 2
vdrawtext t2 "Label" -pos 1 0 1 -font $aLabelFont vdrawtext t2 "Label" -pos 1 0 1 -font $aLabelFont