mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
828a75f228 | ||
|
59515ca600 | ||
|
fa1710b567 | ||
|
9460f8c0b9 | ||
|
a3a3ff3d33 | ||
|
2108d9a25b | ||
|
e8dec5e171 | ||
|
0dab581700 | ||
|
1c728f2d6d | ||
|
6b9b7e3c92 | ||
|
7c08e3ac6e | ||
|
718d07fe5e | ||
|
bc28da5c3a | ||
|
2fb08f0132 |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.6 KiB |
@@ -48,7 +48,7 @@ void AIS_AnimationCamera::update (const AIS_AnimationProgress& theProgress)
|
||||
Handle(Graphic3d_Camera) aCamera = myView->Camera();
|
||||
|
||||
Graphic3d_CameraLerp aCamLerp (myCamStart, myCamEnd);
|
||||
aCamLerp.Interpolate (theProgress.LocalNormalized, aCamera);
|
||||
aCamLerp.Interpolate (HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
|
||||
|
||||
const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate (Standard_False);
|
||||
myView->SetCamera (aCamera);
|
||||
|
@@ -33,6 +33,9 @@ public:
|
||||
//! Return the target view.
|
||||
const Handle(V3d_View)& View() const { return myView; }
|
||||
|
||||
//! Set target view.
|
||||
void SetView (const Handle(V3d_View)& theView) { myView = theView; }
|
||||
|
||||
//! Return camera start position.
|
||||
const Handle(Graphic3d_Camera)& CameraStart() const { return myCamStart; }
|
||||
|
||||
|
@@ -633,9 +633,6 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
|
||||
{
|
||||
aShadedGroup = thePrs->NewGroup();
|
||||
aShadedGroup->SetClosed (isClosed);
|
||||
if (isClosed
|
||||
&& !myCappingStyle.IsNull())
|
||||
aShadedGroup->SetGroupPrimitivesAspect (myCappingStyle);
|
||||
}
|
||||
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
|
||||
aShadedGroup->AddPrimitiveArray (aTriangles);
|
||||
|
@@ -187,6 +187,29 @@ AIS_InteractiveContext::~AIS_InteractiveContext()
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LastActiveView
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(V3d_View) AIS_InteractiveContext::LastActiveView() const
|
||||
{
|
||||
if (myLastActiveView == NULL
|
||||
|| myMainVwr.IsNull())
|
||||
{
|
||||
return Handle(V3d_View)();
|
||||
}
|
||||
|
||||
// as a precaution - check that myLastActiveView pointer is a valid active View
|
||||
for (V3d_ListOfViewIterator aViewIter = myMainVwr->ActiveViewIterator(); aViewIter.More(); aViewIter.Next())
|
||||
{
|
||||
if (aViewIter.Value() == myLastActiveView)
|
||||
{
|
||||
return aViewIter.Value();
|
||||
}
|
||||
}
|
||||
return Handle(V3d_View)();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateCurrentViewer
|
||||
//purpose :
|
||||
@@ -2447,12 +2470,10 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FitSelected
|
||||
//purpose : Fits the view corresponding to the bounds of selected objects
|
||||
//function : BoundingBoxOfSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
|
||||
const Standard_Real theMargin,
|
||||
const Standard_Boolean theToUpdate)
|
||||
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
|
||||
{
|
||||
Bnd_Box aBndSelected;
|
||||
AIS_MapOfObjectOwners anObjectOwnerMap;
|
||||
@@ -2491,12 +2512,22 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
|
||||
aBndSelected.Add (aTmpBox);
|
||||
}
|
||||
|
||||
anObjectOwnerMap.Clear();
|
||||
return aBndSelected;
|
||||
}
|
||||
|
||||
if (aBndSelected.IsVoid())
|
||||
return;
|
||||
|
||||
theView->FitAll (aBndSelected, theMargin, theToUpdate);
|
||||
//=======================================================================
|
||||
//function : FitSelected
|
||||
//purpose : Fits the view corresponding to the bounds of selected objects
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
|
||||
const Standard_Real theMargin,
|
||||
const Standard_Boolean theToUpdate)
|
||||
{
|
||||
Bnd_Box aBndSelected = BoundingBoxOfSelection();
|
||||
if (!aBndSelected.IsVoid())
|
||||
{
|
||||
theView->FitAll (aBndSelected, theMargin, theToUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -370,6 +370,9 @@ public: //! @name mouse picking logic (detection and dynamic highlighting of ent
|
||||
const Standard_Integer theMode,
|
||||
const Standard_Integer theNewSensitivity);
|
||||
|
||||
//! Returns last active View (argument of MoveTo()/Select() methods).
|
||||
Standard_EXPORT Handle(V3d_View) LastActiveView() const;
|
||||
|
||||
//! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors.
|
||||
//! This is done by the view theView passing this position to the main viewer and updating it.
|
||||
//! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object.
|
||||
@@ -505,6 +508,9 @@ public: //! @name Selection management
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean theToUpdateViewer);
|
||||
|
||||
//! Returns bounding box of selected objects.
|
||||
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
|
||||
|
||||
//! Fits the view correspondingly to the bounds of selected objects.
|
||||
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
|
||||
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
|
||||
@@ -1379,6 +1385,7 @@ protected: //! @name internal fields
|
||||
Handle(PrsMgr_PresentationManager3d) myMainPM;
|
||||
Handle(V3d_Viewer) myMainVwr;
|
||||
Handle(StdSelect_ViewerSelector3d) myMainSel;
|
||||
V3d_View* myLastActiveView;
|
||||
Handle(SelectMgr_EntityOwner) myLastPicked;
|
||||
Standard_Boolean myToHilightSelected;
|
||||
Handle(AIS_Selection) mySelection;
|
||||
|
@@ -325,6 +325,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
|
||||
myCurDetected = 0;
|
||||
myCurHighlighted = 0;
|
||||
myDetectedSeq.Clear();
|
||||
myLastActiveView = theView.get();
|
||||
|
||||
// preliminaires
|
||||
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
|
||||
@@ -495,6 +496,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
|
||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||
// new objects are put...
|
||||
ClearSelected (Standard_False);
|
||||
myLastActiveView = theView.get();
|
||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
@@ -534,6 +536,7 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
|
||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||
// new objects are put...
|
||||
ClearSelected (Standard_False);
|
||||
myLastActiveView = theView.get();
|
||||
myMainSel->Pick (thePolyline, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
@@ -565,6 +568,17 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate
|
||||
{
|
||||
if (!myLastPicked.IsNull())
|
||||
{
|
||||
Graphic3d_Vec2i aMousePos (-1, -1);
|
||||
if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
|
||||
{
|
||||
aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
|
||||
(Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
|
||||
}
|
||||
if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
|
||||
{
|
||||
return AIS_SOP_NothingSelected;
|
||||
}
|
||||
|
||||
if (myAutoHilight)
|
||||
{
|
||||
clearDynamicHighlight();
|
||||
@@ -630,6 +644,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
||||
}
|
||||
|
||||
myLastActiveView = theView.get();
|
||||
if (myAutoHilight)
|
||||
{
|
||||
UnhilightSelected (Standard_False);
|
||||
@@ -670,6 +685,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
||||
}
|
||||
|
||||
myLastActiveView = theView.get();
|
||||
if (myAutoHilight)
|
||||
{
|
||||
UnhilightSelected (Standard_False);
|
||||
|
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
@@ -84,37 +83,6 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCappingStyle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveObject::SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
{
|
||||
myCappingStyle = theStyle;
|
||||
|
||||
// Modify existing presentations
|
||||
for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
|
||||
{
|
||||
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter);
|
||||
if (!aPrs3d.IsNull())
|
||||
{
|
||||
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
|
||||
if (!aStruct.IsNull())
|
||||
{
|
||||
const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
|
||||
if (aGrp.IsNull())
|
||||
continue;
|
||||
|
||||
aGrp->SetGroupPrimitivesAspect (theStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasPresentation
|
||||
//purpose :
|
||||
|
@@ -104,12 +104,6 @@ public:
|
||||
void ClearOwner() { myOwner.Nullify(); }
|
||||
|
||||
public:
|
||||
//! Set style of filling capping section created by clipping planes.
|
||||
Standard_EXPORT virtual void SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
|
||||
|
||||
//! Returns style for filling capping section created by clipping planes.
|
||||
const Handle(Graphic3d_AspectFillCapping)& CappingStyle() const { return myCappingStyle; }
|
||||
|
||||
|
||||
//! Returns the context pointer to the interactive context.
|
||||
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
|
||||
@@ -134,7 +128,6 @@ protected:
|
||||
|
||||
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
|
||||
Handle(Standard_Transient) myOwner; //!< application-specific owner object
|
||||
Handle(Graphic3d_AspectFillCapping) myCappingStyle;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -180,7 +180,10 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myCappingStyle);
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
|
||||
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
|
||||
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
|
||||
myUVOrigin, myUVRepeat, myUVScale);
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "AIS_ViewController.hxx"
|
||||
|
||||
#include <AIS_AnimationCamera.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_Manipulator.hxx>
|
||||
#include <AIS_Point.hxx>
|
||||
@@ -47,12 +48,15 @@ AIS_ViewController::AIS_ViewController()
|
||||
myToAllowZFocus (true),
|
||||
myToAllowHighlight (true),
|
||||
myToAllowDragging (true),
|
||||
myToStickToRayOnZoom (true),
|
||||
myToStickToRayOnRotation (true),
|
||||
//
|
||||
myWalkSpeedAbsolute (1.5f),
|
||||
myWalkSpeedRelative (0.1f),
|
||||
myThrustSpeed (0.0f),
|
||||
myHasThrust (false),
|
||||
//
|
||||
myViewAnimation (new AIS_AnimationCamera ("AIS_ViewController_ViewAnimation", Handle(V3d_View)())),
|
||||
myPrevMoveTo (-1, -1),
|
||||
myHasHlrOnBeforeRotation (false),
|
||||
//
|
||||
@@ -1224,6 +1228,20 @@ AIS_WalkDelta AIS_ViewController::FetchNavigationKeys (Standard_Real theCrouchRa
|
||||
return aWalk;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AbortViewAnimation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_ViewController::AbortViewAnimation()
|
||||
{
|
||||
if (!myViewAnimation.IsNull()
|
||||
&& !myViewAnimation->IsStopped())
|
||||
{
|
||||
myViewAnimation->Stop();
|
||||
myViewAnimation->SetView (Handle(V3d_View)());
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : handlePanning
|
||||
// purpose :
|
||||
@@ -1236,6 +1254,8 @@ void AIS_ViewController::handlePanning (const Handle(V3d_View)& theView)
|
||||
return;
|
||||
}
|
||||
|
||||
AbortViewAnimation();
|
||||
|
||||
const Handle(Graphic3d_Camera)& aCam = theView->Camera();
|
||||
if (aCam->IsOrthographic()
|
||||
|| !hasPanningAnchorPoint())
|
||||
@@ -1276,6 +1296,8 @@ void AIS_ViewController::handleZRotate (const Handle(V3d_View)& theView)
|
||||
return;
|
||||
}
|
||||
|
||||
AbortViewAnimation();
|
||||
|
||||
Graphic3d_Vec2i aViewPort;
|
||||
theView->Window()->Size (aViewPort.x(), aViewPort.y());
|
||||
Graphic3d_Vec2d aRotPnt (0.99 * aViewPort.x(),
|
||||
@@ -1299,6 +1321,8 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
|
||||
return;
|
||||
}
|
||||
|
||||
AbortViewAnimation();
|
||||
|
||||
const Handle(Graphic3d_Camera)& aCam = theView->Camera();
|
||||
if (thePnt != NULL)
|
||||
{
|
||||
@@ -1371,9 +1395,9 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
theView->Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
const Graphic3d_Vec2d aPanFromCenterPx (double(theParams.Point.x()) - 0.5 * double(aWinSize.x()),
|
||||
double(theParams.Point.y()) - 0.5 * double(aWinSize.y()));
|
||||
double(aWinSize.y() - theParams.Point.y() - 1) - 0.5 * double(aWinSize.y()));
|
||||
aDxy.x() += -aViewDims1.X() * aPanFromCenterPx.x() / double(aWinSize.x());
|
||||
aDxy.y() += aViewDims1.X() * aPanFromCenterPx.y() / double(aWinSize.x());
|
||||
aDxy.y() += -aViewDims1.Y() * aPanFromCenterPx.y() / double(aWinSize.y());
|
||||
}
|
||||
|
||||
//theView->Translate (aCam, aDxy.x(), aDxy.y());
|
||||
@@ -1450,6 +1474,7 @@ void AIS_ViewController::handleOrbitRotation (const Handle(V3d_View)& theView,
|
||||
return;
|
||||
}
|
||||
|
||||
AbortViewAnimation();
|
||||
if (theToLockZUp)
|
||||
{
|
||||
// amend camera to exclude roll angle (put camera Up vector to plane containing global Z and view direction)
|
||||
@@ -1561,6 +1586,8 @@ void AIS_ViewController::handleViewRotation (const Handle(V3d_View)& theView,
|
||||
return;
|
||||
}
|
||||
|
||||
AbortViewAnimation();
|
||||
|
||||
Graphic3d_Vec2i aWinXY;
|
||||
theView->Window()->Size (aWinXY.x(), aWinXY.y());
|
||||
double aYawAngleDelta = ((myGL.ViewRotation.PointStart.x() - myGL.ViewRotation.PointTo.x()) / double (aWinXY.x())) * (M_PI * 0.5);
|
||||
@@ -1636,7 +1663,7 @@ gp_Pnt AIS_ViewController::GravityPoint (const Handle(AIS_InteractiveContext)& t
|
||||
}
|
||||
|
||||
gp_Pnt aPnt;
|
||||
if (PickPoint (aPnt, theCtx, theView, aCursor, false))
|
||||
if (PickPoint (aPnt, theCtx, theView, aCursor, myToStickToRayOnRotation))
|
||||
{
|
||||
return aPnt;
|
||||
}
|
||||
@@ -1857,12 +1884,9 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
|
||||
|
||||
if (!theView->Camera()->IsOrthographic())
|
||||
{
|
||||
// what is more natural to user - point on ray or point exactly on geometry in corner cases?
|
||||
const bool toStickToRay = false; // true;
|
||||
|
||||
gp_Pnt aPnt;
|
||||
if (aZoomParams.HasPoint()
|
||||
&& PickPoint (aPnt, theCtx, theView, aZoomParams.Point, toStickToRay))
|
||||
&& PickPoint (aPnt, theCtx, theView, aZoomParams.Point, myToStickToRayOnZoom))
|
||||
{
|
||||
handleZoom (theView, aZoomParams, &aPnt);
|
||||
continue;
|
||||
@@ -1870,7 +1894,7 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
|
||||
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
theView->Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
if (PickPoint (aPnt, theCtx, theView, aWinSize / 2, toStickToRay))
|
||||
if (PickPoint (aPnt, theCtx, theView, aWinSize / 2, myToStickToRayOnZoom))
|
||||
{
|
||||
aZoomParams.ResetPoint(); // do not pretend to zoom at 'nothing'
|
||||
handleZoom (theView, aZoomParams, &aPnt);
|
||||
@@ -2035,11 +2059,6 @@ void AIS_ViewController::handleSelectionPick (const Handle(AIS_InteractiveContex
|
||||
{
|
||||
for (NCollection_Sequence<Graphic3d_Vec2i>::Iterator aPntIter (myGL.Selection.Points); aPntIter.More(); aPntIter.Next())
|
||||
{
|
||||
if (!myGL.Selection.IsXOR)
|
||||
{
|
||||
theCtx->ClearSelected (false);
|
||||
}
|
||||
|
||||
const bool hadPrevMoveTo = HasPreviousMoveTo();
|
||||
contextLazyMoveTo (theCtx, theView, aPntIter.Value());
|
||||
if (!hadPrevMoveTo)
|
||||
@@ -2274,6 +2293,15 @@ void AIS_ViewController::handleMoveTo (const Handle(AIS_InteractiveContext)& the
|
||||
void AIS_ViewController::handleViewRedraw (const Handle(AIS_InteractiveContext)& ,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
// manage animation state
|
||||
if (!myViewAnimation.IsNull()
|
||||
&& !myViewAnimation->IsStopped())
|
||||
{
|
||||
myViewAnimation->UpdateTimer();
|
||||
ResetPreviousMoveTo();
|
||||
setAskNextFrame();
|
||||
}
|
||||
|
||||
for (V3d_ListOfViewIterator aViewIter (theView->Viewer()->ActiveViewIterator()); aViewIter.More(); aViewIter.Next())
|
||||
{
|
||||
const Handle(V3d_View)& aView = aViewIter.Value();
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
class AIS_AnimationCamera;
|
||||
class AIS_InteractiveObject;
|
||||
class AIS_InteractiveContext;
|
||||
class AIS_Point;
|
||||
@@ -56,6 +57,15 @@ public:
|
||||
//! Return input buffer.
|
||||
AIS_ViewInputBuffer& ChangeInputBuffer (AIS_ViewInputBufferType theType) { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }
|
||||
|
||||
//! Return view animation; empty (but not NULL) animation by default.
|
||||
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
|
||||
|
||||
//! Set view animation to be handled within handleViewRedraw().
|
||||
void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
|
||||
|
||||
//! Interrupt active view animation.
|
||||
Standard_EXPORT void AbortViewAnimation();
|
||||
|
||||
public: //! @name global parameters
|
||||
|
||||
//! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default.
|
||||
@@ -142,6 +152,18 @@ public: //! @name global parameters
|
||||
//! Set if dynamic highlight on mouse move is allowed.
|
||||
void SetAllowDragging (bool theToEnable) { myToAllowDragging = theToEnable; }
|
||||
|
||||
//! Return TRUE if picked point should be projected to picking ray on zooming at point; TRUE by default.
|
||||
bool ToStickToRayOnZoom() const { return myToStickToRayOnZoom; }
|
||||
|
||||
//! Set if picked point should be projected to picking ray on zooming at point.
|
||||
void SetStickToRayOnZoom (bool theToEnable) { myToStickToRayOnZoom = theToEnable; }
|
||||
|
||||
//! Return TRUE if picked point should be projected to picking ray on rotating around point; TRUE by default.
|
||||
bool ToStickToRayOnRotation() const { return myToStickToRayOnRotation; }
|
||||
|
||||
//! Set if picked point should be projected to picking ray on rotating around point.
|
||||
void SetStickToRayOnRotation (bool theToEnable) { myToStickToRayOnRotation = theToEnable; }
|
||||
|
||||
//! Return TRUE if pitch direction should be inverted while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown; FALSE by default.
|
||||
bool ToInvertPitch() const { return myToInvertPitch; }
|
||||
|
||||
@@ -590,12 +612,15 @@ protected:
|
||||
Standard_Boolean myToAllowZFocus; //!< enable ZFocus change; TRUE by default
|
||||
Standard_Boolean myToAllowHighlight; //!< enable dynamic highlight on mouse move; TRUE by default
|
||||
Standard_Boolean myToAllowDragging; //!< enable dragging object; TRUE by default
|
||||
Standard_Boolean myToStickToRayOnZoom; //!< project picked point to ray while zooming at point, TRUE by default
|
||||
Standard_Boolean myToStickToRayOnRotation; //!< project picked point to ray while rotating around point; TRUE by default
|
||||
|
||||
Standard_ShortReal myWalkSpeedAbsolute; //!< normal walking speed, in m/s; 1.5 by default
|
||||
Standard_ShortReal myWalkSpeedRelative; //!< walking speed relative to scene bounding box; 0.1 by default
|
||||
Standard_ShortReal myThrustSpeed; //!< active thrust value
|
||||
Standard_Boolean myHasThrust; //!< flag indicating active thrust
|
||||
|
||||
Handle(AIS_AnimationCamera) myViewAnimation; //!< view animation
|
||||
Handle(AIS_RubberBand) myRubberBand; //!< Rubber-band presentation
|
||||
Handle(AIS_InteractiveObject) myDragObject; //!< currently dragged object
|
||||
Graphic3d_Vec2i myPrevMoveTo; //!< previous position of MoveTo event in 3D viewer
|
||||
|
891
src/AIS/AIS_ViewCube.cxx
Normal file
891
src/AIS/AIS_ViewCube.cxx
Normal file
@@ -0,0 +1,891 @@
|
||||
// Created on: 2017-07-25
|
||||
// Created by: Anastasia BOBYLEVA
|
||||
// Copyright (c) 2017-2019 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 <AIS_ViewCube.hxx>
|
||||
|
||||
#include <AIS_AnimationCamera.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <Graphic3d_ViewAffinity.hxx>
|
||||
#include <NCollection_Lerp.hxx>
|
||||
#include <Prs3d.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_DatumAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Prs3d_ToolDisk.hxx>
|
||||
#include <Prs3d_ToolSphere.hxx>
|
||||
#include <Select3D_SensitivePrimitiveArray.hxx>
|
||||
#include <SelectMgr_SequenceOfOwner.hxx>
|
||||
#include <V3d.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_Integer THE_NB_ROUND_SPLITS = 8;
|
||||
static const Standard_Integer THE_NB_DISK_SLICES = 20;
|
||||
static const Standard_Integer THE_NB_ARROW_FACETTES = 20;
|
||||
|
||||
//! Return the number of non-zero components.
|
||||
static Standard_Integer nbDirectionComponents (const gp_Dir& theDir)
|
||||
{
|
||||
Standard_Integer aNbComps = 0;
|
||||
for (Standard_Integer aCompIter = 1; aCompIter <= 3; ++aCompIter)
|
||||
{
|
||||
if (Abs (theDir.Coord (aCompIter)) > gp::Resolution())
|
||||
{
|
||||
++aNbComps;
|
||||
}
|
||||
}
|
||||
return aNbComps;
|
||||
}
|
||||
}
|
||||
|
||||
//! Simple sensitive element for picking by point only.
|
||||
class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray
|
||||
{
|
||||
DEFINE_STANDARD_RTTI_INLINE(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
|
||||
public:
|
||||
//! Constructor.
|
||||
AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const Handle(Graphic3d_ArrayOfTriangles)& theTris)
|
||||
: Select3D_SensitivePrimitiveArray (theOwner)
|
||||
{
|
||||
InitTriangulation (theTris->Attributes(), theTris->Indices(), TopLoc_Location());
|
||||
}
|
||||
|
||||
//! Checks whether element overlaps current selecting volume.
|
||||
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
|
||||
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
|
||||
{
|
||||
return isValidRay (theMgr)
|
||||
&& Select3D_SensitivePrimitiveArray::Matches (theMgr, thePickResult);
|
||||
}
|
||||
|
||||
//! Checks if picking ray can be used for detection.
|
||||
bool isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const
|
||||
{
|
||||
if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
|
||||
{
|
||||
// disallow rectangular selection
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AIS_ViewCubeOwner* anOwner = dynamic_cast<AIS_ViewCubeOwner* >(myOwnerId.get()))
|
||||
{
|
||||
const Standard_Real anAngleToler = 10.0 * M_PI / 180.0;
|
||||
const gp_Vec aRay (theMgr.GetNearPickedPnt(), theMgr.GetFarPickedPnt());
|
||||
const gp_Dir aDir = V3d::GetProjAxis (anOwner->MainOrientation());
|
||||
return !aRay.IsNormal (aDir, anAngleToler);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : IsBoxSide
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool AIS_ViewCube::IsBoxSide (V3d_TypeOfOrientation theOrient)
|
||||
{
|
||||
return nbDirectionComponents (V3d::GetProjAxis (theOrient)) == 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsBoxEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool AIS_ViewCube::IsBoxEdge (V3d_TypeOfOrientation theOrient)
|
||||
{
|
||||
return nbDirectionComponents (V3d::GetProjAxis (theOrient)) == 2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsBoxCorner
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool AIS_ViewCube::IsBoxCorner (V3d_TypeOfOrientation theOrient)
|
||||
{
|
||||
return nbDirectionComponents (V3d::GetProjAxis (theOrient)) == 3;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AIS_ViewCube
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_ViewCube::AIS_ViewCube()
|
||||
: myBoxEdgeAspect (new Prs3d_ShadingAspect()),
|
||||
myBoxCornerAspect (new Prs3d_ShadingAspect()),
|
||||
mySize (1.0),
|
||||
myBoxEdgeMinSize (2.0),
|
||||
myBoxEdgeGap (0.0),
|
||||
myBoxFacetExtension (1.0),
|
||||
myAxesPadding (1.0),
|
||||
myCornerMinSize (2.0),
|
||||
myRoundRadius (0.0),
|
||||
myToDisplayAxes (true),
|
||||
myToDisplayEdges (true),
|
||||
myToDisplayVertices (true),
|
||||
myIsYup (false),
|
||||
myViewAnimation (new AIS_AnimationCamera ("AIS_ViewCube", Handle(V3d_View)())),
|
||||
myStartState(new Graphic3d_Camera()),
|
||||
myEndState (new Graphic3d_Camera()),
|
||||
myDuration (0.5),
|
||||
myToAutoStartAnim (true),
|
||||
myIsFixedAnimation (true),
|
||||
myToFitSelected (true),
|
||||
myToResetCameraUp (false)
|
||||
{
|
||||
myInfiniteState = true;
|
||||
myIsMutable = true;
|
||||
myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
|
||||
myTransformPersistence = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100));
|
||||
|
||||
myDrawer->SetTextAspect (new Prs3d_TextAspect());
|
||||
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
|
||||
myDynHilightDrawer = new Prs3d_Drawer();
|
||||
myDynHilightDrawer->SetLink (myDrawer);
|
||||
myDynHilightDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
|
||||
setDefaultAttributes();
|
||||
setDefaultHighlightAttributes();
|
||||
|
||||
// setup default labels
|
||||
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Front, "FRONT");
|
||||
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Back, "BACK");
|
||||
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Top, "TOP");
|
||||
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Bottom, "BOTTOM");
|
||||
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Left, "LEFT");
|
||||
myBoxSideLabels.Bind (V3d_TypeOfOrientation_Zup_Right, "RIGHT");
|
||||
|
||||
myAxesLabels.Bind (Prs3d_DP_XAxis, "X");
|
||||
myAxesLabels.Bind (Prs3d_DP_YAxis, "Y");
|
||||
myAxesLabels.Bind (Prs3d_DP_ZAxis, "Z");
|
||||
|
||||
// define default size
|
||||
SetSize (70.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setDefaultAttributes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::setDefaultAttributes()
|
||||
{
|
||||
myDrawer->TextAspect()->SetHorizontalJustification(Graphic3d_HTA_CENTER);
|
||||
myDrawer->TextAspect()->SetVerticalJustification (Graphic3d_VTA_CENTER);
|
||||
myDrawer->TextAspect()->SetColor (Quantity_NOC_BLACK);
|
||||
myDrawer->TextAspect()->SetFont (Font_NOF_SANS_SERIF);
|
||||
myDrawer->TextAspect()->SetHeight (16.0);
|
||||
// this should be forced back-face culling regardless Closed flag
|
||||
myDrawer->TextAspect()->Aspect()->SetSuppressBackFaces (true);
|
||||
|
||||
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_UserDefined);
|
||||
aMat.SetColor (Quantity_NOC_WHITE);
|
||||
aMat.SetAmbientColor (Quantity_NOC_GRAY60);
|
||||
|
||||
const Handle(Graphic3d_AspectFillArea3d)& aShading = myDrawer->ShadingAspect()->Aspect();
|
||||
aShading->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
// this should be forced back-face culling regardless Closed flag
|
||||
aShading->SetSuppressBackFaces (true);
|
||||
aShading->SetInteriorColor (aMat.Color());
|
||||
aShading->SetFrontMaterial (aMat);
|
||||
myDrawer->SetFaceBoundaryDraw (false);
|
||||
|
||||
*myBoxEdgeAspect ->Aspect() = *aShading;
|
||||
myBoxEdgeAspect->SetColor (Quantity_NOC_GRAY30);
|
||||
*myBoxCornerAspect->Aspect() = *aShading;
|
||||
myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setDefaultHighlightAttributes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::setDefaultHighlightAttributes()
|
||||
{
|
||||
Graphic3d_MaterialAspect aHighlightMaterial;
|
||||
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
|
||||
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
|
||||
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
|
||||
aHighlightMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
|
||||
aHighlightMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
|
||||
myDynHilightDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
myDynHilightDrawer->ShadingAspect()->SetMaterial (aHighlightMaterial);
|
||||
myDynHilightDrawer->ShadingAspect()->SetColor (Quantity_NOC_CYAN1);
|
||||
myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost);
|
||||
myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetYup
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::SetYup (Standard_Boolean theIsYup,
|
||||
Standard_Boolean theToUpdateLabels)
|
||||
{
|
||||
if (myIsYup == theIsYup)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myIsYup = theIsYup;
|
||||
|
||||
static const V3d_TypeOfOrientation THE_ZUP_ORI_LIST[6] =
|
||||
{
|
||||
V3d_TypeOfOrientation_Zup_Front, V3d_TypeOfOrientation_Zup_Back,
|
||||
V3d_TypeOfOrientation_Zup_Top, V3d_TypeOfOrientation_Zup_Bottom,
|
||||
V3d_TypeOfOrientation_Zup_Left, V3d_TypeOfOrientation_Zup_Right
|
||||
};
|
||||
static const V3d_TypeOfOrientation THE_YUP_ORI_LIST[6] =
|
||||
{
|
||||
V3d_TypeOfOrientation_Yup_Front, V3d_TypeOfOrientation_Yup_Back,
|
||||
V3d_TypeOfOrientation_Yup_Top, V3d_TypeOfOrientation_Yup_Bottom,
|
||||
V3d_TypeOfOrientation_Yup_Left, V3d_TypeOfOrientation_Yup_Right
|
||||
};
|
||||
if (theToUpdateLabels)
|
||||
{
|
||||
NCollection_Array1<TCollection_AsciiString> aLabels (0, 5);
|
||||
for (Standard_Integer aLabelIter = 0; aLabelIter < 6; ++aLabelIter)
|
||||
{
|
||||
myBoxSideLabels.Find (!myIsYup ? THE_YUP_ORI_LIST[aLabelIter] : THE_ZUP_ORI_LIST[aLabelIter],
|
||||
aLabels.ChangeValue (aLabelIter));
|
||||
}
|
||||
for (Standard_Integer aLabelIter = 0; aLabelIter < 6; ++aLabelIter)
|
||||
{
|
||||
myBoxSideLabels.Bind (myIsYup ? THE_YUP_ORI_LIST[aLabelIter] : THE_ZUP_ORI_LIST[aLabelIter],
|
||||
aLabels.Value (aLabelIter));
|
||||
}
|
||||
}
|
||||
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ResetStyles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::ResetStyles()
|
||||
{
|
||||
UnsetAttributes();
|
||||
UnsetHilightAttributes();
|
||||
|
||||
myBoxEdgeMinSize = 2.0;
|
||||
myCornerMinSize = 2.0;
|
||||
myBoxEdgeGap = 0.0;
|
||||
myRoundRadius = 0.0;
|
||||
|
||||
myToDisplayAxes = true;
|
||||
myToDisplayEdges = true;
|
||||
myToDisplayVertices = true;
|
||||
|
||||
myBoxFacetExtension = 1.0;
|
||||
myAxesPadding = 1.0;
|
||||
SetSize (70.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetSize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::SetSize (Standard_Real theValue,
|
||||
Standard_Boolean theToAdaptAnother)
|
||||
{
|
||||
const bool isNewSize = Abs (mySize - theValue) > Precision::Confusion();
|
||||
mySize = theValue;
|
||||
if (theToAdaptAnother)
|
||||
{
|
||||
if (myBoxFacetExtension > 0.0)
|
||||
{
|
||||
SetBoxFacetExtension (mySize * 0.15);
|
||||
}
|
||||
if (myAxesPadding > 0.0)
|
||||
{
|
||||
SetAxesPadding (mySize * 0.1);
|
||||
}
|
||||
SetFontHeight (mySize * 0.16);
|
||||
}
|
||||
if (isNewSize)
|
||||
{
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetRoundRadius
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::SetRoundRadius (const Standard_Real theValue)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if (theValue < 0.0 || theValue > 0.5,
|
||||
"AIS_ViewCube::SetRoundRadius(): theValue should be in [0; 0.5]");
|
||||
if (Abs (myRoundRadius - theValue) > Precision::Confusion())
|
||||
{
|
||||
myRoundRadius = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : createRoundRectangleTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createRoundRectangleTriangles (const gp_XY& theSize,
|
||||
Standard_Real theRadius,
|
||||
const gp_Trsf& theTrsf)
|
||||
{
|
||||
const Standard_Real aRadius = Min (theRadius, Min (theSize.X(), theSize.Y()) * 0.5);
|
||||
const gp_XY aHSize (theSize.X() * 0.5 - aRadius, theSize.Y() * 0.5 - aRadius);
|
||||
const gp_Dir aNorm = gp::DZ().Transformed (theTrsf);
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTris;
|
||||
if (aRadius > 0.0)
|
||||
{
|
||||
const Standard_Integer aNbNodes = (THE_NB_ROUND_SPLITS + 1) * 4 + 1;
|
||||
aTris = new Graphic3d_ArrayOfTriangles (aNbNodes, aNbNodes * 3, Graphic3d_ArrayFlags_VertexNormal);
|
||||
|
||||
aTris->AddVertex (gp_Pnt (0.0, 0.0, 0.0).Transformed (theTrsf));
|
||||
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
|
||||
{
|
||||
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (M_PI * 0.5, 0.0, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
|
||||
aTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
|
||||
}
|
||||
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
|
||||
{
|
||||
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (0.0, -M_PI * 0.5, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
|
||||
aTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
|
||||
}
|
||||
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
|
||||
{
|
||||
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (-M_PI * 0.5, -M_PI, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
|
||||
aTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
|
||||
}
|
||||
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
|
||||
{
|
||||
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (-M_PI, -M_PI * 1.5, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
|
||||
aTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
|
||||
}
|
||||
|
||||
// split triangle fan
|
||||
for (Standard_Integer aNodeIter = 2; aNodeIter <= aTris->VertexNumber(); ++aNodeIter)
|
||||
{
|
||||
aTris->AddEdge (1);
|
||||
aTris->AddEdge (aNodeIter - 1);
|
||||
aTris->AddEdge (aNodeIter);
|
||||
}
|
||||
aTris->AddEdge (1);
|
||||
aTris->AddEdge (aTris->VertexNumber());
|
||||
aTris->AddEdge (2);
|
||||
}
|
||||
else
|
||||
{
|
||||
aTris = new Graphic3d_ArrayOfTriangles (4, 6, Graphic3d_ArrayFlags_VertexNormal);
|
||||
aTris->AddVertex (gp_Pnt (-aHSize.X(), -aHSize.Y(), 0.0).Transformed (theTrsf));
|
||||
aTris->AddVertex (gp_Pnt (-aHSize.X(), aHSize.Y(), 0.0).Transformed (theTrsf));
|
||||
aTris->AddVertex (gp_Pnt ( aHSize.X(), aHSize.Y(), 0.0).Transformed (theTrsf));
|
||||
aTris->AddVertex (gp_Pnt ( aHSize.X(), -aHSize.Y(), 0.0).Transformed (theTrsf));
|
||||
aTris->AddEdges (3, 1, 2);
|
||||
aTris->AddEdges (1, 3, 4);
|
||||
}
|
||||
|
||||
for (Standard_Integer aVertIter = 1; aVertIter <= aTris->VertexNumber(); ++aVertIter)
|
||||
{
|
||||
aTris->SetVertexNormal (aVertIter, -aNorm);
|
||||
}
|
||||
return aTris;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : createBoxPartTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxPartTriangles (V3d_TypeOfOrientation theDir) const
|
||||
{
|
||||
if (IsBoxSide (theDir))
|
||||
{
|
||||
return createBoxSideTriangles (theDir);
|
||||
}
|
||||
else if (IsBoxEdge (theDir)
|
||||
&& myToDisplayEdges)
|
||||
{
|
||||
return createBoxEdgeTriangles (theDir);
|
||||
}
|
||||
else if (IsBoxCorner (theDir)
|
||||
&& myToDisplayVertices)
|
||||
{
|
||||
return createBoxCornerTriangles (theDir);
|
||||
}
|
||||
return Handle(Graphic3d_ArrayOfTriangles)();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : createBoxSideTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxSideTriangles (V3d_TypeOfOrientation theDirection) const
|
||||
{
|
||||
const gp_Dir aDir = V3d::GetProjAxis (theDirection);
|
||||
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 + myBoxFacetExtension);
|
||||
const gp_Ax2 aPosition (aPos, aDir.Reversed());
|
||||
|
||||
gp_Ax3 aSystem (aPosition);
|
||||
gp_Trsf aTrsf;
|
||||
aTrsf.SetTransformation (aSystem, gp_Ax3());
|
||||
|
||||
return createRoundRectangleTriangles (gp_XY (mySize, mySize), myRoundRadius * mySize, aTrsf);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : createBoxEdgeTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxEdgeTriangles (V3d_TypeOfOrientation theDirection) const
|
||||
{
|
||||
const Standard_Real aThickness = Max (myBoxFacetExtension * gp_XY (1.0, 1.0).Modulus() - myBoxEdgeGap, myBoxEdgeMinSize);
|
||||
|
||||
const gp_Dir aDir = V3d::GetProjAxis (theDirection);
|
||||
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 * gp_XY (1.0, 1.0).Modulus() + myBoxFacetExtension * Cos (M_PI_4));
|
||||
const gp_Ax2 aPosition (aPos, aDir.Reversed());
|
||||
|
||||
gp_Ax3 aSystem (aPosition);
|
||||
gp_Trsf aTrsf;
|
||||
aTrsf.SetTransformation (aSystem, gp_Ax3());
|
||||
|
||||
return createRoundRectangleTriangles (gp_XY (aThickness, mySize), myRoundRadius * mySize, aTrsf);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : createBoxCornerTriangles
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Graphic3d_ArrayOfTriangles) AIS_ViewCube::createBoxCornerTriangles (V3d_TypeOfOrientation theDir) const
|
||||
{
|
||||
const Standard_Real aHSize = mySize * 0.5;
|
||||
const gp_Dir aDir = V3d::GetProjAxis (theDir);
|
||||
const gp_XYZ aHSizeDir = aDir.XYZ() * (aHSize * gp_Vec (1.0, 1.0, 1.0).Magnitude());
|
||||
if (myRoundRadius > 0.0)
|
||||
{
|
||||
const Standard_Real anEdgeHWidth = myBoxFacetExtension * gp_XY (1.0, 1.0).Modulus() * 0.5;
|
||||
const Standard_Real aHeight = anEdgeHWidth * Sqrt (2.0 / 3.0); // tetrahedron height
|
||||
const gp_Pnt aPos = aDir.XYZ() * (aHSize * gp_Vec (1.0, 1.0, 1.0).Magnitude() + aHeight);
|
||||
const gp_Ax2 aPosition (aPos, aDir.Reversed());
|
||||
gp_Ax3 aSystem (aPosition);
|
||||
gp_Trsf aTrsf;
|
||||
aTrsf.SetTransformation (aSystem, gp_Ax3());
|
||||
const Standard_Real aRadius = Max (myBoxFacetExtension * 0.5 / Cos (M_PI_4), myCornerMinSize);
|
||||
return Prs3d_ToolDisk::Create (0.0, aRadius, THE_NB_DISK_SLICES, 1, aTrsf);
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (3, 3, Graphic3d_ArrayFlags_VertexNormal);
|
||||
|
||||
aTris->AddVertex (aHSizeDir + myBoxFacetExtension * gp_Dir (aDir.X(), 0.0, 0.0).XYZ());
|
||||
aTris->AddVertex (aHSizeDir + myBoxFacetExtension * gp_Dir (0.0, aDir.Y(), 0.0).XYZ());
|
||||
aTris->AddVertex (aHSizeDir + myBoxFacetExtension * gp_Dir (0.0, 0.0, aDir.Z()).XYZ());
|
||||
|
||||
const gp_XYZ aNode1 = aTris->Vertice (1).XYZ();
|
||||
const gp_XYZ aNode2 = aTris->Vertice (2).XYZ();
|
||||
const gp_XYZ aNode3 = aTris->Vertice (3).XYZ();
|
||||
const gp_XYZ aNormTri = ((aNode2 - aNode1).Crossed (aNode3 - aNode1));
|
||||
if (aNormTri.Dot (aDir.XYZ()) < 0.0)
|
||||
{
|
||||
aTris->AddEdges (1, 3, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
aTris->AddEdges (1, 2, 3);
|
||||
}
|
||||
|
||||
for (Standard_Integer aVertIter = 1; aVertIter <= aTris->VertexNumber(); ++aVertIter)
|
||||
{
|
||||
aTris->SetVertexNormal (aVertIter, aDir);
|
||||
}
|
||||
return aTris;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
thePrs->SetInfiniteState (true);
|
||||
if (theMode != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const gp_Pnt aLocation = (mySize * 0.5 + myBoxFacetExtension + myAxesPadding) * gp_XYZ (-1.0, -1.0, -1.0);
|
||||
|
||||
// Display axes
|
||||
if (myToDisplayAxes)
|
||||
{
|
||||
const Standard_Real anAxisSize = mySize + 2.0 * myBoxFacetExtension + myAxesPadding;
|
||||
const Handle(Prs3d_DatumAspect)& aDatumAspect = myDrawer->DatumAspect();
|
||||
for (Standard_Integer anAxisIter = Prs3d_DP_XAxis; anAxisIter <= Prs3d_DP_ZAxis; ++anAxisIter)
|
||||
{
|
||||
const Prs3d_DatumParts aPart = (Prs3d_DatumParts )anAxisIter;
|
||||
if (!aDatumAspect->DrawDatumPart (aPart))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
gp_Ax1 anAx1;
|
||||
switch (aPart)
|
||||
{
|
||||
case Prs3d_DP_XAxis: anAx1 = gp_Ax1 (aLocation, gp::DX()); break;
|
||||
case Prs3d_DP_YAxis: anAx1 = gp_Ax1 (aLocation, gp::DY()); break;
|
||||
case Prs3d_DP_ZAxis: anAx1 = gp_Ax1 (aLocation, gp::DZ()); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Group) anAxisGroup = thePrs->NewGroup();
|
||||
anAxisGroup->SetGroupPrimitivesAspect (aDatumAspect->ShadingAspect (aPart)->Aspect());
|
||||
|
||||
const Standard_Real anArrowLength = 0.2 * anAxisSize;
|
||||
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray = Prs3d_Arrow::DrawShaded (anAx1, 1.0, anAxisSize, 3.0, anArrowLength, THE_NB_ARROW_FACETTES);
|
||||
anAxisGroup->AddPrimitiveArray (aTriangleArray);
|
||||
|
||||
TCollection_AsciiString anAxisLabel;
|
||||
if (aDatumAspect->ToDrawLabels()
|
||||
&& myAxesLabels.Find (aPart, anAxisLabel)
|
||||
&& !anAxisLabel.IsEmpty())
|
||||
{
|
||||
Handle(Graphic3d_Group) anAxisLabelGroup = thePrs->NewGroup();
|
||||
gp_Pnt aTextOrigin = anAx1.Location().Translated (gp_Vec (anAx1.Direction().X() * (anAxisSize + anArrowLength),
|
||||
anAx1.Direction().Y() * (anAxisSize + anArrowLength),
|
||||
anAx1.Direction().Z() * (anAxisSize + anArrowLength)));
|
||||
Prs3d_Text::Draw (anAxisLabelGroup, aDatumAspect->TextAspect(), TCollection_ExtendedString (anAxisLabel), aTextOrigin);
|
||||
}
|
||||
}
|
||||
|
||||
// Display center
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
|
||||
Handle(Prs3d_ShadingAspect) anAspectCen = new Prs3d_ShadingAspect();
|
||||
anAspectCen->SetColor (Quantity_NOC_WHITE);
|
||||
aGroup->SetGroupPrimitivesAspect (anAspectCen->Aspect());
|
||||
Prs3d_ToolSphere aTool (4.0, THE_NB_DISK_SLICES, THE_NB_DISK_SLICES);
|
||||
gp_Trsf aTrsf;
|
||||
aTrsf.SetTranslation (gp_Vec (gp::Origin(), aLocation));
|
||||
Handle(Graphic3d_ArrayOfTriangles) aCenterArray;
|
||||
aTool.FillArray (aCenterArray, aTrsf);
|
||||
aGroup->AddPrimitiveArray (aCenterArray);
|
||||
}
|
||||
}
|
||||
|
||||
// Display box
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroupSides = thePrs->NewGroup(), aGroupEdges = thePrs->NewGroup(), aGroupCorners = thePrs->NewGroup();
|
||||
aGroupSides->SetClosed (true); // should be replaced by forced back-face culling aspect
|
||||
aGroupSides->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
|
||||
|
||||
aGroupEdges->SetClosed (true);
|
||||
aGroupEdges->SetGroupPrimitivesAspect (myBoxEdgeAspect->Aspect());
|
||||
|
||||
aGroupCorners->SetClosed (true);
|
||||
aGroupCorners->SetGroupPrimitivesAspect (myBoxCornerAspect->Aspect());
|
||||
|
||||
Handle(Graphic3d_Group) aTextGroup = thePrs->NewGroup();
|
||||
//aTextGroup->SetClosed (true);
|
||||
aTextGroup->SetGroupPrimitivesAspect (myDrawer->TextAspect()->Aspect());
|
||||
for (Standard_Integer aPartIter = 0; aPartIter <= Standard_Integer(V3d_XnegYnegZneg); ++aPartIter)
|
||||
{
|
||||
const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation )aPartIter;
|
||||
if (Handle(Graphic3d_ArrayOfTriangles) aTris = createBoxPartTriangles (anOrient))
|
||||
{
|
||||
if (IsBoxSide (anOrient))
|
||||
{
|
||||
aGroupSides->AddPrimitiveArray (aTris);
|
||||
|
||||
TCollection_AsciiString aLabel;
|
||||
if (!myBoxSideLabels.Find (anOrient, aLabel)
|
||||
|| aLabel.IsEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const gp_Dir aDir = V3d::GetProjAxis (anOrient);
|
||||
gp_Dir anUp = myIsYup ? gp::DY() : gp::DZ();
|
||||
if (myIsYup)
|
||||
{
|
||||
if (anOrient == V3d_Ypos
|
||||
|| anOrient == V3d_Yneg)
|
||||
{
|
||||
anUp = -gp::DZ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (anOrient == V3d_Zpos)
|
||||
{
|
||||
anUp = gp::DY();
|
||||
}
|
||||
else if (anOrient == V3d_Zneg)
|
||||
{
|
||||
anUp = -gp::DY();
|
||||
}
|
||||
}
|
||||
|
||||
const Standard_Real anOffset = 2.0; // extra offset to avoid overlapping with triangulation
|
||||
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 + myBoxFacetExtension + anOffset);
|
||||
const gp_Ax2 aPosition (aPos, aDir, anUp.Crossed (aDir));
|
||||
Prs3d_Text::Draw (aTextGroup, myDrawer->TextAspect(), aLabel, aPosition);
|
||||
}
|
||||
else if (IsBoxEdge (anOrient))
|
||||
{
|
||||
aGroupEdges->AddPrimitiveArray (aTris);
|
||||
}
|
||||
else if (IsBoxCorner (anOrient))
|
||||
{
|
||||
aGroupCorners->AddPrimitiveArray (aTris);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode)
|
||||
{
|
||||
if (theMode != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Standard_Integer aPartIter = 0; aPartIter <= Standard_Integer(V3d_XnegYnegZneg); ++aPartIter)
|
||||
{
|
||||
const V3d_TypeOfOrientation anOri = (V3d_TypeOfOrientation )aPartIter;
|
||||
if (Handle(Graphic3d_ArrayOfTriangles) aTris = createBoxPartTriangles (anOri))
|
||||
{
|
||||
Standard_Integer aSensitivity = 2;
|
||||
if (IsBoxCorner (anOri))
|
||||
{
|
||||
aSensitivity = 8;
|
||||
}
|
||||
else if (IsBoxEdge (anOri))
|
||||
{
|
||||
aSensitivity = 4;
|
||||
}
|
||||
Handle(AIS_ViewCubeOwner) anOwner = new AIS_ViewCubeOwner (this, anOri);
|
||||
Handle(AIS_ViewCubeSensitive) aTriSens = new AIS_ViewCubeSensitive (anOwner, aTris);
|
||||
aTriSens->SetSensitivityFactor (aSensitivity);
|
||||
theSelection->Add (aTriSens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasAnimation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_ViewCube::HasAnimation() const
|
||||
{
|
||||
return !myViewAnimation->IsStopped();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : StartAnimation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner)
|
||||
{
|
||||
Handle(V3d_View) aView = GetContext()->LastActiveView();
|
||||
if (theOwner.IsNull()
|
||||
|| aView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myStartState->Copy (aView->Camera());
|
||||
myEndState ->Copy (aView->Camera());
|
||||
|
||||
{
|
||||
Handle(Graphic3d_Camera) aBackupCamera = new Graphic3d_Camera (aView->Camera());
|
||||
|
||||
const bool wasImmediateUpdate = aView->SetImmediateUpdate (false);
|
||||
aView->SetCamera (myEndState);
|
||||
aView->SetProj (theOwner->MainOrientation(), myIsYup);
|
||||
|
||||
const gp_Dir aNewDir = aView->Camera()->Direction();
|
||||
if (!myToResetCameraUp
|
||||
&& !aNewDir.IsEqual (aBackupCamera->Direction(), Precision::Angular()))
|
||||
{
|
||||
// find the Up direction closest to current instead of default one
|
||||
const gp_Ax1 aNewDirAx1 (gp::Origin(), aNewDir);
|
||||
const gp_Dir anOldUp = aBackupCamera->Up();
|
||||
const gp_Dir anUpList[4] =
|
||||
{
|
||||
aView->Camera()->Up(),
|
||||
aView->Camera()->Up().Rotated (aNewDirAx1, M_PI_2),
|
||||
aView->Camera()->Up().Rotated (aNewDirAx1, M_PI),
|
||||
aView->Camera()->Up().Rotated (aNewDirAx1, M_PI * 1.5),
|
||||
};
|
||||
|
||||
Standard_Real aBestAngle = Precision::Infinite();
|
||||
gp_Dir anUpBest;
|
||||
for (Standard_Integer anUpIter = 0; anUpIter < 4; ++anUpIter)
|
||||
{
|
||||
Standard_Real anAngle = anUpList[anUpIter].Angle (anOldUp);
|
||||
if (aBestAngle > anAngle)
|
||||
{
|
||||
aBestAngle = anAngle;
|
||||
anUpBest = anUpList[anUpIter];
|
||||
}
|
||||
}
|
||||
aView->Camera()->SetUp (anUpBest);
|
||||
}
|
||||
|
||||
const Bnd_Box aBndSelected = myToFitSelected ? GetContext()->BoundingBoxOfSelection() : Bnd_Box();
|
||||
if (!aBndSelected.IsVoid())
|
||||
{
|
||||
aView->FitAll (aBndSelected, 0.01, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
aView->FitAll (0.01, false);
|
||||
}
|
||||
aView->SetCamera (aBackupCamera);
|
||||
aView->SetImmediateUpdate (wasImmediateUpdate);
|
||||
}
|
||||
|
||||
myViewAnimation->SetView (aView);
|
||||
myViewAnimation->SetCameraStart (myStartState);
|
||||
myViewAnimation->SetCameraEnd (myEndState);
|
||||
myViewAnimation->SetOwnDuration (myDuration);
|
||||
myViewAnimation->StartTimer (0.0, 1.0, true, false);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : updateAnimation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_ViewCube::updateAnimation()
|
||||
{
|
||||
const Standard_Real aPts = myViewAnimation->UpdateTimer();
|
||||
if (aPts >= myDuration)
|
||||
{
|
||||
myViewAnimation->Stop();
|
||||
onAnimationFinished();
|
||||
myViewAnimation->SetView (Handle(V3d_View)());
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateAnimation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS_ViewCube::UpdateAnimation (const Standard_Boolean theToUpdate)
|
||||
{
|
||||
Handle(V3d_View) aView = myViewAnimation->View();
|
||||
if (!HasAnimation()
|
||||
|| !updateAnimation())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (theToUpdate
|
||||
&& !aView.IsNull())
|
||||
{
|
||||
aView->IsInvalidated() ? aView->Redraw() : aView->RedrawImmediate();
|
||||
}
|
||||
|
||||
onAfterAnimation();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HandleClick
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner)
|
||||
{
|
||||
if (!myToAutoStartAnim)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StartAnimation (theOwner);
|
||||
if (!myIsFixedAnimation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (; HasAnimation(); )
|
||||
{
|
||||
UpdateAnimation (true);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightOwnerWithColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner)
|
||||
{
|
||||
if (theOwner.IsNull()
|
||||
|| !thePrsMgr->IsImmediateModeOn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Graphic3d_ZLayerId aLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer();
|
||||
const AIS_ViewCubeOwner* aCubeOwner = dynamic_cast<AIS_ViewCubeOwner* >(theOwner.get());
|
||||
|
||||
Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation (thePrsMgr);
|
||||
aHiPrs->Clear();
|
||||
aHiPrs->CStructure()->ViewAffinity = thePrsMgr->StructureManager()->ObjectAffinity (Handle(Standard_Transient)(this));
|
||||
aHiPrs->SetTransformPersistence (TransformPersistence());
|
||||
aHiPrs->SetZLayer (aLayer);
|
||||
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = aHiPrs->NewGroup();
|
||||
aGroup->SetGroupPrimitivesAspect (theStyle->ShadingAspect()->Aspect());
|
||||
if (Handle(Graphic3d_ArrayOfTriangles) aTris = createBoxPartTriangles (aCubeOwner->MainOrientation()))
|
||||
{
|
||||
aGroup->AddPrimitiveArray (aTris);
|
||||
}
|
||||
}
|
||||
|
||||
if (thePrsMgr->IsImmediateModeOn())
|
||||
{
|
||||
thePrsMgr->AddToImmediateList (aHiPrs);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HilightSelected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_ViewCube::HilightSelected (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
const SelectMgr_SequenceOfOwner& theSeq)
|
||||
{
|
||||
// this method should never be called since AIS_InteractiveObject::HandleClick() has been overridden
|
||||
if (theSeq.Size() == 1)
|
||||
{
|
||||
//HandleClick (Handle(AIS_ViewCubeOwner)::DownCast (theSeq.First()));
|
||||
}
|
||||
}
|
645
src/AIS/AIS_ViewCube.hxx
Normal file
645
src/AIS/AIS_ViewCube.hxx
Normal file
@@ -0,0 +1,645 @@
|
||||
// Created on: 2017-07-25
|
||||
// Created by: Anastasia BOBYLEVA
|
||||
// Copyright (c) 2017-2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _AIS_ViewCube_HeaderFile
|
||||
#define _AIS_ViewCube_HeaderFile
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_Vec2.hxx>
|
||||
#include <Prs3d_DatumParts.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <V3d_TypeOfOrientation.hxx>
|
||||
|
||||
class AIS_AnimationCamera;
|
||||
class AIS_ViewCubeOwner;
|
||||
class Graphic3d_ArrayOfTriangles;
|
||||
|
||||
//! Interactive object for displaying the view manipulation cube.
|
||||
//!
|
||||
//! View cube consists of several parts that are responsible for different camera manipulations:
|
||||
//! @li Cube sides represent main views: top, bottom, left, right, front and back.
|
||||
//! @li Edges represent rotation of one of main views on 45 degrees.
|
||||
//! @li Vertices represent rotation of one of man views in two directions.
|
||||
//!
|
||||
//! The object is expected to behave like a trihedron in the view corner,
|
||||
//! therefore its position should be defined using transformation persistence flags:
|
||||
//! @code SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100)); @endcode
|
||||
//!
|
||||
//! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection),
|
||||
//! and every its owner AIS_ViewCubeOwner corresponds to camera transformation.
|
||||
//! @code
|
||||
//! for (aViewCube->StartAnimation (aDetectedOwner); aViewCube->HasAnimation(); )
|
||||
//! {
|
||||
//! aViewCube->UpdateAnimation();
|
||||
//! ... // updating of application window
|
||||
//! }
|
||||
//! @endcode
|
||||
//! or
|
||||
//! @code aViewCube->HandleClick (aDetectedOwner); @endcode
|
||||
//! that includes transformation loop.
|
||||
//! This loop allows external actions like application updating. For this purpose AIS_ViewCube has virtual interface onAfterAnimation(),
|
||||
//! that is to be redefined on application level.
|
||||
class AIS_ViewCube : public AIS_InteractiveObject
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
|
||||
public:
|
||||
|
||||
//! Return TRUE if specified orientation belongs to box side.
|
||||
Standard_EXPORT static bool IsBoxSide (V3d_TypeOfOrientation theOrient);
|
||||
|
||||
//! Return TRUE if specified orientation belongs to box edge.
|
||||
Standard_EXPORT static bool IsBoxEdge (V3d_TypeOfOrientation theOrient);
|
||||
|
||||
//! Return TRUE if specified orientation belongs to box corner (vertex).
|
||||
Standard_EXPORT static bool IsBoxCorner (V3d_TypeOfOrientation theOrient);
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT AIS_ViewCube();
|
||||
|
||||
//! Return view animation.
|
||||
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
|
||||
|
||||
//! Set view animation.
|
||||
void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
|
||||
|
||||
//! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by default.
|
||||
Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
|
||||
|
||||
//! Enable/disable automatic camera transformation on selection (highlighting).
|
||||
//! The automatic logic can be disabled if application wants performing action manually
|
||||
//! basing on picking results (AIS_ViewCubeOwner).
|
||||
void SetAutoStartAnimation (bool theToEnable) { myToAutoStartAnim = theToEnable; }
|
||||
|
||||
//! Return TRUE if camera animation should be done in uninterruptible loop; TRUE by default.
|
||||
Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
|
||||
|
||||
//! Set if camera animation should be done in uninterruptible loop.
|
||||
void SetFixedAnimationLoop (bool theToEnable) { myIsFixedAnimation = theToEnable; }
|
||||
|
||||
//! Reset all size and style parameters to default.
|
||||
//! @warning It doesn't reset position of View Cube
|
||||
Standard_EXPORT void ResetStyles();
|
||||
|
||||
protected:
|
||||
|
||||
//! Set default visual attributes
|
||||
Standard_EXPORT void setDefaultAttributes();
|
||||
|
||||
//! Set default dynamic highlight properties
|
||||
Standard_EXPORT void setDefaultHighlightAttributes();
|
||||
|
||||
public: //! @name Geometry management API
|
||||
|
||||
//! @return size (width and height) of View cube sides; 100 by default.
|
||||
Standard_Real Size() const { return mySize; }
|
||||
|
||||
//! Sets size (width and height) of View cube sides.
|
||||
//! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size
|
||||
Standard_EXPORT void SetSize (Standard_Real theValue,
|
||||
Standard_Boolean theToAdaptAnother = true);
|
||||
|
||||
//! Return box facet extension to edge/corner facet split; 10 by default.
|
||||
Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
|
||||
|
||||
//! Set new value of box facet extension.
|
||||
void SetBoxFacetExtension (Standard_Real theValue)
|
||||
{
|
||||
if (Abs (myBoxFacetExtension - theValue) > Precision::Confusion())
|
||||
{
|
||||
myBoxFacetExtension = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return padding between axes and 3D part (box); 10 by default.
|
||||
Standard_Real AxesPadding() const { return myAxesPadding; }
|
||||
|
||||
//! Set new value of padding between axes and 3D part (box).
|
||||
void SetAxesPadding (Standard_Real theValue)
|
||||
{
|
||||
if (Abs (myAxesPadding - theValue) > Precision::Confusion())
|
||||
{
|
||||
myAxesPadding = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return gap between box edges and box sides; 0 by default.
|
||||
Standard_Real BoxEdgeGap() const { return myBoxEdgeGap; }
|
||||
|
||||
//! Set new value of box edges gap.
|
||||
void SetBoxEdgeGap (Standard_Real theValue)
|
||||
{
|
||||
if (Abs (myBoxEdgeGap - theValue) > Precision::Confusion())
|
||||
{
|
||||
myBoxEdgeGap = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return minimal size of box edge; 2 by default.
|
||||
Standard_Real BoxEdgeMinSize() const { return myBoxEdgeMinSize; }
|
||||
|
||||
//! Set new value of box edge minimal size.
|
||||
void SetBoxEdgeMinSize (Standard_Real theValue)
|
||||
{
|
||||
if (Abs (myBoxEdgeMinSize - theValue) > Precision::Confusion())
|
||||
{
|
||||
myBoxEdgeMinSize = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return minimal size of box corner; 2 by default.
|
||||
Standard_Real BoxCornerMinSize() const { return myCornerMinSize; }
|
||||
|
||||
//! Set new value of box corner minimal size.
|
||||
void SetBoxCornerMinSize (Standard_Real theValue)
|
||||
{
|
||||
if (Abs (myCornerMinSize - theValue) > Precision::Confusion())
|
||||
{
|
||||
myCornerMinSize = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return relative radius of side corners (round rectangle); 0.0 by default.
|
||||
//! The value in within [0, 0.5] range meaning absolute radius = RoundRadius() / Size().
|
||||
Standard_Real RoundRadius() const { return myRoundRadius; }
|
||||
|
||||
//! Set relative radius of View Cube sides corners (round rectangle).
|
||||
//! The value should be within [0, 0.5] range.
|
||||
Standard_EXPORT void SetRoundRadius (const Standard_Real theValue);
|
||||
|
||||
//! @return TRUE if trihedron is drawn; TRUE by default.
|
||||
Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
|
||||
|
||||
//! Enable/disable drawing of trihedron.
|
||||
void SetDrawAxes (Standard_Boolean theValue)
|
||||
{
|
||||
if (myToDisplayAxes != theValue)
|
||||
{
|
||||
myToDisplayAxes = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! @return TRUE if edges of View Cube is drawn; TRUE by default.
|
||||
Standard_Boolean ToDrawEdges() const { return myToDisplayEdges; }
|
||||
|
||||
//! Enable/disable drawing of edges of View Cube.
|
||||
void SetDrawEdges (Standard_Boolean theValue)
|
||||
{
|
||||
if (myToDisplayEdges != theValue)
|
||||
{
|
||||
myToDisplayEdges = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return TRUE if vertices (vertex) of View Cube is drawn; TRUE by default.
|
||||
Standard_Boolean ToDrawVertices() const { return myToDisplayVertices; }
|
||||
|
||||
//! Enable/disable drawing of vertices (corners) of View Cube.
|
||||
void SetDrawVertices (Standard_Boolean theValue)
|
||||
{
|
||||
if (myToDisplayVertices != theValue)
|
||||
{
|
||||
myToDisplayVertices = theValue;
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return TRUE if application expects Y-up viewer orientation instead of Z-up; FALSE by default.
|
||||
Standard_Boolean IsYup() const { return myIsYup; }
|
||||
|
||||
//! Set if application expects Y-up viewer orientation instead of Z-up.
|
||||
Standard_EXPORT void SetYup (Standard_Boolean theIsYup,
|
||||
Standard_Boolean theToUpdateLabels = Standard_True);
|
||||
|
||||
public: //! @name Style management API
|
||||
|
||||
//! Return shading style of box sides.
|
||||
const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
|
||||
|
||||
//! Return shading style of box edges.
|
||||
const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
|
||||
|
||||
//! Return shading style of box corners.
|
||||
const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
|
||||
|
||||
//! Return value of front color for the 3D part of object.
|
||||
const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
|
||||
|
||||
//! Set new value of front color for the 3D part of object.
|
||||
//! @param theColor [in] input color value.
|
||||
void SetBoxColor (const Quantity_Color& theColor)
|
||||
{
|
||||
if (!myDrawer->ShadingAspect()->Color().IsEqual (theColor)
|
||||
|| !myBoxEdgeAspect ->Color().IsEqual (theColor)
|
||||
|| !myBoxCornerAspect->Color().IsEqual (theColor))
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetColor (theColor);
|
||||
myBoxEdgeAspect->SetColor (theColor);
|
||||
myBoxCornerAspect->SetColor (theColor);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return transparency for 3D part of object.
|
||||
Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
|
||||
|
||||
//! Set new value of transparency for 3D part of object.
|
||||
//! @param theValue [in] input transparency value
|
||||
void SetBoxTransparency (Standard_Real theValue)
|
||||
{
|
||||
if (Abs (myDrawer->ShadingAspect()->Transparency() - theValue) > Precision::Confusion()
|
||||
|| Abs (myBoxEdgeAspect ->Transparency() - theValue) > Precision::Confusion()
|
||||
|| Abs (myBoxCornerAspect->Transparency() - theValue) > Precision::Confusion())
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetTransparency (theValue);
|
||||
myBoxEdgeAspect->SetTransparency (theValue);
|
||||
myBoxCornerAspect->SetTransparency (theValue);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return color of sides back material.
|
||||
const Quantity_Color& InnerColor() const { return myDrawer->ShadingAspect()->Color (Aspect_TOFM_BACK_SIDE); }
|
||||
|
||||
//! Set color of sides back material. Alias for:
|
||||
//! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
|
||||
void SetInnerColor (const Quantity_Color& theColor)
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetColor (theColor, Aspect_TOFM_BACK_SIDE);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//! Return box side label or empty string if undefined.
|
||||
//! Default labels: FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM.
|
||||
TCollection_AsciiString BoxSideLabel (V3d_TypeOfOrientation theSide) const
|
||||
{
|
||||
const TCollection_AsciiString* aLabel = myBoxSideLabels.Seek (theSide);
|
||||
return aLabel != NULL ? *aLabel : TCollection_AsciiString();
|
||||
}
|
||||
|
||||
//! Set box side label.
|
||||
void SetBoxSideLabel (const V3d_TypeOfOrientation theSide,
|
||||
const TCollection_AsciiString& theLabel)
|
||||
{
|
||||
if (!IsBoxSide (theSide))
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_ViewCube::SetBoxSideLabel(), invalid enumeration value");
|
||||
}
|
||||
myBoxSideLabels.Bind (theSide, theLabel);
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
//! Return text color of labels of box sides; BLACK by default.
|
||||
const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
|
||||
|
||||
//! Set color of text labels on box sides. Alias for:
|
||||
//! @code Attributes()->TextAspect()->SetColor() @endcode
|
||||
void SetTextColor (const Quantity_Color& theColor)
|
||||
{
|
||||
myDrawer->TextAspect()->SetColor (theColor);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//! Return font name that is used for displaying of sides and axes text. Alias for:
|
||||
//! @code Attributes()->TextAspect()->Aspect()->SetFont() @endcode
|
||||
const TCollection_AsciiString& Font() const { return myDrawer->TextAspect()->Aspect()->Font(); }
|
||||
|
||||
//! Set font name that is used for displaying of sides and axes text. Alias for:
|
||||
//! @code Attributes()->TextAspect()->SetFont() @endcode
|
||||
void SetFont (const TCollection_AsciiString& theFont)
|
||||
{
|
||||
myDrawer->TextAspect()->Aspect()->SetFont (theFont);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//! Return height of font
|
||||
Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
|
||||
|
||||
//! Change font height. Alias for:
|
||||
//! @code Attributes()->TextAspect()->SetHeight() @endcode
|
||||
void SetFontHeight (Standard_Real theValue)
|
||||
{
|
||||
if (Abs (myDrawer->TextAspect()->Height() - theValue) > Precision::Confusion())
|
||||
{
|
||||
myDrawer->TextAspect()->SetHeight (theValue);
|
||||
SetToUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//! Return axes labels or empty string if undefined.
|
||||
//! Default labels: X, Y, Z.
|
||||
TCollection_AsciiString AxisLabel (Prs3d_DatumParts theAxis) const
|
||||
{
|
||||
const TCollection_AsciiString* aLabel = myAxesLabels.Seek (theAxis);
|
||||
return aLabel != NULL ? *aLabel : TCollection_AsciiString();
|
||||
}
|
||||
|
||||
//! Set axes labels.
|
||||
void SetAxesLabels (const TCollection_AsciiString& theX,
|
||||
const TCollection_AsciiString& theY,
|
||||
const TCollection_AsciiString& theZ)
|
||||
{
|
||||
myAxesLabels.Bind (Prs3d_DP_XAxis, theX);
|
||||
myAxesLabels.Bind (Prs3d_DP_YAxis, theY);
|
||||
myAxesLabels.Bind (Prs3d_DP_ZAxis, theZ);
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Set new value of color for the whole object.
|
||||
//! @param theColor [in] input color value.
|
||||
virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE
|
||||
{
|
||||
SetBoxColor (theColor);
|
||||
}
|
||||
|
||||
//! Reset color for the whole object.
|
||||
virtual void UnsetColor() Standard_OVERRIDE
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
|
||||
myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
|
||||
myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//! Set new value of transparency for the whole object.
|
||||
//! @param theValue [in] input transparency value.
|
||||
virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE
|
||||
{
|
||||
SetBoxTransparency (theValue);
|
||||
}
|
||||
|
||||
//! Reset transparency for the whole object.
|
||||
virtual void UnsetTransparency() Standard_OVERRIDE
|
||||
{
|
||||
SetBoxTransparency (0.0f);
|
||||
}
|
||||
|
||||
//! Sets the material for the interactive object.
|
||||
virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
|
||||
{
|
||||
myDrawer->ShadingAspect()->SetMaterial (theMat);
|
||||
myBoxEdgeAspect ->SetMaterial (theMat);
|
||||
myBoxCornerAspect->SetMaterial (theMat);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
//! Sets the material for the interactive object.
|
||||
virtual void UnsetMaterial() Standard_OVERRIDE
|
||||
{
|
||||
Graphic3d_MaterialAspect aMat (Graphic3d_NOM_UserDefined);
|
||||
aMat.SetColor (Quantity_NOC_WHITE);
|
||||
aMat.SetAmbientColor (Quantity_NOC_GRAY60);
|
||||
myDrawer->ShadingAspect()->SetMaterial (aMat);
|
||||
myBoxEdgeAspect ->SetMaterial (aMat);
|
||||
myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
|
||||
myBoxCornerAspect->SetMaterial (aMat);
|
||||
myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
||||
public: //! @name animation methods
|
||||
|
||||
//! Return duration of animation in seconds; 0.5 sec by default
|
||||
Standard_Real Duration() const { return myDuration; }
|
||||
|
||||
//! Set duration of animation.
|
||||
//! @param theValue [in] input value of duration in seconds
|
||||
void SetDuration (Standard_Real theValue) { myDuration = theValue; }
|
||||
|
||||
//! Return TRUE if new camera Up direction should be always set to default value for a new camera Direction; FALSE by default.
|
||||
//! When this flag is FALSE, the new camera Up will be set as current Up orthogonalized to the new camera Direction,
|
||||
//! and will set to default Up on second click.
|
||||
Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
|
||||
|
||||
//! Set if new camera Up direction should be always set to default value for a new camera Direction.
|
||||
void SetResetCamera (Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
|
||||
|
||||
//! Return TRUE if animation should fit selected objects and FALSE to fit entire scene; TRUE by default.
|
||||
Standard_Boolean ToFitSelected() const { return myToFitSelected; }
|
||||
|
||||
//! Set if animation should fit selected objects or to fit entire scene.
|
||||
void SetFitSelected (Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
|
||||
|
||||
//! @return TRUE if View Cube has unfinished animation of view camera.
|
||||
Standard_EXPORT Standard_Boolean HasAnimation() const;
|
||||
|
||||
//! Start camera transformation corresponding to the input detected owner.
|
||||
//! @param theOwner [in] detected owner.
|
||||
Standard_EXPORT virtual void StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner);
|
||||
|
||||
//! Perform one step of current camera transformation.
|
||||
//! theToUpdate [in] enable/disable update of view.
|
||||
//! @return TRUE if animation is not stopped.
|
||||
Standard_EXPORT virtual Standard_Boolean UpdateAnimation (const Standard_Boolean theToUpdate);
|
||||
|
||||
//! Perform camera transformation corresponding to the input detected owner.
|
||||
Standard_EXPORT virtual void HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner);
|
||||
|
||||
protected:
|
||||
|
||||
//! Perform internal single step of animation.
|
||||
//! @return FALSE if animation has been finished
|
||||
Standard_EXPORT Standard_Boolean updateAnimation();
|
||||
|
||||
protected: //! @name protected virtual API
|
||||
|
||||
//! Method that is called after one step of transformation.
|
||||
virtual void onAfterAnimation() {}
|
||||
|
||||
//! Method that is called after transformation finish.
|
||||
virtual void onAnimationFinished() {}
|
||||
|
||||
public: //! @name Presentation computation
|
||||
|
||||
//! Return TRUE for supported display mode.
|
||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
|
||||
|
||||
//! Global selection has no meaning for this class.
|
||||
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return Handle(SelectMgr_EntityOwner)(); }
|
||||
|
||||
//! Compute 3D part of View Cube.
|
||||
//! @param thePrsMgr [in] presentation manager.
|
||||
//! @param thePrs [in] input presentation that is to be filled with flat presentation primitives.
|
||||
//! @param theMode [in] display mode.
|
||||
//! @warning this object accept only 0 display mode.
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Standard_Integer theMode = 0) Standard_OVERRIDE;
|
||||
|
||||
//! Redefine computing of sensitive entities for View Cube.
|
||||
//! @param theSelection [in] input selection object that is to be filled with sensitive entities.
|
||||
//! @param theMode [in] selection mode.
|
||||
//! @warning object accepts only 0 selection mode.
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
|
||||
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
|
||||
|
||||
//! Method which clear all selected owners belonging to this selectable object.
|
||||
//! @warning this object does not support selection.
|
||||
virtual void ClearSelected() Standard_OVERRIDE {}
|
||||
|
||||
//! Method which highlights input owner belonging to this selectable object.
|
||||
//! @param thePM [in] presentation manager
|
||||
//! @param theStyle [in] style for dynamic highlighting.
|
||||
//! @param theOwner [in] input entity owner.
|
||||
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
|
||||
|
||||
//! Method which draws selected owners.
|
||||
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
|
||||
|
||||
//! Set default parameters for visual attributes
|
||||
//! @sa Attributes()
|
||||
virtual void UnsetAttributes() Standard_OVERRIDE
|
||||
{
|
||||
setDefaultAttributes();
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
//! Set default parameters for dynamic highlighting attributes, reset highlight attributes
|
||||
virtual void UnsetHilightAttributes() Standard_OVERRIDE
|
||||
{
|
||||
myHilightDrawer.Nullify();
|
||||
setDefaultHighlightAttributes();
|
||||
SetToUpdate();
|
||||
}
|
||||
|
||||
protected: //! @name Auxiliary classes to fill presentation with proper primitives
|
||||
|
||||
//! Create triangulation for a box part - for presentation and selection purposes.
|
||||
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxPartTriangles (V3d_TypeOfOrientation theDir) const;
|
||||
|
||||
//! Create triangulation for a box side.
|
||||
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxSideTriangles (V3d_TypeOfOrientation theDir) const;
|
||||
|
||||
//! Create triangulation for a box edge.
|
||||
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxEdgeTriangles (V3d_TypeOfOrientation theDir) const;
|
||||
|
||||
//! Create triangulation for a box corner (vertex).
|
||||
Standard_EXPORT virtual Handle(Graphic3d_ArrayOfTriangles) createBoxCornerTriangles (V3d_TypeOfOrientation theDir) const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Create triangulation for a rectangle with round corners.
|
||||
//! @param theSize rectangle dimensions
|
||||
//! @param theRadius radius at corners
|
||||
//! @param theTrsf transformation
|
||||
Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) createRoundRectangleTriangles (const gp_XY& theSize,
|
||||
Standard_Real theRadius,
|
||||
const gp_Trsf& theTrsf);
|
||||
|
||||
protected:
|
||||
|
||||
//! Trivial hasher to avoid ambiguity with enumeration type.
|
||||
struct IntegerHasher
|
||||
{
|
||||
static Standard_Integer HashCode (Standard_Integer theValue, Standard_Integer theUpper) { return ::HashCode (theValue, theUpper); }
|
||||
static Standard_Boolean IsEqual (Standard_Integer theA, Standard_Integer theB) { return theA == theB; }
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString, IntegerHasher>
|
||||
myBoxSideLabels; //!< map with box side labels
|
||||
NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString, IntegerHasher>
|
||||
myAxesLabels; //!< map with axes labels
|
||||
Handle(Prs3d_ShadingAspect) myBoxEdgeAspect; //!< style for box edges
|
||||
Handle(Prs3d_ShadingAspect) myBoxCornerAspect; //!< style for box corner
|
||||
|
||||
Standard_Real mySize; //!< size of box side, length of one axis
|
||||
Standard_Real myBoxEdgeMinSize; //!< minimal size of box edge
|
||||
Standard_Real myBoxEdgeGap; //!< gap between box side and box edge
|
||||
Standard_Real myBoxFacetExtension; //!< box facet extension
|
||||
Standard_Real myAxesPadding; //!< Padding between box and axes
|
||||
Standard_Real myCornerMinSize; //!< minimal size of box corner
|
||||
Standard_Real myRoundRadius; //!< relative round radius within [0; 0.5] range
|
||||
Standard_Boolean myToDisplayAxes; //!< trihedron visibility
|
||||
Standard_Boolean myToDisplayEdges; //!< box edges visibility
|
||||
Standard_Boolean myToDisplayVertices; //!< box corners (vertices) visibility
|
||||
Standard_Boolean myIsYup; //!< flag indicating that application expects Y-up viewer orientation instead of Z-up
|
||||
|
||||
protected: //! @name Animation options
|
||||
|
||||
Handle(AIS_AnimationCamera) myViewAnimation; //!< Camera animation object
|
||||
Handle(Graphic3d_Camera) myStartState; //!< Start state of view camera
|
||||
Handle(Graphic3d_Camera) myEndState; //!< End state of view camera
|
||||
Standard_Real myDuration; //!< Duration of animation. By default it is half a second
|
||||
Standard_Boolean myToAutoStartAnim; //!< start animation automatically on click
|
||||
Standard_Boolean myIsFixedAnimation; //!< fixed-loop animation
|
||||
Standard_Boolean myToFitSelected; //!< fit selected or fit entire scene
|
||||
Standard_Boolean myToResetCameraUp; //!< always reset camera up direction to default
|
||||
|
||||
};
|
||||
|
||||
//! Redefined entity owner that is highlighted when owner is detected,
|
||||
//! even if Interactive Context highlighted on last detection procedure.
|
||||
class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
AIS_ViewCubeOwner (const Handle(AIS_ViewCube)& theObject,
|
||||
V3d_TypeOfOrientation theOrient,
|
||||
Standard_Integer thePriority = 5)
|
||||
: SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theObject, thePriority),
|
||||
myMainOrient (theOrient)
|
||||
{
|
||||
myFromDecomposition = true;
|
||||
}
|
||||
|
||||
//! @return TRUE. This owner will always call method
|
||||
//! Hilight for its Selectable Object when the owner is detected.
|
||||
virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE { return Standard_True; }
|
||||
|
||||
//! Return new orientation to set.
|
||||
V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
|
||||
|
||||
//! Handle mouse button click event.
|
||||
virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
|
||||
Aspect_VKeyMouse theButton,
|
||||
Aspect_VKeyFlags theModifiers,
|
||||
bool theIsDoubleClick) Standard_OVERRIDE
|
||||
{
|
||||
(void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
|
||||
AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube* >(mySelectable);
|
||||
aCubePrs->HandleClick (this);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
V3d_TypeOfOrientation myMainOrient; //!< new orientation to set
|
||||
|
||||
};
|
||||
|
||||
#endif // _AIS_ViewCube_HeaderFile
|
@@ -182,4 +182,6 @@ AIS_TypeOfPlane.hxx
|
||||
AIS_ViewController.cxx
|
||||
AIS_ViewController.hxx
|
||||
AIS_ViewInputBuffer.hxx
|
||||
AIS_ViewCube.cxx
|
||||
AIS_ViewCube.hxx
|
||||
AIS_WalkDelta.hxx
|
||||
|
@@ -48,25 +48,6 @@ Aspect_GenId::Aspect_GenId (const Standard_Integer theLow,
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasFree
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Aspect_GenId::HasFree() const
|
||||
{
|
||||
return myFreeCount > 0
|
||||
|| myFreeIds.Extent() > 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Available
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Aspect_GenId::Available() const
|
||||
{
|
||||
return myFreeCount + myFreeIds.Extent();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Free
|
||||
// purpose :
|
||||
@@ -99,41 +80,37 @@ void Aspect_GenId::Free (const Standard_Integer theId)
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Lower
|
||||
// function : Next
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Aspect_GenId::Lower() const
|
||||
Standard_Integer Aspect_GenId::Next()
|
||||
{
|
||||
return myLowerBound;
|
||||
Standard_Integer aNewId = 0;
|
||||
if (!Next (aNewId))
|
||||
{
|
||||
throw Aspect_IdentDefinitionError("Aspect_GenId::Next(), Error: Available == 0");
|
||||
}
|
||||
return aNewId;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Next
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Aspect_GenId::Next()
|
||||
Standard_Boolean Aspect_GenId::Next (Standard_Integer& theId)
|
||||
{
|
||||
if (!myFreeIds.IsEmpty())
|
||||
{
|
||||
const Standard_Integer anId = myFreeIds.First();
|
||||
theId = myFreeIds.First();
|
||||
myFreeIds.RemoveFirst();
|
||||
return anId;
|
||||
return Standard_True;
|
||||
}
|
||||
else if (myFreeCount < 1)
|
||||
{
|
||||
throw Aspect_IdentDefinitionError("GenId Next Error: Available == 0");
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
--myFreeCount;
|
||||
const Standard_Integer anId = myLowerBound + myLength - myFreeCount - 1;
|
||||
return anId;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Upper
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Aspect_GenId::Upper() const
|
||||
{
|
||||
return myUpperBound;
|
||||
theId = myLowerBound + myLength - myFreeCount - 1;
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -49,47 +49,38 @@ public:
|
||||
Standard_EXPORT void Free (const Standard_Integer theId);
|
||||
|
||||
//! Returns true if there are available identifiers in range.
|
||||
Standard_EXPORT Standard_Boolean HasFree() const;
|
||||
Standard_Boolean HasFree() const
|
||||
{
|
||||
return myFreeCount > 0
|
||||
|| myFreeIds.Extent() > 0;
|
||||
}
|
||||
|
||||
//! Returns the number of available identifiers.
|
||||
Standard_EXPORT Standard_Integer Available() const;
|
||||
Standard_Integer Available() const { return myFreeCount + myFreeIds.Extent(); }
|
||||
|
||||
//! Returns the lower identifier in range.
|
||||
Standard_EXPORT Standard_Integer Lower() const;
|
||||
Standard_Integer Lower() const { return myLowerBound; }
|
||||
|
||||
//! Returns the next available identifier.
|
||||
//! Warning: Raises IdentDefinitionError if all identifiers are busy.
|
||||
Standard_EXPORT Standard_Integer Next();
|
||||
|
||||
//! Generates the next available identifier.
|
||||
//! @param theId [out] generated identifier
|
||||
//! @return FALSE if all identifiers are busy.
|
||||
Standard_EXPORT Standard_Boolean Next (Standard_Integer& theId);
|
||||
|
||||
//! Returns the upper identifier in range.
|
||||
Standard_EXPORT Standard_Integer Upper() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
Standard_Integer Upper() const { return myUpperBound; }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
Standard_Integer myFreeCount;
|
||||
Standard_Integer myLength;
|
||||
Standard_Integer myLowerBound;
|
||||
Standard_Integer myUpperBound;
|
||||
TColStd_ListOfInteger myFreeIds;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Aspect_GenId_HeaderFile
|
||||
|
@@ -16,10 +16,8 @@
|
||||
#include <BRepExtrema_TriangleSet.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BVH_LinearBuilder.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
|
||||
|
||||
@@ -152,9 +150,6 @@ void BRepExtrema_TriangleSet::Clear()
|
||||
BVH_Array4i anEmptyTriangles;
|
||||
myTriangles.swap (anEmptyTriangles);
|
||||
|
||||
BVH_Array2d anEmptyVertUVArray;
|
||||
myVertUVArray.swap (anEmptyVertUVArray);
|
||||
|
||||
BVH_Array3d anEmptyVertexArray;
|
||||
myVertexArray.swap (anEmptyVertexArray);
|
||||
}
|
||||
@@ -179,8 +174,6 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
BRepAdaptor_Surface aFaceAdaptor (theFaces (aFaceIdx), Standard_False);
|
||||
|
||||
const Standard_Integer aVertOffset =
|
||||
static_cast<Standard_Integer> (myVertexArray.size()) - 1;
|
||||
|
||||
@@ -193,11 +186,6 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
|
||||
myVertexArray.push_back (BVH_Vec3d (aVertex.X(),
|
||||
aVertex.Y(),
|
||||
aVertex.Z()));
|
||||
|
||||
const Standard_Real aU = aTriangulation->UVNodes().Value (aVertIdx).X();
|
||||
const Standard_Real aV = aTriangulation->UVNodes().Value (aVertIdx).Y();
|
||||
|
||||
myVertUVArray.push_back (BVH_Vec2d (aU, aV));
|
||||
}
|
||||
|
||||
for (Standard_Integer aTriIdx = 1; aTriIdx <= aTriangulation->NbTriangles(); ++aTriIdx)
|
||||
|
@@ -75,9 +75,6 @@ protected:
|
||||
//! Array of vertex indices.
|
||||
BVH_Array4i myTriangles;
|
||||
|
||||
//! Array of vertex UV params.
|
||||
BVH_Array2d myVertUVArray;
|
||||
|
||||
//! Array of vertex coordinates.
|
||||
BVH_Array3d myVertexArray;
|
||||
|
||||
|
@@ -845,7 +845,6 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
|
||||
// take all isolated Wires
|
||||
for (Ex.Init(start, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next()) {
|
||||
TopoDS_Wire S = TopoDS::Wire(Ex.Current());
|
||||
AddWarning(S," a Wire alone is not an IGESBRep entity : no Transfer");
|
||||
|
||||
BRepToIGES_BRWire BW(*this);
|
||||
BW.SetModel(GetModel());
|
||||
@@ -857,7 +856,6 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
|
||||
// take all isolated Edges
|
||||
for (Ex.Init(start, TopAbs_EDGE, TopAbs_WIRE); Ex.More(); Ex.Next()) {
|
||||
TopoDS_Edge S = TopoDS::Edge(Ex.Current());
|
||||
AddWarning(S," a Edge alone is not an IGESBRep entity : no Transfer");
|
||||
|
||||
BRepToIGES_BRWire BW(*this);
|
||||
BW.SetModel(GetModel());
|
||||
@@ -869,7 +867,6 @@ Handle(IGESData_IGESEntity) BRepToIGESBRep_Entity::TransferCompound (const TopoD
|
||||
// take all isolated Vertices
|
||||
for (Ex.Init(start, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next()) {
|
||||
TopoDS_Vertex S = TopoDS::Vertex(Ex.Current());
|
||||
AddWarning(S," a Vertex alone is not an IGESBRep entity : no Transfer");
|
||||
|
||||
BRepToIGES_BRWire BW(*this);
|
||||
BW.SetModel(GetModel());
|
||||
|
@@ -156,6 +156,13 @@ void BRepTools_ReShape::replace (const TopoDS_Shape& ashape,
|
||||
TopoDS_Shape shape = ashape;
|
||||
TopoDS_Shape newshape = anewshape;
|
||||
if ( shape.IsNull() || shape == newshape ) return;
|
||||
if (Apply (newshape) == shape)
|
||||
{
|
||||
#ifdef OCCT_DEBUG
|
||||
cout << "Warning: BRepTools_ReShape::Replace: recording the shape will lead to a loop" << endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (shape.Orientation() == TopAbs_REVERSED)
|
||||
{
|
||||
@@ -181,7 +188,9 @@ void BRepTools_ReShape::replace (const TopoDS_Shape& ashape,
|
||||
#ifdef OCCT_DEBUG
|
||||
if ( IsRecorded ( shape ) && ((myConsiderLocation && ! Value ( shape ).IsPartner ( newshape )) ||
|
||||
(!myConsiderLocation && ! Value ( shape ).IsSame ( newshape ))))
|
||||
{
|
||||
cout << "Warning: BRepTools_ReShape::Replace: shape already recorded" << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
myShapeToReplacement.Bind(shape, TReplacement(newshape, theKind));
|
||||
|
@@ -44,22 +44,17 @@ D3DHost_GraphicDriver::~D3DHost_GraphicDriver()
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : View
|
||||
// function : CreateView
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Graphic3d_CView) D3DHost_GraphicDriver::CreateView (const Handle(Graphic3d_StructureManager)& theMgr)
|
||||
{
|
||||
Handle(D3DHost_View) aView = new D3DHost_View (theMgr, this, myCaps, &myStateCounter);
|
||||
|
||||
myMapOfView.Add (aView);
|
||||
|
||||
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
const Graphic3d_ZLayerId aLayerID = aLayerIt.Value();
|
||||
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerID);
|
||||
aView->AddZLayer (aLayerID);
|
||||
aView->SetZLayerSettings (aLayerID, aSettings);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
|
||||
aView->InsertLayerAfter (aLayer->LayerId(), aLayer->LayerSettings(), Graphic3d_ZLayerId_UNKNOWN);
|
||||
}
|
||||
|
||||
return aView;
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ Graphic3d_Aspects.cxx
|
||||
Graphic3d_Aspects.hxx
|
||||
Graphic3d_AspectFillArea3d.cxx
|
||||
Graphic3d_AspectFillArea3d.hxx
|
||||
Graphic3d_AspectFillCapping.cxx
|
||||
Graphic3d_AspectFillCapping.hxx
|
||||
Graphic3d_AspectLine3d.cxx
|
||||
Graphic3d_AspectLine3d.hxx
|
||||
Graphic3d_AspectMarker3d.cxx
|
||||
|
@@ -1,110 +0,0 @@
|
||||
// Created on: 2017-04-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2017 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_AspectFillCapping.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_AspectFillCapping
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_AspectFillCapping::Graphic3d_AspectFillCapping()
|
||||
: myFlags (Flags_None),
|
||||
myHatchingState (0)
|
||||
{
|
||||
Graphic3d_MaterialAspect aMaterial;
|
||||
aMaterial.SetColor (Quantity_NOC_BLACK);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
|
||||
aMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
|
||||
SetHatchStyle (Aspect_HS_HORIZONTAL);
|
||||
SetHatchMaterial (aMaterial);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Aspect_HatchStyle theStyle)
|
||||
{
|
||||
myStippleHatch = new Graphic3d_HatchStyle (theStyle);
|
||||
myTextureHatch.Nullify();
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle)
|
||||
{
|
||||
myStippleHatch = theStyle;
|
||||
myTextureHatch.Nullify();
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture)
|
||||
{
|
||||
myStippleHatch.Nullify();
|
||||
myTextureHatch = theTexture;
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial)
|
||||
{
|
||||
myHatchMaterial = theMaterial;
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetToDrawHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetToDrawHatch (const Standard_Boolean theToDraw)
|
||||
{
|
||||
setFlag (theToDraw, Flags_DrawHatching);
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchZoomPeristent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchZoomPeristent (const Standard_Boolean theToSet)
|
||||
{
|
||||
setFlag (theToSet, Flags_HatchZoomPersistent);
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchRotationPeristent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchRotationPeristent (const Standard_Boolean theToSet)
|
||||
{
|
||||
setFlag (theToSet, Flags_HatchRotationPersistent);
|
||||
myHatchingState++;
|
||||
}
|
@@ -1,164 +0,0 @@
|
||||
// Created on: 2017-04-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_AspectFillCapping_HeaderFile
|
||||
#define _Graphic3d_AspectFillCapping_HeaderFile
|
||||
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <Graphic3d_Aspects.hxx>
|
||||
#include <Graphic3d_HatchStyle.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
//! Defines graphical attributes for drawing section planes on solids resulted from clipping (cutting) planes.
|
||||
class Graphic3d_AspectFillCapping : public Graphic3d_Aspects
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Standard_EXPORT Graphic3d_AspectFillCapping();
|
||||
|
||||
public:
|
||||
|
||||
//! Sets material for filling section created by clipping.
|
||||
void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) { myMaterial = theMaterial; }
|
||||
|
||||
//! Returns material for filling section created by clipping.
|
||||
const Graphic3d_MaterialAspect& Material() const { return myMaterial; }
|
||||
|
||||
//! Sets flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectMaterial (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectMaterial); }
|
||||
|
||||
//! Returns flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectMaterial() const { return (myFlags & Flags_UseObjectMaterial) != 0; }
|
||||
|
||||
//! Sets texture for filling section created by clipping.
|
||||
void SetTexture (const Handle(Graphic3d_TextureMap)& theTexture) { myTexture = theTexture; }
|
||||
|
||||
//! Returns texture for filling section created by clipping.
|
||||
const Handle(Graphic3d_TextureMap)& Texture() const { return myTexture; }
|
||||
|
||||
//! Sets flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectTexture (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectTexture); }
|
||||
|
||||
//! Returns flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectTexture() const { return (myFlags & Flags_UseObjectTexture) != 0; }
|
||||
|
||||
//! Sets OpenGL/GLSL shader program.
|
||||
void SetShader (const Handle(Graphic3d_ShaderProgram)& theShader) { myShader = theShader; }
|
||||
|
||||
//! Returns OpenGL/GLSL shader program.
|
||||
const Handle(Graphic3d_ShaderProgram)& Shader() const { return myShader; }
|
||||
|
||||
//! Sets flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectShader (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectShader); }
|
||||
|
||||
//! Returns flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectShader() const { return (myFlags & Flags_UseObjectShader) != 0; }
|
||||
|
||||
public:
|
||||
|
||||
//! Sets style of hatch defined by predefined stipple mask.
|
||||
Standard_EXPORT void SetHatchStyle (const Aspect_HatchStyle theStyle);
|
||||
|
||||
//! Sets style of hatch defined by custom stipple mask.
|
||||
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle);
|
||||
|
||||
//! Sets style of hatch defined by texture map (decal texture with alpha channel should be used).
|
||||
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture);
|
||||
|
||||
//! Sets material style for hatch lines (texture).
|
||||
Standard_EXPORT void SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial);
|
||||
|
||||
//! Returns material style for hatch lines (texture).
|
||||
const Graphic3d_MaterialAspect& HatchMaterial() const { return myHatchMaterial; }
|
||||
|
||||
//! Sets boolean flag indicating whether the hatch layer should be drawn or not.
|
||||
Standard_EXPORT void SetToDrawHatch (const Standard_Boolean theToDraw);
|
||||
|
||||
//! Returns boolean flag indicating whether the hatch layer should be drawn or not.
|
||||
Standard_Boolean ToDrawHatch() const { return (myFlags & Flags_DrawHatching) != 0; }
|
||||
|
||||
//! Sets flag controlling behavior of hatch texture mapping on zooming.
|
||||
//! @param theToSet [in] if passed TRUE the texture will keep constant screen-scale independent of zooming.
|
||||
Standard_EXPORT void SetHatchZoomPeristent (const Standard_Boolean theToSet);
|
||||
|
||||
//! Returns value of flag controlling behavior of hatch texture mapping on zooming.
|
||||
Standard_Boolean IsHatchZoomPersistent() { return (myFlags & Flags_HatchZoomPersistent) != 0; }
|
||||
|
||||
//! Sets flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
|
||||
Standard_EXPORT void SetHatchRotationPeristent (const Standard_Boolean theToSet);
|
||||
|
||||
//! Returns value of flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
|
||||
Standard_Boolean IsHatchRotationPersistent() { return (myFlags & Flags_HatchRotationPersistent) != 0; }
|
||||
|
||||
//! Returns true if hatch is defined by texture.
|
||||
Standard_Boolean IsTextureHatch() const { return !myTextureHatch.IsNull(); }
|
||||
|
||||
//! Returns texture map defining the hatch.
|
||||
const Handle(Graphic3d_TextureMap)& TextureHatch() const { return myTextureHatch; }
|
||||
|
||||
//! Returns true if hatch is defined by stipple mask.
|
||||
Standard_Boolean IsStippleHatch() const { return !myStippleHatch.IsNull(); }
|
||||
|
||||
//! Returns the stipple mask.
|
||||
const Handle(Graphic3d_HatchStyle)& StippleHatch() const { return myStippleHatch; }
|
||||
|
||||
//! Returns modification counter for hatching state.
|
||||
Standard_Size HatchingState() const { return myHatchingState; }
|
||||
|
||||
private:
|
||||
|
||||
enum Flags
|
||||
{
|
||||
Flags_None = 0x00, //!< no flags
|
||||
Flags_UseObjectMaterial = 0x01, //!< use object material
|
||||
Flags_UseObjectTexture = 0x02, //!< use object texture
|
||||
Flags_UseObjectShader = 0x04, //!< use object GLSL program
|
||||
Flags_HatchZoomPersistent = 0x08, //!< zoom-persistent texturing
|
||||
Flags_HatchRotationPersistent = 0x10, //!< rotation-persistent texturing
|
||||
Flags_DrawHatching = 0x20, //!< draw hatching
|
||||
Flags_UseObjectProperties = //!< use entire fill area aspect from object
|
||||
Flags_UseObjectMaterial
|
||||
| Flags_UseObjectTexture
|
||||
| Flags_UseObjectShader
|
||||
};
|
||||
|
||||
void setFlag (const Standard_Boolean theToUse, const unsigned int theFlag)
|
||||
{
|
||||
myFlags = theToUse ? myFlags | theFlag : myFlags & ~theFlag;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Graphic3d_MaterialAspect myMaterial;
|
||||
Handle(Graphic3d_TextureMap) myTexture;
|
||||
Handle(Graphic3d_ShaderProgram) myShader;
|
||||
Handle(Graphic3d_HatchStyle) myStippleHatch;
|
||||
Handle(Graphic3d_TextureMap) myTextureHatch;
|
||||
Graphic3d_MaterialAspect myHatchMaterial;
|
||||
unsigned int myFlags;
|
||||
Standard_Size myHatchingState;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Graphic3d_Aspects)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_AspectFillCapping, Graphic3d_Aspects)
|
||||
|
||||
#endif // _Graphic3d_AspectFillCapping_HeaderFile
|
@@ -12,22 +12,13 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_CView.hxx>
|
||||
|
||||
#include <Graphic3d_Layer.hxx>
|
||||
#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
|
||||
#include <Graphic3d_StructureManager.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CView,Graphic3d_DataStructureManager)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const int THE_DEFAULT_LAYERS[] = { Graphic3d_ZLayerId_Top,
|
||||
Graphic3d_ZLayerId_Topmost,
|
||||
Graphic3d_ZLayerId_BotOSD,
|
||||
Graphic3d_ZLayerId_TopOSD };
|
||||
|
||||
static const int THE_NB_DEFAULT_LAYERS = sizeof(THE_DEFAULT_LAYERS) / sizeof(*THE_DEFAULT_LAYERS);
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
@@ -357,6 +348,28 @@ void Graphic3d_CView::Update (const Graphic3d_ZLayerId theLayerId)
|
||||
InvalidateZLayerBoundingBox (theLayerId);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InvalidateZLayerBoundingBox
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CView::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId)
|
||||
{
|
||||
if (Handle(Graphic3d_Layer) aLayer = Layer (theLayerId))
|
||||
{
|
||||
aLayer->InvalidateBoundingBox();
|
||||
return;
|
||||
}
|
||||
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
|
||||
if (aLayer->NbOfTransformPersistenceObjects() > 0)
|
||||
{
|
||||
aLayer->InvalidateBoundingBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ContainsFacet
|
||||
// purpose :
|
||||
@@ -407,40 +420,25 @@ void Graphic3d_CView::DisplayedStructures (Graphic3d_MapOfStructure& theStructur
|
||||
// =======================================================================
|
||||
Bnd_Box Graphic3d_CView::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const
|
||||
{
|
||||
Bnd_Box aResult;
|
||||
|
||||
if (!IsDefined())
|
||||
{
|
||||
return aResult;
|
||||
return Bnd_Box();
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Camera) aCamera = Camera();
|
||||
Standard_Integer aWinWidth = 0;
|
||||
Standard_Integer aWinHeight = 0;
|
||||
const Handle(Graphic3d_Camera)& aCamera = Camera();
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
|
||||
Window()->Size (aWinWidth, aWinHeight);
|
||||
|
||||
for (Standard_Integer aLayer = 0; aLayer < THE_NB_DEFAULT_LAYERS; ++aLayer)
|
||||
Bnd_Box aResult;
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
Bnd_Box aBox = ZLayerBoundingBox (THE_DEFAULT_LAYERS[aLayer],
|
||||
aCamera,
|
||||
aWinWidth,
|
||||
aWinHeight,
|
||||
theToIncludeAuxiliary);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
|
||||
Bnd_Box aBox = aLayer->BoundingBox (Identification(),
|
||||
aCamera,
|
||||
aWinSize.x(), aWinSize.y(),
|
||||
theToIncludeAuxiliary);
|
||||
aResult.Add (aBox);
|
||||
}
|
||||
|
||||
Standard_Integer aMaxZLayer = ZLayerMax();
|
||||
for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId <= aMaxZLayer; ++aLayerId)
|
||||
{
|
||||
Bnd_Box aBox = ZLayerBoundingBox (aLayerId,
|
||||
aCamera,
|
||||
aWinWidth,
|
||||
aWinHeight,
|
||||
theToIncludeAuxiliary);
|
||||
aResult.Add(aBox);
|
||||
}
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
@@ -455,21 +453,15 @@ Standard_Real Graphic3d_CView::ConsiderZoomPersistenceObjects()
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Camera) aCamera = Camera();
|
||||
Standard_Integer aWinWidth = 0;
|
||||
Standard_Integer aWinHeight = 0;
|
||||
|
||||
Window()->Size (aWinWidth, aWinHeight);
|
||||
const Handle(Graphic3d_Camera)& aCamera = Camera();
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
|
||||
Standard_Real aMaxCoef = 1.0;
|
||||
for (Standard_Integer aLayer = 0; aLayer < THE_NB_DEFAULT_LAYERS; ++aLayer)
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
aMaxCoef = Max (aMaxCoef, considerZoomPersistenceObjects (THE_DEFAULT_LAYERS[aLayer], aCamera, aWinWidth, aWinHeight));
|
||||
}
|
||||
|
||||
for (Standard_Integer aLayer = Graphic3d_ZLayerId_Default; aLayer <= ZLayerMax(); ++aLayer)
|
||||
{
|
||||
aMaxCoef = Max (aMaxCoef, considerZoomPersistenceObjects (aLayer, aCamera, aWinWidth, aWinHeight));
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
|
||||
aMaxCoef = Max (aMaxCoef, aLayer->considerZoomPersistenceObjects (Identification(), aCamera, aWinSize.x(), aWinSize.y()));
|
||||
}
|
||||
|
||||
return aMaxCoef;
|
||||
|
@@ -46,6 +46,7 @@
|
||||
|
||||
class Graphic3d_CView;
|
||||
class Graphic3d_GraphicDriver;
|
||||
class Graphic3d_Layer;
|
||||
class Graphic3d_StructureManager;
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
|
||||
@@ -267,32 +268,34 @@ public:
|
||||
//! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
|
||||
virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) = 0;
|
||||
|
||||
//! Add a new top-level z layer with ID <theLayerId> for
|
||||
//! the view. Z layers allow drawing structures in higher layers
|
||||
//! in foreground of structures in lower layers. To add a structure
|
||||
//! to desired layer on display it is necessary to set the layer
|
||||
//! ID for the structure.
|
||||
virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
|
||||
//! Add a layer to the view.
|
||||
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerAfter [in] id of layer to append new layer before
|
||||
virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter) = 0;
|
||||
|
||||
//! Add a layer to the view.
|
||||
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerBefore [in] id of layer to append new layer after
|
||||
virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore) = 0;
|
||||
|
||||
//! Returns the maximum Z layer ID.
|
||||
//! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
|
||||
virtual Standard_Integer ZLayerMax() const = 0;
|
||||
|
||||
//! Returns the bounding box of all structures displayed in the Z layer.
|
||||
virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const = 0;
|
||||
//! Returns the list of layers.
|
||||
virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const = 0;
|
||||
|
||||
//! Returns layer with given ID or NULL if undefined.
|
||||
virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const = 0;
|
||||
|
||||
//! Returns the bounding box of all structures displayed in the Z layer.
|
||||
//! @param theLayerId layer identifier
|
||||
//! @param theCamera camera definition
|
||||
//! @param theWindowWidth viewport width (for applying transformation-persistence)
|
||||
//! @param theWindowHeight viewport height (for applying transformation-persistence)
|
||||
//! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
|
||||
//! @return computed bounding box
|
||||
virtual Bnd_Box ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight,
|
||||
const Standard_Boolean theToIncludeAuxiliary) const = 0;
|
||||
Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
|
||||
|
||||
//! Remove Z layer from the specified view. All structures
|
||||
//! displayed at the moment in layer will be displayed in default layer
|
||||
@@ -447,12 +450,6 @@ private:
|
||||
virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
|
||||
const Standard_Integer theNewPriority) = 0;
|
||||
|
||||
//! Returns zoom-scale factor.
|
||||
virtual Standard_Real considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Integer myId;
|
||||
|
@@ -24,6 +24,19 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
|
||||
namespace
|
||||
{
|
||||
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
|
||||
|
||||
static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
|
||||
{
|
||||
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
|
||||
anAspect->SetDistinguishOff();
|
||||
anAspect->SetFrontMaterial (aMaterial);
|
||||
anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetInteriorColor (aMaterial.Color());
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
return anAspect;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -31,8 +44,19 @@ namespace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (0.0, 0.0, 1.0, 0.0),
|
||||
myEquation (0.0, 0.0, 1.0, 0.0),
|
||||
myEquationRev(0.0, 0.0,-1.0, 0.0),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
init();
|
||||
makeId();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -40,8 +64,19 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
|
||||
myEquation (theEquation),
|
||||
myEquationRev(0.0, 0.0,-1.0, 0.0),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
init (gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.a()));
|
||||
makeId();
|
||||
updateInversedPlane();
|
||||
}
|
||||
|
||||
@@ -49,27 +84,42 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
|
||||
// function : Graphic3d_ClipPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_ClipPlane& theOther)
|
||||
: Standard_Transient (theOther)
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
|
||||
: Standard_Transient(theOther),
|
||||
myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (theOther.myPlane),
|
||||
myEquation (theOther.myEquation),
|
||||
myEquationRev(theOther.myEquationRev),
|
||||
myChainLenFwd(1),
|
||||
myFlags (theOther.myFlags),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (theOther.myIsOn),
|
||||
myIsCapping (theOther.myIsCapping)
|
||||
{
|
||||
*mySectionStyle = *theOther.CappingSectionStyle();
|
||||
init (theOther.myPlane,
|
||||
theOther.myEquationRev,
|
||||
theOther.myIsOn,
|
||||
theOther.myIsCapping,
|
||||
theOther.ToOverrideCappingAspect(),
|
||||
theOther.CappingSectionStyle());
|
||||
updateInversedPlane();
|
||||
makeId();
|
||||
*myAspect = *theOther.CappingAspect();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_ClipPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const gp_Pln& thePlane)
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (thePlane),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
init (thePlane);
|
||||
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
updateInversedPlane();
|
||||
makeId();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -81,7 +131,7 @@ void Graphic3d_ClipPlane::SetEquation (const Graphic3d_Vec4d& theEquation)
|
||||
myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
|
||||
myEquation = theEquation;
|
||||
updateInversedPlane();
|
||||
myOrientationDirty = Standard_True;
|
||||
myEquationMod++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -93,7 +143,7 @@ void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
|
||||
myPlane = thePlane;
|
||||
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
updateInversedPlane();
|
||||
myOrientationDirty = Standard_True;
|
||||
myEquationMod++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -128,106 +178,119 @@ Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingSectionStyle
|
||||
// function : SetCappingMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
|
||||
{
|
||||
mySectionStyle = theStyle;
|
||||
myAspect->SetFrontMaterial (theMat);
|
||||
myAspect->SetInteriorColor (theMat.Color());
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OrientationMatrix
|
||||
// function : SetCappingTexture
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_Mat4& Graphic3d_ClipPlane::OrientationMatrix() const
|
||||
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
|
||||
{
|
||||
if (myOrientationDirty)
|
||||
if (!theTexture.IsNull())
|
||||
{
|
||||
const Standard_ShortReal aDirection[] = {
|
||||
static_cast<Standard_ShortReal> (myEquation[0]),
|
||||
static_cast<Standard_ShortReal> (myEquation[1]),
|
||||
static_cast<Standard_ShortReal> (myEquation[2])
|
||||
};
|
||||
|
||||
const Standard_ShortReal aTranslate[] = {
|
||||
static_cast<Standard_ShortReal> (myEquation[0] * -myEquation[3]),
|
||||
static_cast<Standard_ShortReal> (myEquation[1] * -myEquation[3]),
|
||||
static_cast<Standard_ShortReal> (myEquation[2] * -myEquation[3])
|
||||
};
|
||||
|
||||
Standard_ShortReal aSide1[] = { 0.0f, 0.0f, 0.0f };
|
||||
Standard_ShortReal aSide2[] = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
const Standard_ShortReal aMagintude = static_cast<Standard_ShortReal> (Sqrt (myEquation[0] * myEquation[0] + myEquation[2] * myEquation[2]));
|
||||
|
||||
if (aMagintude < ShortRealSmall())
|
||||
myAspect->SetTextureMapOn();
|
||||
Handle(Graphic3d_TextureSet) aTextureSet = myAspect->TextureSet();
|
||||
if (aTextureSet.IsNull() || aTextureSet->Size() != 1)
|
||||
{
|
||||
aSide1[0] = 1.0f;
|
||||
aTextureSet = new Graphic3d_TextureSet (theTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
aSide1[0] = aDirection[2] / aMagintude;
|
||||
aSide1[2] = -aDirection[0] / aMagintude;
|
||||
aTextureSet->SetFirst (theTexture);
|
||||
}
|
||||
|
||||
aSide2[0] = (-aSide1[1] * aDirection[2]) - (-aSide1[2] * aDirection[1]);
|
||||
aSide2[1] = (-aSide1[2] * aDirection[0]) - (-aSide1[0] * aDirection[2]);
|
||||
aSide2[2] = (-aSide1[0] * aDirection[1]) - (-aSide1[1] * aDirection[0]);
|
||||
|
||||
myOrientationMat.SetValue (0, 0, aSide1[0]);
|
||||
myOrientationMat.SetValue (1, 0, aSide1[1]);
|
||||
myOrientationMat.SetValue (2, 0, aSide1[2]);
|
||||
myOrientationMat.SetValue (3, 0, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 1, aDirection[0]);
|
||||
myOrientationMat.SetValue (1, 1, aDirection[1]);
|
||||
myOrientationMat.SetValue (2, 1, aDirection[2]);
|
||||
myOrientationMat.SetValue (3, 1, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 2, aSide2[0]);
|
||||
myOrientationMat.SetValue (1, 2, aSide2[1]);
|
||||
myOrientationMat.SetValue (2, 2, aSide2[2]);
|
||||
myOrientationMat.SetValue (3, 2, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 3, aTranslate[0]);
|
||||
myOrientationMat.SetValue (1, 3, aTranslate[1]);
|
||||
myOrientationMat.SetValue (2, 3, aTranslate[2]);
|
||||
myOrientationMat.SetValue (3, 3, 1.0F);
|
||||
|
||||
myOrientationDirty = Standard_False;
|
||||
myAspect->SetTextureSet (aTextureSet);
|
||||
}
|
||||
|
||||
return myOrientationMat;
|
||||
else
|
||||
{
|
||||
myAspect->SetTextureMapOff();
|
||||
myAspect->SetTextureSet (Handle(Graphic3d_TextureSet)());
|
||||
}
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : init
|
||||
// function : SetCappingHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::init (const gp_Pln& thePlane,
|
||||
const Graphic3d_Vec4d& theEquationRev,
|
||||
const Standard_Boolean theIsOn,
|
||||
const Standard_Boolean theIsCapping,
|
||||
const Standard_Boolean theOverrideStyle,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
|
||||
{
|
||||
if (myEntityUID.IsEmpty())
|
||||
{
|
||||
myEntityUID = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
|
||||
}
|
||||
myAspect->SetHatchStyle (theStyle);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
myPrevInChain = NULL;
|
||||
myEquationRev = theEquationRev;
|
||||
myChainLenFwd = 1;
|
||||
myPlane = thePlane;
|
||||
myPlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
myIsOn = theIsOn;
|
||||
myIsCapping = theIsCapping;
|
||||
myOverrideObjectStyle = theOverrideStyle;
|
||||
mySectionStyle = theStyle.IsNull() ? new Graphic3d_AspectFillCapping() : theStyle;
|
||||
myOrientationDirty = Standard_True;
|
||||
// =======================================================================
|
||||
// function : SetCappingCustomHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle)
|
||||
{
|
||||
myAspect->SetHatchStyle (theStyle);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatchOn
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingHatchOn()
|
||||
{
|
||||
myAspect->SetInteriorStyle (Aspect_IS_HATCH);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatchOff
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingHatchOff()
|
||||
{
|
||||
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||
{
|
||||
myAspect = theAspect;
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setCappingFlag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
|
||||
{
|
||||
if (theToUse)
|
||||
{
|
||||
myFlags |= theFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
myFlags &= ~(theFlag);
|
||||
}
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : makeId
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::makeId()
|
||||
{
|
||||
myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -249,7 +312,7 @@ void Graphic3d_ClipPlane::updateChainLen()
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||
{
|
||||
myOrientationDirty = Standard_True;
|
||||
++myEquationMod;
|
||||
if (!myNextInChain.IsNull())
|
||||
{
|
||||
myNextInChain->myPrevInChain = NULL;
|
||||
|
@@ -19,12 +19,9 @@
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_BndBox3d.hxx>
|
||||
#include <Graphic3d_CappingFlags.hxx>
|
||||
#include <Graphic3d_Mat4.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
@@ -169,6 +166,44 @@ public:
|
||||
|
||||
public: // @name user-defined graphical attributes
|
||||
|
||||
//! Set material for rendering capping surface.
|
||||
//! @param theMat [in] the material.
|
||||
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
|
||||
|
||||
//! @return capping material.
|
||||
const Graphic3d_MaterialAspect& CappingMaterial() const { return myAspect->FrontMaterial(); }
|
||||
|
||||
//! Set texture to be applied on capping surface.
|
||||
//! @param theTexture [in] the texture.
|
||||
Standard_EXPORT void SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture);
|
||||
|
||||
//! @return capping texture map.
|
||||
Handle(Graphic3d_TextureMap) CappingTexture() const { return !myAspect->TextureSet().IsNull() && !myAspect->TextureSet()->IsEmpty()
|
||||
? myAspect->TextureSet()->First()
|
||||
: Handle(Graphic3d_TextureMap)(); }
|
||||
|
||||
//! Set hatch style (stipple) and turn hatching on.
|
||||
//! @param theStyle [in] the hatch style.
|
||||
Standard_EXPORT void SetCappingHatch (const Aspect_HatchStyle theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
Aspect_HatchStyle CappingHatch() const { return (Aspect_HatchStyle)myAspect->HatchStyle()->HatchType(); }
|
||||
|
||||
//! Set custom hatch style (stipple) and turn hatching on.
|
||||
//! @param theStyle [in] the hatch pattern.
|
||||
Standard_EXPORT void SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
const Handle(Graphic3d_HatchStyle)& CappingCustomHatch() const { return myAspect->HatchStyle(); }
|
||||
|
||||
//! Turn on hatching.
|
||||
Standard_EXPORT void SetCappingHatchOn();
|
||||
|
||||
//! Turn off hatching.
|
||||
Standard_EXPORT void SetCappingHatchOff();
|
||||
|
||||
//! @return True if hatching mask is turned on.
|
||||
Standard_Boolean IsHatchOn() const { return myAspect->InteriorStyle() == Aspect_IS_HATCH; }
|
||||
|
||||
//! This ID is used for managing associated resources in graphical driver.
|
||||
//! The clip plane can be assigned within a range of IO which can be
|
||||
@@ -179,18 +214,41 @@ public: // @name user-defined graphical attributes
|
||||
//! @return clip plane resource identifier string.
|
||||
const TCollection_AsciiString& GetId() const
|
||||
{
|
||||
return myEntityUID;
|
||||
return myId;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Returns style used for drawing capping section.
|
||||
//! Return capping aspect.
|
||||
//! @return capping surface rendering aspect.
|
||||
const Handle(Graphic3d_AspectFillCapping)& CappingSectionStyle() const { return mySectionStyle; }
|
||||
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
|
||||
|
||||
//! Sets clipping section filling aspect.
|
||||
Standard_EXPORT void SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
|
||||
//! Assign capping aspect.
|
||||
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
|
||||
|
||||
//! Flag indicating whether material for capping plane should be taken from object.
|
||||
//! Default value: FALSE (use dedicated capping plane material).
|
||||
bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane material.
|
||||
void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); }
|
||||
|
||||
//! Flag indicating whether texture for capping plane should be taken from object.
|
||||
//! Default value: FALSE.
|
||||
bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane texture.
|
||||
void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); }
|
||||
|
||||
//! Flag indicating whether shader program for capping plane should be taken from object.
|
||||
//! Default value: FALSE.
|
||||
bool ToUseObjectShader() const { return (myFlags & Graphic3d_CappingFlags_ObjectShader) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane shader program.
|
||||
void SetUseObjectShader(bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectShader); }
|
||||
|
||||
//! Return true if some fill area aspect properties should be taken from object.
|
||||
bool ToUseObjectProperties() const { return myFlags != Graphic3d_CappingFlags_None; }
|
||||
|
||||
public:
|
||||
|
||||
@@ -294,25 +352,14 @@ public: // @name modification counters
|
||||
{
|
||||
return myAspectMod;
|
||||
}
|
||||
//! Flag indicating whether section style of the plane should overrides similar property of object presentation.
|
||||
//! Default value: FALSE (use dedicated presentation aspect style).
|
||||
bool ToOverrideCappingAspect() const { return myOverrideObjectStyle; }
|
||||
|
||||
//! Sets flag for controlling the preference of using section style between clip plane and object.
|
||||
void SetToOverrideCappingAspect (const bool theToOverride) { myOverrideObjectStyle = theToOverride; }
|
||||
|
||||
//! Returns plane's orientation matrix.
|
||||
Standard_EXPORT const Graphic3d_Mat4& OrientationMatrix() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Initializes plane and makes unique identifier (UID) to differentiate clipping plane entities.
|
||||
void init (const gp_Pln& thePlane = gp_Pln(),
|
||||
const Graphic3d_Vec4d& theEquationRev = Graphic3d_Vec4d(0.0, 0.0,-1.0, 0.0),
|
||||
const Standard_Boolean theIsOn = Standard_True,
|
||||
const Standard_Boolean theIsCapping = Standard_False,
|
||||
const Standard_Boolean theOverrideStyle = Standard_False,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theStyle = Handle(Graphic3d_AspectFillCapping)());
|
||||
//! Generate unique object id for OpenGL graphic resource manager.
|
||||
void makeId();
|
||||
|
||||
//! Set capping flag.
|
||||
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
|
||||
|
||||
//! Update chain length in backward direction.
|
||||
void updateChainLen();
|
||||
@@ -327,10 +374,10 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
Handle(Graphic3d_AspectFillCapping) mySectionStyle; //!< Style set for drawing capped solid section.
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
|
||||
Handle(Graphic3d_ClipPlane) myNextInChain; //!< next plane in a chain of planes defining logical AND operation
|
||||
Graphic3d_ClipPlane* myPrevInChain; //!< previous plane in a chain of planes defining logical AND operation
|
||||
TCollection_AsciiString myEntityUID; //!< Unique identifier for the plane
|
||||
TCollection_AsciiString myId; //!< resource id
|
||||
gp_Pln myPlane; //!< plane definition
|
||||
Graphic3d_Vec4d myEquation; //!< plane equation vector
|
||||
Graphic3d_Vec4d myEquationRev; //!< reversed plane equation
|
||||
@@ -340,9 +387,6 @@ private:
|
||||
unsigned int myAspectMod; //!< modification counter of aspect
|
||||
Standard_Boolean myIsOn; //!< state of the clipping plane
|
||||
Standard_Boolean myIsCapping; //!< state of graphic driver capping
|
||||
Standard_Boolean myOverrideObjectStyle; //!< Flag forcing to use plane's section style rather than section style defined for object
|
||||
mutable Standard_Boolean myOrientationDirty; //!< Boolean flag indicating whether orientation matrix is dirty or not.
|
||||
mutable Graphic3d_Mat4 myOrientationMat; //!< Plane orientation matrix (for visualization purposes).
|
||||
|
||||
};
|
||||
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
|
||||
#include <Graphic3d_Layer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
@@ -25,70 +27,85 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,Standard_Transient)
|
||||
Graphic3d_GraphicDriver::Graphic3d_GraphicDriver (const Handle(Aspect_DisplayConnection)& theDisp)
|
||||
: myDisplayConnection (theDisp)
|
||||
{
|
||||
// default layers are always presented in display layer sequence it can not be removed
|
||||
// default layers are always presented in display layer sequence and cannot be removed
|
||||
{
|
||||
Graphic3d_ZLayerSettings aSettings;
|
||||
aSettings.SetName ("UNDERLAY");
|
||||
aSettings.SetImmediate (Standard_False);
|
||||
aSettings.SetRaytracable (Standard_False);
|
||||
aSettings.SetEnvironmentTexture (Standard_False);
|
||||
aSettings.SetEnableDepthTest (Standard_False);
|
||||
aSettings.SetEnableDepthWrite (Standard_False);
|
||||
aSettings.SetClearDepth (Standard_False);
|
||||
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
|
||||
myLayerIds.Add (Graphic3d_ZLayerId_BotOSD);
|
||||
myLayerSeq.Append (Graphic3d_ZLayerId_BotOSD);
|
||||
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_BotOSD, aSettings);
|
||||
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_BotOSD, 1, Handle(Select3D_BVHBuilder3d)());
|
||||
aLayer->SetLayerSettings (aSettings);
|
||||
myLayers.Append (aLayer);
|
||||
myLayerIds.Bind (aLayer->LayerId(), aLayer);
|
||||
}
|
||||
|
||||
{
|
||||
Graphic3d_ZLayerSettings aSettings;
|
||||
aSettings.SetName ("DEFAULT");
|
||||
aSettings.SetImmediate (Standard_False);
|
||||
aSettings.SetRaytracable (Standard_True);
|
||||
aSettings.SetEnvironmentTexture (Standard_True);
|
||||
aSettings.SetEnableDepthTest (Standard_True);
|
||||
aSettings.SetEnableDepthWrite (Standard_True);
|
||||
aSettings.SetClearDepth (Standard_False);
|
||||
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
|
||||
myLayerIds.Add (Graphic3d_ZLayerId_Default);
|
||||
myLayerSeq.Append (Graphic3d_ZLayerId_Default);
|
||||
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Default, aSettings);
|
||||
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_Default, 1, Handle(Select3D_BVHBuilder3d)());
|
||||
aLayer->SetLayerSettings (aSettings);
|
||||
myLayers.Append (aLayer);
|
||||
myLayerIds.Bind (aLayer->LayerId(), aLayer);
|
||||
}
|
||||
|
||||
{
|
||||
Graphic3d_ZLayerSettings aSettings;
|
||||
aSettings.SetName ("TOP");
|
||||
aSettings.SetImmediate (Standard_True);
|
||||
aSettings.SetRaytracable (Standard_False);
|
||||
aSettings.SetEnvironmentTexture (Standard_True);
|
||||
aSettings.SetEnableDepthTest (Standard_True);
|
||||
aSettings.SetEnableDepthWrite (Standard_True);
|
||||
aSettings.SetClearDepth (Standard_False);
|
||||
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
|
||||
myLayerIds.Add (Graphic3d_ZLayerId_Top);
|
||||
myLayerSeq.Append (Graphic3d_ZLayerId_Top);
|
||||
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Top, aSettings);
|
||||
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_Top, 1, Handle(Select3D_BVHBuilder3d)());
|
||||
aLayer->SetLayerSettings (aSettings);
|
||||
myLayers.Append (aLayer);
|
||||
myLayerIds.Bind (aLayer->LayerId(), aLayer);
|
||||
}
|
||||
|
||||
{
|
||||
Graphic3d_ZLayerSettings aSettings;
|
||||
aSettings.SetName ("TOPMOST");
|
||||
aSettings.SetImmediate (Standard_True);
|
||||
aSettings.SetRaytracable (Standard_False);
|
||||
aSettings.SetEnvironmentTexture (Standard_True);
|
||||
aSettings.SetEnableDepthTest (Standard_True);
|
||||
aSettings.SetEnableDepthWrite (Standard_True);
|
||||
aSettings.SetClearDepth (Standard_True);
|
||||
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
|
||||
myLayerIds.Add (Graphic3d_ZLayerId_Topmost);
|
||||
myLayerSeq.Append (Graphic3d_ZLayerId_Topmost);
|
||||
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Topmost, aSettings);
|
||||
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_Topmost, 1, Handle(Select3D_BVHBuilder3d)());
|
||||
aLayer->SetLayerSettings (aSettings);
|
||||
myLayers.Append (aLayer);
|
||||
myLayerIds.Bind (aLayer->LayerId(), aLayer);
|
||||
}
|
||||
|
||||
{
|
||||
Graphic3d_ZLayerSettings aSettings;
|
||||
aSettings.SetName ("OVERLAY");
|
||||
aSettings.SetImmediate (Standard_True);
|
||||
aSettings.SetRaytracable (Standard_False);
|
||||
aSettings.SetEnvironmentTexture (Standard_False);
|
||||
aSettings.SetEnableDepthTest (Standard_False);
|
||||
aSettings.SetEnableDepthWrite (Standard_False);
|
||||
aSettings.SetClearDepth (Standard_False);
|
||||
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
|
||||
myLayerIds.Add (Graphic3d_ZLayerId_TopOSD);
|
||||
myLayerSeq.Append (Graphic3d_ZLayerId_TopOSD);
|
||||
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_TopOSD, aSettings);
|
||||
Handle(Graphic3d_Layer) aLayer = new Graphic3d_Layer (Graphic3d_ZLayerId_TopOSD, 1, Handle(Select3D_BVHBuilder3d)());
|
||||
aLayer->SetLayerSettings (aSettings);
|
||||
myLayers.Append (aLayer);
|
||||
myLayerIds.Bind (aLayer->LayerId(), aLayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,52 +142,130 @@ void Graphic3d_GraphicDriver::RemoveIdentification(const Standard_Integer theId)
|
||||
//=======================================================================
|
||||
const Graphic3d_ZLayerSettings& Graphic3d_GraphicDriver::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
|
||||
{
|
||||
Standard_ASSERT_RAISE (myLayerIds.Contains (theLayerId), "Graphic3d_GraphicDriver::ZLayerSettings, Layer with theLayerId does not exist");
|
||||
return myMapOfZLayerSettings.Find (theLayerId);
|
||||
const Handle(Graphic3d_Layer)* aLayer = myLayerIds.Seek (theLayerId);
|
||||
if (aLayer == NULL)
|
||||
{
|
||||
throw Standard_OutOfRange ("Graphic3d_GraphicDriver::ZLayerSettings, Layer with theLayerId does not exist");
|
||||
}
|
||||
return (*aLayer)->LayerSettings();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : addZLayerIndex
|
||||
//function : ZLayers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_GraphicDriver::addZLayerIndex (const Graphic3d_ZLayerId theLayerId)
|
||||
void Graphic3d_GraphicDriver::ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
|
||||
{
|
||||
// remove index
|
||||
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
|
||||
theLayerSeq.Clear();
|
||||
|
||||
// append normal layers
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
if (aLayerIt.Value() == theLayerId)
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
|
||||
if (!aLayer->IsImmediate())
|
||||
{
|
||||
myLayerSeq.Remove (aLayerIt);
|
||||
break;
|
||||
theLayerSeq.Append (aLayer->LayerId());
|
||||
}
|
||||
}
|
||||
|
||||
if (myMapOfZLayerSettings.Find (theLayerId).IsImmediate())
|
||||
// append immediate layers
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
myLayerSeq.Append (theLayerId);
|
||||
return;
|
||||
}
|
||||
|
||||
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
|
||||
{
|
||||
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerIt.Value());
|
||||
if (aSettings.IsImmediate())
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
|
||||
if (aLayer->IsImmediate())
|
||||
{
|
||||
aLayerIt.Previous();
|
||||
if (aLayerIt.More())
|
||||
theLayerSeq.Append (aLayer->LayerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InsertLayerBefore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_GraphicDriver::InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theNewLayerId > 0,
|
||||
"Graphic3d_GraphicDriver::InsertLayerBefore, negative and zero IDs are reserved");
|
||||
Standard_ASSERT_RAISE (!myLayerIds.IsBound (theNewLayerId),
|
||||
"Graphic3d_GraphicDriver::InsertLayerBefore, Layer with theLayerId already exists");
|
||||
|
||||
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, 1, Handle(Select3D_BVHBuilder3d)());
|
||||
aNewLayer->SetLayerSettings (theSettings);
|
||||
|
||||
Handle(Graphic3d_Layer) anOtherLayer;
|
||||
if (theLayerAfter != Graphic3d_ZLayerId_UNKNOWN
|
||||
&& myLayerIds.Find (theLayerAfter, anOtherLayer))
|
||||
{
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
if (aLayerIter.Value() == anOtherLayer)
|
||||
{
|
||||
myLayerSeq.InsertAfter (aLayerIt, theLayerId);
|
||||
return;
|
||||
myLayers.InsertBefore (aNewLayer, aLayerIter);
|
||||
break;
|
||||
}
|
||||
|
||||
// first non-immediate layer
|
||||
myLayerSeq.Prepend (theLayerId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myLayers.Prepend (aNewLayer);
|
||||
}
|
||||
myLayerIds.Bind (theNewLayerId, aNewLayer);
|
||||
}
|
||||
|
||||
// no immediate layers
|
||||
myLayerSeq.Append (theLayerId);
|
||||
//=======================================================================
|
||||
//function : InsertLayerAfter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_GraphicDriver::InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theNewLayerId > 0,
|
||||
"Graphic3d_GraphicDriver::InsertLayerAfter, negative and zero IDs are reserved");
|
||||
Standard_ASSERT_RAISE (!myLayerIds.IsBound (theNewLayerId),
|
||||
"Graphic3d_GraphicDriver::InsertLayerAfter, Layer with theLayerId already exists");
|
||||
|
||||
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, 1, Handle(Select3D_BVHBuilder3d)());
|
||||
aNewLayer->SetLayerSettings (theSettings);
|
||||
|
||||
Handle(Graphic3d_Layer) anOtherLayer;
|
||||
if (theLayerBefore != Graphic3d_ZLayerId_UNKNOWN
|
||||
&& myLayerIds.Find (theLayerBefore, anOtherLayer))
|
||||
{
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
if (aLayerIter.Value() == anOtherLayer)
|
||||
{
|
||||
myLayers.InsertAfter (aNewLayer, aLayerIter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myLayers.Append (aNewLayer);
|
||||
}
|
||||
myLayerIds.Bind (theNewLayerId, aNewLayer);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveZLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Graphic3d_GraphicDriver::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theLayerId > 0,
|
||||
"Graphic3d_GraphicDriver::RemoveZLayer, negative and zero IDs are reserved and cannot be removed");
|
||||
|
||||
Handle(Graphic3d_Layer) aLayerDef;
|
||||
myLayerIds.Find (theLayerId, aLayerDef);
|
||||
Standard_ASSERT_RAISE (!aLayerDef.IsNull(),
|
||||
"Graphic3d_GraphicDriver::RemoveZLayer, Layer with theLayerId does not exist");
|
||||
myLayers.Remove (aLayerDef);
|
||||
myLayerIds.UnBind (theLayerId);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -180,20 +275,9 @@ void Graphic3d_GraphicDriver::addZLayerIndex (const Graphic3d_ZLayerId theLayerI
|
||||
void Graphic3d_GraphicDriver::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings)
|
||||
{
|
||||
Graphic3d_ZLayerSettings* aSettings = myMapOfZLayerSettings.ChangeSeek (theLayerId);
|
||||
if (aSettings != NULL)
|
||||
{
|
||||
const bool isChanged = (aSettings->IsImmediate() != theSettings.IsImmediate());
|
||||
*aSettings = theSettings;
|
||||
if (isChanged)
|
||||
{
|
||||
addZLayerIndex (theLayerId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// abnormal case
|
||||
myMapOfZLayerSettings.Bind (theLayerId, theSettings);
|
||||
addZLayerIndex (theLayerId);
|
||||
}
|
||||
Handle(Graphic3d_Layer) aLayerDef;
|
||||
myLayerIds.Find (theLayerId, aLayerDef);
|
||||
Standard_ASSERT_RAISE (!aLayerDef.IsNull(),
|
||||
"Graphic3d_GraphicDriver::SetZLayerSettings, Layer with theLayerId does not exist");
|
||||
aLayerDef->SetLayerSettings (theSettings);
|
||||
}
|
||||
|
@@ -52,6 +52,7 @@
|
||||
class Aspect_DisplayConnection;
|
||||
class Graphic3d_CView;
|
||||
class Graphic3d_GraphicDriver;
|
||||
class Graphic3d_Layer;
|
||||
class Graphic3d_TransformError;
|
||||
class Graphic3d_Structure;
|
||||
class Graphic3d_StructureManager;
|
||||
@@ -65,7 +66,7 @@ DEFINE_STANDARD_HANDLE(Graphic3d_GraphicDriver, Standard_Transient)
|
||||
//! for 3d interface (currently only OpenGl driver is used).
|
||||
class Graphic3d_GraphicDriver : public Standard_Transient
|
||||
{
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriver, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Request limit of graphic resource of specific type.
|
||||
@@ -110,24 +111,31 @@ public:
|
||||
Standard_ShortReal& theAscent,
|
||||
Standard_ShortReal& theDescent) const = 0;
|
||||
|
||||
//! Add a new top-level z layer with ID <theLayerId> for
|
||||
//! the view. Z layers allow drawing structures in higher layers
|
||||
//! in foreground of structures in lower layers. To add a structure
|
||||
//! to desired layer on display it is necessary to set the layer
|
||||
//! ID for the structure.
|
||||
virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
|
||||
//! Adds a layer to all views.
|
||||
//! To add a structure to desired layer on display it is necessary to set the layer ID for the structure.
|
||||
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerAfter [in] id of layer to append new layer before
|
||||
Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter) = 0;
|
||||
|
||||
//! Adds a layer to all views.
|
||||
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerBefore [in] id of layer to append new layer after
|
||||
Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore) = 0;
|
||||
|
||||
//! Removes Z layer. All structures displayed at the moment in layer will be displayed in
|
||||
//! default layer (the bottom-level z layer). By default, there are always default
|
||||
//! bottom-level layer that can't be removed. The passed theLayerId should be not less than 0
|
||||
//! (reserved for default layers that can not be removed).
|
||||
virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
|
||||
Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) = 0;
|
||||
|
||||
//! Returns list of Z layers defined for the graphical driver.
|
||||
virtual void ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
|
||||
{
|
||||
theLayerSeq.Assign (myLayerSeq);
|
||||
}
|
||||
Standard_EXPORT virtual void ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const;
|
||||
|
||||
//! Sets the settings for a single Z layer.
|
||||
Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings) = 0;
|
||||
@@ -148,23 +156,17 @@ public:
|
||||
//! Frees the identifier of a structure.
|
||||
Standard_EXPORT void RemoveIdentification(const Standard_Integer theId);
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_GraphicDriver,Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
//! Initializes the Driver
|
||||
Standard_EXPORT Graphic3d_GraphicDriver(const Handle(Aspect_DisplayConnection)& theDisp);
|
||||
|
||||
//! Insert index layer at proper position.
|
||||
Standard_EXPORT void addZLayerIndex (const Graphic3d_ZLayerId theLayerId);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Aspect_DisplayConnection) myDisplayConnection;
|
||||
Aspect_GenId myStructGenId;
|
||||
TColStd_MapOfInteger myLayerIds;
|
||||
TColStd_SequenceOfInteger myLayerSeq;
|
||||
Graphic3d_MapOfZLayerSettings myMapOfZLayerSettings;
|
||||
NCollection_List<Handle(Graphic3d_Layer)> myLayers;
|
||||
NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -37,7 +37,6 @@
|
||||
|
||||
class Graphic3d_Structure;
|
||||
class Graphic3d_ArrayOfPrimitives;
|
||||
class Graphic3d_AspectFillCapping;
|
||||
|
||||
//! This class allows the definition of groups
|
||||
//! of primitives inside of graphic objects (presentations).
|
||||
@@ -105,9 +104,6 @@ public:
|
||||
//! Modifies the current context of the group to give another aspect for all the primitives created after this call in the group.
|
||||
virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
|
||||
|
||||
//! Returns style of filling clipping sections on closed shell primitives.
|
||||
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const = 0;
|
||||
|
||||
//! Update presentation aspects after their modification.
|
||||
virtual void SynchronizeAspects() = 0;
|
||||
|
||||
|
@@ -21,15 +21,13 @@
|
||||
//! - ASPECT_LINE: aspect for line primitives;
|
||||
//! - ASPECT_TEXT: aspect for text primitives;
|
||||
//! - ASPECT_MARKER: aspect for marker primitives;
|
||||
//! - ASPECT_FILL_AREA: aspect for face primitives;
|
||||
//! - Graphic3d_ASPECT_FILL_CAPPING: aspect for filling clipping sections.
|
||||
//! - ASPECT_FILL_AREA: aspect for face primitives.
|
||||
enum Graphic3d_GroupAspect
|
||||
{
|
||||
Graphic3d_ASPECT_LINE,
|
||||
Graphic3d_ASPECT_TEXT,
|
||||
Graphic3d_ASPECT_MARKER,
|
||||
Graphic3d_ASPECT_FILL_AREA,
|
||||
Graphic3d_ASPECT_FILL_CAPPING
|
||||
Graphic3d_ASPECT_FILL_AREA
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_GroupAspect_HeaderFile
|
||||
|
@@ -22,11 +22,13 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Layer, Standard_Transient)
|
||||
// function : Graphic3d_Layer
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Layer::Graphic3d_Layer (Standard_Integer theNbPriorities,
|
||||
Graphic3d_Layer::Graphic3d_Layer (Graphic3d_ZLayerId theId,
|
||||
Standard_Integer theNbPriorities,
|
||||
const Handle(Select3D_BVHBuilder3d)& theBuilder)
|
||||
: myArray (0, theNbPriorities - 1),
|
||||
myNbStructures (0),
|
||||
myNbStructuresNotCulled (0),
|
||||
myLayerId (theId),
|
||||
myBVHPrimitivesTrsfPers (theBuilder),
|
||||
myBVHIsLeftChildQueuedFirst (Standard_True),
|
||||
myIsBVHPrimitivesNeedsReset (Standard_False)
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include <Graphic3d_BvhCStructureSet.hxx>
|
||||
#include <Graphic3d_BvhCStructureSetTrsfPers.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_ZLayerId.hxx>
|
||||
#include <Graphic3d_ZLayerSettings.hxx>
|
||||
#include <Graphic3d_RenderingParams.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
@@ -38,12 +39,16 @@ class Graphic3d_Layer : public Standard_Transient
|
||||
public:
|
||||
|
||||
//! Initializes associated priority list and layer properties
|
||||
Standard_EXPORT Graphic3d_Layer (Standard_Integer theNbPriorities,
|
||||
Standard_EXPORT Graphic3d_Layer (Graphic3d_ZLayerId theId,
|
||||
Standard_Integer theNbPriorities,
|
||||
const Handle(Select3D_BVHBuilder3d)& theBuilder);
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~Graphic3d_Layer();
|
||||
|
||||
//! Return layer id.
|
||||
Graphic3d_ZLayerId LayerId() const { return myLayerId; }
|
||||
|
||||
//! Returns BVH tree builder for frustom culling.
|
||||
const Handle(Select3D_BVHBuilder3d)& FrustumCullingBVHBuilder() const { return myBVHPrimitivesTrsfPers.Builder(); }
|
||||
|
||||
@@ -158,6 +163,9 @@ private:
|
||||
//! Layer setting flags.
|
||||
Graphic3d_ZLayerSettings myLayerSettings;
|
||||
|
||||
//! Layer id.
|
||||
Graphic3d_ZLayerId myLayerId;
|
||||
|
||||
//! Set of Graphic3d_CStructures structures for building BVH tree.
|
||||
mutable Graphic3d_BvhCStructureSet myBVHPrimitives;
|
||||
|
||||
|
@@ -462,6 +462,15 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f, 0.970f, 0.970f));
|
||||
break;
|
||||
case Graphic3d_NOM_UserDefined:
|
||||
MaterialType = Graphic3d_MATERIAL_PHYSIC;
|
||||
ColorCoef[Graphic3d_TOR_AMBIENT] = 1.00f;
|
||||
ColorCoef[Graphic3d_TOR_DIFFUSE] = 1.00f;
|
||||
ColorCoef[Graphic3d_TOR_SPECULAR] = 1.00f;
|
||||
ColorCoef[Graphic3d_TOR_EMISSION] = 1.00f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.1f, 0.1f, 0.1f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.8f, 0.8f, 0.8f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.2f, 0.2f, 0.2f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f, 0.0f, 0.0f));
|
||||
break;
|
||||
case Graphic3d_NOM_DEFAULT:
|
||||
break;
|
||||
|
@@ -38,6 +38,7 @@ struct Graphic3d_ZLayerSettings
|
||||
: myCullingDistance (Precision::Infinite()),
|
||||
myCullingSize (Precision::Infinite()),
|
||||
myIsImmediate (Standard_False),
|
||||
myToRaytrace (Standard_True),
|
||||
myUseEnvironmentTexture (Standard_True),
|
||||
myToEnableDepthTest (Standard_True),
|
||||
myToEnableDepthWrite(Standard_True),
|
||||
@@ -105,6 +106,13 @@ struct Graphic3d_ZLayerSettings
|
||||
//! Set the flag indicating the immediate layer, which should be drawn after all normal (non-immediate) layers.
|
||||
void SetImmediate (const Standard_Boolean theValue) { myIsImmediate = theValue; }
|
||||
|
||||
//! Returns TRUE if layer should be processed by ray-tracing renderer; TRUE by default.
|
||||
//! Note that this flag is IGNORED for layers with IsImmediate() flag.
|
||||
Standard_Boolean IsRaytracable() const { return myToRaytrace; }
|
||||
|
||||
//! Sets if layer should be processed by ray-tracing renderer.
|
||||
void SetRaytracable (Standard_Boolean theToRaytrace) { myToRaytrace = theToRaytrace; }
|
||||
|
||||
//! Return flag to allow/prevent environment texture mapping usage for specific layer.
|
||||
Standard_Boolean UseEnvironmentTexture() const { return myUseEnvironmentTexture; }
|
||||
|
||||
@@ -210,6 +218,7 @@ protected:
|
||||
Standard_Real myCullingSize; //!< size to discard objects
|
||||
Graphic3d_PolygonOffset myPolygonOffset; //!< glPolygonOffset() arguments
|
||||
Standard_Boolean myIsImmediate; //!< immediate layer will be drawn after all normal layers
|
||||
Standard_Boolean myToRaytrace; //!< option to render layer within ray-tracing engine
|
||||
Standard_Boolean myUseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer
|
||||
Standard_Boolean myToEnableDepthTest; //!< option to enable depth test
|
||||
Standard_Boolean myToEnableDepthWrite; //!< option to enable write depth values
|
||||
|
@@ -132,6 +132,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
|
||||
:
|
||||
Tol(aTol),
|
||||
done(Standard_False),
|
||||
myReady(Standard_False),
|
||||
nbpnt(0),
|
||||
PtrOnPolyhedron(NULL),
|
||||
PtrOnBndBounding(NULL),
|
||||
@@ -175,7 +176,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
|
||||
if (nbsu > aMaxSamples) nbsu = aMaxSamples;
|
||||
if (nbsv > aMaxSamples) nbsv = aMaxSamples;
|
||||
|
||||
if (dU > gp::Resolution() && dV > gp::Resolution()) {
|
||||
if (dU > Precision::Confusion() && dV > Precision::Confusion()) {
|
||||
if (Max(dU, dV) > Min(dU, dV) * aTresh)
|
||||
{
|
||||
aMinSamples = 10;
|
||||
@@ -190,12 +191,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (dU < gp::Resolution()) {
|
||||
nbsu = 1;
|
||||
}
|
||||
if (dV < gp::Resolution()) {
|
||||
nbsv = 1;
|
||||
}
|
||||
return; // surface has no extension along one of directions
|
||||
}
|
||||
|
||||
Standard_Integer NbUOnS = Hsurface->NbUIntervals(GeomAbs_C2);
|
||||
@@ -215,6 +211,7 @@ IntCurvesFace_Intersector::IntCurvesFace_Intersector(const TopoDS_Face& Face,
|
||||
new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
|
||||
}
|
||||
}
|
||||
myReady = Standard_True;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : InternalCall
|
||||
@@ -350,6 +347,11 @@ void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax)
|
||||
{
|
||||
done = Standard_False;
|
||||
if (!myReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
done = Standard_True;
|
||||
SeqPnt.Clear();
|
||||
mySeqState.Clear();
|
||||
@@ -428,6 +430,11 @@ void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_HCurve)& HCu,
|
||||
const Standard_Real ParMin,
|
||||
const Standard_Real ParMax)
|
||||
{
|
||||
done = Standard_False;
|
||||
if (!myReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
done = Standard_True;
|
||||
SeqPnt.Clear();
|
||||
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
|
||||
|
@@ -160,6 +160,7 @@ private:
|
||||
IntCurveSurface_SequenceOfPnt SeqPnt;
|
||||
TColStd_SequenceOfInteger mySeqState;
|
||||
Standard_Boolean done;
|
||||
Standard_Boolean myReady;
|
||||
Standard_Integer nbpnt;
|
||||
TopoDS_Face face;
|
||||
Standard_Address PtrOnPolyhedron;
|
||||
|
@@ -34,14 +34,12 @@ static int OSD_OpenFile_iosMode2FileFlags (::std::ios_base::openmode theMode)
|
||||
{
|
||||
aFlags |= O_WRONLY;
|
||||
aFlags |= O_CREAT;
|
||||
aFlags |= O_TRUNC;
|
||||
|
||||
if (theMode & ::std::ios_base::app)
|
||||
{
|
||||
aFlags |= O_APPEND;
|
||||
}
|
||||
if (theMode & ::std::ios_base::trunc)
|
||||
{
|
||||
aFlags |= O_TRUNC;
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (theMode & ::std::ios_base::binary)
|
||||
|
@@ -21,16 +21,11 @@
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
#include <OpenGl_CappingPlaneResource.hxx>
|
||||
#include <OpenGl_Vec.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static const OpenGl_CappingPlaneResource THE_DEFAULT_ASPECT = OpenGl_CappingPlaneResource (new Graphic3d_AspectFillCapping);
|
||||
static const TCollection_AsciiString THE_QUAD_PARRAY = "OpenGl_CappingAlgo_Quad";
|
||||
static const TCollection_AsciiString THE_PLANE_STYLE = "OpenGl_CappingAlgo_CappingStyle_";
|
||||
|
||||
//! Auxiliary sentry object managing stencil test.
|
||||
struct StencilTestSentry
|
||||
{
|
||||
@@ -63,113 +58,21 @@ namespace
|
||||
GLint myDepthFuncPrev;
|
||||
};
|
||||
|
||||
class OpenGl_SharedElement : public OpenGl_Resource
|
||||
{
|
||||
public:
|
||||
OpenGl_SharedElement (OpenGl_Element* theGlElement) : myGlElement (theGlElement) {}
|
||||
virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE
|
||||
{
|
||||
OpenGl_Element::Destroy (theGlCtx, myGlElement);
|
||||
}
|
||||
OpenGl_Element* GlElement() const { return myGlElement; }
|
||||
|
||||
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
|
||||
Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
private:
|
||||
OpenGl_Element* myGlElement;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE (OpenGl_SharedElement, OpenGl_Resource)
|
||||
};
|
||||
|
||||
//! Iitializes and returns vertex buffer for plane section
|
||||
OpenGl_PrimitiveArray* initQuad (const Handle(OpenGl_Context)& theContext)
|
||||
{
|
||||
Handle(OpenGl_SharedElement) aSharedResource;
|
||||
|
||||
if (!theContext->GetResource (THE_QUAD_PARRAY, aSharedResource))
|
||||
{
|
||||
aSharedResource = new OpenGl_SharedElement (OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices());
|
||||
theContext->ShareResource (THE_QUAD_PARRAY, aSharedResource);
|
||||
}
|
||||
|
||||
return dynamic_cast<OpenGl_PrimitiveArray*> (aSharedResource->GlElement());
|
||||
}
|
||||
|
||||
//! Render section plane using the given aspects.
|
||||
void renderSection (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const OpenGl_PrimitiveArray* theQuad,
|
||||
const OpenGl_Aspects* theCappingAspect,
|
||||
const OpenGl_Aspects* theHatchAspect,
|
||||
const OpenGl_Mat4& theCappingMatrix,
|
||||
const Standard_ShortReal theHatchScale,
|
||||
const Standard_ShortReal theHatchRotate)
|
||||
//! Render infinite capping plane.
|
||||
//! @param theWorkspace [in] the GL workspace, context state.
|
||||
//! @param thePlane [in] the graphical plane, for which the capping surface is rendered.
|
||||
static void renderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane)
|
||||
{
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
const bool wasCullAllowed = theWorkspace->SetAllowFaceCulling (true);
|
||||
|
||||
const Standard_Boolean isTextureHatch =
|
||||
theHatchAspect != NULL
|
||||
&& theHatchAspect->Aspect()->TextureMapState();
|
||||
|
||||
// set identity model matrix
|
||||
aContext->ModelWorldState.Push();
|
||||
aContext->ModelWorldState.SetCurrent (theCappingMatrix);
|
||||
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
theWorkspace->SetAspects (theCappingAspect);
|
||||
theWorkspace->ApplyAspects();
|
||||
|
||||
theQuad->Render (theWorkspace);
|
||||
|
||||
if (theHatchAspect != NULL)
|
||||
{
|
||||
Graphic3d_Vec2 aPrevScale;
|
||||
Standard_ShortReal aPrevRotate = 0.0;
|
||||
|
||||
if (isTextureHatch)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if ((theHatchScale != 1.0 || theHatchRotate != 0.0) && !theHatchAspect->TextureSet(aContext)->IsEmpty())
|
||||
{
|
||||
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
|
||||
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
|
||||
|
||||
aPrevScale = aTexParams->Scale();
|
||||
aPrevRotate = aTexParams->Rotation();
|
||||
|
||||
const Standard_Boolean isMirror = aPrevScale.x() * aPrevScale.y() < 0.0;
|
||||
aTexParams->SetScale (aPrevScale * theHatchScale);
|
||||
aTexParams->SetRotation (isMirror ? aPrevRotate - theHatchRotate : aPrevRotate + theHatchRotate);
|
||||
}
|
||||
}
|
||||
|
||||
theWorkspace->SetAspects (theHatchAspect);
|
||||
theWorkspace->ApplyAspects();
|
||||
|
||||
glDepthFunc (GL_LEQUAL);
|
||||
|
||||
theQuad->Render (theWorkspace);
|
||||
|
||||
glDepthFunc (GL_LESS);
|
||||
|
||||
if (isTextureHatch)
|
||||
{
|
||||
glDisable (GL_BLEND);
|
||||
|
||||
if (theHatchScale != 1.0 || theHatchRotate != 0.0)
|
||||
{
|
||||
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
|
||||
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
|
||||
|
||||
aTexParams->SetScale (aPrevScale);
|
||||
aTexParams->SetRotation (aPrevRotate);
|
||||
}
|
||||
}
|
||||
}
|
||||
thePlane->Primitives().Render (theWorkspace);
|
||||
|
||||
aContext->ModelWorldState.Pop();
|
||||
aContext->ApplyModelViewMatrix();
|
||||
@@ -183,23 +86,13 @@ namespace
|
||||
const OpenGl_Structure& theStructure,
|
||||
const Handle(Graphic3d_ClipPlane)& theClipChain,
|
||||
const Standard_Integer theSubPlaneIndex,
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane,
|
||||
const OpenGl_PrimitiveArray* theQuad)
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane)
|
||||
{
|
||||
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
|
||||
const Standard_Integer anAnyFilter = aPrevFilter & ~(Standard_Integer )(OpenGl_RenderFilter_OpaqueOnly | OpenGl_RenderFilter_TransparentOnly);
|
||||
|
||||
const Handle(Graphic3d_ClipPlane)& aPlane = theClipChain;
|
||||
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
const Handle(Graphic3d_Camera) aCamera = theWorkspace->View() != NULL
|
||||
? theWorkspace->View()->Camera()
|
||||
: Handle(Graphic3d_Camera)();
|
||||
const OpenGl_Mat4& aPlaneMat = OpenGl_Mat4::Map (aPlane->OrientationMatrix());
|
||||
Standard_ShortReal aRotateAngle = 0.0;
|
||||
Standard_ShortReal aViewScale = ShortRealLast();
|
||||
OpenGl_Mat4 aRotateZoomMat;
|
||||
|
||||
const Handle(Graphic3d_ClipPlane)& aRenderPlane = thePlane->Plane();
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
if (!aGroupIter.Value()->IsClosed())
|
||||
@@ -210,6 +103,16 @@ namespace
|
||||
// clear stencil only if something has been actually drawn
|
||||
theStencilSentry.Init();
|
||||
|
||||
// check if capping plane should be rendered within current pass (only opaque / only transparent)
|
||||
const OpenGl_Aspects* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->GlAspects() : NULL;
|
||||
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_Aspects)());
|
||||
theWorkspace->SetAspects (thePlane->AspectFace());
|
||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// suppress only opaque/transparent filter since for filling stencil the whole geometry should be drawn
|
||||
theWorkspace->SetRenderFilter (anAnyFilter);
|
||||
|
||||
@@ -218,7 +121,7 @@ namespace
|
||||
aContext->ShaderManager()->UpdateClippingState();
|
||||
|
||||
glClear (GL_STENCIL_BUFFER_BIT);
|
||||
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
const bool aColorMaskBack = aContext->SetColorMask (false);
|
||||
|
||||
// override aspects, disable culling
|
||||
theWorkspace->SetAspects (&theWorkspace->NoneCulling());
|
||||
@@ -237,7 +140,20 @@ namespace
|
||||
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
|
||||
|
||||
// render closed primitives
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
if (aRenderPlane->ToUseObjectProperties())
|
||||
{
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
if (aGroupIter.Value()->IsClosed())
|
||||
{
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// override material, cull back faces
|
||||
theWorkspace->SetAspects (&theWorkspace->FrontCulling());
|
||||
@@ -248,7 +164,7 @@ namespace
|
||||
aContext->ShaderManager()->UpdateClippingState();
|
||||
|
||||
// render capping plane using the generated stencil mask
|
||||
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
aContext->SetColorMask (aColorMaskBack);
|
||||
if (theWorkspace->UseDepthWrite())
|
||||
{
|
||||
glDepthMask (GL_TRUE);
|
||||
@@ -260,66 +176,8 @@ namespace
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
const OpenGl_Aspects* aGroupAspectFace = aGroupIter.Value()->GlAspects();
|
||||
const OpenGl_CappingPlaneResource* aGroupAspectCapping = aGroupIter.Value()->AspectFillCapping();
|
||||
const OpenGl_CappingPlaneResource* anAspectCapping =
|
||||
thePlane && (!aGroupAspectCapping || aGroupAspectCapping->Aspect().IsNull() || aPlane->ToOverrideCappingAspect())
|
||||
? thePlane.get()
|
||||
: aGroupAspectCapping;
|
||||
|
||||
if (anAspectCapping == NULL)
|
||||
{
|
||||
anAspectCapping = &THE_DEFAULT_ASPECT;
|
||||
}
|
||||
|
||||
const OpenGl_Aspects* anAspectFace = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
|
||||
const Standard_Boolean hasHatch = anAspectCapping->Aspect()->ToDrawHatch();
|
||||
const OpenGl_Aspects* anAspectHatching = hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL;
|
||||
const Standard_Boolean hasTextureHatch = hasHatch && !anAspectCapping->Aspect()->TextureHatch().IsNull();
|
||||
const Standard_Boolean isRotatePers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchRotationPersistent();
|
||||
const Standard_Boolean isZoomPers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchZoomPersistent();
|
||||
|
||||
Standard_ShortReal aHatchScale = 1.0;
|
||||
Standard_ShortReal aHatchAngle = 0.0;
|
||||
|
||||
if (isRotatePers || isZoomPers)
|
||||
{
|
||||
|
||||
if (isRotatePers)
|
||||
{
|
||||
if (aRotateAngle == 0.0)
|
||||
{
|
||||
const gp_Dir aPlaneSide (aPlaneMat.GetValue (0, 0), aPlaneMat.GetValue (1, 0), aPlaneMat.GetValue (2, 0));
|
||||
const gp_Dir aPlaneUp (aPlaneMat.GetValue (0, 2), aPlaneMat.GetValue (1, 2), aPlaneMat.GetValue (2, 2));
|
||||
const gp_Dir& aCameraUp = aCamera->Up();
|
||||
const gp_Vec aCameraPln = aPlaneSide.Dot (aCameraUp) * aPlaneSide + aPlaneUp.Dot (aCameraUp) * aPlaneUp;
|
||||
const gp_Dir& aCameraDir = aCamera->Direction();
|
||||
aRotateAngle = static_cast<Standard_ShortReal> (aCameraPln.AngleWithRef (aPlaneUp, aCameraDir) / M_PI * 180.0);
|
||||
}
|
||||
|
||||
aHatchAngle = aRotateAngle;
|
||||
}
|
||||
|
||||
if (isZoomPers)
|
||||
{
|
||||
if (aViewScale == ShortRealLast())
|
||||
{
|
||||
const Standard_Real aFocus = aCamera->IsOrthographic()
|
||||
? aCamera->Distance()
|
||||
: (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
|
||||
? Standard_Real(aCamera->ZFocus() * aCamera->Distance())
|
||||
: Standard_Real(aCamera->ZFocus()));
|
||||
|
||||
const gp_XYZ aViewDim = aCamera->ViewDimensions (aFocus);
|
||||
aViewScale = static_cast<Standard_ShortReal> (aViewDim.Y() / aContext->Viewport()[3]);
|
||||
}
|
||||
|
||||
if (!anAspectHatching->TextureSet(aContext)->IsEmpty())
|
||||
aHatchScale = 1.0f / (aViewScale * anAspectHatching->TextureSet(aContext)->First()->SizeY());
|
||||
}
|
||||
}
|
||||
|
||||
renderSection (theWorkspace, theQuad, anAspectFace, hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL, aPlaneMat, aHatchScale, aHatchAngle);
|
||||
theWorkspace->SetAspects (thePlane->AspectFace());
|
||||
renderPlane (theWorkspace, thePlane);
|
||||
|
||||
// turn on the current plane to restore initial state
|
||||
aContext->ChangeClipping().ResetCappingFilter();
|
||||
@@ -329,7 +187,7 @@ namespace
|
||||
|
||||
if (theStructure.InstancedStructure() != NULL)
|
||||
{
|
||||
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane, theQuad);
|
||||
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,12 +206,6 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
return;
|
||||
}
|
||||
|
||||
const OpenGl_PrimitiveArray* aCappingQuad = initQuad (aContext);
|
||||
if (!aCappingQuad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// remember current aspect face defined in workspace
|
||||
const OpenGl_Aspects* aFaceAsp = theWorkspace->Aspects();
|
||||
|
||||
@@ -362,16 +214,6 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
theWorkspace->SetRenderFilter (aPrevFilter | OpenGl_RenderFilter_FillModeOnly);
|
||||
StencilTestSentry aStencilSentry;
|
||||
|
||||
GLboolean aPrevBlend = glIsEnabled (GL_BLEND);
|
||||
GLint aPrevBlendSrc = GL_ONE;
|
||||
GLint aPrevBlendDst = GL_ZERO;
|
||||
if (aPrevBlend == GL_TRUE)
|
||||
{
|
||||
glGetIntegerv (GL_BLEND_SRC_ALPHA, &aPrevBlendSrc);
|
||||
glGetIntegerv (GL_BLEND_DST_ALPHA, &aPrevBlendDst);
|
||||
glDisable (GL_BLEND);
|
||||
}
|
||||
|
||||
// generate capping for every clip plane
|
||||
for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next())
|
||||
{
|
||||
@@ -387,33 +229,23 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipChain.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get(), ++aSubPlaneIndex)
|
||||
{
|
||||
// get resource for the plane
|
||||
const TCollection_AsciiString& aResId = THE_PLANE_STYLE + aSubPlaneIter->GetId();
|
||||
const TCollection_AsciiString& aResId = aSubPlaneIter->GetId();
|
||||
Handle(OpenGl_CappingPlaneResource) aPlaneRes;
|
||||
if (!aContext->GetResource (aResId, aPlaneRes))
|
||||
{
|
||||
// share and register for release once the resource is no longer used
|
||||
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter->CappingSectionStyle());
|
||||
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter);
|
||||
aContext->ShareResource (aResId, aPlaneRes);
|
||||
}
|
||||
|
||||
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes, aCappingQuad);
|
||||
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes);
|
||||
|
||||
// set delayed resource release
|
||||
aPlaneRes.Nullify();
|
||||
if (!aResId.IsEmpty())
|
||||
{
|
||||
// schedule release of resource if not used
|
||||
aContext->ReleaseResource (aResId, Standard_True);
|
||||
}
|
||||
aContext->ReleaseResource (aResId, Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
if (aPrevBlend == GL_TRUE)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (aPrevBlendSrc, aPrevBlendDst);
|
||||
}
|
||||
|
||||
// restore rendering aspects
|
||||
theWorkspace->SetAspects (aFaceAsp);
|
||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||
|
@@ -56,28 +56,21 @@ namespace
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f } }
|
||||
};
|
||||
|
||||
Handle(Graphic3d_Aspects) defaultMaterial()
|
||||
{
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect;
|
||||
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
|
||||
anAspect = new Graphic3d_AspectFillArea3d();
|
||||
anAspect->SetDistinguishOff();
|
||||
anAspect->SetFrontMaterial (aMaterial);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetInteriorColor (aMaterial.Color());
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
return anAspect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : BuildInfinitPlaneVertices
|
||||
// function : OpenGl_CappingPlaneResource
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
|
||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||
: myPrimitives (NULL),
|
||||
myOrientation (OpenGl_IdentityMatrix),
|
||||
myAspect (NULL),
|
||||
myPlaneRoot (thePlane),
|
||||
myEquationMod ((unsigned int )-1),
|
||||
myAspectMod ((unsigned int )-1)
|
||||
{
|
||||
OpenGl_PrimitiveArray* aPrimitives = NULL;
|
||||
// Fill primitive array
|
||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
|
||||
@@ -90,26 +83,8 @@ OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
|
||||
if (anAttribs->Init (12, anAttribInfo, 3))
|
||||
{
|
||||
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
|
||||
|
||||
aPrimitives = new OpenGl_PrimitiveArray (NULL);
|
||||
aPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
}
|
||||
return aPrimitives;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_CappingPlaneResource
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect)
|
||||
: myCappingAspect(),//defaultMaterial()),
|
||||
myHatchingAspect(),//defaultMaterial()),
|
||||
myHatchingState (0)
|
||||
{
|
||||
myCappingAspect.SetAspect (defaultMaterial());
|
||||
myHatchingAspect.SetAspect (defaultMaterial());
|
||||
|
||||
SetAspect (theAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -118,83 +93,18 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
|
||||
{
|
||||
Release (NULL);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetAspect
|
||||
// function : Update
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
|
||||
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_Aspects)& theObjAspect)
|
||||
{
|
||||
myAspect = theAspect;
|
||||
|
||||
if (theAspect.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectMaterial()
|
||||
|| !theAspect->ToUseObjectTexture()
|
||||
|| !theAspect->ToUseObjectShader())
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myCappingAspect.Aspect();
|
||||
|
||||
if (!theAspect->ToUseObjectMaterial())
|
||||
{
|
||||
aFillAspect->SetFrontMaterial (theAspect->Material());
|
||||
aFillAspect->SetInteriorColor (theAspect->Material().Color());
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectTexture())
|
||||
{
|
||||
aFillAspect->SetTextureMap (theAspect->Texture());
|
||||
|
||||
if (!theAspect->Texture().IsNull())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMap (Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectShader())
|
||||
{
|
||||
aFillAspect->SetShaderProgram (theAspect->Shader());
|
||||
}
|
||||
|
||||
myCappingAspect.SetAspect (aFillAspect);
|
||||
}
|
||||
|
||||
if (theAspect->ToDrawHatch()
|
||||
&& (theAspect->IsTextureHatch()
|
||||
|| theAspect->IsStippleHatch()))
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myHatchingAspect.Aspect();
|
||||
|
||||
aFillAspect->SetInteriorStyle (theAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
|
||||
aFillAspect->SetHatchStyle (theAspect->IsStippleHatch() ? theAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
|
||||
aFillAspect->SetTextureMap (theAspect->IsTextureHatch() ? theAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetFrontMaterial (theAspect->HatchMaterial());
|
||||
aFillAspect->SetInteriorColor (theAspect->HatchMaterial().Color());
|
||||
if (theAspect->IsTextureHatch())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
|
||||
myHatchingAspect.SetAspect (aFillAspect);
|
||||
myHatchingState = theAspect->HatchingState();
|
||||
}
|
||||
updateTransform (theCtx);
|
||||
updateAspect (theObjAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -203,109 +113,123 @@ void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCa
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
||||
{
|
||||
myCappingAspect .Release (theContext);
|
||||
myHatchingAspect.Release (theContext);
|
||||
OpenGl_Element::Destroy (theContext, myAspect);
|
||||
myPrimitives.Release (theContext);
|
||||
myEquationMod = (unsigned int )-1;
|
||||
myAspectMod = (unsigned int )-1;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : CappingFaceAspect
|
||||
// function : updateAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const OpenGl_Aspects* OpenGl_CappingPlaneResource::CappingFaceAspect (const OpenGl_Aspects* theObjectAspect) const
|
||||
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect)
|
||||
{
|
||||
if (myAspect.IsNull())
|
||||
if (myAspect == NULL)
|
||||
{
|
||||
return NULL;
|
||||
myAspect = new OpenGl_Aspects();
|
||||
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
|
||||
}
|
||||
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myCappingAspect.Aspect();
|
||||
if (theObjAspect.IsNull())
|
||||
{
|
||||
if (myAspectMod != myPlaneRoot->MCountAspect())
|
||||
{
|
||||
myAspect->SetAspect (myPlaneRoot->CappingAspect());
|
||||
myAspectMod = myPlaneRoot->MCountAspect();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspect->ToUseObjectMaterial() && theObjectAspect != NULL)
|
||||
if (myFillAreaAspect.IsNull())
|
||||
{
|
||||
myFillAreaAspect = new Graphic3d_AspectFillArea3d();
|
||||
}
|
||||
if (myAspectMod != myPlaneRoot->MCountAspect())
|
||||
{
|
||||
*myFillAreaAspect = *myPlaneRoot->CappingAspect();
|
||||
}
|
||||
|
||||
if (myPlaneRoot->ToUseObjectMaterial())
|
||||
{
|
||||
// only front material currently supported by capping rendering
|
||||
aFillAspect->SetFrontMaterial (theObjectAspect->Aspect()->FrontMaterial());
|
||||
aFillAspect->SetInteriorColor (theObjectAspect->Aspect()->InteriorColor());
|
||||
myFillAreaAspect->SetFrontMaterial (theObjAspect->FrontMaterial());
|
||||
myFillAreaAspect->SetInteriorColor (theObjAspect->InteriorColor());
|
||||
}
|
||||
else
|
||||
if (myPlaneRoot->ToUseObjectTexture())
|
||||
{
|
||||
aFillAspect->SetFrontMaterial (myAspect->Material());
|
||||
aFillAspect->SetInteriorColor (myAspect->Material().Color());
|
||||
}
|
||||
|
||||
if (myAspect->ToUseObjectTexture() && theObjectAspect != NULL)
|
||||
{
|
||||
if (theObjectAspect->Aspect()->ToMapTexture())
|
||||
myFillAreaAspect->SetTextureSet (theObjAspect->TextureSet());
|
||||
if (theObjAspect->ToMapTexture())
|
||||
{
|
||||
aFillAspect->SetTextureMap (theObjectAspect->Aspect()->TextureMap());
|
||||
aFillAspect->SetTextureMapOn();
|
||||
myFillAreaAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
myFillAreaAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
else
|
||||
if (myPlaneRoot->ToUseObjectShader())
|
||||
{
|
||||
aFillAspect->SetTextureMap (myAspect->Texture());
|
||||
if (!myAspect->Texture().IsNull())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
myFillAreaAspect->SetShaderProgram (theObjAspect->ShaderProgram());
|
||||
}
|
||||
|
||||
if (myAspect->ToUseObjectShader() && theObjectAspect != NULL)
|
||||
{
|
||||
aFillAspect->SetShaderProgram (theObjectAspect->Aspect()->ShaderProgram());
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetShaderProgram (myAspect->Shader());
|
||||
}
|
||||
|
||||
myCappingAspect.SetAspect (aFillAspect);
|
||||
|
||||
return &myCappingAspect;
|
||||
myAspect->SetAspect (myFillAreaAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HatchingFaceAspect
|
||||
// function : updateTransform
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const OpenGl_Aspects* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
|
||||
void OpenGl_CappingPlaneResource::updateTransform (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
if (myAspect.IsNull())
|
||||
if (myEquationMod == myPlaneRoot->MCountEquation()
|
||||
&& myLocalOrigin.IsEqual (theCtx->ShaderManager()->LocalOrigin(), gp::Resolution()))
|
||||
{
|
||||
return NULL;
|
||||
return; // nothing to update
|
||||
}
|
||||
|
||||
const Standard_Size aHatchingState = myAspect->HatchingState();
|
||||
if (myHatchingState != aHatchingState)
|
||||
{
|
||||
if (myAspect->ToDrawHatch())
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myHatchingAspect.Aspect();
|
||||
myEquationMod = myPlaneRoot->MCountEquation();
|
||||
myLocalOrigin = theCtx->ShaderManager()->LocalOrigin();
|
||||
|
||||
aFillAspect->SetInteriorStyle (myAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
|
||||
aFillAspect->SetHatchStyle (myAspect->IsStippleHatch() ? myAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
|
||||
aFillAspect->SetTextureMap (myAspect->IsTextureHatch() ? myAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetFrontMaterial (myAspect->HatchMaterial());
|
||||
aFillAspect->SetInteriorColor (myAspect->HatchMaterial().Color());
|
||||
if (myAspect->IsTextureHatch())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
myHatchingAspect.SetAspect (aFillAspect);
|
||||
myHatchingState = aHatchingState;
|
||||
}
|
||||
const Graphic3d_ClipPlane::Equation& anEq = myPlaneRoot->GetEquation();
|
||||
const Standard_Real anEqW = theCtx->ShaderManager()->LocalClippingPlaneW (*myPlaneRoot);
|
||||
|
||||
// re-evaluate infinite plane transformation matrix
|
||||
const Graphic3d_Vec3 aNorm (anEq.xyz());
|
||||
const Graphic3d_Vec3 T (anEq.xyz() * -anEqW);
|
||||
|
||||
// project plane normal onto OX to find left vector
|
||||
const Standard_ShortReal aProjLen = sqrt ((Standard_ShortReal)anEq.xz().SquareModulus());
|
||||
Graphic3d_Vec3 aLeft;
|
||||
if (aProjLen < ShortRealSmall())
|
||||
{
|
||||
aLeft[0] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
aLeft[0] = aNorm[2] / aProjLen;
|
||||
aLeft[2] = -aNorm[0] / aProjLen;
|
||||
}
|
||||
|
||||
return &myHatchingAspect;
|
||||
const Graphic3d_Vec3 F = Graphic3d_Vec3::Cross (-aLeft, aNorm);
|
||||
|
||||
myOrientation.mat[0][0] = aLeft[0];
|
||||
myOrientation.mat[0][1] = aLeft[1];
|
||||
myOrientation.mat[0][2] = aLeft[2];
|
||||
myOrientation.mat[0][3] = 0.0f;
|
||||
|
||||
myOrientation.mat[1][0] = aNorm[0];
|
||||
myOrientation.mat[1][1] = aNorm[1];
|
||||
myOrientation.mat[1][2] = aNorm[2];
|
||||
myOrientation.mat[1][3] = 0.0f;
|
||||
|
||||
myOrientation.mat[2][0] = F[0];
|
||||
myOrientation.mat[2][1] = F[1];
|
||||
myOrientation.mat[2][2] = F[2];
|
||||
myOrientation.mat[2][3] = 0.0f;
|
||||
|
||||
myOrientation.mat[3][0] = T[0];
|
||||
myOrientation.mat[3][1] = T[1];
|
||||
myOrientation.mat[3][2] = T[2];
|
||||
myOrientation.mat[3][3] = 1.0f;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <OpenGl_Resource.hxx>
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <OpenGl_Matrix.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_ClipPlane.hxx>
|
||||
|
||||
class OpenGl_CappingPlaneResource;
|
||||
DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
|
||||
@@ -30,23 +30,25 @@ DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
|
||||
//! This resource holds data necessary for OpenGl_CappingAlgo.
|
||||
//! This object is implemented as OpenGl resource for the following reasons:
|
||||
//! - one instance should be shared between contexts.
|
||||
//! - instance associated to Graphic3d_AspectFillCapping data.
|
||||
//! - instance associated to Graphic3d_ClipPlane data by id.
|
||||
//! - should created and released within context (owns OpenGl elements and resources).
|
||||
class OpenGl_CappingPlaneResource : public OpenGl_Resource
|
||||
{
|
||||
public:
|
||||
|
||||
//! Create and assign style.
|
||||
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect);
|
||||
//! Constructor.
|
||||
//! Create capping plane presentation associated to clipping plane data.
|
||||
//! @param thePlane [in] the plane data.
|
||||
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane);
|
||||
|
||||
//! Destroy object.
|
||||
Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
|
||||
|
||||
//! Assign section style.
|
||||
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect);
|
||||
|
||||
//! Returns section style parameters.
|
||||
const Handle(Graphic3d_AspectFillCapping)& Aspect() const { return myAspect; }
|
||||
//! Update resource data in the passed context.
|
||||
//! @param theContext [in] the context
|
||||
//! @param theObjAspect [in] object aspect
|
||||
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
|
||||
const Handle(Graphic3d_Aspects)& theObjAspect);
|
||||
|
||||
//! Release associated OpenGl resources.
|
||||
//! @param theContext [in] the resource context.
|
||||
@@ -55,23 +57,17 @@ public:
|
||||
//! Returns estimated GPU memory usage - not implemented.
|
||||
virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
//! Return parent clipping plane structure.
|
||||
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
|
||||
|
||||
//! @return aspect face for rendering capping surface.
|
||||
inline const OpenGl_Aspects* AspectFace() const { return myAspect; }
|
||||
|
||||
//! @return evaluated orientation matrix to transform infinite plane.
|
||||
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
|
||||
|
||||
//! @return primitive array of vertices to render infinite plane.
|
||||
static OpenGl_PrimitiveArray* BuildInfinitPlaneVertices();
|
||||
|
||||
//! Returns true if capping should draw hatch layer.
|
||||
Standard_Boolean ToDrawHatch() const
|
||||
{
|
||||
return myAspect->ToDrawHatch()
|
||||
&& (myAspect->IsStippleHatch()
|
||||
|| myAspect->IsTextureHatch());
|
||||
}
|
||||
|
||||
//! Returns the shading aspect for drawing face of a clipping section itself.
|
||||
//! @param theObjectAspect [in] the aspect of an object if it requires combining.
|
||||
Standard_EXPORT const OpenGl_Aspects* CappingFaceAspect (const OpenGl_Aspects* theObjectAspect) const;
|
||||
|
||||
//! Returns the shading aspect for drawing hatch layer of a section.
|
||||
Standard_EXPORT const OpenGl_Aspects* HatchingFaceAspect() const;
|
||||
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -83,11 +79,14 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
Handle(Graphic3d_AspectFillCapping) myAspect; //!< Section style settings from application's level.
|
||||
mutable OpenGl_Aspects myCappingAspect; //!< GL aspect for shading base layer of a capping section.
|
||||
mutable OpenGl_Aspects myHatchingAspect; //!< GL aspect for shading hatching layer (additional to base) of a capping section.
|
||||
mutable Standard_Size myHatchingState;
|
||||
gp_XYZ myLocalOrigin; //!< layer origin
|
||||
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
|
||||
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
|
||||
OpenGl_Aspects* myAspect; //!< capping face aspect.
|
||||
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
|
||||
Handle(Graphic3d_Aspects) myFillAreaAspect;//!< own capping aspect
|
||||
gp_XYZ myLocalOrigin; //!< layer origin
|
||||
unsigned int myEquationMod; //!< modification counter for plane equation.
|
||||
unsigned int myAspectMod; //!< modification counter for aspect.
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -51,6 +51,9 @@ OpenGl_Caps::OpenGl_Caps()
|
||||
#else
|
||||
contextCompatible (Standard_False),
|
||||
#endif
|
||||
contextNoExtensions (Standard_False),
|
||||
contextMajorVersionUpper (-1),
|
||||
contextMinorVersionUpper (-1),
|
||||
glslWarnings (Standard_False),
|
||||
suppressExtraMsg (Standard_True),
|
||||
glslDumpLevel (OpenGl_ShaderProgramDumpLevel_Off)
|
||||
@@ -76,6 +79,9 @@ OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy)
|
||||
contextSyncDebug = theCopy.contextSyncDebug;
|
||||
contextNoAccel = theCopy.contextNoAccel;
|
||||
contextCompatible = theCopy.contextCompatible;
|
||||
contextNoExtensions = theCopy.contextNoExtensions;
|
||||
contextMajorVersionUpper = theCopy.contextMajorVersionUpper;
|
||||
contextMinorVersionUpper = theCopy.contextMinorVersionUpper;
|
||||
glslWarnings = theCopy.glslWarnings;
|
||||
suppressExtraMsg = theCopy.suppressExtraMsg;
|
||||
glslDumpLevel = theCopy.glslDumpLevel;
|
||||
|
@@ -107,6 +107,23 @@ public: //! @name context creation parameters
|
||||
*/
|
||||
Standard_Boolean contextCompatible;
|
||||
|
||||
/**
|
||||
* Disallow using OpenGL extensions.
|
||||
* Should be used for debugging purposes only!
|
||||
*
|
||||
* OFF by default.
|
||||
*/
|
||||
Standard_Boolean contextNoExtensions;
|
||||
|
||||
/**
|
||||
* Synthetically restrict upper version of OpenGL functionality to be used.
|
||||
* Should be used for debugging purposes only!
|
||||
*
|
||||
* (-1, -1) by default, which means no restriction.
|
||||
*/
|
||||
Standard_Integer contextMajorVersionUpper;
|
||||
Standard_Integer contextMinorVersionUpper;
|
||||
|
||||
public: //! @name flags to activate verbose output
|
||||
|
||||
//! Print GLSL program compilation/linkage warnings, if any. OFF by default.
|
||||
|
@@ -123,6 +123,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
hasTexRGBA8(Standard_True),
|
||||
hasFlatShading (OpenGl_FeatureInCore),
|
||||
#endif
|
||||
hasGlslBitwiseOps (OpenGl_FeatureNotAvailable),
|
||||
hasDrawBuffers (OpenGl_FeatureNotAvailable),
|
||||
hasFloatBuffer (OpenGl_FeatureNotAvailable),
|
||||
hasHalfFloatBuffer (OpenGl_FeatureNotAvailable),
|
||||
@@ -749,6 +750,10 @@ Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const
|
||||
#endif
|
||||
return Standard_False;
|
||||
}
|
||||
else if (caps->contextNoExtensions)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// available since OpenGL 3.0
|
||||
@@ -1217,6 +1222,44 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
ReadGlVersion (myGlVerMajor, myGlVerMinor);
|
||||
myVendor = (const char* )::glGetString (GL_VENDOR);
|
||||
myVendor.LowerCase();
|
||||
|
||||
if (caps->contextMajorVersionUpper != -1)
|
||||
{
|
||||
// synthetically restrict OpenGL version for testing
|
||||
Standard_Integer aCtxVer[2] = { myGlVerMajor, myGlVerMinor };
|
||||
bool isLowered = false;
|
||||
if (myGlVerMajor > caps->contextMajorVersionUpper)
|
||||
{
|
||||
isLowered = true;
|
||||
myGlVerMajor = caps->contextMajorVersionUpper;
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
switch (myGlVerMajor)
|
||||
{
|
||||
case 2: myGlVerMinor = 0; break;
|
||||
}
|
||||
#else
|
||||
switch (myGlVerMajor)
|
||||
{
|
||||
case 1: myGlVerMinor = 5; break;
|
||||
case 2: myGlVerMinor = 1; break;
|
||||
case 3: myGlVerMinor = 3; break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (caps->contextMinorVersionUpper != -1
|
||||
&& myGlVerMinor > caps->contextMinorVersionUpper)
|
||||
{
|
||||
isLowered = true;
|
||||
myGlVerMinor = caps->contextMinorVersionUpper;
|
||||
}
|
||||
if (isLowered)
|
||||
{
|
||||
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_MEDIUM,
|
||||
TCollection_AsciiString ("OpenGL version ") + aCtxVer[0] + "." + aCtxVer[1]
|
||||
+ " has been lowered to " + myGlVerMajor + "." + myGlVerMinor);
|
||||
}
|
||||
}
|
||||
|
||||
if (!caps->ffpEnable
|
||||
&& !IsGlGreaterEqual (2, 0))
|
||||
{
|
||||
@@ -1436,6 +1479,9 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
hasSampleVariables = IsGlGreaterEqual (3, 2) ? OpenGl_FeatureInCore :
|
||||
oesSampleVariables ? OpenGl_FeatureInExtensions
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
hasGlslBitwiseOps = IsGlGreaterEqual (3, 0)
|
||||
? OpenGl_FeatureInCore
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
// without hasHighp, dFdx/dFdy precision is considered too low for flat shading (visual artifacts)
|
||||
hasFlatShading = IsGlGreaterEqual (3, 0)
|
||||
? OpenGl_FeatureInCore
|
||||
@@ -1474,6 +1520,12 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
arbDrawBuffers ? OpenGl_FeatureInExtensions
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
|
||||
hasGlslBitwiseOps = IsGlGreaterEqual (3, 0)
|
||||
? OpenGl_FeatureInCore
|
||||
: CheckExtension ("GL_EXT_gpu_shader4")
|
||||
? OpenGl_FeatureInExtensions
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
|
||||
hasFloatBuffer = hasHalfFloatBuffer = IsGlGreaterEqual (3, 0) ? OpenGl_FeatureInCore :
|
||||
CheckExtension ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
|
||||
: OpenGl_FeatureNotAvailable;
|
||||
@@ -2989,9 +3041,16 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString
|
||||
|
||||
if ((theFlags & Graphic3d_DiagnosticInfo_Device) != 0)
|
||||
{
|
||||
Standard_Integer aDriverVer[2] = {};
|
||||
ReadGlVersion (aDriverVer[0], aDriverVer[1]);
|
||||
addInfo (theDict, "GLvendor", (const char*)::glGetString (GL_VENDOR));
|
||||
addInfo (theDict, "GLdevice", (const char*)::glGetString (GL_RENDERER));
|
||||
addInfo (theDict, "GLversion", (const char*)::glGetString (GL_VERSION));
|
||||
if (myGlVerMajor != aDriverVer[0]
|
||||
|| myGlVerMinor != aDriverVer[1])
|
||||
{
|
||||
addInfo (theDict, "GLversionOcct", TCollection_AsciiString (myGlVerMajor) + "." + TCollection_AsciiString (myGlVerMinor));
|
||||
}
|
||||
if (IsGlGreaterEqual (2, 0))
|
||||
{
|
||||
addInfo (theDict, "GLSLversion", (const char*)::glGetString (GL_SHADING_LANGUAGE_VERSION));
|
||||
@@ -3496,8 +3555,23 @@ void OpenGl_Context::SetTypeOfLine (const Aspect_TypeOfLine theType,
|
||||
|
||||
if (!myActiveProgram.IsNull())
|
||||
{
|
||||
myActiveProgram->SetUniform (this, "uPattern", aPattern);
|
||||
myActiveProgram->SetUniform (this, "uFactor", theFactor);
|
||||
if (const OpenGl_ShaderUniformLocation aPatternLoc = myActiveProgram->GetStateLocation (OpenGl_OCCT_LINE_STIPPLE_PATTERN))
|
||||
{
|
||||
if (hasGlslBitwiseOps != OpenGl_FeatureNotAvailable)
|
||||
{
|
||||
myActiveProgram->SetUniform (this, aPatternLoc, aPattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_Integer aPatArr[16] = {};
|
||||
for (unsigned int aBit = 0; aBit < 16; ++aBit)
|
||||
{
|
||||
aPatArr[aBit] = ((unsigned int)(aPattern) & (1U << aBit)) != 0 ? 1 : 0;
|
||||
}
|
||||
myActiveProgram->SetUniform (this, aPatternLoc, 16, aPatArr);
|
||||
}
|
||||
myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_LINE_STIPPLE_FACTOR), theFactor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -889,6 +889,7 @@ public: //! @name extensions
|
||||
Standard_Boolean hasUintIndex; //!< GLuint for index buffer is supported (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_element_index_uint)
|
||||
Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
|
||||
OpenGl_FeatureFlag hasFlatShading; //!< Complex flag indicating support of Flat shading (Graphic3d_TOSM_FACET) (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives)
|
||||
OpenGl_FeatureFlag hasGlslBitwiseOps; //!< GLSL supports bitwise operations; OpenGL 3.0 / OpenGL ES 3.0 (GLSL 130 / GLSL ES 300) or OpenGL 2.1 + GL_EXT_gpu_shader4
|
||||
OpenGl_FeatureFlag hasDrawBuffers; //!< Complex flag indicating support of multiple draw buffers (desktop OpenGL 2.0, OpenGL ES 3.0, GL_ARB_draw_buffers, GL_EXT_draw_buffers)
|
||||
OpenGl_FeatureFlag hasFloatBuffer; //!< Complex flag indicating support of float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_float)
|
||||
OpenGl_FeatureFlag hasHalfFloatBuffer; //!< Complex flag indicating support of half-float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_half_float)
|
||||
|
@@ -103,7 +103,7 @@ void OpenGl_FrameStats::updateStatistics (const Handle(Graphic3d_CView)& theView
|
||||
|| (aBits & Graphic3d_RenderingParams::PerfCounters_Layers) != 0)
|
||||
{
|
||||
const Standard_Integer aViewId = aView->Identification();
|
||||
for (OpenGl_SequenceOfLayers::Iterator aLayerIter (aView->LayerList().Layers()); aLayerIter.More(); aLayerIter.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (aView->LayerList().Layers()); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
const Handle(OpenGl_Layer)& aLayer = aLayerIter.Value();
|
||||
myCountersTmp[Graphic3d_FrameStatsCounter_NbStructs] += aLayer->NbStructures();
|
||||
|
@@ -303,7 +303,10 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext()
|
||||
::Message::DefaultMessenger()->Send ("Error: EGL does not provide OpenGL ES client!", Message_Fail);
|
||||
return Standard_False;
|
||||
}
|
||||
myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs3);
|
||||
if (myCaps->contextMajorVersionUpper != 2)
|
||||
{
|
||||
myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs3);
|
||||
}
|
||||
if ((EGLContext )myEglContext == EGL_NO_CONTEXT)
|
||||
{
|
||||
myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs2);
|
||||
@@ -526,29 +529,36 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddZLayer
|
||||
//function : InsertLayerBefore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_GraphicDriver::AddZLayer (const Graphic3d_ZLayerId theLayerId)
|
||||
void OpenGl_GraphicDriver::InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter)
|
||||
{
|
||||
if (theLayerId < 1)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theLayerId > 0,
|
||||
"OpenGl_GraphicDriver::AddZLayer, "
|
||||
"negative and zero IDs are reserved");
|
||||
}
|
||||
|
||||
myLayerIds.Add (theLayerId);
|
||||
|
||||
// Default z-layer settings
|
||||
myMapOfZLayerSettings.Bind (theLayerId, Graphic3d_ZLayerSettings());
|
||||
addZLayerIndex (theLayerId);
|
||||
base_type::InsertLayerBefore (theLayerId, theSettings, theLayerAfter);
|
||||
|
||||
// Add layer to all views
|
||||
NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView);
|
||||
for (; aViewIt.More(); aViewIt.Next())
|
||||
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView); aViewIt.More(); aViewIt.Next())
|
||||
{
|
||||
aViewIt.Value()->AddZLayer (theLayerId);
|
||||
aViewIt.Value()->InsertLayerBefore (theLayerId, theSettings, theLayerAfter);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InsertLayerAfter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_GraphicDriver::InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore)
|
||||
{
|
||||
base_type::InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
|
||||
|
||||
// Add layer to all views
|
||||
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView); aViewIt.More(); aViewIt.Next())
|
||||
{
|
||||
aViewIt.Value()->InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -558,43 +568,21 @@ void OpenGl_GraphicDriver::AddZLayer (const Graphic3d_ZLayerId theLayerId)
|
||||
//=======================================================================
|
||||
void OpenGl_GraphicDriver::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
|
||||
{
|
||||
Standard_ASSERT_RAISE (theLayerId > 0,
|
||||
"OpenGl_GraphicDriver::AddZLayer, "
|
||||
"negative and zero IDs are reserved"
|
||||
"and can not be removed");
|
||||
|
||||
Standard_ASSERT_RAISE (myLayerIds.Contains (theLayerId),
|
||||
"OpenGl_GraphicDriver::RemoveZLayer, "
|
||||
"Layer with theLayerId does not exist");
|
||||
base_type::RemoveZLayer (theLayerId);
|
||||
|
||||
// Remove layer from all of the views
|
||||
NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView);
|
||||
for (; aViewIt.More(); aViewIt.Next())
|
||||
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView); aViewIt.More(); aViewIt.Next())
|
||||
{
|
||||
aViewIt.Value()->RemoveZLayer (theLayerId);
|
||||
}
|
||||
|
||||
// Unset Z layer for all of the structures.
|
||||
NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator aStructIt (myMapOfStructure);
|
||||
for( ; aStructIt.More (); aStructIt.Next ())
|
||||
for (NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator aStructIt (myMapOfStructure); aStructIt.More(); aStructIt.Next())
|
||||
{
|
||||
OpenGl_Structure* aStruct = aStructIt.ChangeValue ();
|
||||
if (aStruct->ZLayer() == theLayerId)
|
||||
aStruct->SetZLayer (Graphic3d_ZLayerId_Default);
|
||||
}
|
||||
|
||||
// Remove index
|
||||
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
|
||||
{
|
||||
if (aLayerIt.Value() == theLayerId)
|
||||
{
|
||||
myLayerSeq.Remove (aLayerIt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
myMapOfZLayerSettings.UnBind (theLayerId);
|
||||
myLayerIds.Remove (theLayerId);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -642,23 +630,18 @@ void OpenGl_GraphicDriver::RemoveStructure (Handle(Graphic3d_CStructure)& theCSt
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : View
|
||||
// function : CreateView
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Graphic3d_CView) OpenGl_GraphicDriver::CreateView (const Handle(Graphic3d_StructureManager)& theMgr)
|
||||
{
|
||||
Handle(OpenGl_View) aView = new OpenGl_View (theMgr, this, myCaps, &myStateCounter);
|
||||
|
||||
myMapOfView.Add (aView);
|
||||
|
||||
for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
const Graphic3d_ZLayerId aLayerID = aLayerIt.Value();
|
||||
const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerID);
|
||||
aView->AddZLayer (aLayerID);
|
||||
aView->SetZLayerSettings (aLayerID, aSettings);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
|
||||
aView->InsertLayerAfter (aLayer->LayerId(), aLayer->LayerSettings(), Graphic3d_ZLayerId_UNKNOWN);
|
||||
}
|
||||
|
||||
return aView;
|
||||
}
|
||||
|
||||
|
@@ -108,10 +108,21 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//! Adds a new top-level z layer with ID theLayerId for all views. Z layers allow drawing structures in higher layers
|
||||
//! in foreground of structures in lower layers. To add a structure to desired layer on display it is necessary to
|
||||
//! set the layer index for the structure. The passed theLayerId should be not less than 0 (reserved for default layers).
|
||||
Standard_EXPORT void AddZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
|
||||
//! Adds a layer to all views.
|
||||
//! @param theLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerAfter [in] id of layer to append new layer before
|
||||
Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter) Standard_OVERRIDE;
|
||||
|
||||
//! Adds a layer to all views.
|
||||
//! @param theLayerId [in] id of created layer
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerBefore [in] id of layer to append new layer after
|
||||
Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore) Standard_OVERRIDE;
|
||||
|
||||
//! Removes Z layer. All structures displayed at the moment in layer will be displayed in
|
||||
//! default layer (the bottom-level z layer). By default, there are always default
|
||||
|
@@ -25,7 +25,6 @@
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_GroupDefinitionError.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
|
||||
@@ -91,20 +90,6 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& th
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theAspect.IsNull() && theAspect->IsKind (STANDARD_TYPE(Graphic3d_AspectFillCapping)))
|
||||
{
|
||||
Handle(Graphic3d_AspectFillCapping) aFillCappingAspect = Handle(Graphic3d_AspectFillCapping)::DownCast (theAspect);
|
||||
if (myAspectFillCapping == NULL)
|
||||
{
|
||||
myAspectFillCapping = new OpenGl_CappingPlaneResource (aFillCappingAspect);
|
||||
}
|
||||
else
|
||||
{
|
||||
myAspectFillCapping->SetAspect (aFillCappingAspect);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspects == NULL)
|
||||
{
|
||||
myAspects = new OpenGl_Aspects (theAspect);
|
||||
|
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <OpenGl_CappingPlaneResource.hxx>
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
||||
class OpenGl_Group;
|
||||
@@ -118,17 +117,6 @@ public:
|
||||
//! Is the group ray-tracable (contains ray-tracable elements)?
|
||||
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
|
||||
|
||||
//! Returns section style aspect.
|
||||
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const Standard_OVERRIDE
|
||||
{
|
||||
return myAspectFillCapping != NULL
|
||||
? myAspectFillCapping->Aspect()
|
||||
: Handle(Graphic3d_AspectFillCapping)();
|
||||
}
|
||||
|
||||
//! Returns OpenGL capping filling aspect.
|
||||
const OpenGl_CappingPlaneResource* AspectFillCapping() const { return myAspectFillCapping; }
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT virtual ~OpenGl_Group();
|
||||
@@ -136,7 +124,6 @@ protected:
|
||||
protected:
|
||||
|
||||
OpenGl_Aspects* myAspects;
|
||||
OpenGl_CappingPlaneResource* myAspectFillCapping;
|
||||
OpenGl_ElementNode* myFirst;
|
||||
OpenGl_ElementNode* myLast;
|
||||
Standard_Boolean myIsRaytracable;
|
||||
|
@@ -16,13 +16,14 @@
|
||||
#ifndef _OpenGl_LayerFilter_H__
|
||||
#define _OpenGl_LayerFilter_H__
|
||||
|
||||
//! Tool object to specify processed OpenGL layers.
|
||||
//! Tool object to specify processed OpenGL layers
|
||||
//! for intermixed rendering of raytracable and non-raytracable layers.
|
||||
enum OpenGl_LayerFilter
|
||||
{
|
||||
OpenGl_LF_All, //!< process all layers
|
||||
OpenGl_LF_Upper, //!< process only top layers
|
||||
OpenGl_LF_Bottom, //!< process only bottom layer
|
||||
OpenGl_LF_Default //!< process only default layer
|
||||
OpenGl_LF_All, //!< process all layers
|
||||
OpenGl_LF_Upper, //!< process only top non-raytracable layers
|
||||
OpenGl_LF_Bottom, //!< process only Graphic3d_ZLayerId_BotOSD
|
||||
OpenGl_LF_RayTracable //!< process only normal raytracable layers (save the bottom layer)
|
||||
};
|
||||
|
||||
#endif //_OpenGl_LayerFilter_H__
|
||||
|
@@ -29,13 +29,13 @@
|
||||
namespace
|
||||
{
|
||||
//! Auxiliary class extending sequence iterator with index.
|
||||
class OpenGl_IndexedLayerIterator : public OpenGl_SequenceOfLayers::Iterator
|
||||
class OpenGl_IndexedLayerIterator : public NCollection_List<Handle(Graphic3d_Layer)>::Iterator
|
||||
{
|
||||
public:
|
||||
//! Main constructor.
|
||||
OpenGl_IndexedLayerIterator (const OpenGl_SequenceOfLayers& theSeq)
|
||||
: OpenGl_SequenceOfLayers::Iterator (theSeq),
|
||||
myIndex (theSeq.Lower()) {}
|
||||
OpenGl_IndexedLayerIterator (const NCollection_List<Handle(Graphic3d_Layer)>& theSeq)
|
||||
: NCollection_List<Handle(Graphic3d_Layer)>::Iterator (theSeq),
|
||||
myIndex (1) {}
|
||||
|
||||
//! Return index of current position.
|
||||
Standard_Integer Index() const { return myIndex; }
|
||||
@@ -43,7 +43,7 @@ namespace
|
||||
//! Move to the next position.
|
||||
void Next()
|
||||
{
|
||||
OpenGl_SequenceOfLayers::Iterator::Next();
|
||||
NCollection_List<Handle(Graphic3d_Layer)>::Iterator::Next();
|
||||
++myIndex;
|
||||
}
|
||||
|
||||
@@ -56,12 +56,10 @@ namespace
|
||||
{
|
||||
public:
|
||||
//! Main constructor.
|
||||
OpenGl_FilteredIndexedLayerIterator (const OpenGl_SequenceOfLayers& theSeq,
|
||||
Standard_Integer theDefaultLayerIndex,
|
||||
OpenGl_FilteredIndexedLayerIterator (const NCollection_List<Handle(Graphic3d_Layer)>& theSeq,
|
||||
Standard_Boolean theToDrawImmediate,
|
||||
OpenGl_LayerFilter theLayersToProcess)
|
||||
: myIter (theSeq),
|
||||
myDefaultLayerIndex (theDefaultLayerIndex),
|
||||
myLayersToProcess (theLayersToProcess),
|
||||
myToDrawImmediate (theToDrawImmediate)
|
||||
{
|
||||
@@ -90,7 +88,8 @@ namespace
|
||||
{
|
||||
for (; myIter.More(); myIter.Next())
|
||||
{
|
||||
if (myIter.Value()->IsImmediate() != myToDrawImmediate)
|
||||
const Handle(Graphic3d_Layer)& aLayer = myIter.Value();
|
||||
if (aLayer->IsImmediate() != myToDrawImmediate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -99,39 +98,41 @@ namespace
|
||||
{
|
||||
case OpenGl_LF_All:
|
||||
{
|
||||
break;
|
||||
return;
|
||||
}
|
||||
case OpenGl_LF_Upper:
|
||||
{
|
||||
if (myIter.Index() <= myDefaultLayerIndex)
|
||||
if (aLayer->LayerId() != Graphic3d_ZLayerId_BotOSD
|
||||
&& (!aLayer->LayerSettings().IsRaytracable()
|
||||
|| aLayer->IsImmediate()))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OpenGl_LF_Bottom:
|
||||
{
|
||||
if (myIter.Index() >= myDefaultLayerIndex)
|
||||
if (aLayer->LayerId() == Graphic3d_ZLayerId_BotOSD
|
||||
&& !aLayer->LayerSettings().IsRaytracable())
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OpenGl_LF_Default:
|
||||
case OpenGl_LF_RayTracable:
|
||||
{
|
||||
if (myIter.Index() != myDefaultLayerIndex)
|
||||
if (aLayer->LayerSettings().IsRaytracable()
|
||||
&& !aLayer->IsImmediate())
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
private:
|
||||
OpenGl_IndexedLayerIterator myIter;
|
||||
Standard_Integer myDefaultLayerIndex;
|
||||
OpenGl_LayerFilter myLayersToProcess;
|
||||
Standard_Boolean myToDrawImmediate;
|
||||
};
|
||||
@@ -150,31 +151,12 @@ struct OpenGl_GlobalLayerSettings
|
||||
|
||||
OpenGl_LayerList::OpenGl_LayerList (const Standard_Integer theNbPriorities)
|
||||
: myBVHBuilder (new BVH_LinearBuilder<Standard_Real, 3> (BVH_Constants_LeafNodeSizeSingle, BVH_Constants_MaxTreeDepth)),
|
||||
myDefaultLayerIndex (0),
|
||||
myNbPriorities (theNbPriorities),
|
||||
myNbStructures (0),
|
||||
myImmediateNbStructures (0),
|
||||
myModifStateOfRaytraceable (0)
|
||||
{
|
||||
// insert default priority layers
|
||||
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
|
||||
myLayerIds.Bind (Graphic3d_ZLayerId_BotOSD, myLayers.Upper());
|
||||
|
||||
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
|
||||
myLayerIds.Bind (Graphic3d_ZLayerId_Default, myLayers.Upper());
|
||||
|
||||
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
|
||||
myLayerIds.Bind (Graphic3d_ZLayerId_Top, myLayers.Upper());
|
||||
|
||||
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
|
||||
myLayerIds.Bind (Graphic3d_ZLayerId_Topmost, myLayers.Upper());
|
||||
|
||||
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
|
||||
myLayerIds.Bind (Graphic3d_ZLayerId_TopOSD, myLayers.Upper());
|
||||
|
||||
myDefaultLayerIndex = myLayerIds.Find (Graphic3d_ZLayerId_Default);
|
||||
|
||||
myTransparentToProcess.Allocate (myLayers.Length());
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -193,85 +175,109 @@ OpenGl_LayerList::~OpenGl_LayerList()
|
||||
void OpenGl_LayerList::SetFrustumCullingBVHBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder)
|
||||
{
|
||||
myBVHBuilder = theBuilder;
|
||||
for (OpenGl_SequenceOfLayers::Iterator anIts (myLayers); anIts.More(); anIts.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
anIts.ChangeValue()->SetFrustumCullingBVHBuilder (theBuilder);
|
||||
aLayerIter.ChangeValue()->SetFrustumCullingBVHBuilder (theBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddLayer
|
||||
//purpose :
|
||||
//function : InsertLayerBefore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void OpenGl_LayerList::AddLayer (const Graphic3d_ZLayerId theLayerId)
|
||||
void OpenGl_LayerList::InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter)
|
||||
{
|
||||
if (myLayerIds.IsBound (theLayerId))
|
||||
if (myLayerIds.IsBound (theNewLayerId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// add the new layer
|
||||
myLayers.Append (new OpenGl_Layer (myNbPriorities, myBVHBuilder));
|
||||
myLayerIds.Bind (theLayerId, myLayers.Length());
|
||||
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, myNbPriorities, myBVHBuilder);
|
||||
aNewLayer->SetLayerSettings (theSettings);
|
||||
|
||||
myTransparentToProcess.Allocate (myLayers.Length());
|
||||
Handle(Graphic3d_Layer) anOtherLayer;
|
||||
if (theLayerAfter != Graphic3d_ZLayerId_UNKNOWN
|
||||
&& myLayerIds.Find (theLayerAfter, anOtherLayer))
|
||||
{
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
if (aLayerIter.Value() == anOtherLayer)
|
||||
{
|
||||
myLayers.InsertBefore (aNewLayer, aLayerIter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myLayers.Prepend (aNewLayer);
|
||||
}
|
||||
|
||||
myLayerIds.Bind (theNewLayerId, aNewLayer);
|
||||
myTransparentToProcess.Allocate (myLayers.Size());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Layer
|
||||
//purpose :
|
||||
//function : InsertLayerAfter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
OpenGl_Layer& OpenGl_LayerList::Layer (const Graphic3d_ZLayerId theLayerId)
|
||||
void OpenGl_LayerList::InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore)
|
||||
{
|
||||
return *myLayers.ChangeValue (myLayerIds.Find (theLayerId));
|
||||
}
|
||||
if (myLayerIds.IsBound (theNewLayerId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Layer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const OpenGl_Layer& OpenGl_LayerList::Layer (const Graphic3d_ZLayerId theLayerId) const
|
||||
{
|
||||
return *myLayers.Value (myLayerIds.Find (theLayerId));
|
||||
Handle(Graphic3d_Layer) aNewLayer = new Graphic3d_Layer (theNewLayerId, myNbPriorities, myBVHBuilder);
|
||||
aNewLayer->SetLayerSettings (theSettings);
|
||||
|
||||
Handle(Graphic3d_Layer) anOtherLayer;
|
||||
if (theLayerBefore != Graphic3d_ZLayerId_UNKNOWN
|
||||
&& myLayerIds.Find (theLayerBefore, anOtherLayer))
|
||||
{
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
if (aLayerIter.Value() == anOtherLayer)
|
||||
{
|
||||
myLayers.InsertAfter (aNewLayer, aLayerIter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myLayers.Append (aNewLayer);
|
||||
}
|
||||
|
||||
myLayerIds.Bind (theNewLayerId, aNewLayer);
|
||||
myTransparentToProcess.Allocate (myLayers.Size());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void OpenGl_LayerList::RemoveLayer (const Graphic3d_ZLayerId theLayerId)
|
||||
{
|
||||
if (!myLayerIds.IsBound (theLayerId)
|
||||
|| theLayerId <= 0)
|
||||
Handle(Graphic3d_Layer) aLayerToRemove;
|
||||
if (theLayerId <= 0
|
||||
|| !myLayerIds.Find (theLayerId, aLayerToRemove))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Integer aRemovePos = myLayerIds.Find (theLayerId);
|
||||
|
||||
// move all displayed structures to first layer
|
||||
{
|
||||
const OpenGl_Layer& aLayerToMove = *myLayers.Value (aRemovePos);
|
||||
myLayers.ChangeFirst()->Append (aLayerToMove);
|
||||
}
|
||||
myLayerIds.Find (Graphic3d_ZLayerId_Default)->Append (*aLayerToRemove);
|
||||
|
||||
// remove layer
|
||||
myLayers.Remove (aRemovePos);
|
||||
myLayers.Remove (aLayerToRemove);
|
||||
myLayerIds.UnBind (theLayerId);
|
||||
|
||||
// updated sequence indexes in map
|
||||
for (OpenGl_LayerSeqIds::Iterator aMapIt (myLayerIds); aMapIt.More(); aMapIt.Next())
|
||||
{
|
||||
Standard_Integer& aSeqIdx = aMapIt.ChangeValue();
|
||||
if (aSeqIdx > aRemovePos)
|
||||
aSeqIdx--;
|
||||
}
|
||||
|
||||
myDefaultLayerIndex = myLayerIds.Find (Graphic3d_ZLayerId_Default);
|
||||
|
||||
myTransparentToProcess.Allocate (myLayers.Length());
|
||||
myTransparentToProcess.Allocate (myLayers.Size());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -286,13 +292,11 @@ void OpenGl_LayerList::AddStructure (const OpenGl_Structure* theStruct,
|
||||
{
|
||||
// add structure to associated layer,
|
||||
// if layer doesn't exists, display structure in default layer
|
||||
Standard_Integer aSeqPos = myLayers.Lower();
|
||||
myLayerIds.Find (theLayerId, aSeqPos);
|
||||
|
||||
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
|
||||
aLayer.Add (theStruct, thePriority, isForChangePriority);
|
||||
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theLayerId);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
|
||||
aLayer->Add (theStruct, thePriority, isForChangePriority);
|
||||
++myNbStructures;
|
||||
if (aLayer.IsImmediate())
|
||||
if (aLayer->IsImmediate())
|
||||
{
|
||||
++myImmediateNbStructures;
|
||||
}
|
||||
@@ -310,25 +314,23 @@ void OpenGl_LayerList::AddStructure (const OpenGl_Structure* theStruct,
|
||||
void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
|
||||
{
|
||||
const Graphic3d_ZLayerId aLayerId = theStructure->ZLayer();
|
||||
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (aLayerId);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
|
||||
|
||||
Standard_Integer aSeqPos = myLayers.Lower();
|
||||
myLayerIds.Find (aLayerId, aSeqPos);
|
||||
|
||||
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
|
||||
Standard_Integer aPriority = -1;
|
||||
|
||||
// remove structure from associated list
|
||||
// if the structure is not found there,
|
||||
// scan through layers and remove it
|
||||
if (aLayer.Remove (theStructure, aPriority))
|
||||
if (aLayer->Remove (theStructure, aPriority))
|
||||
{
|
||||
--myNbStructures;
|
||||
if (aLayer.IsImmediate())
|
||||
if (aLayer->IsImmediate())
|
||||
{
|
||||
--myImmediateNbStructures;
|
||||
}
|
||||
|
||||
if (aLayerId == Graphic3d_ZLayerId_Default
|
||||
if (aLayer->LayerSettings().IsRaytracable()
|
||||
&& theStructure->IsRaytracable())
|
||||
{
|
||||
++myModifStateOfRaytraceable;
|
||||
@@ -338,23 +340,23 @@ void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
|
||||
}
|
||||
|
||||
// scan through layers and remove it
|
||||
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
OpenGl_Layer& aLayerEx = *anIts.ChangeValue();
|
||||
if (aSeqPos == anIts.Index())
|
||||
const Handle(Graphic3d_Layer)& aLayerEx = aLayerIter.ChangeValue();
|
||||
if (aLayerEx == aLayer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aLayerEx.Remove (theStructure, aPriority))
|
||||
if (aLayerEx->Remove (theStructure, aPriority))
|
||||
{
|
||||
--myNbStructures;
|
||||
if (aLayerEx.IsImmediate())
|
||||
if (aLayerEx->IsImmediate())
|
||||
{
|
||||
--myImmediateNbStructures;
|
||||
}
|
||||
|
||||
if (anIts.Index() == myDefaultLayerIndex
|
||||
if (aLayerEx->LayerSettings().IsRaytracable()
|
||||
&& theStructure->IsRaytracable())
|
||||
{
|
||||
++myModifStateOfRaytraceable;
|
||||
@@ -370,10 +372,9 @@ void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure* theStructure)
|
||||
//=======================================================================
|
||||
void OpenGl_LayerList::InvalidateBVHData (const Graphic3d_ZLayerId theLayerId)
|
||||
{
|
||||
Standard_Integer aSeqPos = myLayers.Lower();
|
||||
myLayerIds.Find (theLayerId, aSeqPos);
|
||||
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
|
||||
aLayer.InvalidateBVHData();
|
||||
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theLayerId);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
|
||||
aLayer->InvalidateBVHData();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -385,23 +386,24 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure* theStructure,
|
||||
const Graphic3d_ZLayerId theOldLayerId,
|
||||
const Graphic3d_ZLayerId theNewLayerId)
|
||||
{
|
||||
Standard_Integer aSeqPos = myLayers.Lower();
|
||||
myLayerIds.Find (theOldLayerId, aSeqPos);
|
||||
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
|
||||
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theOldLayerId);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
|
||||
|
||||
Standard_Integer aPriority = -1;
|
||||
|
||||
// take priority and remove structure from list found by <theOldLayerId>
|
||||
// if the structure is not found there, scan through all other layers
|
||||
if (aLayer.Remove (theStructure, aPriority, Standard_False))
|
||||
if (aLayer->Remove (theStructure, aPriority, Standard_False))
|
||||
{
|
||||
if (theOldLayerId == Graphic3d_ZLayerId_Default
|
||||
&& theStructure->IsRaytracable())
|
||||
if (aLayer->LayerSettings().IsRaytracable()
|
||||
&& !aLayer->LayerSettings().IsImmediate()
|
||||
&& theStructure->IsRaytracable())
|
||||
{
|
||||
++myModifStateOfRaytraceable;
|
||||
}
|
||||
|
||||
--myNbStructures;
|
||||
if (aLayer.IsImmediate())
|
||||
if (aLayer->IsImmediate())
|
||||
{
|
||||
--myImmediateNbStructures;
|
||||
}
|
||||
@@ -413,25 +415,26 @@ void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure* theStructure,
|
||||
}
|
||||
|
||||
// scan through layers and remove it
|
||||
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
if (aSeqPos == anIts.Index())
|
||||
const Handle(OpenGl_Layer)& aLayerEx = aLayerIter.ChangeValue();
|
||||
if (aLayerEx == aLayer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// try to remove structure and get priority value from this layer
|
||||
OpenGl_Layer& aLayerEx = *anIts.ChangeValue();
|
||||
if (aLayerEx.Remove (theStructure, aPriority, Standard_True))
|
||||
if (aLayerEx->Remove (theStructure, aPriority, Standard_True))
|
||||
{
|
||||
if (anIts.Index() == myDefaultLayerIndex
|
||||
&& theStructure->IsRaytracable())
|
||||
if (aLayerEx->LayerSettings().IsRaytracable()
|
||||
&& !aLayerEx->LayerSettings().IsImmediate()
|
||||
&& theStructure->IsRaytracable())
|
||||
{
|
||||
++myModifStateOfRaytraceable;
|
||||
}
|
||||
|
||||
--myNbStructures;
|
||||
if (aLayerEx.IsImmediate())
|
||||
if (aLayerEx->IsImmediate())
|
||||
{
|
||||
--myImmediateNbStructures;
|
||||
}
|
||||
@@ -452,15 +455,15 @@ void OpenGl_LayerList::ChangePriority (const OpenGl_Structure* theStructure,
|
||||
const Graphic3d_ZLayerId theLayerId,
|
||||
const Standard_Integer theNewPriority)
|
||||
{
|
||||
Standard_Integer aSeqPos = myLayers.Lower();
|
||||
myLayerIds.Find (theLayerId, aSeqPos);
|
||||
OpenGl_Layer& aLayer = *myLayers.ChangeValue (aSeqPos);
|
||||
const Handle(Graphic3d_Layer)* aLayerPtr = myLayerIds.Seek (theLayerId);
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerPtr != NULL ? *aLayerPtr : myLayerIds.Find (Graphic3d_ZLayerId_Default);
|
||||
|
||||
Standard_Integer anOldPriority = -1;
|
||||
|
||||
if (aLayer.Remove (theStructure, anOldPriority, Standard_True))
|
||||
if (aLayer->Remove (theStructure, anOldPriority, Standard_True))
|
||||
{
|
||||
--myNbStructures;
|
||||
if (aLayer.IsImmediate())
|
||||
if (aLayer->IsImmediate())
|
||||
{
|
||||
--myImmediateNbStructures;
|
||||
}
|
||||
@@ -469,18 +472,18 @@ void OpenGl_LayerList::ChangePriority (const OpenGl_Structure* theStructure,
|
||||
return;
|
||||
}
|
||||
|
||||
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
if (aSeqPos == anIts.Index())
|
||||
const Handle(OpenGl_Layer)& aLayerEx = aLayerIter.ChangeValue();
|
||||
if (aLayerEx == aLayer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
OpenGl_Layer& aLayerEx = *anIts.ChangeValue();
|
||||
if (aLayerEx.Remove (theStructure, anOldPriority, Standard_True))
|
||||
if (aLayerEx->Remove (theStructure, anOldPriority, Standard_True))
|
||||
{
|
||||
--myNbStructures;
|
||||
if (aLayerEx.IsImmediate())
|
||||
if (aLayerEx->IsImmediate())
|
||||
{
|
||||
--myImmediateNbStructures;
|
||||
}
|
||||
@@ -498,7 +501,12 @@ void OpenGl_LayerList::ChangePriority (const OpenGl_Structure* theStructure,
|
||||
void OpenGl_LayerList::SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings)
|
||||
{
|
||||
OpenGl_Layer& aLayer = Layer (theLayerId);
|
||||
Graphic3d_Layer& aLayer = Layer (theLayerId);
|
||||
if (aLayer.LayerSettings().IsRaytracable() != theSettings.IsRaytracable()
|
||||
&& aLayer.NbStructures() != 0)
|
||||
{
|
||||
++myModifStateOfRaytraceable;
|
||||
}
|
||||
if (aLayer.LayerSettings().IsImmediate() != theSettings.IsImmediate())
|
||||
{
|
||||
if (theSettings.IsImmediate())
|
||||
@@ -526,15 +534,15 @@ void OpenGl_LayerList::UpdateCulling (const Handle(OpenGl_Workspace)& theWorkspa
|
||||
|
||||
const Standard_Integer aViewId = theWorkspace->View()->Identification();
|
||||
const Graphic3d_CullingTool& aSelector = theWorkspace->View()->BVHTreeSelector();
|
||||
for (OpenGl_IndexedLayerIterator anIts (myLayers); anIts.More(); anIts.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myLayers); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
OpenGl_Layer& aLayer = *anIts.ChangeValue();
|
||||
if (aLayer.IsImmediate() != theToDrawImmediate)
|
||||
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.ChangeValue();
|
||||
if (aLayer->IsImmediate() != theToDrawImmediate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
aLayer.UpdateCulling (aViewId, aSelector, theWorkspace->View()->RenderingParams().FrustumCullingState);
|
||||
aLayer->UpdateCulling (aViewId, aSelector, theWorkspace->View()->RenderingParams().FrustumCullingState);
|
||||
}
|
||||
|
||||
aTimer.Stop();
|
||||
@@ -716,7 +724,7 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const bool toPerformDepthPrepass = theWorkspace->View()->RenderingParams().ToEnableDepthPrepass
|
||||
&& aPrevSettings.DepthMask == GL_TRUE;
|
||||
const Handle(Graphic3d_LightSet) aLightsBack = aCtx->ShaderManager()->LightSourceState().LightSources();
|
||||
for (OpenGl_FilteredIndexedLayerIterator aLayerIterStart (myLayers, myDefaultLayerIndex, theToDrawImmediate, theLayersToProcess); aLayerIterStart.More();)
|
||||
for (OpenGl_FilteredIndexedLayerIterator aLayerIterStart (myLayers, theToDrawImmediate, theLayersToProcess); aLayerIterStart.More();)
|
||||
{
|
||||
bool hasSkippedDepthLayers = false;
|
||||
for (int aPassIter = toPerformDepthPrepass ? 0 : 2; aPassIter < 3; ++aPassIter)
|
||||
|
@@ -29,9 +29,6 @@ class OpenGl_Structure;
|
||||
class OpenGl_Workspace;
|
||||
struct OpenGl_GlobalLayerSettings;
|
||||
|
||||
typedef NCollection_Sequence<Handle(OpenGl_Layer)> OpenGl_SequenceOfLayers;
|
||||
typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
|
||||
|
||||
//! Class defining the list of layers.
|
||||
class OpenGl_LayerList
|
||||
{
|
||||
@@ -53,7 +50,14 @@ public:
|
||||
Standard_Integer NbImmediateStructures() const { return myImmediateNbStructures; }
|
||||
|
||||
//! Insert a new layer with id.
|
||||
void AddLayer (const Graphic3d_ZLayerId theLayerId);
|
||||
void InsertLayerBefore (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter);
|
||||
|
||||
//! Insert a new layer with id.
|
||||
void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore);
|
||||
|
||||
//! Remove layer by its id.
|
||||
void RemoveLayer (const Graphic3d_ZLayerId theLayerId);
|
||||
@@ -82,10 +86,10 @@ public:
|
||||
const Standard_Integer theNewPriority);
|
||||
|
||||
//! Returns reference to the layer with given ID.
|
||||
OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId);
|
||||
OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) { return *myLayerIds.Find (theLayerId); }
|
||||
|
||||
//! Returns reference to the layer with given ID.
|
||||
const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const;
|
||||
const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const { return *myLayerIds.Find (theLayerId); }
|
||||
|
||||
//! Assign new settings to the layer.
|
||||
void SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
|
||||
@@ -103,10 +107,10 @@ public:
|
||||
OpenGl_FrameBuffer* theOitAccumFbo) const;
|
||||
|
||||
//! Returns the set of OpenGL Z-layers.
|
||||
const OpenGl_SequenceOfLayers& Layers() const { return myLayers; }
|
||||
const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const { return myLayers; }
|
||||
|
||||
//! Returns the map of Z-layer IDs to indexes.
|
||||
const OpenGl_LayerSeqIds& LayerIDs() const { return myLayerIds; }
|
||||
const NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)>& LayerIDs() const { return myLayerIds; }
|
||||
|
||||
//! Marks BVH tree for given priority list as dirty and
|
||||
//! marks primitive set for rebuild.
|
||||
@@ -134,13 +138,14 @@ protected:
|
||||
{
|
||||
if (theSize > 0)
|
||||
{
|
||||
myStackSpace = new NCollection_Array1<const Graphic3d_Layer*> (1, theSize);
|
||||
myStackSpace->Init (NULL);
|
||||
myBackPtr = myStackSpace->begin();
|
||||
myStackSpace.Resize (1, theSize, false);
|
||||
myStackSpace.Init (NULL);
|
||||
myBackPtr = myStackSpace.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
myStackSpace.Nullify();
|
||||
NCollection_Array1<const Graphic3d_Layer*> aDummy;
|
||||
myStackSpace.Move (aDummy);
|
||||
myBackPtr = iterator();
|
||||
}
|
||||
}
|
||||
@@ -148,18 +153,15 @@ protected:
|
||||
//! Clear stack.
|
||||
void Clear()
|
||||
{
|
||||
if (!myStackSpace.IsNull())
|
||||
{
|
||||
myStackSpace->Init (NULL);
|
||||
myBackPtr = myStackSpace->begin();
|
||||
}
|
||||
myStackSpace.Init (NULL);
|
||||
myBackPtr = myStackSpace.begin();
|
||||
}
|
||||
|
||||
//! Push a new layer reference to the stack.
|
||||
void Push (const OpenGl_Layer* theLayer) { (*myBackPtr++) = theLayer; }
|
||||
|
||||
//! Returns iterator to the origin of the stack.
|
||||
iterator Origin() const { return myStackSpace.IsNull() ? iterator() : myStackSpace->begin(); }
|
||||
iterator Origin() const { return myStackSpace.IsEmpty() ? iterator() : myStackSpace.begin(); }
|
||||
|
||||
//! Returns iterator to the back of the stack (after last item added).
|
||||
iterator Back() const { return myBackPtr; }
|
||||
@@ -169,8 +171,8 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
NCollection_Handle<NCollection_Array1<const OpenGl_Layer*> > myStackSpace;
|
||||
iterator myBackPtr;
|
||||
NCollection_Array1<const OpenGl_Layer*> myStackSpace;
|
||||
iterator myBackPtr;
|
||||
};
|
||||
|
||||
//! Render transparent objects using blending operator.
|
||||
@@ -195,11 +197,9 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
// number of structures temporary put to default layer
|
||||
OpenGl_SequenceOfLayers myLayers;
|
||||
OpenGl_LayerSeqIds myLayerIds;
|
||||
NCollection_List<Handle(Graphic3d_Layer)> myLayers;
|
||||
NCollection_DataMap<Graphic3d_ZLayerId, Handle(Graphic3d_Layer)> myLayerIds;
|
||||
Handle(Select3D_BVHBuilder3d) myBVHBuilder; //!< BVH tree builder for frustom culling
|
||||
Standard_Integer myDefaultLayerIndex; //!< index of Graphic3d_ZLayerId_Default layer in myLayers sequence
|
||||
|
||||
Standard_Integer myNbPriorities;
|
||||
Standard_Integer myNbStructures;
|
||||
|
@@ -1505,6 +1505,8 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
|
||||
bool theUsesDerivates) const
|
||||
{
|
||||
int aBits = theBits;
|
||||
const bool toUseDerivates = theUsesDerivates
|
||||
|| (theBits & OpenGl_PO_StippleLine) != 0;
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->core32 != NULL)
|
||||
{
|
||||
@@ -1518,19 +1520,15 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
|
||||
{
|
||||
theProgram->SetHeader ("#version 130");
|
||||
}
|
||||
else if (myContext->CheckExtension ("GL_EXT_gpu_shader4"))
|
||||
else if (myContext->CheckExtension ("GL_EXT_gpu_shader4")) // myContext->hasGlslBitwiseOps == OpenGl_FeatureInExtensions
|
||||
{
|
||||
// GL_EXT_gpu_shader4 defines GLSL type "unsigned int", while core GLSL specs define type "uint"
|
||||
theProgram->SetHeader ("#extension GL_EXT_gpu_shader4 : enable\n"
|
||||
"#define uint unsigned int");
|
||||
}
|
||||
else
|
||||
{
|
||||
aBits = aBits & ~OpenGl_PO_StippleLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
(void )theUsesDerivates;
|
||||
(void )toUseDerivates;
|
||||
#else
|
||||
// prefer "100 es" on OpenGL ES 3.0- devices (save the features unavailable before "300 es")
|
||||
// and "300 es" on OpenGL ES 3.1+ devices
|
||||
@@ -1557,10 +1555,13 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
|
||||
else
|
||||
{
|
||||
aBits = aBits & ~OpenGl_PO_WriteOit;
|
||||
aBits = aBits & ~OpenGl_PO_StippleLine;
|
||||
if (!myContext->oesStdDerivatives)
|
||||
{
|
||||
aBits = aBits & ~OpenGl_PO_StippleLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (theUsesDerivates)
|
||||
if (toUseDerivates)
|
||||
{
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
@@ -1819,28 +1820,34 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
|
||||
const Standard_Integer aBits = defaultGlslVersion (aProgramSrc, "unlit", theBits);
|
||||
if ((aBits & OpenGl_PO_StippleLine) != 0)
|
||||
{
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int uPattern", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor", Graphic3d_TOS_FRAGMENT));
|
||||
if (myContext->hasGlslBitwiseOps != OpenGl_FeatureNotAvailable)
|
||||
{
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int occStipplePattern", Graphic3d_TOS_FRAGMENT));
|
||||
}
|
||||
else
|
||||
{
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("bool occStipplePattern[16]", Graphic3d_TOS_FRAGMENT));
|
||||
}
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float occStippleFactor", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 occViewport", Graphic3d_TOS_VERTEX));
|
||||
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec2 ScreenSpaceCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||
aSrcVertEndMain =
|
||||
EOL" vec2 aPosition = gl_Position.xy / gl_Position.w;"
|
||||
EOL" aPosition = aPosition * 0.5 + 0.5;"
|
||||
EOL" ScreenSpaceCoord = aPosition.xy * occViewport.zw + occViewport.xy;";
|
||||
aSrcFragMainGetColor =
|
||||
EOL" vec2 anAxis = vec2 (0.0);"
|
||||
aSrcFragMainGetColor = TCollection_AsciiString()
|
||||
+ EOL" vec2 anAxis = vec2 (0.0, 1.0);"
|
||||
EOL" if (abs (dFdx (ScreenSpaceCoord.x)) - abs (dFdy (ScreenSpaceCoord.y)) > 0.001)"
|
||||
EOL" {"
|
||||
EOL" anAxis = vec2 (1.0, 0.0);"
|
||||
EOL" }"
|
||||
EOL" else"
|
||||
EOL" {"
|
||||
EOL" anAxis = vec2 (0.0, 1.0);"
|
||||
EOL" }"
|
||||
EOL" float aRotatePoint = dot (gl_FragCoord.xy, anAxis);"
|
||||
EOL" uint aBit = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
|
||||
EOL" if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
|
||||
EOL" vec4 aColor = getFinalColor();"
|
||||
+ (myContext->hasGlslBitwiseOps != OpenGl_FeatureNotAvailable
|
||||
? EOL" uint aBit = uint (floor (aRotatePoint / occStippleFactor + 0.5)) & 15U;"
|
||||
EOL" if ((uint (occStipplePattern) & (1U << aBit)) == 0U) discard;"
|
||||
: EOL" int aBit = int (mod (floor (aRotatePoint / occStippleFactor + 0.5), 16.0));"
|
||||
EOL" if (!occStipplePattern[aBit]) discard;")
|
||||
+ EOL" vec4 aColor = getFinalColor();"
|
||||
EOL" if (aColor.a <= 0.1) discard;"
|
||||
EOL" occSetFragColor (aColor);";
|
||||
}
|
||||
|
@@ -81,6 +81,8 @@ Standard_CString OpenGl_ShaderProgram::PredefinedKeywords[] =
|
||||
"occViewport", // OpenGl_OCCT_VIEWPORT
|
||||
"occLineWidth", // OpenGl_OCCT_LINE_WIDTH
|
||||
"occLineFeather", // OpenGl_OCCT_LINE_FEATHER
|
||||
"occStipplePattern", // OpenGl_OCCT_LINE_STIPPLE_PATTERN
|
||||
"occStippleFactor", // OpenGl_OCCT_LINE_STIPPLE_FACTOR
|
||||
"occWireframeColor", // OpenGl_OCCT_WIREFRAME_COLOR
|
||||
"occIsQuadMode", // OpenGl_OCCT_QUAD_MODE_STATE
|
||||
|
||||
|
@@ -79,6 +79,8 @@ enum OpenGl_StateVariable
|
||||
OpenGl_OCCT_VIEWPORT,
|
||||
OpenGl_OCCT_LINE_WIDTH,
|
||||
OpenGl_OCCT_LINE_FEATHER,
|
||||
OpenGl_OCCT_LINE_STIPPLE_PATTERN, // occStipplePattern
|
||||
OpenGl_OCCT_LINE_STIPPLE_FACTOR, // occStippleFactor
|
||||
OpenGl_OCCT_WIREFRAME_COLOR,
|
||||
OpenGl_OCCT_QUAD_MODE_STATE,
|
||||
|
||||
|
@@ -31,13 +31,7 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
static const GLdouble THE_IDENTITY_MATRIX[16] =
|
||||
{
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0
|
||||
};
|
||||
static const OpenGl_Mat4d THE_IDENTITY_MATRIX;
|
||||
|
||||
static const TCollection_AsciiString THE_DEFAULT_FONT (Font_NOF_ASCII_MONO);
|
||||
|
||||
@@ -80,10 +74,7 @@ namespace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Text::OpenGl_Text()
|
||||
: myWinX (0.0f),
|
||||
myWinY (0.0f),
|
||||
myWinZ (0.0f),
|
||||
myScaleHeight (1.0f),
|
||||
: myScaleHeight (1.0f),
|
||||
myPoint (0.0f, 0.0f, 0.0f),
|
||||
myIs2d (false),
|
||||
myHasPlane (false),
|
||||
@@ -101,10 +92,7 @@ OpenGl_Text::OpenGl_Text()
|
||||
OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
||||
const OpenGl_Vec3& thePoint,
|
||||
const OpenGl_TextParam& theParams)
|
||||
: myWinX (0.0f),
|
||||
myWinY (0.0f),
|
||||
myWinZ (0.0f),
|
||||
myScaleHeight (1.0f),
|
||||
: myScaleHeight (1.0f),
|
||||
myExportHeight (1.0f),
|
||||
myParams (theParams),
|
||||
myString (theText),
|
||||
@@ -124,10 +112,7 @@ OpenGl_Text::OpenGl_Text (const Standard_Utf8Char* theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const OpenGl_TextParam& theParams,
|
||||
const bool theHasOwnAnchor)
|
||||
: myWinX (0.0),
|
||||
myWinY (0.0),
|
||||
myWinZ (0.0),
|
||||
myScaleHeight (1.0),
|
||||
: myScaleHeight (1.0),
|
||||
myExportHeight (1.0),
|
||||
myParams (theParams),
|
||||
myString (theText),
|
||||
@@ -362,7 +347,15 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
// Bind custom shader program or generate default version
|
||||
aCtx->ShaderManager()->BindFontProgram (aTextAspect->ShaderProgramRes (aCtx));
|
||||
|
||||
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
|
||||
if (myHasPlane && myHasAnchorPoint)
|
||||
{
|
||||
myOrientationMatrix = theWorkspace->View()->Camera()->OrientationMatrix();
|
||||
// reset translation part
|
||||
myOrientationMatrix.ChangeValue (0, 3) = 0.0;
|
||||
myOrientationMatrix.ChangeValue (1, 3) = 0.0;
|
||||
myOrientationMatrix.ChangeValue (2, 3) = 0.0;
|
||||
}
|
||||
|
||||
myProjMatrix.Convert (aCtx->ProjectionState.Current());
|
||||
|
||||
// use highlight color or colors from aspect
|
||||
@@ -417,8 +410,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
const OpenGl_Aspects& theTextAspect,
|
||||
const OpenGl_Vec3& theDVec) const
|
||||
{
|
||||
OpenGl_Mat4d aModViewMat;
|
||||
OpenGl_Mat4d aProjectMat;
|
||||
OpenGl_Mat4d aModViewMat, aProjectMat;
|
||||
if (myHasPlane && myHasAnchorPoint)
|
||||
{
|
||||
aProjectMat = myProjMatrix * myOrientationMatrix;
|
||||
@@ -436,18 +428,20 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
else
|
||||
{
|
||||
// align coordinates to the nearest integer
|
||||
// to avoid extra interpolation issues
|
||||
GLdouble anObjX, anObjY, anObjZ;
|
||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (std::floor (myWinX + theDVec.x()),
|
||||
std::floor (myWinY + theDVec.y()),
|
||||
myWinZ + theDVec.z(),
|
||||
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX),
|
||||
OpenGl_Mat4d::Map (aProjectMat),
|
||||
theCtx->Viewport(),
|
||||
anObjX,
|
||||
anObjY,
|
||||
anObjZ);
|
||||
OpenGl_Vec3d anObjXYZ;
|
||||
OpenGl_Vec3d aWinXYZ = myWinXYZ + OpenGl_Vec3d (theDVec);
|
||||
if (!myHasPlane && !theTextAspect.Aspect()->IsTextZoomable())
|
||||
{
|
||||
// Align coordinates to the nearest integer to avoid extra interpolation issues.
|
||||
// Note that for better readability we could also try aligning freely rotated in 3D text (myHasPlane),
|
||||
// when camera orientation co-aligned with horizontal text orientation,
|
||||
// but this might look awkward while rotating camera.
|
||||
aWinXYZ.x() = Floor (aWinXYZ.x());
|
||||
aWinXYZ.y() = Floor (aWinXYZ.y());
|
||||
}
|
||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (aWinXYZ.x(), aWinXYZ.y(), aWinXYZ.z(),
|
||||
THE_IDENTITY_MATRIX, aProjectMat, theCtx->Viewport(),
|
||||
anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
|
||||
|
||||
if (myHasPlane)
|
||||
{
|
||||
@@ -468,12 +462,12 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
else
|
||||
{
|
||||
aModViewMat.SetColumn (3, OpenGl_Vec3d (anObjX, anObjY, anObjZ));
|
||||
aModViewMat.SetColumn (3, anObjXYZ);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
||||
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjXYZ.x(), anObjXYZ.y(), anObjXYZ.z());
|
||||
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -737,7 +731,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
Graphic3d_TransformUtils::Project<Standard_Real> (myPoint.x(), myPoint.y(), myPoint.z(),
|
||||
myModelMatrix, myProjMatrix, theCtx->Viewport(),
|
||||
myWinX, myWinY, myWinZ);
|
||||
myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z());
|
||||
|
||||
// compute scale factor for constant text height
|
||||
if (theTextAspect.Aspect()->IsTextZoomable())
|
||||
@@ -747,11 +741,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
||||
else
|
||||
{
|
||||
Graphic3d_Vec3d aPnt1, aPnt2;
|
||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX, myWinY, myWinZ,
|
||||
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX), myProjMatrix, theCtx->Viewport(),
|
||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y(), myWinXYZ.z(),
|
||||
THE_IDENTITY_MATRIX, myProjMatrix, theCtx->Viewport(),
|
||||
aPnt1.x(), aPnt1.y(), aPnt1.z());
|
||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinX, myWinY + aPointSize, myWinZ,
|
||||
OpenGl_Mat4d::Map (THE_IDENTITY_MATRIX), myProjMatrix, theCtx->Viewport(),
|
||||
Graphic3d_TransformUtils::UnProject<Standard_Real> (myWinXYZ.x(), myWinXYZ.y() + aPointSize, myWinXYZ.z(),
|
||||
THE_IDENTITY_MATRIX, myProjMatrix, theCtx->Viewport(),
|
||||
aPnt2.x(), aPnt2.y(), aPnt2.z());
|
||||
myScaleHeight = (aPnt2.y() - aPnt1.y()) / aPointSize;
|
||||
}
|
||||
|
@@ -160,9 +160,7 @@ protected:
|
||||
mutable OpenGl_Mat4d myProjMatrix;
|
||||
mutable OpenGl_Mat4d myModelMatrix;
|
||||
mutable OpenGl_Mat4d myOrientationMatrix;
|
||||
mutable GLdouble myWinX;
|
||||
mutable GLdouble myWinY;
|
||||
mutable GLdouble myWinZ;
|
||||
mutable OpenGl_Vec3d myWinXYZ;
|
||||
mutable GLdouble myScaleHeight;
|
||||
mutable GLdouble myExportHeight;
|
||||
|
||||
|
@@ -488,12 +488,25 @@ void OpenGl_View::SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle)
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddZLayer
|
||||
//function : InsertLayerBefore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_View::AddZLayer (const Graphic3d_ZLayerId theLayerId)
|
||||
void OpenGl_View::InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter)
|
||||
{
|
||||
myZLayers.AddLayer (theLayerId);
|
||||
myZLayers.InsertLayerBefore (theLayerId, theSettings, theLayerAfter);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InsertLayerAfter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_View::InsertLayerAfter (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore)
|
||||
{
|
||||
myZLayers.InsertLayerAfter (theLayerId, theSettings, theLayerBefore);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -522,83 +535,74 @@ void OpenGl_View::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
|
||||
Standard_Integer OpenGl_View::ZLayerMax() const
|
||||
{
|
||||
Standard_Integer aLayerMax = Graphic3d_ZLayerId_Default;
|
||||
for (OpenGl_LayerSeqIds::Iterator aMapIt(myZLayers.LayerIDs()); aMapIt.More(); aMapIt.Next())
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myZLayers.Layers()); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
aLayerMax = Max (aLayerMax, aMapIt.Value());
|
||||
aLayerMax = Max (aLayerMax, aLayerIter.Value()->LayerId());
|
||||
}
|
||||
|
||||
return aLayerMax;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InvalidateZLayerBoundingBox
|
||||
//function : Layers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void OpenGl_View::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const
|
||||
const NCollection_List<Handle(Graphic3d_Layer)>& OpenGl_View::Layers() const
|
||||
{
|
||||
if (myZLayers.LayerIDs().IsBound (theLayerId))
|
||||
{
|
||||
myZLayers.Layer (theLayerId).InvalidateBoundingBox();
|
||||
}
|
||||
else
|
||||
{
|
||||
const Standard_Integer aLayerMax = ZLayerMax();
|
||||
for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId < aLayerMax; ++aLayerId)
|
||||
{
|
||||
if (myZLayers.LayerIDs().IsBound (aLayerId))
|
||||
{
|
||||
const OpenGl_Layer& aLayer = myZLayers.Layer (aLayerId);
|
||||
if (aLayer.NbOfTransformPersistenceObjects() > 0)
|
||||
{
|
||||
aLayer.InvalidateBoundingBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return myZLayers.Layers();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ZLayerBoundingBox
|
||||
//function : Layer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Bnd_Box OpenGl_View::ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight,
|
||||
const Standard_Boolean theToIncludeAuxiliary) const
|
||||
Handle(Graphic3d_Layer) OpenGl_View::Layer (const Graphic3d_ZLayerId theLayerId) const
|
||||
{
|
||||
Bnd_Box aBox;
|
||||
if (myZLayers.LayerIDs().IsBound (theLayerId))
|
||||
Handle(Graphic3d_Layer) aLayer;
|
||||
if (theLayerId != Graphic3d_ZLayerId_UNKNOWN)
|
||||
{
|
||||
aBox = myZLayers.Layer (theLayerId).BoundingBox (Identification(),
|
||||
theCamera,
|
||||
theWindowWidth,
|
||||
theWindowHeight,
|
||||
theToIncludeAuxiliary);
|
||||
myZLayers.LayerIDs().Find (theLayerId, aLayer);
|
||||
}
|
||||
return aLayer;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MinMaxValues
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Bnd_Box OpenGl_View::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const
|
||||
{
|
||||
if (!IsDefined())
|
||||
{
|
||||
return Bnd_Box();
|
||||
}
|
||||
|
||||
Bnd_Box aBox = base_type::MinMaxValues (theToIncludeAuxiliary);
|
||||
|
||||
// add bounding box of gradient/texture background for proper Z-fit
|
||||
if (theToIncludeAuxiliary
|
||||
&& theLayerId == Graphic3d_ZLayerId_BotOSD
|
||||
&& (myBgTextureArray->IsDefined()
|
||||
|| myBgGradientArray->IsDefined()))
|
||||
{
|
||||
const Handle(Graphic3d_Camera)& aCamera = Camera();
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
|
||||
// Background is drawn using 2D transformation persistence
|
||||
// (e.g. it is actually placed in 3D coordinates within active camera position).
|
||||
// We add here full-screen plane with 2D transformation persistence
|
||||
// for simplicity (myBgTextureArray might define a little bit different options
|
||||
// but it is updated within ::Render())
|
||||
const Graphic3d_Mat4d& aProjectionMat = theCamera->ProjectionMatrix();
|
||||
const Graphic3d_Mat4d& aWorldViewMat = theCamera->OrientationMatrix();
|
||||
const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
|
||||
const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix();
|
||||
Graphic3d_BndBox3d aBox2d (Graphic3d_Vec3d (0.0, 0.0, 0.0),
|
||||
Graphic3d_Vec3d (double(theWindowWidth), double(theWindowHeight), 0.0));
|
||||
Graphic3d_Vec3d (double(aWinSize.x()), double(aWinSize.y()), 0.0));
|
||||
|
||||
Graphic3d_TransformPers aTrsfPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER);
|
||||
aTrsfPers.Apply (theCamera,
|
||||
aTrsfPers.Apply (aCamera,
|
||||
aProjectionMat,
|
||||
aWorldViewMat,
|
||||
theWindowWidth,
|
||||
theWindowHeight,
|
||||
aWinSize.x(),
|
||||
aWinSize.y(),
|
||||
aBox2d);
|
||||
aBox.Add (gp_Pnt (aBox2d.CornerMin().x(), aBox2d.CornerMin().y(), aBox2d.CornerMin().z()));
|
||||
aBox.Add (gp_Pnt (aBox2d.CornerMax().x(), aBox2d.CornerMax().y(), aBox2d.CornerMax().z()));
|
||||
@@ -607,26 +611,6 @@ Bnd_Box OpenGl_View::ZLayerBoundingBox (const Graphic3d_ZLayerId theLayer
|
||||
return aBox;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : considerZoomPersistenceObjects
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real OpenGl_View::considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight) const
|
||||
{
|
||||
if (myZLayers.LayerIDs().IsBound (theLayerId))
|
||||
{
|
||||
return myZLayers.Layer (theLayerId).considerZoomPersistenceObjects (Identification(),
|
||||
theCamera,
|
||||
theWindowWidth,
|
||||
theWindowHeight);
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FBO
|
||||
//purpose :
|
||||
|
@@ -136,8 +136,21 @@ public:
|
||||
//! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
|
||||
Standard_EXPORT virtual void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
|
||||
|
||||
//! Insert a new top-level z layer with the given ID.
|
||||
Standard_EXPORT virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
|
||||
//! Add a layer to the view.
|
||||
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerAfter [in] id of layer to append new layer before
|
||||
Standard_EXPORT virtual void InsertLayerBefore (const Graphic3d_ZLayerId theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter) Standard_OVERRIDE;
|
||||
|
||||
//! Add a layer to the view.
|
||||
//! @param theNewLayerId [in] id of new layer, should be > 0 (negative values are reserved for default layers).
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerBefore [in] id of layer to append new layer after
|
||||
Standard_EXPORT virtual void InsertLayerAfter (const Graphic3d_ZLayerId theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore) Standard_OVERRIDE;
|
||||
|
||||
//! Remove a z layer with the given ID.
|
||||
Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
|
||||
@@ -150,23 +163,18 @@ public:
|
||||
//! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
|
||||
Standard_EXPORT virtual Standard_Integer ZLayerMax() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns the bounding box of all structures displayed in the Z layer.
|
||||
//! Never fails. If Z layer does not exist nothing happens.
|
||||
Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const Standard_OVERRIDE;
|
||||
//! Returns the list of layers.
|
||||
Standard_EXPORT virtual const NCollection_List<Handle(Graphic3d_Layer)>& Layers() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns the bounding box of all structures displayed in the Z layer.
|
||||
//! If Z layer does not exist the empty box is returned.
|
||||
//! @param theLayerId layer identifier
|
||||
//! @param theCamera camera definition
|
||||
//! @param theWindowWidth viewport width (for applying transformation-persistence)
|
||||
//! @param theWindowHeight viewport height (for applying transformation-persistence)
|
||||
//! Returns layer with given ID or NULL if undefined.
|
||||
Standard_EXPORT virtual Handle(Graphic3d_Layer) Layer (const Graphic3d_ZLayerId theLayerId) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns the bounding box of all structures displayed in the view.
|
||||
//! If theToIncludeAuxiliary is TRUE, then the boundary box also includes minimum and maximum limits
|
||||
//! of graphical elements forming parts of infinite and other auxiliary structures.
|
||||
//! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
|
||||
//! @return computed bounding box
|
||||
Standard_EXPORT virtual Bnd_Box ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight,
|
||||
const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Bnd_Box MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns pointer to an assigned framebuffer object.
|
||||
Standard_EXPORT virtual Handle(Standard_Transient) FBO() const Standard_OVERRIDE;
|
||||
@@ -409,12 +417,6 @@ private:
|
||||
Standard_EXPORT virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
|
||||
const Standard_Integer theNewPriority) Standard_OVERRIDE;
|
||||
|
||||
//! Returns zoom-scale factor.
|
||||
Standard_EXPORT virtual Standard_Real considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
|
||||
const Handle(Graphic3d_Camera)& theCamera,
|
||||
const Standard_Integer theWindowWidth,
|
||||
const Standard_Integer theWindowHeight) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
//! Copy content of Back buffer to the Front buffer.
|
||||
|
@@ -107,12 +107,17 @@ Standard_Boolean OpenGl_View::updateRaytraceGeometry (const RaytraceUpdateMode
|
||||
// of changes in OpenGL scene (only for path tracing)
|
||||
std::set<Standard_Integer> aNonRaytraceIDs;
|
||||
|
||||
const OpenGl_Layer& aLayer = myZLayers.Layer (Graphic3d_ZLayerId_Default);
|
||||
|
||||
if (aLayer.NbStructures() != 0)
|
||||
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (myZLayers.Layers()); aLayerIter.More(); aLayerIter.Next())
|
||||
{
|
||||
const Graphic3d_ArrayOfIndexedMapOfStructure& aStructArray = aLayer.ArrayOfStructures();
|
||||
const Handle(OpenGl_Layer)& aLayer = aLayerIter.Value();
|
||||
if (aLayer->NbStructures() == 0
|
||||
|| !aLayer->LayerSettings().IsRaytracable()
|
||||
|| aLayer->LayerSettings().IsImmediate())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Graphic3d_ArrayOfIndexedMapOfStructure& aStructArray = aLayer->ArrayOfStructures();
|
||||
for (Standard_Integer anIndex = 0; anIndex < aStructArray.Length(); ++anIndex)
|
||||
{
|
||||
for (OpenGl_Structure::StructIterator aStructIt (aStructArray.Value (anIndex)); aStructIt.More(); aStructIt.Next())
|
||||
|
@@ -1129,7 +1129,7 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
|
||||
}
|
||||
|
||||
// Render non-polygonal elements in default layer
|
||||
myZLayers.Render (myWorkspace, theToDrawImmediate, OpenGl_LF_Default, theReadDrawFbo, theOitAccumFbo);
|
||||
myZLayers.Render (myWorkspace, theToDrawImmediate, OpenGl_LF_RayTracable, theReadDrawFbo, theOitAccumFbo);
|
||||
}
|
||||
myWorkspace->SetRenderFilter (aPrevFilter);
|
||||
}
|
||||
|
@@ -43,15 +43,24 @@ public:
|
||||
//! Returns the right-handed coordinate system set in SetComponent.
|
||||
Standard_EXPORT Handle(Prs3d_ShadingAspect) ShadingAspect (Prs3d_DatumParts thePart) const;
|
||||
|
||||
//! Returns the right-handed coordinate system set in SetComponent.
|
||||
//! Returns the text attributes for rendering labels.
|
||||
const Handle(Prs3d_TextAspect)& TextAspect() const { return myTextAspect; }
|
||||
|
||||
//! Sets text attributes for rendering labels.
|
||||
void SetTextAspect (const Handle(Prs3d_TextAspect)& theTextAspect) { myTextAspect = theTextAspect; }
|
||||
|
||||
//! Returns the point aspect of origin wireframe presentation
|
||||
const Handle(Prs3d_PointAspect)& PointAspect() const { return myPointAspect; }
|
||||
|
||||
//! Returns the point aspect of origin wireframe presentation
|
||||
void SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect) { myPointAspect = theAspect; }
|
||||
|
||||
//! Returns the arrow aspect of presentation
|
||||
const Handle(Prs3d_ArrowAspect)& ArrowAspect() const { return myArrowAspect; }
|
||||
|
||||
//! Sets the arrow aspect of presentation
|
||||
void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) { myArrowAspect = theAspect; }
|
||||
|
||||
//! Returns the attributes for display of the first axis.
|
||||
Standard_DEPRECATED("This method is deprecated - LineAspect() should be called instead")
|
||||
const Handle(Prs3d_LineAspect)& FirstAxisAspect() const { return myLineAspects.Find (Prs3d_DP_XAxis); }
|
||||
|
@@ -28,7 +28,9 @@ Prs3d_ToolDisk::Prs3d_ToolDisk (const Standard_Real theInnerRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks)
|
||||
: myInnerRadius (theInnerRadius),
|
||||
myOuterRadius (theOuterRadius)
|
||||
myOuterRadius (theOuterRadius),
|
||||
myStartAngle (0.0),
|
||||
myEndAngle (M_PI * 2.0)
|
||||
{
|
||||
mySlicesNb = theNbSlices;
|
||||
myStacksNb = theNbStacks;
|
||||
@@ -40,22 +42,13 @@ Prs3d_ToolDisk::Prs3d_ToolDisk (const Standard_Real theInnerRadius,
|
||||
//=======================================================================
|
||||
gp_Pnt Prs3d_ToolDisk::Vertex (const Standard_Real theU, const Standard_Real theV)
|
||||
{
|
||||
const Standard_Real aU = theU * M_PI * 2.0;
|
||||
const Standard_Real aU = myStartAngle + theU * (myEndAngle - myStartAngle);
|
||||
const Standard_Real aRadius = myInnerRadius + (myOuterRadius - myInnerRadius) * theV;
|
||||
return gp_Pnt (Cos (aU) * aRadius,
|
||||
Sin (aU) * aRadius,
|
||||
0.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
gp_Dir Prs3d_ToolDisk::Normal (const Standard_Real /*theU*/, const Standard_Real /*theV*/)
|
||||
{
|
||||
return gp_Dir (0.0, 0.0, -1.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
|
@@ -37,18 +37,31 @@ public:
|
||||
const Standard_Real theOuterRadius,
|
||||
const Standard_Integer theNbSlices,
|
||||
const Standard_Integer theNbStacks);
|
||||
|
||||
//! Set angle range in radians [0, 2*PI] by default.
|
||||
//! @param theStartAngle [in] Start angle in counter clockwise order
|
||||
//! @param theEndAngle [in] End angle in counter clockwise order
|
||||
void SetAngleRange (Standard_Real theStartAngle,
|
||||
Standard_Real theEndAngle)
|
||||
{
|
||||
myStartAngle = theStartAngle;
|
||||
myEndAngle = theEndAngle;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes vertex at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
|
||||
//! Computes normal at given parameter location of the surface.
|
||||
Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) Standard_OVERRIDE;
|
||||
virtual gp_Dir Normal (const Standard_Real , const Standard_Real ) Standard_OVERRIDE { return gp_Dir (0.0, 0.0, -1.0); }
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Real myInnerRadius;
|
||||
Standard_Real myOuterRadius;
|
||||
Standard_Real myStartAngle; //!< Start angle in counter clockwise order
|
||||
Standard_Real myEndAngle; //!< End angle in counter clockwise order
|
||||
|
||||
};
|
||||
|
||||
|
@@ -37,15 +37,17 @@ void RWHeaderSection_RWFileDescription::ReadStep
|
||||
|
||||
Handle(Interface_HArray1OfHAsciiString) aDescription;
|
||||
Handle(TCollection_HAsciiString) aDescriptionItem;
|
||||
Standard_Integer nsub1;
|
||||
nsub1 = data->SubListNumber(num, 1, Standard_False);
|
||||
Standard_Integer nsub1 = data->SubListNumber(num, 1, Standard_False);
|
||||
if (nsub1 !=0) {
|
||||
Standard_Integer nb1 = data->NbParams(nsub1);
|
||||
aDescription = new Interface_HArray1OfHAsciiString (1, nb1);
|
||||
for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
|
||||
Standard_Boolean stat1 = data->ReadString
|
||||
(nsub1,i1,"description",ach,aDescriptionItem);
|
||||
if (stat1) aDescription->SetValue(i1,aDescriptionItem);
|
||||
if (nb1 > 0)
|
||||
{
|
||||
aDescription = new Interface_HArray1OfHAsciiString (1, nb1);
|
||||
for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
|
||||
Standard_Boolean stat1 = data->ReadString
|
||||
(nsub1,i1,"description",ach,aDescriptionItem);
|
||||
if (stat1) aDescription->SetValue(i1,aDescriptionItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#ifndef _SelectMgr_EntityOwner_HeaderFile
|
||||
#define _SelectMgr_EntityOwner_HeaderFile
|
||||
|
||||
#include <Aspect_VKey.hxx>
|
||||
#include <PrsMgr_PresentationManager.hxx>
|
||||
#include <SelectMgr_SelectableObject.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
@@ -60,6 +61,22 @@ public:
|
||||
//! Sets the selectable object.
|
||||
virtual void SetSelectable (const Handle(SelectMgr_SelectableObject)& theSelObj) { mySelectable = theSelObj.get(); }
|
||||
|
||||
//! Handle mouse button click event.
|
||||
//! Does nothing by default and returns FALSE.
|
||||
//! @param thePoint mouse cursor position
|
||||
//! @param theButton clicked button
|
||||
//! @param theModifiers key modifiers
|
||||
//! @param theIsDoubleClick flag indicating double mouse click
|
||||
//! @return TRUE if object handled click
|
||||
virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
|
||||
Aspect_VKeyMouse theButton,
|
||||
Aspect_VKeyFlags theModifiers,
|
||||
bool theIsDoubleClick)
|
||||
{
|
||||
(void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! Returns true if the presentation manager highlights selections corresponding to the selection mode.
|
||||
virtual Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
|
||||
const Standard_Integer theMode = 0) const
|
||||
|
@@ -77,6 +77,7 @@ Standard_PrimitiveTypes.hxx
|
||||
Standard_ProgramError.hxx
|
||||
Standard_RangeError.hxx
|
||||
Standard_ReadBuffer.hxx
|
||||
Standard_ReadLineBuffer.hxx
|
||||
Standard_Real.cxx
|
||||
Standard_Real.hxx
|
||||
Standard_ShortReal.cxx
|
||||
|
198
src/Standard/Standard_ReadLineBuffer.hxx
Normal file
198
src/Standard/Standard_ReadLineBuffer.hxx
Normal file
@@ -0,0 +1,198 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Standard_ReadLineBuffer_HeaderFile
|
||||
#define _Standard_ReadLineBuffer_HeaderFile
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
//! Auxiliary tool for buffered reading of lines from input stream.
|
||||
class Standard_ReadLineBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor with initialization.
|
||||
//! @param theMaxBufferSizeBytes the length of buffer to read (in bytes)
|
||||
Standard_ReadLineBuffer (size_t theMaxBufferSizeBytes)
|
||||
: myUseReadBufferLastStr(false),
|
||||
myBufferPos (0),
|
||||
myBytesLastRead (0)
|
||||
{
|
||||
// allocate read buffer
|
||||
myReadBuffer.resize (theMaxBufferSizeBytes);
|
||||
}
|
||||
|
||||
//! Destructor.
|
||||
virtual ~Standard_ReadLineBuffer() {}
|
||||
|
||||
//! Clear buffer and cached values.
|
||||
void Clear()
|
||||
{
|
||||
myReadBufferLastStr.clear();
|
||||
myUseReadBufferLastStr = false;
|
||||
myBufferPos = 0;
|
||||
myBytesLastRead = 0;
|
||||
}
|
||||
|
||||
//! Read next line from the stream.
|
||||
//! @return pointer to the line or NULL on error / end of reading buffer
|
||||
//! (in case of NULL result theStream should be checked externally to identify the presence of errors).
|
||||
//! Empty lines will be returned also with zero length.
|
||||
//! @param theLineLength [out] - output parameter defined length of returned line.
|
||||
template<typename Stream_T>
|
||||
const char* ReadLine (Stream_T& theStream,
|
||||
size_t& theLineLength)
|
||||
{
|
||||
int64_t aReadData = 0;
|
||||
return ReadLine (theStream, theLineLength, aReadData);
|
||||
}
|
||||
|
||||
//! Read next line from the stream.
|
||||
//! @return pointer to the line or NULL on error / end of reading buffer
|
||||
//! (in case of NULL result theStream should be checked externally to identify the presence of errors).
|
||||
//! Empty lines will be returned also with zero length.
|
||||
//! @param theLineLength [out] - output parameter defined length of returned line.
|
||||
//! @param theReadData [out] - output parameter defined the number of elements successfully read from the stream during this call,
|
||||
//! it can be zero if no data was read and the line is taken from the buffer.
|
||||
template<typename Stream_T>
|
||||
const char* ReadLine (Stream_T& theStream,
|
||||
size_t& theLineLength,
|
||||
int64_t& theReadData)
|
||||
{
|
||||
char* aResultLine = NULL;
|
||||
theLineLength = 0;
|
||||
theReadData = 0;
|
||||
|
||||
while (aResultLine == NULL)
|
||||
{
|
||||
if (myBufferPos == 0 || myBufferPos >= (myBytesLastRead))
|
||||
{
|
||||
// read new chunk from the stream
|
||||
if (!readStream (theStream, myReadBuffer.size(), myBytesLastRead))
|
||||
{
|
||||
// error during file reading
|
||||
break;
|
||||
}
|
||||
|
||||
theReadData = myBytesLastRead;
|
||||
|
||||
if (myBytesLastRead > 0)
|
||||
{
|
||||
myBufferPos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// end of the stream
|
||||
if (myUseReadBufferLastStr)
|
||||
{
|
||||
theLineLength = myReadBufferLastStr.size();
|
||||
aResultLine = myReadBufferLastStr.data();
|
||||
myUseReadBufferLastStr = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t aStartLinePos = myBufferPos;
|
||||
bool isEndLineFound = false;
|
||||
|
||||
// read next line from myReadBuffer
|
||||
while (myBufferPos < myBytesLastRead)
|
||||
{
|
||||
if (myReadBuffer[myBufferPos] == '\n')
|
||||
{
|
||||
isEndLineFound = true;
|
||||
}
|
||||
|
||||
++myBufferPos;
|
||||
|
||||
if (isEndLineFound) break;
|
||||
}
|
||||
|
||||
if (isEndLineFound)
|
||||
{
|
||||
if (myUseReadBufferLastStr)
|
||||
{
|
||||
// append current string to the last "unfinished" string of the previous chunk
|
||||
myReadBufferLastStr.insert (myReadBufferLastStr.end(), myReadBuffer.begin() + aStartLinePos, myReadBuffer.begin() + myBufferPos);
|
||||
myUseReadBufferLastStr = false;
|
||||
theLineLength = myReadBufferLastStr.size();
|
||||
aResultLine = myReadBufferLastStr.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myReadBufferLastStr.size() > 0)
|
||||
{
|
||||
myReadBufferLastStr.clear();
|
||||
}
|
||||
theLineLength = myBufferPos - aStartLinePos;
|
||||
aResultLine = myReadBuffer.data() + aStartLinePos;
|
||||
}
|
||||
// make string null terminated by replacing '\n' or '\r' (before '\n') symbol to null character.
|
||||
if (theLineLength > 1 && aResultLine[theLineLength - 2] == '\r')
|
||||
{
|
||||
aResultLine[theLineLength - 2] = '\0';
|
||||
theLineLength -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
aResultLine[theLineLength - 1] = '\0';
|
||||
theLineLength -= 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// save "unfinished" part of string to additional buffer
|
||||
if (aStartLinePos != myBufferPos)
|
||||
{
|
||||
myReadBufferLastStr = std::vector<char>(myReadBuffer.begin() + aStartLinePos, myReadBuffer.begin() + myBufferPos);
|
||||
myUseReadBufferLastStr = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return aResultLine;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Read from stl stream.
|
||||
//! @return true if reading was finished without errors.
|
||||
bool readStream (std::istream& theStream,
|
||||
size_t theLen,
|
||||
size_t& theReadLen)
|
||||
{
|
||||
theReadLen = theStream.read (myReadBuffer.data(), theLen).gcount();
|
||||
return !theStream.bad();
|
||||
}
|
||||
|
||||
//! Read from FILE stream.
|
||||
//! @return true if reading was finished without errors.
|
||||
bool readStream (FILE* theStream,
|
||||
size_t theLen,
|
||||
size_t& theReadLen)
|
||||
{
|
||||
theReadLen = ::fread (myReadBuffer.data(), 1, theLen, theStream);
|
||||
return ::ferror (theStream) == 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
std::vector<char> myReadBuffer; //!< Temp read buffer
|
||||
std::vector<char> myReadBufferLastStr; //!< Part of last string of myReadBuffer
|
||||
bool myUseReadBufferLastStr; //!< Flag to use myReadBufferLastStr during next line reading
|
||||
size_t myBufferPos; //!< Current position in myReadBuffer
|
||||
size_t myBytesLastRead; //!< The number of characters that were read last time from myReadBuffer.
|
||||
};
|
||||
|
||||
#endif // _Standard_ReadLineBuffer_HeaderFile
|
@@ -208,7 +208,7 @@ namespace
|
||||
aPoint = aNodes (aNodeIter);
|
||||
const Standard_Integer anId = 3 * (aNodeIter - aNodes.Lower());
|
||||
gp_Dir aNorm (aNormArr[anId + 0], aNormArr[anId + 1], aNormArr[anId + 2]);
|
||||
if (aFace.Orientation() == TopAbs_REVERSED)
|
||||
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
|
||||
{
|
||||
aNorm.Reverse();
|
||||
}
|
||||
@@ -237,7 +237,7 @@ namespace
|
||||
Standard_Integer anIndex[3];
|
||||
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
|
||||
{
|
||||
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
|
||||
if ((aFace.Orientation() == TopAbs_REVERSED))
|
||||
{
|
||||
aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
|
||||
}
|
||||
@@ -283,7 +283,6 @@ namespace
|
||||
static Standard_Boolean shadeFromShape (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
@@ -299,9 +298,6 @@ namespace
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
|
||||
aGroup->SetClosed (theIsClosed);
|
||||
aGroup->SetGroupPrimitivesAspect (theDrawer->ShadingAspect()->Aspect());
|
||||
if (!theCappingStyle.IsNull())
|
||||
aGroup->SetGroupPrimitivesAspect (theCappingStyle);
|
||||
|
||||
aGroup->AddPrimitiveArray (aPArray);
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -521,12 +517,11 @@ void StdPrs_ShadedShape::ExploreSolids (const TopoDS_Shape& theShape,
|
||||
void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const StdPrs_Volume theVolume)
|
||||
{
|
||||
gp_Pnt2d aDummy;
|
||||
StdPrs_ShadedShape::Add (thePrs, theShape, theDrawer,
|
||||
Standard_False, aDummy, aDummy, aDummy, theCappingStyle, theVolume);
|
||||
Standard_False, aDummy, aDummy, aDummy, theVolume);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -540,7 +535,6 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const StdPrs_Volume theVolume)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
@@ -578,20 +572,20 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
|
||||
if (aClosed.NbChildren() > 0)
|
||||
{
|
||||
shadeFromShape (aClosed, thePrs, theDrawer, theCappingStyle,
|
||||
shadeFromShape (aClosed, thePrs, theDrawer,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, true);
|
||||
}
|
||||
|
||||
if (anOpened.NbChildren() > 0)
|
||||
{
|
||||
shadeFromShape (anOpened, thePrs, theDrawer, theCappingStyle,
|
||||
shadeFromShape (anOpened, thePrs, theDrawer,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the shape type is not compound, composolid or solid, use autodetection back-facing filled
|
||||
shadeFromShape (theShape, thePrs, theDrawer, theCappingStyle,
|
||||
shadeFromShape (theShape, thePrs, theDrawer,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale,
|
||||
theVolume == StdPrs_Volume_Closed);
|
||||
}
|
||||
|
@@ -38,25 +38,13 @@ public:
|
||||
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
|
||||
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
|
||||
//! or to perform Autodetection (would split input shape into two groups)
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
|
||||
StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
|
||||
//! Shades <theShape> with texture coordinates.
|
||||
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
|
||||
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
|
||||
//! or to perform Autodetection (would split input shape into two groups)
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
|
||||
const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const Standard_Boolean theHasTexels, const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
|
||||
//! Searches closed and unclosed subshapes in shape structure and puts them
|
||||
//! into two compounds for separate processing of closed and unclosed sub-shapes
|
||||
|
@@ -275,26 +275,37 @@ void V3d_Viewer::DelView (const Handle(V3d_View)& theView)
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddZLayer
|
||||
//function : InsertLayerBefore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean V3d_Viewer::AddZLayer (Graphic3d_ZLayerId& theLayerId)
|
||||
Standard_Boolean V3d_Viewer::InsertLayerBefore (Graphic3d_ZLayerId& theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter)
|
||||
{
|
||||
try
|
||||
if (myZLayerGenId.Next (theNewLayerId))
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
theLayerId = myZLayerGenId.Next();
|
||||
myLayerIds.Add (theNewLayerId);
|
||||
myDriver->InsertLayerBefore (theNewLayerId, theSettings, theLayerAfter);
|
||||
return Standard_True;
|
||||
}
|
||||
catch (Aspect_IdentDefinitionError const&)
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InsertLayerAfter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean V3d_Viewer::InsertLayerAfter (Graphic3d_ZLayerId& theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore)
|
||||
{
|
||||
if (myZLayerGenId.Next (theNewLayerId))
|
||||
{
|
||||
// new index can't be generated
|
||||
return Standard_False;
|
||||
myLayerIds.Add (theNewLayerId);
|
||||
myDriver->InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
myLayerIds.Add (theLayerId);
|
||||
myDriver->AddZLayer (theLayerId);
|
||||
|
||||
return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -339,7 +350,7 @@ void V3d_Viewer::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const G
|
||||
//function : ZLayerSettings
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Graphic3d_ZLayerSettings V3d_Viewer::ZLayerSettings (const Graphic3d_ZLayerId theLayerId)
|
||||
const Graphic3d_ZLayerSettings& V3d_Viewer::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
|
||||
{
|
||||
return myDriver->ZLayerSettings (theLayerId);
|
||||
}
|
||||
|
@@ -190,9 +190,39 @@ public:
|
||||
|
||||
//! Add a new top-level Z layer to all managed views and get its ID as <theLayerId> value.
|
||||
//! The Z layers are controlled entirely by viewer, it is not possible to add a layer to a particular view.
|
||||
//! The method returns Standard_False if the layer can not be created.
|
||||
//! The layer mechanism allows to display structures in higher layers in overlay of structures in lower layers.
|
||||
Standard_EXPORT Standard_Boolean AddZLayer (Graphic3d_ZLayerId& theLayerId);
|
||||
//! Custom layers will be inserted before Graphic3d_ZLayerId_Top (e.g. between Graphic3d_ZLayerId_Default and before Graphic3d_ZLayerId_Top).
|
||||
//! @param theLayerId [out] id of created layer
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @return FALSE if the layer can not be created
|
||||
Standard_Boolean AddZLayer (Graphic3d_ZLayerId& theLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings = Graphic3d_ZLayerSettings())
|
||||
{
|
||||
return InsertLayerBefore (theLayerId, theSettings, Graphic3d_ZLayerId_Top);
|
||||
}
|
||||
|
||||
//! Add a new top-level Z layer to all managed views and get its ID as <theLayerId> value.
|
||||
//! The Z layers are controlled entirely by viewer, it is not possible to add a layer to a particular view.
|
||||
//! Layer rendering order is defined by its position in list (altered by theLayerAfter)
|
||||
//! and IsImmediate() flag (all layers with IsImmediate() flag are drawn afterwards);
|
||||
//! @param theNewLayerId [out] id of created layer; layer id is arbitrary and does not depend on layer position in the list
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerAfter [in] id of layer to append new layer before
|
||||
//! @return FALSE if the layer can not be created
|
||||
Standard_EXPORT Standard_Boolean InsertLayerBefore (Graphic3d_ZLayerId& theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerAfter);
|
||||
|
||||
//! Add a new top-level Z layer to all managed views and get its ID as <theLayerId> value.
|
||||
//! The Z layers are controlled entirely by viewer, it is not possible to add a layer to a particular view.
|
||||
//! Layer rendering order is defined by its position in list (altered by theLayerAfter)
|
||||
//! and IsImmediate() flag (all layers with IsImmediate() flag are drawn afterwards);
|
||||
//! @param theNewLayerId [out] id of created layer; layer id is arbitrary and does not depend on layer position in the list
|
||||
//! @param theSettings [in] new layer settings
|
||||
//! @param theLayerBefore [in] id of layer to append new layer after
|
||||
//! @return FALSE if the layer can not be created
|
||||
Standard_EXPORT Standard_Boolean InsertLayerAfter (Graphic3d_ZLayerId& theNewLayerId,
|
||||
const Graphic3d_ZLayerSettings& theSettings,
|
||||
const Graphic3d_ZLayerId theLayerBefore);
|
||||
|
||||
//! Remove Z layer with ID <theLayerId>.
|
||||
//! Method returns Standard_False if the layer can not be removed or doesn't exists.
|
||||
@@ -200,7 +230,7 @@ public:
|
||||
Standard_EXPORT Standard_Boolean RemoveZLayer (const Graphic3d_ZLayerId theLayerId);
|
||||
|
||||
//! Returns the settings of a single Z layer.
|
||||
Standard_EXPORT Graphic3d_ZLayerSettings ZLayerSettings (const Graphic3d_ZLayerId theLayerId);
|
||||
Standard_EXPORT const Graphic3d_ZLayerSettings& ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const;
|
||||
|
||||
//! Sets the settings for a single Z layer.
|
||||
Standard_EXPORT void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings);
|
||||
|
@@ -1762,6 +1762,8 @@ struct ViewerTest_AspectsChangeSet
|
||||
|
||||
Standard_Integer ToSetColor;
|
||||
Quantity_Color Color;
|
||||
Standard_Integer ToSetBackFaceColor;
|
||||
Quantity_Color BackFaceColor;
|
||||
|
||||
Standard_Integer ToSetLineWidth;
|
||||
Standard_Real LineWidth;
|
||||
@@ -1848,6 +1850,8 @@ struct ViewerTest_AspectsChangeSet
|
||||
Visibility (1),
|
||||
ToSetColor (0),
|
||||
Color (DEFAULT_COLOR),
|
||||
ToSetBackFaceColor(0),
|
||||
BackFaceColor (DEFAULT_COLOR),
|
||||
ToSetLineWidth (0),
|
||||
LineWidth (1.0),
|
||||
ToSetTypeOfLine (0),
|
||||
@@ -1909,6 +1913,7 @@ struct ViewerTest_AspectsChangeSet
|
||||
&& ToSetTransparency == 0
|
||||
&& ToSetAlphaMode == 0
|
||||
&& ToSetColor == 0
|
||||
&& ToSetBackFaceColor == 0
|
||||
&& ToSetMaterial == 0
|
||||
&& ToSetShowFreeBoundary == 0
|
||||
&& ToSetFreeBoundaryColor == 0
|
||||
@@ -2143,6 +2148,15 @@ struct ViewerTest_AspectsChangeSet
|
||||
theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
|
||||
}
|
||||
}
|
||||
if (ToSetBackFaceColor != 0)
|
||||
{
|
||||
if (ToSetBackFaceColor != -1
|
||||
|| theDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
|
||||
theDrawer->ShadingAspect()->SetColor (BackFaceColor, Aspect_TOFM_BACK_SIDE);
|
||||
}
|
||||
}
|
||||
if (ToSetAlphaMode != 0)
|
||||
{
|
||||
if (ToSetAlphaMode != -1
|
||||
@@ -2675,6 +2689,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
}
|
||||
else if (anArg == "-setcolor"
|
||||
|| anArg == "-color"
|
||||
|| anArg == "-setbackfacecolor"
|
||||
|| anArg == "-backfacecolor"
|
||||
|| anArg == "-setbackcolor"
|
||||
|| anArg == "-backcolor"
|
||||
|| anArg == "-setfaceboundarycolor"
|
||||
|| anArg == "-setboundarycolor"
|
||||
|| anArg == "-faceboundarycolor"
|
||||
@@ -2704,6 +2722,14 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
aChangeSet->ToSetFaceBoundaryColor = 1;
|
||||
aChangeSet->FaceBoundaryColor = aColor;
|
||||
}
|
||||
else if (anArg == "-setbackfacecolor"
|
||||
|| anArg == "-backfacecolor"
|
||||
|| anArg == "-setbackcolor"
|
||||
|| anArg == "-backcolor")
|
||||
{
|
||||
aChangeSet->ToSetBackFaceColor = 1;
|
||||
aChangeSet->BackFaceColor = aColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
aChangeSet->ToSetColor = 1;
|
||||
@@ -3218,6 +3244,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
aChangeSet->AlphaCutoff = 0.5f;
|
||||
aChangeSet->ToSetColor = -1;
|
||||
aChangeSet->Color = DEFAULT_COLOR;
|
||||
//aChangeSet->ToSetBackFaceColor = -1; // should be reset by ToSetColor
|
||||
//aChangeSet->BackFaceColor = DEFAULT_COLOR;
|
||||
aChangeSet->ToSetMaterial = -1;
|
||||
aChangeSet->Material = Graphic3d_NOM_DEFAULT;
|
||||
aChangeSet->ToSetShowFreeBoundary = -1;
|
||||
@@ -6565,6 +6593,7 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
"vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]"
|
||||
"\n\t\t: [-setVisibility 0|1]"
|
||||
"\n\t\t: [-setColor ColorName] [-setcolor R G B] [-unsetColor]"
|
||||
"\n\t\t: [-setBackFaceColor Color]"
|
||||
"\n\t\t: [-setMaterial MatName] [-unsetMaterial]"
|
||||
"\n\t\t: [-setTransparency Transp] [-unsetTransparency]"
|
||||
"\n\t\t: [-setWidth LineWidth] [-unsetWidth]"
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <ViewerTest_EventManager.hxx>
|
||||
|
||||
#include <AIS_AnimationCamera.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <Aspect_Grid.hxx>
|
||||
@@ -26,6 +27,16 @@ Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(ViewerTest_EventManager,Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
//function : GlobalViewAnimation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Handle(AIS_AnimationCamera)& ViewerTest_EventManager::GlobalViewAnimation()
|
||||
{
|
||||
static Handle(AIS_AnimationCamera) THE_CAMERA_ANIM = new AIS_AnimationCamera ("ViewerTest_EventManager_ViewAnimation", Handle(V3d_View)());
|
||||
return THE_CAMERA_ANIM;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewerTest_EventManager
|
||||
//purpose :
|
||||
@@ -35,7 +46,23 @@ ViewerTest_EventManager::ViewerTest_EventManager (const Handle(V3d_View)&
|
||||
: myCtx (theCtx),
|
||||
myView (theView),
|
||||
myToPickPnt (Standard_False)
|
||||
{}
|
||||
{
|
||||
myViewAnimation = GlobalViewAnimation();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ~ViewerTest_EventManager
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
ViewerTest_EventManager::~ViewerTest_EventManager()
|
||||
{
|
||||
if (!myViewAnimation.IsNull()
|
||||
&& myViewAnimation->View() == myView)
|
||||
{
|
||||
myViewAnimation->Stop();
|
||||
myViewAnimation->SetView (Handle(V3d_View)());
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateMouseButtons
|
||||
|
@@ -47,11 +47,17 @@ public:
|
||||
return Draw_ToExitOnCloseView;
|
||||
}
|
||||
|
||||
//! Use global camera animation object shared across all Views in ViewerTest.
|
||||
Standard_EXPORT static const Handle(AIS_AnimationCamera)& GlobalViewAnimation();
|
||||
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
Standard_EXPORT ViewerTest_EventManager(const Handle(V3d_View)& aView, const Handle(AIS_InteractiveContext)& aCtx);
|
||||
|
||||
|
||||
//! Destructor.
|
||||
Standard_EXPORT virtual ~ViewerTest_EventManager();
|
||||
|
||||
//! Return interactive context.
|
||||
const Handle(AIS_InteractiveContext)& Context() const { return myCtx; }
|
||||
|
||||
|
@@ -606,13 +606,20 @@ static Standard_Integer VShaderProg (Draw_Interpretor& theDI,
|
||||
TCollection_AsciiString anArg (theArgVec[anArgIter]);
|
||||
anArg.LowerCase();
|
||||
Graphic3d_TypeOfShaderObject aShaderTypeArg = Graphic3d_TypeOfShaderObject(-1);
|
||||
if (anArg == "-list"
|
||||
|| ((anArg == "-update"
|
||||
|| anArg == "-dump"
|
||||
|| anArg == "-debug"
|
||||
|| anArg == "-reload"
|
||||
|| anArg == "-load")
|
||||
&& anArgIter + 1 < theArgNb))
|
||||
if (!aProgram.IsNull()
|
||||
&& anArg == "-uniform"
|
||||
&& anArgIter + 2 < theArgNb)
|
||||
{
|
||||
TCollection_AsciiString aName = theArgVec[++anArgIter];
|
||||
aProgram->PushVariableFloat (aName, float (Draw::Atof (theArgVec[++anArgIter])));
|
||||
}
|
||||
else if (anArg == "-list"
|
||||
|| ((anArg == "-update"
|
||||
|| anArg == "-dump"
|
||||
|| anArg == "-debug"
|
||||
|| anArg == "-reload"
|
||||
|| anArg == "-load")
|
||||
&& anArgIter + 1 < theArgNb))
|
||||
{
|
||||
Handle(OpenGl_Context) aGlCtx;
|
||||
if (Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aCtx->CurrentViewer()->Driver()))
|
||||
@@ -895,6 +902,7 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-off] [-phong] [-aspect {shading|line|point|text}=shading]"
|
||||
"\n\t\t: [-header VersionHeader]"
|
||||
"\n\t\t: [-tessControl TessControlShader -tesseval TessEvaluationShader]"
|
||||
"\n\t\t: [-uniform Name FloatValue]"
|
||||
"\n\t\t: Assign custom GLSL program to presentation aspects."
|
||||
"\nvshader [-list] [-dump] [-reload] ShaderId"
|
||||
"\n\t\t: -list prints the list of registered GLSL programs"
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <AIS_Manipulator.hxx>
|
||||
#include <AIS_ViewCube.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <Aspect_DisplayConnection.hxx>
|
||||
#include <Aspect_Grid.hxx>
|
||||
@@ -1657,8 +1658,9 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
|
||||
// alternatively we can disable buffer swap at all, but this might be inappropriate for testing
|
||||
//ViewerTest_myDefaultCaps.buffersNoSwap = true;
|
||||
}
|
||||
aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection());
|
||||
aGraphicDriver = new OpenGl_GraphicDriver (GetDisplayConnection(), false);
|
||||
aGraphicDriver->ChangeOptions() = ViewerTest_myDefaultCaps;
|
||||
aGraphicDriver->InitContext();
|
||||
|
||||
ViewerTest_myDrivers.Bind (aViewNames.GetDriverName(), aGraphicDriver);
|
||||
toCreateViewer = Standard_True;
|
||||
@@ -5322,6 +5324,7 @@ static int VZLayer (Draw_Interpretor& theDI,
|
||||
}
|
||||
}
|
||||
|
||||
Graphic3d_ZLayerId anOtherLayerId = Graphic3d_ZLayerId_UNKNOWN;
|
||||
for (; anArgIter < theArgNb; ++anArgIter)
|
||||
{
|
||||
// perform operation
|
||||
@@ -5343,6 +5346,34 @@ static int VZLayer (Draw_Interpretor& theDI,
|
||||
|
||||
theDI << aLayerId;
|
||||
}
|
||||
else if (anArg == "-insertbefore"
|
||||
&& anArgIter + 1 < theArgNb
|
||||
&& ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
|
||||
{
|
||||
++anArgIter;
|
||||
aLayerId = Graphic3d_ZLayerId_UNKNOWN;
|
||||
if (!aViewer->InsertLayerBefore (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
|
||||
{
|
||||
std::cout << "Error: can not add a new z layer!\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
theDI << aLayerId;
|
||||
}
|
||||
else if (anArg == "-insertafter"
|
||||
&& anArgIter + 1 < theArgNb
|
||||
&& ViewerTest::ParseZLayer (theArgVec[anArgIter + 1], anOtherLayerId))
|
||||
{
|
||||
++anArgIter;
|
||||
aLayerId = Graphic3d_ZLayerId_UNKNOWN;
|
||||
if (!aViewer->InsertLayerAfter (aLayerId, Graphic3d_ZLayerSettings(), anOtherLayerId))
|
||||
{
|
||||
std::cout << "Error: can not add a new z layer!\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
theDI << aLayerId;
|
||||
}
|
||||
else if (anArg == "-del"
|
||||
|| anArg == "-delete"
|
||||
|| anArg == "del")
|
||||
@@ -5584,6 +5615,10 @@ static int VZLayer (Draw_Interpretor& theDI,
|
||||
{
|
||||
aSettings.SetEnvironmentTexture (toEnable);
|
||||
}
|
||||
else if (aSubOp == "raytracing")
|
||||
{
|
||||
aSettings.SetRaytracable (toEnable);
|
||||
}
|
||||
|
||||
aViewer->SetZLayerSettings (aLayerId, aSettings);
|
||||
}
|
||||
@@ -6592,6 +6627,8 @@ static int VCaps (Draw_Interpretor& theDI,
|
||||
theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
|
||||
theDI << "Stereo: " << (aCaps->contextStereo ? "1" : "0") << "\n";
|
||||
theDI << "WinBuffer: " << (aCaps->useSystemBuffer ? "1" : "0") << "\n";
|
||||
theDI << "NoExt:" << (aCaps->contextNoExtensions ? "1" : "0") << "\n";
|
||||
theDI << "MaxVersion:" << aCaps->contextMajorVersionUpper << "." << aCaps->contextMinorVersionUpper << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6735,6 +6772,44 @@ static int VCaps (Draw_Interpretor& theDI,
|
||||
}
|
||||
aCaps->contextStereo = toEnable;
|
||||
}
|
||||
else if (anArgCase == "-noext"
|
||||
|| anArgCase == "-noextensions"
|
||||
|| anArgCase == "-noextension")
|
||||
{
|
||||
Standard_Boolean toDisable = Standard_True;
|
||||
if (++anArgIter < theArgNb
|
||||
&& !ViewerTest::ParseOnOff (theArgVec[anArgIter], toDisable))
|
||||
{
|
||||
--anArgIter;
|
||||
}
|
||||
aCaps->contextNoExtensions = toDisable;
|
||||
}
|
||||
else if (anArgCase == "-maxversion"
|
||||
|| anArgCase == "-upperversion"
|
||||
|| anArgCase == "-limitversion")
|
||||
{
|
||||
Standard_Integer aVer[2] = { -2, -1 };
|
||||
for (Standard_Integer aValIter = 0; aValIter < 2; ++aValIter)
|
||||
{
|
||||
if (anArgIter + 1 < theArgNb)
|
||||
{
|
||||
const TCollection_AsciiString aStr (theArgVec[anArgIter + 1]);
|
||||
if (aStr.IsIntegerValue())
|
||||
{
|
||||
aVer[aValIter] = aStr.IntegerValue();
|
||||
++anArgIter;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aVer[0] < -1
|
||||
|| aVer[1] < -1)
|
||||
{
|
||||
std::cout << "Syntax error at '" << anArgCase << "'\n";
|
||||
return 1;
|
||||
}
|
||||
aCaps->contextMajorVersionUpper = aVer[0];
|
||||
aCaps->contextMinorVersionUpper = aVer[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: unknown argument '" << anArg << "'\n";
|
||||
@@ -9309,7 +9384,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetUseObjectMaterial (toEnable == Standard_True);
|
||||
aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
@@ -9326,7 +9401,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetUseObjectTexture (toEnable == Standard_True);
|
||||
aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
@@ -9341,7 +9416,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetUseObjectShader (toEnable == Standard_True);
|
||||
aClipPlane->SetUseObjectShader (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
@@ -9358,10 +9433,10 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material();
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
|
||||
aMat.SetAmbientColor (aColor);
|
||||
aMat.SetDiffuseColor (aColor);
|
||||
aClipPlane->CappingSectionStyle()->SetMaterial (aMat);
|
||||
aClipPlane->SetCappingMaterial (aMat);
|
||||
anArgIter += aNbParsed;
|
||||
}
|
||||
else if ((aChangeArg == "-transparency"
|
||||
@@ -9369,34 +9444,44 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
&& aNbChangeArgs >= 2)
|
||||
{
|
||||
TCollection_AsciiString aValStr (aChangeArgs[1]);
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = aClipPlane->CappingAspect();
|
||||
if (aValStr.IsRealValue())
|
||||
{
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->Material();
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
|
||||
aMat.SetTransparency ((float )aValStr.RealValue());
|
||||
aClipPlane->CappingSectionStyle()->SetMaterial (aMat);
|
||||
anAspect->SetAlphaMode (Graphic3d_AlphaMode_BlendAuto);
|
||||
aClipPlane->SetCappingMaterial (aMat);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << aValStr << "'\n";
|
||||
return 1;
|
||||
aValStr.LowerCase();
|
||||
Graphic3d_AlphaMode aMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
if (aValStr == "opaque")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Opaque;
|
||||
}
|
||||
else if (aValStr == "mask")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Mask;
|
||||
}
|
||||
else if (aValStr == "blend")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Blend;
|
||||
}
|
||||
else if (aValStr == "blendauto")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << aValStr << "'\n";
|
||||
return 1;
|
||||
}
|
||||
anAspect->SetAlphaMode (aMode);
|
||||
aClipPlane->SetCappingAspect (anAspect);
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-overrideaspect"
|
||||
|| aChangeArg == "overrideaspect")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->SetToOverrideCappingAspect (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-texname"
|
||||
|| aChangeArg == "texname")
|
||||
{
|
||||
@@ -9410,22 +9495,20 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
|
||||
if (!aTexture->IsDone())
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetTexture (Handle(Graphic3d_TextureMap)());
|
||||
aClipPlane->SetCappingTexture (NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
aTexture->EnableModulate();
|
||||
aTexture->EnableRepeat();
|
||||
aClipPlane->CappingSectionStyle()->SetTexture (aTexture.get());
|
||||
aClipPlane->SetCappingTexture (aTexture);
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-texscale"
|
||||
|| aChangeArg == "texscale")
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
@@ -9439,15 +9522,13 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
|
||||
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-texorigin"
|
||||
|| aChangeArg == "texorigin") // texture origin
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
@@ -9462,15 +9543,13 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
|
||||
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-texrotate"
|
||||
|| aChangeArg == "texrotate") // texture rotation
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
@@ -9483,7 +9562,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
}
|
||||
|
||||
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
aHatchTexture->GetParams()->SetRotation (aRot);
|
||||
aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatch"
|
||||
@@ -9495,165 +9574,22 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
TCollection_AsciiString aHatchStr (aChangeArgs[1]);
|
||||
aHatchStr.LowerCase();
|
||||
if (aHatchStr == "on")
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetToDrawHatch (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
aClipPlane->SetCappingHatchOn();
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-hatchtexture"
|
||||
|| aChangeArg == "hatchtexture")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
else if (aHatchStr == "off")
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aTextureName (aChangeArgs[1]);
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
|
||||
if (!aTexture->IsDone())
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetHatchStyle (Handle(Graphic3d_TextureMap)());
|
||||
aClipPlane->SetCappingHatchOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
aTexture->EnableModulate();
|
||||
aTexture->EnableRepeat();
|
||||
aClipPlane->CappingSectionStyle()->SetHatchStyle (aTexture.get());
|
||||
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
|
||||
aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatchstipple"
|
||||
|| aChangeArg == "hatchstipple")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aClipPlane->CappingSectionStyle()->SetHatchStyle ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
|
||||
aClipPlane->CappingSectionStyle()->SetToDrawHatch (true);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatchcolor"
|
||||
|| aChangeArg == "hatchcolor")
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
|
||||
aChangeArgs + 1,
|
||||
aColor);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingSectionStyle()->HatchMaterial();
|
||||
aMat.SetAmbientColor (aColor);
|
||||
aMat.SetDiffuseColor (aColor);
|
||||
aClipPlane->CappingSectionStyle()->SetHatchMaterial (aMat);
|
||||
anArgIter += aNbParsed;
|
||||
}
|
||||
|
||||
else if (aChangeArg == "-hatchscale"
|
||||
|| aChangeArg == "hatchscale")
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-hatchorigin"
|
||||
|| aChangeArg == "hatchorigin") // texture origin
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
|
||||
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-hatchrotate"
|
||||
|| aChangeArg == "hatchrotate") // texture rotation
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = aClipPlane->CappingSectionStyle()->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
aHatchTexture->GetParams()->SetRotation (aRot);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatchzoompers"
|
||||
|| aChangeArg == "hatchzoompers")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetHatchZoomPeristent (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-hatchrotatepers"
|
||||
|| aChangeArg == "hatchrotatepers")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->CappingSectionStyle()->SetHatchRotationPeristent (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-delete"
|
||||
|| aChangeArg == "delete")
|
||||
{
|
||||
@@ -13190,6 +13126,258 @@ static int VDumpSelectionImage (Draw_Interpretor& /*theDi*/,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : VViewCube
|
||||
//purpose :
|
||||
//===============================================================================================
|
||||
static int VViewCube (Draw_Interpretor& ,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
|
||||
const Handle(V3d_View)& aView = ViewerTest::CurrentView();
|
||||
if (aContext.IsNull() || aView.IsNull())
|
||||
{
|
||||
std::cout << "Error: no active view.\n";
|
||||
return 1;
|
||||
}
|
||||
else if (theNbArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(AIS_ViewCube) aViewCube;
|
||||
ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
|
||||
Quantity_Color aColorRgb;
|
||||
TCollection_AsciiString aName;
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||
{
|
||||
TCollection_AsciiString anArg (theArgVec[anArgIter]);
|
||||
anArg.LowerCase();
|
||||
if (anUpdateTool.parseRedrawMode (anArg))
|
||||
{
|
||||
//
|
||||
}
|
||||
else if (aViewCube.IsNull())
|
||||
{
|
||||
aName = theArgVec[anArgIter];
|
||||
if (aName.StartsWith ("-"))
|
||||
{
|
||||
std::cout << "Syntax error: object name should be specified.\n";
|
||||
return 1;
|
||||
}
|
||||
Handle(AIS_InteractiveObject) aPrs;
|
||||
GetMapOfAIS().Find2 (aName, aPrs);
|
||||
aViewCube = Handle(AIS_ViewCube)::DownCast (aPrs);
|
||||
if (aViewCube.IsNull())
|
||||
{
|
||||
aViewCube = new AIS_ViewCube();
|
||||
aViewCube->SetBoxColor (Quantity_NOC_GRAY50);
|
||||
aViewCube->SetViewAnimation (ViewerTest::CurrentEventManager()->ViewAnimation());
|
||||
aViewCube->SetFixedAnimationLoop (false);
|
||||
}
|
||||
}
|
||||
else if (anArg == "-reset")
|
||||
{
|
||||
aViewCube->ResetStyles();
|
||||
}
|
||||
else if (anArg == "-color"
|
||||
|| anArg == "-boxcolor"
|
||||
|| anArg == "-boxsidecolor"
|
||||
|| anArg == "-sidecolor"
|
||||
|| anArg == "-boxedgecolor"
|
||||
|| anArg == "-edgecolor"
|
||||
|| anArg == "-boxcornercolor"
|
||||
|| anArg == "-cornercolor"
|
||||
|| anArg == "-innercolor"
|
||||
|| anArg == "-textcolor")
|
||||
{
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
|
||||
theArgVec + anArgIter + 1,
|
||||
aColorRgb);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cerr << "Error: wrong syntax at '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
anArgIter += aNbParsed;
|
||||
if (anArg == "-boxcolor")
|
||||
{
|
||||
aViewCube->SetBoxColor (aColorRgb);
|
||||
}
|
||||
else if (anArg == "-boxsidecolor"
|
||||
|| anArg == "-sidecolor")
|
||||
{
|
||||
aViewCube->BoxSideStyle()->SetColor (aColorRgb);
|
||||
aViewCube->SynchronizeAspects();
|
||||
}
|
||||
else if (anArg == "-boxedgecolor"
|
||||
|| anArg == "-edgecolor")
|
||||
{
|
||||
aViewCube->BoxEdgeStyle()->SetColor (aColorRgb);
|
||||
aViewCube->SynchronizeAspects();
|
||||
}
|
||||
else if (anArg == "-boxcornercolor"
|
||||
|| anArg == "-cornercolor")
|
||||
{
|
||||
aViewCube->BoxCornerStyle()->SetColor (aColorRgb);
|
||||
aViewCube->SynchronizeAspects();
|
||||
}
|
||||
else if (anArg == "-innercolor")
|
||||
{
|
||||
aViewCube->SetInnerColor (aColorRgb);
|
||||
}
|
||||
else if (anArg == "-textcolor")
|
||||
{
|
||||
aViewCube->SetTextColor (aColorRgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
aViewCube->SetColor (aColorRgb);
|
||||
}
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& (anArg == "-transparency"
|
||||
|| anArg == "-boxtransparency"))
|
||||
{
|
||||
const Standard_Real aValue = Draw::Atof (theArgVec[++anArgIter]);
|
||||
if (aValue < 0.0 || aValue > 1.0)
|
||||
{
|
||||
std::cout << "Syntax error: invalid transparency value " << theArgVec[anArgIter] << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (anArg == "-boxtransparency")
|
||||
{
|
||||
aViewCube->SetBoxTransparency (aValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
aViewCube->SetTransparency (aValue);
|
||||
}
|
||||
}
|
||||
else if (anArg == "-axes"
|
||||
|| anArg == "-edges"
|
||||
|| anArg == "-vertices"
|
||||
|| anArg == "-vertexes"
|
||||
|| anArg == "-fixedanimation")
|
||||
{
|
||||
bool toShow = true;
|
||||
if (anArgIter + 1 < theNbArgs
|
||||
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShow))
|
||||
{
|
||||
++anArgIter;
|
||||
}
|
||||
if (anArg == "-fixedanimation")
|
||||
{
|
||||
aViewCube->SetFixedAnimationLoop (toShow);
|
||||
}
|
||||
else if (anArg == "-axes")
|
||||
{
|
||||
aViewCube->SetDrawAxes (toShow);
|
||||
}
|
||||
else if (anArg == "-edges")
|
||||
{
|
||||
aViewCube->SetDrawEdges (toShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
aViewCube->SetDrawVertices (toShow);
|
||||
}
|
||||
}
|
||||
else if (anArg == "-yup"
|
||||
|| anArg == "-zup")
|
||||
{
|
||||
bool isOn = true;
|
||||
if (anArgIter + 1 < theNbArgs
|
||||
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isOn))
|
||||
{
|
||||
++anArgIter;
|
||||
}
|
||||
if (anArg == "-yup")
|
||||
{
|
||||
aViewCube->SetYup (isOn);
|
||||
}
|
||||
else
|
||||
{
|
||||
aViewCube->SetYup (!isOn);
|
||||
}
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-font")
|
||||
{
|
||||
aViewCube->SetFont (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-fontheight")
|
||||
{
|
||||
aViewCube->SetFontHeight (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& (anArg == "-size"
|
||||
|| anArg == "-boxsize"))
|
||||
{
|
||||
aViewCube->SetSize (Draw::Atof (theArgVec[++anArgIter]),
|
||||
anArg != "-boxsize");
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& (anArg == "-boxfacet"
|
||||
|| anArg == "-boxfacetextension"
|
||||
|| anArg == "-facetextension"
|
||||
|| anArg == "-extension"))
|
||||
{
|
||||
aViewCube->SetBoxFacetExtension (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& (anArg == "-boxedgegap"
|
||||
|| anArg == "-edgegap"))
|
||||
{
|
||||
aViewCube->SetBoxEdgeGap (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& (anArg == "-boxedgeminsize"
|
||||
|| anArg == "-edgeminsize"))
|
||||
{
|
||||
aViewCube->SetBoxEdgeMinSize (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& (anArg == "-boxcornerminsize"
|
||||
|| anArg == "-cornerminsize"))
|
||||
{
|
||||
aViewCube->SetBoxCornerMinSize (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-axespadding")
|
||||
{
|
||||
aViewCube->SetAxesPadding (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-roundradius")
|
||||
{
|
||||
aViewCube->SetRoundRadius (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-duration")
|
||||
{
|
||||
aViewCube->SetDuration (Draw::Atof (theArgVec[++anArgIter]));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error: unknown argument '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (aViewCube.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
ViewerTest::Display (aName, aViewCube, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ViewerCommands
|
||||
//purpose :
|
||||
@@ -13475,12 +13663,14 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
__FILE__, VTile, group);
|
||||
theCommands.Add("vzlayer",
|
||||
"vzlayer [layerId]"
|
||||
"\n\t\t: [-add|-delete|-get|-settings]"
|
||||
"\n\t\t: [-add|-delete|-get|-settings] [-insertBefore AnotherLayer] [-insertAfter AnotherLayer]"
|
||||
"\n\t\t: [-origin X Y Z] [-cullDist Distance] [-cullSize Size]"
|
||||
"\n\t\t: [-enable|-disable {depthTest|depthWrite|depthClear|depthoffset}]"
|
||||
"\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv}]"
|
||||
"\n\t\t: [-enable|-disable {positiveOffset|negativeOffset|textureenv|rayTracing}]"
|
||||
"\n\t\t: ZLayer list management:"
|
||||
"\n\t\t: -add add new z layer to viewer and print its id"
|
||||
"\n\t\t: -insertBefore add new z layer and insert it before existing one"
|
||||
"\n\t\t: -insertAfter add new z layer and insert it after existing one"
|
||||
"\n\t\t: -delete delete z layer"
|
||||
"\n\t\t: -get print sequence of z layers"
|
||||
"\n\t\t: -settings print status of z layer settings"
|
||||
@@ -13564,6 +13754,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
|
||||
"\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
|
||||
"\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
|
||||
"\n\t\t: [-noExtensions {0|1}] [-maxVersion Major Minor]"
|
||||
"\n\t\t: Modify particular graphic driver options:"
|
||||
"\n\t\t: FFP - use fixed-function pipeline instead of"
|
||||
"\n\t\t: built-in GLSL programs"
|
||||
@@ -13578,6 +13769,8 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: softMode - software OpenGL implementation"
|
||||
"\n\t\t: compatibleProfile - backward-compatible profile"
|
||||
"\n\t\t: quadbuffer - QuadBuffer"
|
||||
"\n\t\t: noExtensions - disallow usage of extensions"
|
||||
"\n\t\t: maxVersion - force upper OpenGL version to be used"
|
||||
"\n\t\t: Unlike vrenderparams, these parameters control alternative"
|
||||
"\n\t\t: rendering paths producing the same visual result when"
|
||||
"\n\t\t: possible."
|
||||
@@ -13800,16 +13993,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-color R G B] [-transparency Value] [-hatch {on|off|ID}]"
|
||||
"\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
|
||||
"\n\t\t: [-texRotate Angle]"
|
||||
/*"\n\t\t: [-overrideAspect {0|1}]"
|
||||
"\n\t\t: [-color R G B]"
|
||||
"\n\t\t: [-texture Texture] [-texScale SX SY]"
|
||||
"\n\t\t: [-texOrigin TX TY] [-texRotate Angle]"
|
||||
"\n\t\t: [-hatch {on|off}] [-hatchStipple mask]"
|
||||
"\n\t\t: [-hatchColor R G B] [-hatchTexture texture]"
|
||||
"\n\t\t: [-hatchScale SX SY] [-hatchOrigin TX TY]"
|
||||
"\n\t\t: [-hatchRotate Angle]"
|
||||
"\n\t\t: [-hatchZoomPers {0|1}]"
|
||||
"\n\t\t: [-hatchRotatePers {0|1}]"*/
|
||||
"\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
|
||||
"\n\t\t: [-useObjShader {0|1}]"
|
||||
"\n\t\t: Clipping planes management:"
|
||||
@@ -13822,22 +14005,13 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
|
||||
"\n\t\t: Capping options:"
|
||||
"\n\t\t: -capping {off|on|0|1} turn capping on/off"
|
||||
"\n\t\t: -overrideAspect override presentation aspect (if defined)"
|
||||
"\n\t\t: -color R G B set capping color"
|
||||
"\n\t\t: -transparency Value set capping transparency 0..1"
|
||||
"\n\t\t: -texName Texture set capping texture"
|
||||
"\n\t\t: -texScale SX SY set capping tex scale"
|
||||
"\n\t\t: -texOrigin TX TY set capping tex origin"
|
||||
"\n\t\t: -texRotate Angle set capping tex rotation"
|
||||
"\n\t\t: -hatch {on|off} turn on/off hatch style on capping"
|
||||
"\n\t\t: -hatchStipple ID set stipple mask for drawing hatch"
|
||||
"\n\t\t: -hatchColor R G B set color for hatch material"
|
||||
"\n\t\t: -hatchTexture Texture set texture (semi-opaque) for drawing hatch"
|
||||
"\n\t\t: -hatchScale SX SY set hatch texture scale"
|
||||
"\n\t\t: -hatchOrigin TX TY set hatch texture origin"
|
||||
"\n\t\t: -hatchRotate Angle set hatch texture rotation"
|
||||
"\n\t\t: -hatchZoomPers allow hatch tetxure mapping to be constant when zooming"
|
||||
"\n\t\t: -hatchRotatePers allow hatch tetxure mapping to be constant when rotating"
|
||||
"\n\t\t: -hatch {on|off|ID} set capping hatching mask"
|
||||
"\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
|
||||
"\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
|
||||
"\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
|
||||
@@ -14003,5 +14177,37 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: selMode color of selection mode"
|
||||
"\n\t\t: entity color of etected entity",
|
||||
__FILE__, VDumpSelectionImage, group);
|
||||
}
|
||||
|
||||
theCommands.Add ("vviewcube",
|
||||
"vviewcube name"
|
||||
"\n\t\t: Displays interactive view manipualtion object."
|
||||
"\n\t\t: Options: "
|
||||
"\n\t\t: -reset reset geomertical and visual attributes'"
|
||||
"\n\t\t: -size Size adapted size of View Cube"
|
||||
"\n\t\t: -boxSize Size box size"
|
||||
"\n\t\t: -axes {0|1 } show/hide axes (trihedron)"
|
||||
"\n\t\t: -edges {0|1} show/hide edges of View Cube"
|
||||
"\n\t\t: -vertices {0|1} show/hide vertices of View Cube"
|
||||
"\n\t\t: -Yup {0|1} -Zup {0|1} set Y-up or Z-up view orientation"
|
||||
"\n\t\t: -color Color color of View Cube"
|
||||
"\n\t\t: -boxColor Color box color"
|
||||
"\n\t\t: -boxSideColor Color box sides color"
|
||||
"\n\t\t: -boxEdgeColor Color box edges color"
|
||||
"\n\t\t: -boxCornerColor Color box corner color"
|
||||
"\n\t\t: -textColor Color color of side text of view cube"
|
||||
"\n\t\t: -innerColor Color inner box color"
|
||||
"\n\t\t: -transparency Value transparency of object within [0, 1] range"
|
||||
"\n\t\t: -boxTransparency Value transparency of box within [0, 1] range"
|
||||
"\n\t\t: -font Name font name"
|
||||
"\n\t\t: -fontHeight Value font height"
|
||||
"\n\t\t: -boxFacetExtension Value box facet extension"
|
||||
"\n\t\t: -boxEdgeGap Value gap between box edges and box sides"
|
||||
"\n\t\t: -boxEdgeMinSize Value minimal box edge size"
|
||||
"\n\t\t: -boxCornerMinSize Value minimal box corner size"
|
||||
"\n\t\t: -axesPadding Value padding between box and arrows"
|
||||
"\n\t\t: -roundRadius Value relative radius of corners of sides within [0.0, 0.5] range"
|
||||
"\n\t\t: -fixedanimation {0|1} uninterruptible animation loop"
|
||||
"\n\t\t: -duration Seconds animation duration in seconds",
|
||||
__FILE__, VViewCube, group);
|
||||
|
||||
}
|
||||
|
@@ -26,5 +26,5 @@ for {set i 1} {${i} <= ${NCycles}} {incr i } {
|
||||
bop b1 b2
|
||||
bopcut r
|
||||
lappend listmem [meminfo h]
|
||||
checktrend $listmem 0 100 "Memory leak detected"
|
||||
}
|
||||
checktrend $listmem 0 100 "Memory leak detected"
|
||||
|
20
tests/bugs/modalg_7/bug30829
Normal file
20
tests/bugs/modalg_7/bug30829
Normal file
@@ -0,0 +1,20 @@
|
||||
puts "========"
|
||||
puts "0030829: BRepExtrema_ShapeProximity crashes with shape from STL/WRL"
|
||||
puts "========"
|
||||
puts ""
|
||||
|
||||
pload XSDRAW
|
||||
|
||||
box b 10 10 10
|
||||
pcylinder c 5 10
|
||||
incmesh b 0.1
|
||||
incmesh c 0.1
|
||||
|
||||
writestl b ${imagedir}/${test_image}_b.stl
|
||||
writestl c ${imagedir}/${test_image}_c.stl
|
||||
readstl b ${imagedir}/${test_image}_b.stl
|
||||
readstl c ${imagedir}/${test_image}_c.stl
|
||||
file delete ${imagedir}/${test_image}_b.stl
|
||||
file delete ${imagedir}/${test_image}_c.stl
|
||||
|
||||
proximity b c
|
12
tests/bugs/step/bug30628
Normal file
12
tests/bugs/step/bug30628
Normal file
@@ -0,0 +1,12 @@
|
||||
puts "# ====================================================================="
|
||||
puts "# 0030628: Data Exchange - Crash on importing STEP file"
|
||||
puts "# ====================================================================="
|
||||
puts ""
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
ReadStep D [locate_data_file bug30628_319892-GSE306L520-HOG-s5.stp]
|
||||
XDisplay D -dispMode 1
|
||||
vfit
|
||||
vdump ${imagedir}/${casename}.png
|
13
tests/bugs/step/bug30790
Normal file
13
tests/bugs/step/bug30790
Normal file
@@ -0,0 +1,13 @@
|
||||
puts "========================"
|
||||
puts "0030790: Crash when loading specific step file"
|
||||
puts "========================"
|
||||
|
||||
puts "TODO 30790 ALL: Faulty shapes in variables faulty_1 to"
|
||||
|
||||
stepread [locate_data_file bug30790.step] a *
|
||||
|
||||
tpcompound result
|
||||
|
||||
checkshape result
|
||||
|
||||
checkview -display result -2d -path ${imagedir}/${test_image}.png
|
@@ -46,7 +46,6 @@ vclipplane change pln2 equation -0.707 0.707 0 -25
|
||||
vclipplane change pln2 capping on
|
||||
vclipplane change pln2 capping color 0.5 0.5 0.9
|
||||
vclipplane change pln2 capping hatch on
|
||||
vclipplane change pln2 capping hatchStipple 7
|
||||
vclipplane set pln2 object b3
|
||||
|
||||
checkcolor $x3_coord $y3_coord 0.5 0.5 0.9
|
||||
|
@@ -71,5 +71,5 @@ vdisplay pp1 pp2
|
||||
vzoom 0.8
|
||||
|
||||
puts "Enable capping planes"
|
||||
vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -hatchtexture $aHatch -hatchscale 0.02 -0.02 -useObjMaterial 1
|
||||
vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -hatchtexture $aHatch -hatchscale 0.02 -0.02
|
||||
vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -texname $aHatch -texscale 0.02 -0.02 -useObjMaterial 1
|
||||
vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -texname $aHatch -texscale 0.02 -0.02
|
||||
|
48
tests/bugs/vis/bug30630_1
Normal file
48
tests/bugs/vis/bug30630_1
Normal file
@@ -0,0 +1,48 @@
|
||||
puts "=================================================================================="
|
||||
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
|
||||
puts "Check that displaying of non-solid shapes (shells) is not affected by mirror transformation"
|
||||
puts "=================================================================================="
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vrotate 3 0 0
|
||||
vcamera -persp
|
||||
|
||||
# Simple box
|
||||
box b 1 1 1
|
||||
explode b sh
|
||||
renamevar b_1 b
|
||||
vdisplay -dispMode 1 b
|
||||
vaspects b -setBackFaceColor RED
|
||||
vfit
|
||||
vdump $imagedir/${casename}_simple.png
|
||||
verase b
|
||||
|
||||
# Box with mirror transformation
|
||||
box a 1 1 1
|
||||
bmirror a 0 0 0 1 0 0
|
||||
explode a sh
|
||||
renamevar a_1 a
|
||||
vdisplay -dispMode 1 a
|
||||
vaspects a -setBackFaceColor RED
|
||||
vfit
|
||||
box aa -0.5 0.5 0.5 0.1 0.1 0.1
|
||||
vdisplay -dispMode 1 aa
|
||||
vsetcolor aa BLUE1
|
||||
vdump $imagedir/${casename}_mirror.png
|
||||
if { [vreadpixel 300 200 rgb name] != "RED2" } { puts "Error: shell of mirrored box should show back faces" }
|
||||
verase a
|
||||
|
||||
# Box with mirror transformation and reversed face
|
||||
box c 1 1 1
|
||||
bmirror c 0 0 0 1 0 0
|
||||
orientation c R
|
||||
explode c sh
|
||||
renamevar c_1 c
|
||||
vdisplay -dispMode 1 c
|
||||
vaspects c -setBackFaceColor RED
|
||||
vfit
|
||||
vdump $imagedir/${casename}_mirrev.png
|
||||
if { [vreadpixel 300 200 rgb name] == "RED2" } { puts "Error: shell of reversed mirrored box should show front faces" }
|
40
tests/bugs/vis/bug30630_2
Normal file
40
tests/bugs/vis/bug30630_2
Normal file
@@ -0,0 +1,40 @@
|
||||
puts "=================================================================================="
|
||||
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
|
||||
puts "Check that local transformation of visualizated object"
|
||||
puts "affects only position, not material place"
|
||||
puts "=================================================================================="
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vrotate 3 0 0
|
||||
vcamera -persp
|
||||
|
||||
# Simple box
|
||||
box b 1 1 1
|
||||
bmirror b 0 0 0 0 0 1
|
||||
vdisplay -dispMode 1 b
|
||||
vaspects b -setBackFaceColor RED
|
||||
box bb 0.5 0.5 -0.5 0.1 0.1 0.1
|
||||
vdisplay -dispMode 1 bb
|
||||
vsetcolor bb BLUE1
|
||||
vfit
|
||||
vdump $imagedir/${casename}_simple.png
|
||||
if { [vreadpixel 195 220 rgb name] != "BLUE2" } { puts "Error: mirrored box should look inside out" }
|
||||
|
||||
# Box with rotation transformation
|
||||
vlocation b -rotate 0 0 0 1 0 0 90
|
||||
vlocation bb -rotate 0 0 0 1 0 0 90
|
||||
vfit
|
||||
vdump $imagedir/${casename}_rotate.png
|
||||
if { [vreadpixel 215 230 rgb name] != "BLUE2" } { puts "Error: rotated mirrored box should look inside out" }
|
||||
|
||||
# Box with mirror transformation
|
||||
vlocation b -reset
|
||||
vlocation b -mirror 0 -0.5 0 0 1 0
|
||||
vlocation bb -reset
|
||||
vlocation bb -mirror 0 -0.5 0 0 1 0
|
||||
vfit
|
||||
vdump $imagedir/${casename}_mirror.png
|
||||
if { [vreadpixel 215 230 rgb name] != "BLUE2" } { puts "Error: mirrored mirrored box should look inside out" }
|
42
tests/bugs/vis/bug30630_3
Normal file
42
tests/bugs/vis/bug30630_3
Normal file
@@ -0,0 +1,42 @@
|
||||
puts "=================================================================================="
|
||||
puts "0030630: Visualization - wrong visualization of shape with mirrored transformation"
|
||||
puts "Check that solid with mirrored transformation is displayed as turned out"
|
||||
puts "=================================================================================="
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vrotate 3 0 0
|
||||
vcamera -persp
|
||||
|
||||
# Simple box
|
||||
box b 1 1 1
|
||||
vdisplay -dispMode 1 b
|
||||
vaspects b -setBackFaceColor RED
|
||||
vfit
|
||||
vdump $imagedir/${casename}_simple.png
|
||||
verase b
|
||||
|
||||
# Box with mirror transformation
|
||||
box a 1 1 1
|
||||
bmirror a 0 0 0 1 0 0
|
||||
vdisplay -dispMode 1 a
|
||||
vaspects a -setBackFaceColor RED
|
||||
vfit
|
||||
box aa -0.5 0.5 0.5 0.1 0.1 0.1
|
||||
vdisplay -dispMode 1 aa
|
||||
vsetcolor aa BLUE1
|
||||
vdump $imagedir/${casename}_mirror.png
|
||||
if { [vreadpixel 195 220 rgb name] != "BLUE2" } { puts "Error: mirrored box should look inside out" }
|
||||
verase a
|
||||
|
||||
# Box with mirror transformation and reversed face
|
||||
box c 1 1 1
|
||||
bmirror c 0 0 0 1 0 0
|
||||
orientation c R
|
||||
vdisplay -dispMode 1 c
|
||||
vaspects c -setBackFaceColor RED
|
||||
vfit
|
||||
vdump $imagedir/${casename}_mirrev.png
|
||||
if { [vreadpixel 195 220 rgb name] == "BLUE2" } { puts "Error: revered mirrored box should NOT look inside out" }
|
@@ -1,7 +1,7 @@
|
||||
# !!!! This file is generated automatically, do not edit manually! See end script
|
||||
puts "TODO CR23096 ALL: Update of 3D-Parameters has failed"
|
||||
puts "TODO CR23096 ALL: CHECKSHAPE : Faulty"
|
||||
|
||||
puts "TODO CR23096 ALL: Error : 2 differences with reference data found"
|
||||
|
||||
set filename 53921163S0.stp
|
||||
|
||||
|
@@ -28,7 +28,7 @@ vzbufftrihedron
|
||||
|
||||
catch { vzlayer del 1 }
|
||||
set aLayerId [vzlayer add]
|
||||
vzlayer $aLayerId -enable depthClear
|
||||
vzlayer $aLayerId -enable depthClear -disable rayTracing
|
||||
|
||||
vtrihedron trh
|
||||
vdisplay -noupdate trh -layer $aLayerId -trihedron topRight 100 100
|
||||
|
@@ -19,3 +19,4 @@
|
||||
020 anim
|
||||
021 dimensions
|
||||
022 transparency
|
||||
023 viewcube
|
||||
|
36
tests/v3d/viewcube/default
Normal file
36
tests/v3d/viewcube/default
Normal file
@@ -0,0 +1,36 @@
|
||||
puts "=================================="
|
||||
puts "0028954: Visualization - implement interactive object AIS_ViewCube for camera manipulations"
|
||||
puts "Display and erase with default settings"
|
||||
puts "=================================="
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
|
||||
box b 15 20 70
|
||||
vdisplay -dispMode 1 b
|
||||
vaxo
|
||||
vfit
|
||||
vviewcube vc -fixedAnimation 1 -duration 0
|
||||
|
||||
vmoveto 70 340
|
||||
if {[vreadpixel 70 340 name rgb] != "CYAN1"} { puts "Error: Highlighting of view cube Side is wrong." }
|
||||
vmoveto 0 0
|
||||
vdump $imagedir/${casename}_axo.png
|
||||
|
||||
# check FRONT side
|
||||
vselect 70 340
|
||||
if {[vreadpixel 255 300 name rgb] != "BLACK"} { puts "Error: Position of FRONT camera is wrong." }
|
||||
vdump $imagedir/${casename}_side.png
|
||||
|
||||
# check FRONT/TOP edge
|
||||
vselect 100 270
|
||||
if {[vreadpixel 100 300 name rgb] != "GRAY51"} { puts "Error: Position of FRONT-TOP camera is wrong." }
|
||||
if {[vreadpixel 100 310 name rgb] != "CYAN1"} { puts "Error: Position of FRONT-TOP camera is wrong." }
|
||||
vdump $imagedir/${casename}_edge.png
|
||||
|
||||
# Check vertex
|
||||
vselect 140 310
|
||||
if {[vreadpixel 100 290 name rgb] != "GRAY42"} { puts "Error: Position of TOP-FRONT-RIGHT camera is wrong." }
|
||||
if {[vreadpixel 100 310 name rgb] != "CYAN1"} { puts "Error: Position of TOP-FRONT-RIGHT camera is wrong." }
|
||||
if {[vreadpixel 100 320 name rgb] != "MATRAGRAY"} { puts "Error: Position of TOP-FRONT-RIGHT camera is wrong." }
|
||||
vdump $imagedir/${casename}_corner.png
|
17
tests/v3d/viewcube/largedist
Normal file
17
tests/v3d/viewcube/largedist
Normal file
@@ -0,0 +1,17 @@
|
||||
puts "=================================="
|
||||
puts "0030850: Visualization, OpenGl_Text - text within trihedron persistence jitters when camera is far from origin"
|
||||
puts "=================================="
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
|
||||
box b 0.001 0.001 0.001
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vdisplay -dispMode 1 b
|
||||
vlocation b -setLocation 1000000 0 0
|
||||
vfit
|
||||
vzlayer DEFAULT -origin 1000000 0 0
|
||||
vviewcube vc
|
||||
|
||||
vdump $imagedir/${casename}.png
|
44
tests/v3d/viewcube/style
Normal file
44
tests/v3d/viewcube/style
Normal file
@@ -0,0 +1,44 @@
|
||||
puts "=================================="
|
||||
puts "0028954: Visualization - implement interactive object AIS_ViewCube for camera manipulations"
|
||||
puts "Display custom styled View Cube"
|
||||
puts "=================================="
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
|
||||
vviewcube vc -edges 0
|
||||
if {[vreadpixel 70 295 name rgb] != "BLACK"} { puts "Error: Invalid display of View Cube without edges." }
|
||||
vdump $imagedir/${casename}_noedges.png
|
||||
|
||||
vviewcube vc -edges 1 -vertices 0
|
||||
if {[vreadpixel 100 308 name rgb] != "BLACK"} { puts "Error: Invalid display of View Cube without vertices." }
|
||||
vdump $imagedir/${casename}_noverts.png
|
||||
|
||||
vviewcube vc -edges 0 -vertices 0
|
||||
|
||||
if {[vreadpixel 70 295 name rgb] != "BLACK" || [vreadpixel 100 308 name rgb] != "BLACK"} {
|
||||
puts "Error: Invalid display of View Cube without edges & vertices."
|
||||
}
|
||||
vdump $imagedir/${casename}_noedgeandvert.png
|
||||
vclear
|
||||
|
||||
# Color
|
||||
vviewcube vc1 -boxColor 0.69 0.88 1 -textColor 0 0.4 0.54
|
||||
vdisplay vc1 -trihedron bottomLeft 100 100
|
||||
|
||||
# Transparency
|
||||
vviewcube vc2 -transparency 0.5
|
||||
vdisplay vc2 -trihedron topLeft 100 100
|
||||
|
||||
# Font
|
||||
vviewcube vc3 -reset -boxSideColor WHITE -font "monospace" -fontHeight 16
|
||||
vdisplay vc3 -trihedron bottomRight 100 100
|
||||
|
||||
# Corner radius
|
||||
vviewcube vc4 -reset -boxSideColor WHITE -roundRadius 0.2 -boxEdgeGap 2
|
||||
vdisplay vc4 -trihedron topRight 100 100
|
||||
|
||||
# Padding
|
||||
vviewcube vc5 -reset -boxFacetExtension 0 -axesPadding 0
|
||||
vdisplay vc5 -trihedron center
|
||||
vdump $imagedir/${casename}_styles.png
|
22
tests/v3d/viewcube/view
Normal file
22
tests/v3d/viewcube/view
Normal file
@@ -0,0 +1,22 @@
|
||||
puts "=================================="
|
||||
puts "0028954: Visualization - implement interactive object AIS_ViewCube for camera manipulations"
|
||||
puts "Check view affinity"
|
||||
puts "=================================="
|
||||
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit View1
|
||||
vinit View2
|
||||
|
||||
vviewcube vc
|
||||
verase vc -view
|
||||
|
||||
if {[vreadpixel 100 350 name rgb] != "BLACK"} { puts "Error: hiding Cube in View2 fails." }
|
||||
vdump $imagedir/${casename}_v2.png
|
||||
|
||||
vactivate View1
|
||||
|
||||
if {[vreadpixel 100 350 name rgb] == "BLACK"} { puts "Error: showing Cube in View1 fails." }
|
||||
vdump $imagedir/${casename}_v1.png
|
||||
|
||||
vactivate View2
|
Reference in New Issue
Block a user