diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index c39da2fec4..6c489f6de7 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1716,6 +1716,21 @@ aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array aGroup->AddPrimitiveArray (aLines); ~~~~ +@subsection upgrade_740_prsupdate Presentation invalidation + +Historically AIS_InteractiveObject provided two independent mechanisms invalidating presentation (asking presentation manager to recompute specific display mode or all modes): + +1. *AIS_InteractiveObject::SetToUpdate()*, marking existing presentation for update. + This is main invalidation API, which is expected to be followed by *AIS_InteractiveContext::Update()* call. +2. *AIS_InteractiveObject::myToRecomputeModes* + *myRecomputeEveryPrs*. + This is auxiliary invalidation API, used internally by AIS_InteractiveContext::SetColor()/UnsetColor() and similar modification methods. + +The latter one has been removed to avoid confusion and unexpected behavior. +In addition, two methods *AIS_InteractiveObject::Update()* have been deprecated in favor of new *AIS_InteractiveObject::UpdatePresentations()* recomputing only invalidated presentations. + +Custom presentations implementing interface methods *AIS_InteractiveObject::SetColor()* and others should be revised to use *AIS_InteractiveObject::SetToUpdate()* +or updating presentation without recomputation (see *AIS_InteractiveObject::SynchronizeAspects()* and *AIS_InteractiveObject::replaceAspects()*). + @subsection upgrade_740_interiorstyles Interior styles * *Aspect_IS_HOLLOW* is now an alias to *Aspect_IS_EMPTY* and does not implicitly enables drawing mesh edges anymore. diff --git a/samples/mfc/standard/Common/ISession2D/ISession2D_Shape.cpp b/samples/mfc/standard/Common/ISession2D/ISession2D_Shape.cpp index 378debad79..c26d81e742 100755 --- a/samples/mfc/standard/Common/ISession2D/ISession2D_Shape.cpp +++ b/samples/mfc/standard/Common/ISession2D/ISession2D_Shape.cpp @@ -17,7 +17,8 @@ void ISession2D_Shape::Add(const TopoDS_Shape& aShape) myListOfShape.Append(aShape); myAlgo.Nullify(); myPolyAlgo.Nullify(); - Update(); // protected method used to specify that the presentation are not up to date + SetToUpdate(); + UpdatePresentations(); } void ISession2D_Shape::Remove (const TopoDS_Shape& theShape) @@ -42,23 +43,17 @@ void ISession2D_Shape::SetProjector (HLRAlgo_Projector& aProjector) myProjector= aProjector; myAlgo.Nullify(); myPolyAlgo.Nullify(); - Update(); // protected method used to specify that the presentation are not up to date + SetToUpdate(); + UpdatePresentations(); }; void ISession2D_Shape::SetNbIsos(Standard_Integer& aNbIsos) -{ - myNbIsos= aNbIsos; - myAlgo.Nullify(); - - // declare the mode 100 to 110 as non valid - for (int i=100;i<=110;i++) - Update(i,Standard_False); // protected method used to specify that the presentation are not up to date - - // declare the mode 1100 to 1110 as non valid - for (int i=1100;i<=1110;i++) - Update(i,Standard_False); // protected method used to specify that the presentation are not up to date - +{ + myNbIsos= aNbIsos; + myAlgo.Nullify(); + SetToUpdate(); + UpdatePresentations(); }; void ISession2D_Shape::BuildAlgo() diff --git a/src/AIS/AIS_Axis.cxx b/src/AIS/AIS_Axis.cxx index 9123430c89..8ae1383eea 100644 --- a/src/AIS/AIS_Axis.cxx +++ b/src/AIS/AIS_Axis.cxx @@ -221,7 +221,7 @@ void AIS_Axis::SetColor(const Quantity_Color &aCol) DA->LineAspect(Prs3d_DP_XAxis)->SetColor(aCol); DA->LineAspect(Prs3d_DP_YAxis)->SetColor(aCol); DA->LineAspect(Prs3d_DP_ZAxis)->SetColor(aCol); - + SynchronizeAspects(); } //======================================================================= @@ -230,7 +230,6 @@ void AIS_Axis::SetColor(const Quantity_Color &aCol) //======================================================================= void AIS_Axis::SetWidth(const Standard_Real aValue) { - if(aValue<0.0) return; if(aValue==0) UnsetWidth(); @@ -240,6 +239,7 @@ void AIS_Axis::SetWidth(const Standard_Real aValue) DA->LineAspect(Prs3d_DP_XAxis)->SetWidth(aValue); DA->LineAspect(Prs3d_DP_YAxis)->SetWidth(aValue); DA->LineAspect(Prs3d_DP_ZAxis)->SetWidth(aValue); + SynchronizeAspects(); } @@ -324,14 +324,13 @@ AcceptDisplayMode(const Standard_Integer aMode) const //======================================================================= void AIS_Axis::UnsetColor() { - myDrawer->LineAspect()->SetColor(Quantity_NOC_RED); - - hasOwnColor=Standard_False; + hasOwnColor = Standard_False; myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetColor(Quantity_NOC_TURQUOISE); myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetColor(Quantity_NOC_TURQUOISE); myDrawer->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_NOC_TURQUOISE); + SynchronizeAspects(); } //======================================================================= //function : UnsetWidth @@ -340,10 +339,10 @@ void AIS_Axis::UnsetColor() void AIS_Axis::UnsetWidth() { - myOwnWidth = 0.0; + myOwnWidth = 0.0f; myDrawer->LineAspect()->SetWidth(1.); myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetWidth(1.); myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetWidth(1.); myDrawer->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetWidth(1.); + SynchronizeAspects(); } - diff --git a/src/AIS/AIS_CameraFrustum.cxx b/src/AIS/AIS_CameraFrustum.cxx index da4e77669f..a9131c02a0 100644 --- a/src/AIS/AIS_CameraFrustum.cxx +++ b/src/AIS/AIS_CameraFrustum.cxx @@ -90,6 +90,7 @@ void AIS_CameraFrustum::SetColor (const Quantity_Color& theColor) AIS_InteractiveObject::SetColor (theColor); myDrawer->ShadingAspect()->SetColor (theColor); myDrawer->LineAspect()->SetColor (theColor); + SynchronizeAspects(); } //======================================================================= @@ -107,6 +108,7 @@ void AIS_CameraFrustum::UnsetColor() myDrawer->ShadingAspect()->SetColor (THE_DEFAULT_COLOR); myDrawer->LineAspect()->SetColor (THE_DEFAULT_COLOR); + SynchronizeAspects(); } //======================================================================= @@ -117,6 +119,7 @@ void AIS_CameraFrustum::UnsetTransparency() { myDrawer->ShadingAspect()->SetTransparency (0.0f); myDrawer->SetTransparency (0.0f); + SynchronizeAspects(); } //======================================================================= diff --git a/src/AIS/AIS_Circle.cxx b/src/AIS/AIS_Circle.cxx index 0c07482fef..55b1d33d64 100644 --- a/src/AIS/AIS_Circle.cxx +++ b/src/AIS/AIS_Circle.cxx @@ -112,6 +112,29 @@ void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, } +//======================================================================= +//function : replaceWithNewLineAspect +//purpose : +//======================================================================= +void AIS_Circle::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect) +{ + if (!myDrawer->HasLink()) + { + myDrawer->SetLineAspect (theAspect); + return; + } + + const Handle(Graphic3d_AspectLine3d) anAspectOld = myDrawer->LineAspect()->Aspect(); + const Handle(Graphic3d_AspectLine3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect(); + if (anAspectNew != anAspectOld) + { + myDrawer->SetLineAspect (theAspect); + Graphic3d_MapOfAspectsToAspects aReplaceMap; + aReplaceMap.Bind (anAspectOld, anAspectNew); + replaceAspects (aReplaceMap); + } +} + //======================================================================= //function : SetColor //purpose : @@ -122,34 +145,41 @@ void AIS_Circle::SetColor(const Quantity_Color &aCol) hasOwnColor=Standard_True; myDrawer->SetColor (aCol); - Standard_Real WW = HasWidth() ? myOwnWidth : - myDrawer->HasLink() ? - AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : - 1.; - - if (!myDrawer->HasOwnLineAspect ()) - myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); + if (!myDrawer->HasOwnLineAspect()) + { + Standard_Real WW = HasWidth() ? myOwnWidth : + myDrawer->HasLink() ? + AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : + 1.; + replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW)); + } else + { myDrawer->LineAspect()->SetColor(aCol); + SynchronizeAspects(); + } } - - //======================================================================= //function : SetWidth //purpose : //======================================================================= void AIS_Circle::SetWidth(const Standard_Real aValue) { - myOwnWidth=aValue; + myOwnWidth = (Standard_ShortReal )aValue; - if (!myDrawer->HasOwnLineAspect ()) { + if (!myDrawer->HasOwnLineAspect()) + { Quantity_Color CC = Quantity_NOC_YELLOW; if( HasColor() ) CC = myDrawer->Color(); else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); - myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue)); - } else + replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue)); + } + else + { myDrawer->LineAspect()->SetWidth(aValue); + SynchronizeAspects(); + } } @@ -161,15 +191,18 @@ void AIS_Circle::UnsetColor() { hasOwnColor = Standard_False; - Handle(Prs3d_LineAspect) NullAsp; - - if (!HasWidth()) myDrawer->SetLineAspect(NullAsp); - else{ + if (!HasWidth()) + { + replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); + } + else + { Quantity_Color CC = Quantity_NOC_YELLOW;; if( HasColor() ) CC = myDrawer->Color(); else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); myDrawer->LineAspect()->SetColor(CC); myDrawer->SetColor (CC); + SynchronizeAspects(); } } @@ -179,11 +212,13 @@ void AIS_Circle::UnsetColor() //======================================================================= void AIS_Circle::UnsetWidth() { - Handle(Prs3d_LineAspect) NullAsp; - - if (!HasColor()) myDrawer->SetLineAspect(NullAsp); - else{ - Standard_Real WW = myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.; + if (!HasColor()) + { + replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); + } + else + { + Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.0f; myDrawer->LineAspect()->SetWidth(WW); myOwnWidth = WW; } diff --git a/src/AIS/AIS_Circle.hxx b/src/AIS/AIS_Circle.hxx index 7e49f5abab..5408bf78e8 100644 --- a/src/AIS/AIS_Circle.hxx +++ b/src/AIS/AIS_Circle.hxx @@ -115,6 +115,9 @@ private: Standard_EXPORT void ComputeArcSelection (const Handle(SelectMgr_Selection)& aSelection); + //! Replace aspects of already computed groups with the new value. + void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect); + private: Handle(Geom_Circle) myComponent; diff --git a/src/AIS/AIS_ColoredShape.cxx b/src/AIS/AIS_ColoredShape.cxx index 9211c0e71b..584d277d6d 100644 --- a/src/AIS/AIS_ColoredShape.cxx +++ b/src/AIS/AIS_ColoredShape.cxx @@ -124,8 +124,7 @@ Handle(AIS_ColoredDrawer) AIS_ColoredShape::CustomAspects (const TopoDS_Shape& t { aDrawer = new AIS_ColoredDrawer (myDrawer); myShapeColors.Bind (theShape, aDrawer); - LoadRecomputable (AIS_WireFrame); - LoadRecomputable (AIS_Shaded); + SetToUpdate(); } return aDrawer; } @@ -141,8 +140,7 @@ void AIS_ColoredShape::ClearCustomAspects() return; } myShapeColors.Clear(); - LoadRecomputable (AIS_WireFrame); - LoadRecomputable (AIS_Shaded); + SetToUpdate(); } //======================================================================= @@ -157,8 +155,7 @@ void AIS_ColoredShape::UnsetCustomAspects (const TopoDS_Shape& theShape, return; } - LoadRecomputable (AIS_WireFrame); - LoadRecomputable (AIS_Shaded); + SetToUpdate(); if (theToUnregister) { myShapeColors.UnBind (theShape); @@ -183,8 +180,6 @@ void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape& theShape, const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape); setColor (aDrawer, theColor); aDrawer->SetOwnColor (theColor); - LoadRecomputable (AIS_WireFrame); - LoadRecomputable (AIS_Shaded); } //======================================================================= @@ -202,8 +197,6 @@ void AIS_ColoredShape::SetCustomTransparency (const TopoDS_Shape& theShape, const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape); setTransparency (aDrawer, theTransparency); aDrawer->SetOwnTransparency (theTransparency); - LoadRecomputable (AIS_WireFrame); - LoadRecomputable (AIS_Shaded); } //======================================================================= @@ -221,8 +214,6 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape, const Handle(AIS_ColoredDrawer)& aDrawer = CustomAspects (theShape); setWidth (aDrawer, theLineWidth); aDrawer->SetOwnWidth (theLineWidth); - LoadRecomputable (AIS_WireFrame); - LoadRecomputable (AIS_Shaded); } //======================================================================= diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 5c8aa1368c..77aa02c379 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -952,7 +952,8 @@ void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObjec return; } - theIObj->Update (theAllModes); + theIObj->SetToUpdate(); + theIObj->UpdatePresentations (theAllModes); if (!theToUpdateViewer) { return; @@ -1006,13 +1007,7 @@ void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIOb return; } - TColStd_ListOfInteger aPrsModes; - theIObj->ToBeUpdated (aPrsModes); - for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next()) - { - theIObj->Update (aPrsModesIt.Value(), Standard_False); - } - + theIObj->UpdatePresentations(); mgrSelector->Update(theIObj); if (theUpdateViewer) @@ -1369,63 +1364,6 @@ void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_Interactive } } -//======================================================================= -//function : redisplayPrsRecModes -//purpose : -//======================================================================= -void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj, - const Standard_Boolean theToUpdateViewer) -{ - if (theIObj->RecomputeEveryPrs()) - { - theIObj->Update (Standard_True); - theIObj->UpdateSelection(); - } - else - { - for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next()) - { - theIObj->Update (aModes.Value(), Standard_False); - } - theIObj->UpdateSelection(); - theIObj->SetRecomputeOk(); - } - - if (theToUpdateViewer) - { - UpdateCurrentViewer(); - } -} - -//======================================================================= -//function : redisplayPrsModes -//purpose : -//======================================================================= -void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj, - const Standard_Boolean theToUpdateViewer) -{ - if (theIObj->RecomputeEveryPrs()) - { - theIObj->Update (Standard_True); - theIObj->UpdateSelection(); - } - else - { - TColStd_ListOfInteger aModes; - theIObj->ToBeUpdated (aModes); - for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next()) - { - theIObj->Update (aModeIter.Value(), Standard_False); - } - theIObj->SetRecomputeOk(); - } - - if (theToUpdateViewer) - { - UpdateCurrentViewer(); - } -} - //======================================================================= //function : SetColor //purpose : @@ -1441,7 +1379,11 @@ void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theI setContextToObject (theIObj); theIObj->SetColor (theColor); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1486,7 +1428,11 @@ void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_Interacti Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); aShape->SetOwnDeviationCoefficient (theCoefficient); - redisplayPrsModes (theIObj, theToUpdateViewer); + aShape->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1516,7 +1462,11 @@ void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_Intera Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); aShape->SetOwnHLRDeviationCoefficient (theCoefficient); - redisplayPrsModes (theIObj, theToUpdateViewer); + aShape->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1545,7 +1495,11 @@ void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObje Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); aShape->SetOwnDeviationAngle (theAngle); - redisplayPrsModes (theIObj, theToUpdateViewer); + aShape->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1574,15 +1528,10 @@ void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveO Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); aShape->SetAngleAndDeviation (theAngle); - - if (theIObj->RecomputeEveryPrs()) + aShape->UpdatePresentations(); + if (theToUpdateViewer) { - theIObj->Update (Standard_True); - theIObj->UpdateSelection(); - } - else - { - Update (theIObj, theToUpdateViewer); + UpdateCurrentViewer(); } } @@ -1611,7 +1560,11 @@ void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_Interacti } Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); aShape->SetHLRAngleAndDeviation (theAngle); - redisplayPrsModes (theIObj, theToUpdateViewer); + aShape->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1639,7 +1592,11 @@ void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveO } Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); aShape->SetOwnHLRDeviationAngle (theAngle); - redisplayPrsModes (theIObj, theToUpdateViewer); + aShape->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1655,7 +1612,11 @@ void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& th } theIObj->UnsetColor(); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1701,7 +1662,7 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI setContextToObject (theIObj); theIObj->SetWidth (theWidth); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj)) { if (myLastinMain->IsAutoHilight()) @@ -1718,6 +1679,10 @@ void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theI myLastinMain); } } + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1733,7 +1698,11 @@ void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& th } theIObj->UnsetWidth(); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1751,7 +1720,11 @@ void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& t setContextToObject (theIObj); theIObj->SetMaterial (theMaterial); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1766,7 +1739,11 @@ void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& return; } theIObj->UnsetMaterial(); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1796,7 +1773,11 @@ void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject } theIObj->SetTransparency (theValue); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= @@ -1812,7 +1793,11 @@ void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObje } theIObj->UnsetTransparency(); - redisplayPrsRecModes (theIObj, theToUpdateViewer); + theIObj->UpdatePresentations(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } } //======================================================================= diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index cd68336e22..95299cf147 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -1208,14 +1208,6 @@ protected: //! @name internal methods Standard_EXPORT void InitAttributes(); Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr); - - //! UNKNOWN - Standard_EXPORT void redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj, - const Standard_Boolean theToUpdateViewer); - - //! UNKNOWN - Standard_EXPORT void redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj, - const Standard_Boolean theToUpdateViewer); //! Helper function to unhighlight all entity owners currently highlighted with seleciton color. Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject); diff --git a/src/AIS/AIS_InteractiveObject.cxx b/src/AIS/AIS_InteractiveObject.cxx index 78df8e2fae..54decc127b 100644 --- a/src/AIS/AIS_InteractiveObject.cxx +++ b/src/AIS/AIS_InteractiveObject.cxx @@ -52,12 +52,11 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject,SelectMgr_SelectableObject) AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) : SelectMgr_SelectableObject (aTypeOfPresentation3d), myCTXPtr (NULL), - myOwnWidth (0.0), + myOwnWidth (0.0f), myCurrentFacingModel (Aspect_TOFM_BOTH_SIDE), myInfiniteState (Standard_False), hasOwnColor (Standard_False), - hasOwnMaterial (Standard_False), - myRecomputeEveryPrs (Standard_True) + hasOwnMaterial (Standard_False) { SetCurrentFacingModel(); } @@ -90,14 +89,6 @@ AIS_KindOfInteractive AIS_InteractiveObject::Type() const Standard_Integer AIS_InteractiveObject::Signature() const {return -1;} -//======================================================================= -//function : RecomputeEveryPrs -//purpose : -//======================================================================= - -Standard_Boolean AIS_InteractiveObject::RecomputeEveryPrs() const -{return myRecomputeEveryPrs;} - //======================================================================= //function : //purpose : @@ -200,7 +191,7 @@ void AIS_InteractiveObject::UnsetColor() //======================================================================= void AIS_InteractiveObject::SetWidth(const Standard_Real aValue) { - myOwnWidth = aValue; + myOwnWidth = (Standard_ShortReal )aValue; } //======================================================================= @@ -209,7 +200,7 @@ void AIS_InteractiveObject::SetWidth(const Standard_Real aValue) //======================================================================= void AIS_InteractiveObject::UnsetWidth() { - myOwnWidth = 0.; + myOwnWidth = 0.0f; } //======================================================================= @@ -333,32 +324,10 @@ void AIS_InteractiveObject::UnsetAttributes() hasOwnColor = Standard_False; hasOwnMaterial = Standard_False; - myOwnWidth = 0.0; + myOwnWidth = 0.0f; myDrawer->SetTransparency (0.0f); } -//======================================================================= -//function : -//purpose : -//======================================================================= -void AIS_InteractiveObject::MustRecomputePrs(const Standard_Integer ) const -{} - -//======================================================================= -//function : -//purpose : -//======================================================================= -const TColStd_ListOfInteger& AIS_InteractiveObject::ListOfRecomputeModes() const -{return myToRecomputeModes;} - -//======================================================================= -//function : -//purpose : -//======================================================================= -void AIS_InteractiveObject::SetRecomputeOk() -{myToRecomputeModes.Clear();} - - //======================================================================= //function : AcceptDisplayMode //purpose : diff --git a/src/AIS/AIS_InteractiveObject.hxx b/src/AIS/AIS_InteractiveObject.hxx index 8f37176489..29e7e2384a 100644 --- a/src/AIS/AIS_InteractiveObject.hxx +++ b/src/AIS/AIS_InteractiveObject.hxx @@ -283,7 +283,7 @@ public: virtual void Color (Quantity_Color& theColor) const { theColor = myDrawer->Color(); } //! Returns true if the Interactive Object has width. - Standard_Boolean HasWidth() const { return myOwnWidth != 0.0; } + Standard_Boolean HasWidth() const { return myOwnWidth != 0.0f; } //! Returns the width setting of the Interactive Object. Standard_Real Width() const { return myOwnWidth; } @@ -395,36 +395,19 @@ protected: //! and then modify them directly followed by SynchronizeAspects() call. Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap); -private: - - Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const; - - Standard_EXPORT void MustRecomputePrs (const Standard_Integer aMode) const; - - Standard_EXPORT const TColStd_ListOfInteger& ListOfRecomputeModes() const; - - Standard_EXPORT void SetRecomputeOk(); - -protected: - //! The TypeOfPresention3d means that the interactive object //! may have a presentation dependant of the view of Display. Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); -private: +protected: AIS_InteractiveContext* myCTXPtr; Handle(Standard_Transient) myOwner; - -protected: - - TColStd_ListOfInteger myToRecomputeModes; - Standard_Real myOwnWidth; + Standard_ShortReal myOwnWidth; Aspect_TypeOfFacingModel myCurrentFacingModel; Standard_Boolean myInfiniteState; Standard_Boolean hasOwnColor; Standard_Boolean hasOwnMaterial; - Standard_Boolean myRecomputeEveryPrs; }; diff --git a/src/AIS/AIS_Line.cxx b/src/AIS/AIS_Line.cxx index fceb20d93b..ae4e111322 100644 --- a/src/AIS/AIS_Line.cxx +++ b/src/AIS/AIS_Line.cxx @@ -41,52 +41,6 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_Line,AIS_InteractiveObject) -//================================================================== -// function: FindLimits -// purpose: -//================================================================== -//unused -/*#ifdef OCCT_DEBUG -static void FindLimits(const Adaptor3d_Curve& aCurve, - const Standard_Real aLimit, - gp_Pnt& P1, - gp_Pnt& P2) -{ - Standard_Real First = aCurve.FirstParameter(); - Standard_Real Last = aCurve.LastParameter(); - Standard_Boolean firstInf = Precision::IsNegativeInfinite(First); - Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last); - if (firstInf || lastInf) { - Standard_Real delta = 1; - if (firstInf && lastInf) { - do { - delta *= 2; - First = - delta; - Last = delta; - aCurve.D0(First,P1); - aCurve.D0(Last,P2); - } while (P1.Distance(P2) < aLimit); - } - else if (firstInf) { - aCurve.D0(Last,P2); - do { - delta *= 2; - First = Last - delta; - aCurve.D0(First,P1); - } while (P1.Distance(P2) < aLimit); - } - else if (lastInf) { - aCurve.D0(First,P1); - do { - delta *= 2; - Last = First + delta; - aCurve.D0(Last,P2); - } while (P1.Distance(P2) < aLimit); - } - } -} -#endif -*/ //======================================================================= //function : AIS_Line //purpose : @@ -126,8 +80,7 @@ void AIS_Line::Compute(const Handle(PrsMgr_PresentationManager3d)&, void AIS_Line::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTransformation, const Handle(Prs3d_Presentation)& aPresentation) { -// throw Standard_NotImplemented("AIS_Line::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ; + PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ; } //======================================================================= @@ -152,6 +105,29 @@ void AIS_Line::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection, } } +//======================================================================= +//function : replaceWithNewLineAspect +//purpose : +//======================================================================= +void AIS_Line::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect) +{ + if (!myDrawer->HasLink()) + { + myDrawer->SetLineAspect (theAspect); + return; + } + + const Handle(Graphic3d_Aspects)& anAspectOld = myDrawer->LineAspect()->Aspect(); + const Handle(Graphic3d_Aspects)& anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect(); + if (anAspectNew != anAspectOld) + { + myDrawer->SetLineAspect (theAspect); + Graphic3d_MapOfAspectsToAspects aReplaceMap; + aReplaceMap.Bind (anAspectOld, anAspectNew); + replaceAspects (aReplaceMap); + } +} + //======================================================================= //function : SetColor //purpose : @@ -165,10 +141,15 @@ void AIS_Line::SetColor(const Quantity_Color &aCol) myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.; - if (!myDrawer->HasOwnLineAspect ()) - myDrawer->SetLineAspect (new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); + if (!myDrawer->HasOwnLineAspect()) + { + replaceWithNewLineAspect (new Prs3d_LineAspect (aCol, Aspect_TOL_SOLID, WW)); + } else - myDrawer->LineAspect()->SetColor(aCol); + { + myDrawer->LineAspect()->SetColor (aCol); + SynchronizeAspects(); + } } @@ -180,16 +161,19 @@ void AIS_Line::UnsetColor() { hasOwnColor = Standard_False; - Handle(Prs3d_LineAspect) NullAsp; - - if (!HasWidth()) myDrawer->SetLineAspect(NullAsp); - else{ + if (!HasWidth()) + { + replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); + } + else + { Quantity_Color CC = Quantity_NOC_YELLOW; if( HasColor() ) CC = myDrawer->Color(); else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); myDrawer->LineAspect()->SetColor(CC); myDrawer->SetColor (CC); - } + SynchronizeAspects(); + } } //======================================================================= @@ -198,15 +182,20 @@ void AIS_Line::UnsetColor() //======================================================================= void AIS_Line::SetWidth(const Standard_Real aValue) { - myOwnWidth=aValue; + myOwnWidth = (Standard_ShortReal )aValue; - if (!myDrawer->HasOwnLineAspect ()) { + if (!myDrawer->HasOwnLineAspect()) + { Quantity_Color CC = Quantity_NOC_YELLOW; if( HasColor() ) CC = myDrawer->Color(); else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC); - myDrawer->SetLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue)); - } else - myDrawer->LineAspect()->SetWidth(aValue); + replaceWithNewLineAspect (new Prs3d_LineAspect (CC, Aspect_TOL_SOLID, aValue)); + } + else + { + myDrawer->LineAspect()->SetWidth (aValue); + SynchronizeAspects(); + } } @@ -216,14 +205,16 @@ void AIS_Line::SetWidth(const Standard_Real aValue) //======================================================================= void AIS_Line::UnsetWidth() { - Handle(Prs3d_LineAspect) NullAsp; - - if (!HasColor()) myDrawer->SetLineAspect(NullAsp); - else{ - Standard_Real WW = myDrawer->HasLink() ? - AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.; - myDrawer->LineAspect()->SetWidth(WW); + if (!HasColor()) + { + replaceWithNewLineAspect (Handle(Prs3d_LineAspect)()); + } + else + { + Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.0f; + myDrawer->LineAspect()->SetWidth (WW); myOwnWidth = WW; + SynchronizeAspects(); } } diff --git a/src/AIS/AIS_Line.hxx b/src/AIS/AIS_Line.hxx index 05abbcf078..ffb0653373 100644 --- a/src/AIS/AIS_Line.hxx +++ b/src/AIS/AIS_Line.hxx @@ -107,6 +107,9 @@ private: Standard_EXPORT void ComputeSegmentLineSelection (const Handle(SelectMgr_Selection)& aSelection); + //! Replace aspects of already computed groups with the new value. + void replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspect); + private: Handle(Geom_Line) myComponent; diff --git a/src/AIS/AIS_Plane.cxx b/src/AIS/AIS_Plane.cxx index a2b9510efd..76fa3af8e0 100644 --- a/src/AIS/AIS_Plane.cxx +++ b/src/AIS/AIS_Plane.cxx @@ -387,7 +387,8 @@ void AIS_Plane::SetSize(const Standard_Real aXLength, myHasOwnSize = Standard_True; - Update(); + SetToUpdate(); + UpdatePresentations(); UpdateSelection(); } @@ -418,7 +419,8 @@ void AIS_Plane::UnsetSize() } myHasOwnSize = Standard_False; - Update(); + SetToUpdate(); + UpdatePresentations(); UpdateSelection(); } diff --git a/src/AIS/AIS_PlaneTrihedron.cxx b/src/AIS/AIS_PlaneTrihedron.cxx index 46636b88b1..6f38424180 100644 --- a/src/AIS/AIS_PlaneTrihedron.cxx +++ b/src/AIS/AIS_PlaneTrihedron.cxx @@ -248,6 +248,7 @@ void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol) myDrawer->SetColor (aCol); myDrawer->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetColor(aCol); myDrawer->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetColor(aCol); + SynchronizeAspects(); } diff --git a/src/AIS/AIS_PlaneTrihedron.hxx b/src/AIS/AIS_PlaneTrihedron.hxx index 44393bbc1f..5d8d9a8011 100644 --- a/src/AIS/AIS_PlaneTrihedron.hxx +++ b/src/AIS/AIS_PlaneTrihedron.hxx @@ -89,7 +89,7 @@ public: virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Datum; } //! Allows you to provide settings for the color aColor. - Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; + Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; void SetXLabel (const TCollection_AsciiString& theLabel) { myXLabel = theLabel; } diff --git a/src/AIS/AIS_Point.cxx b/src/AIS/AIS_Point.cxx index ae204116ed..955fa44314 100644 --- a/src/AIS/AIS_Point.cxx +++ b/src/AIS/AIS_Point.cxx @@ -205,6 +205,29 @@ void AIS_Point::UnsetMarker() || theMode == -99; } +//======================================================================= +//function : replaceWithNewPointAspect +//purpose : +//======================================================================= +void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theAspect) +{ + if (!myDrawer->HasLink()) + { + myDrawer->SetPointAspect (theAspect); + return; + } + + const Handle(Graphic3d_AspectMarker3d) anAspectOld = myDrawer->PointAspect()->Aspect(); + const Handle(Graphic3d_AspectMarker3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect(); + if (anAspectNew != anAspectOld) + { + myDrawer->SetPointAspect (theAspect); + Graphic3d_MapOfAspectsToAspects aReplaceMap; + aReplaceMap.Bind (anAspectOld, anAspectNew); + replaceAspects (aReplaceMap); + } +} + //======================================================================= //function : UpdatePointValues //purpose : @@ -212,12 +235,14 @@ void AIS_Point::UnsetMarker() void AIS_Point::UpdatePointValues() { - - if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM) + if (!hasOwnColor + && myOwnWidth == 0.0f + && !myHasTOM) { - myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)()); + replaceWithNewPointAspect (Handle(Prs3d_PointAspect)()); return; } + Quantity_Color aCol (Quantity_NOC_YELLOW); Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS; Standard_Real aScale = 1.0; @@ -229,20 +254,20 @@ void AIS_Point::UpdatePointValues() } if(hasOwnColor) aCol = myDrawer->Color(); - if(myOwnWidth!=0.0) aScale = myOwnWidth; + if(myOwnWidth != 0.0f) aScale = myOwnWidth; if(myHasTOM) aTOM = myTOM; - - - if(myDrawer->HasOwnPointAspect()){ - // CLE - // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect(); + + if(myDrawer->HasOwnPointAspect()) + { Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect(); - // ENDCLE PA->SetColor(aCol); PA->SetTypeOfMarker(aTOM); PA->SetScale(aScale); + SynchronizeAspects(); } else - myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale)); + { + replaceWithNewPointAspect (new Prs3d_PointAspect (aTOM, aCol, aScale)); + } } diff --git a/src/AIS/AIS_Point.hxx b/src/AIS/AIS_Point.hxx index baf842d611..4a0682878d 100644 --- a/src/AIS/AIS_Point.hxx +++ b/src/AIS/AIS_Point.hxx @@ -59,10 +59,10 @@ public: Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; //! Allows you to provide settings for the Color. - Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; + Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; //! Allows you to remove color settings. - Standard_EXPORT void UnsetColor() Standard_OVERRIDE; + Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE; //! Allows you to provide settings for a marker. These include //! - type of marker, @@ -91,6 +91,9 @@ private: Standard_EXPORT void UpdatePointValues(); + //! Replace aspects of already computed groups with the new value. + void replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theAspect); + private: Handle(Geom_Point) myComponent; diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 75a7e8fd3f..e6f75cb1ed 100644 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -68,15 +68,6 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject) -static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode) -{ - TColStd_ListIteratorOfListOfInteger It(LL); - for(;It.More();It.Next()){ - if(It.Value()==aMode) - return Standard_True;} - return Standard_False; -} - // Auxiliary macros #define replaceAspectWithDef(theMap, theAspect) \ if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \ @@ -411,8 +402,6 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor) myDrawer->SetColor (theColor); hasOwnColor = Standard_True; - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); if (!toRecompute || !myDrawer->HasLink()) { @@ -432,8 +421,6 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor) void AIS_Shape::UnsetColor() { - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); if (!HasColor()) { return; @@ -578,10 +565,8 @@ bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer, void AIS_Shape::SetWidth (const Standard_Real theLineWidth) { - myOwnWidth = theLineWidth; + myOwnWidth = (Standard_ShortReal )theLineWidth; - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); if (!setWidth (myDrawer, theLineWidth) || !myDrawer->HasLink()) { @@ -601,14 +586,12 @@ void AIS_Shape::SetWidth (const Standard_Real theLineWidth) void AIS_Shape::UnsetWidth() { - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); - if (myOwnWidth == 0.0) + if (myOwnWidth == 0.0f) { return; } - myOwnWidth = 0.0; + myOwnWidth = 0.0f; if (!HasColor()) { Graphic3d_MapOfAspectsToAspects aReplaceMap; @@ -681,8 +664,6 @@ void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat) setMaterial (myDrawer, theMat, HasColor(), IsTransparent()); hasOwnMaterial = Standard_True; - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); if (!toRecompute || !myDrawer->HasLink()) { @@ -701,8 +682,6 @@ void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat) void AIS_Shape::UnsetMaterial() { - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); if (!HasMaterial()) { return; @@ -761,8 +740,6 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue) setTransparency (myDrawer, theValue); myDrawer->SetTransparency ((Standard_ShortReal )theValue); - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); if (!toRecompute || !myDrawer->HasLink()) { @@ -781,9 +758,6 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue) void AIS_Shape::UnsetTransparency() { - myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update - myToRecomputeModes.Clear(); - myDrawer->SetTransparency (0.0f); if (!myDrawer->HasOwnShadingAspect()) { @@ -805,18 +779,6 @@ void AIS_Shape::UnsetTransparency() } } -//======================================================================= -//function : LoadRecomputable -//purpose : -//======================================================================= - -void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode) -{ - myRecomputeEveryPrs = Standard_False; - if(!IsInList(myToRecomputeModes,TheMode)) - myToRecomputeModes.Append(TheMode); -} - //======================================================================= //function : BoundingBox //purpose : @@ -903,8 +865,7 @@ Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle () void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient ) { myDrawer->SetDeviationCoefficient( aCoefficient ); - SetToUpdate(0) ; // WireFrame - SetToUpdate(1) ; // Shadding + SetToUpdate(); } //======================================================================= @@ -923,11 +884,10 @@ void AIS_Shape::SetOwnHLRDeviationCoefficient ( const Standard_Real aCoefficien //purpose : //======================================================================= -void AIS_Shape::SetOwnDeviationAngle ( const Standard_Real anAngle ) +void AIS_Shape::SetOwnDeviationAngle (const Standard_Real theAngle) { - - myDrawer->SetDeviationAngle(anAngle ); - SetToUpdate(0) ; // WireFrame + myDrawer->SetDeviationAngle (theAngle); + SetToUpdate (AIS_WireFrame); } //======================================================================= //function : SetOwnDeviationAngle @@ -941,8 +901,7 @@ void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle ) SetOwnDeviationAngle(anAngle) ; SetOwnDeviationCoefficient(OutDefl) ; myInitAng = anAngle; - SetToUpdate(0); - SetToUpdate(1); + SetToUpdate(); } //======================================================================= diff --git a/src/AIS/AIS_Shape.hxx b/src/AIS/AIS_Shape.hxx index 242ca6faf6..f648228c3c 100644 --- a/src/AIS/AIS_Shape.hxx +++ b/src/AIS/AIS_Shape.hxx @@ -302,8 +302,6 @@ protected: Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE; - Standard_EXPORT void LoadRecomputable (const Standard_Integer TheMode); - //! Create own aspects (if they do not exist) and set color to them. //! @return TRUE if new aspects have been created Standard_EXPORT bool setColor (const Handle(Prs3d_Drawer)& theDrawer, const Quantity_Color& theColor) const; diff --git a/src/AIS/AIS_TextLabel.cxx b/src/AIS/AIS_TextLabel.cxx index 5b364f0965..5f0d7032d6 100644 --- a/src/AIS/AIS_TextLabel.cxx +++ b/src/AIS/AIS_TextLabel.cxx @@ -57,6 +57,7 @@ void AIS_TextLabel::SetColor (const Quantity_Color& theColor) hasOwnColor = Standard_True; myDrawer->SetColor (theColor); myDrawer->TextAspect()->SetColor (theColor); + SynchronizeAspects(); } //======================================================================= @@ -74,6 +75,7 @@ void AIS_TextLabel::SetTransparency (const Standard_Real theValue) myDrawer->TextAspect()->Aspect()->SetColor (aTextColor); myDrawer->TextAspect()->Aspect()->SetColorSubTitle (aSubColor); myDrawer->SetTransparency (Standard_ShortReal(theValue)); + SynchronizeAspects(); } //======================================================================= diff --git a/src/AIS/AIS_Triangulation.cxx b/src/AIS/AIS_Triangulation.cxx index 89d9d7151d..0ff986f3b6 100644 --- a/src/AIS/AIS_Triangulation.cxx +++ b/src/AIS/AIS_Triangulation.cxx @@ -111,9 +111,6 @@ void AIS_Triangulation::updatePresentation() aGroup->SetGroupPrimitivesAspect (anAreaAsp); } } - - myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update - myToRecomputeModes.Clear(); } } diff --git a/src/AIS/AIS_Trihedron.cxx b/src/AIS/AIS_Trihedron.cxx index 23896ab252..ba87081a43 100644 --- a/src/AIS/AIS_Trihedron.cxx +++ b/src/AIS/AIS_Trihedron.cxx @@ -85,7 +85,7 @@ AIS_Trihedron::AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent) void AIS_Trihedron::SetComponent (const Handle(Geom_Axis2Placement)& theComponent) { myComponent = theComponent; - LoadRecomputable (AIS_WireFrame); + SetToUpdate(); } //======================================================================= @@ -135,7 +135,8 @@ void AIS_Trihedron::SetSize(const Standard_Real aValue) setOwnDatumAspect(); myDrawer->DatumAspect()->SetAxisLength(aValue, aValue, aValue); - Update(); + SetToUpdate(); + UpdatePresentations(); UpdateSelection(); } @@ -162,7 +163,8 @@ void AIS_Trihedron::UnsetSize() } else { - Update(); + SetToUpdate(); + UpdatePresentations(); } UpdateSelection(); } @@ -560,19 +562,6 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager } } -//======================================================================= -//function : LoadRecomputable -//purpose : -//======================================================================= -void AIS_Trihedron::LoadRecomputable (const Standard_Integer theMode) -{ - myRecomputeEveryPrs = Standard_False; - if (!myToRecomputeModes.Contains (theMode)) - { - myToRecomputeModes.Append (theMode); - } -} - //======================================================================= //function : SetColor //purpose : diff --git a/src/AIS/AIS_Trihedron.hxx b/src/AIS/AIS_Trihedron.hxx index 9fc5fd773d..9576915ce9 100644 --- a/src/AIS/AIS_Trihedron.hxx +++ b/src/AIS/AIS_Trihedron.hxx @@ -224,8 +224,6 @@ protected: protected: - Standard_EXPORT void LoadRecomputable (const Standard_Integer theMode); - //! Creates a sensitive entity for the datum part that will be used in selection owner creation. Standard_EXPORT Handle(SelectBasics_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart, const Handle(SelectBasics_EntityOwner)& theOwner) const; diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index d5c86f9e3a..fffce5cfbf 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -115,80 +115,101 @@ void PrsMgr_PresentableObject::Compute(const Handle(Prs3d_Projector)& /* aProjec } //======================================================================= -//function : Update -//purpose : -//======================================================================= -void PrsMgr_PresentableObject::Update (const Standard_Boolean AllModes) { - Standard_Integer l = myPresentations.Length(); - Handle(PrsMgr_PresentationManager) PM; - for (Standard_Integer i=1; i <= l; i++) { - PM = myPresentations(i).Presentation()->PresentationManager(); - if(AllModes) - PM->Update(this,myPresentations(i).Mode()); - else{ - if(PM->IsDisplayed(this,myPresentations(i).Mode()) || - PM->IsHighlighted(this,myPresentations(i).Mode())){ - PM->Update(this,myPresentations(i).Mode()); - } - else - SetToUpdate(myPresentations(i).Mode()); - } - } -} - -//======================================================================= -//function : Update -//purpose : -//======================================================================= -void PrsMgr_PresentableObject::Update (const Standard_Integer aMode, const Standard_Boolean ClearOther) { - Standard_Integer l = myPresentations.Length(); - for (Standard_Integer i=1; i <= l; i++) { - if( myPresentations(i).Mode() == aMode){ - Handle(PrsMgr_PresentationManager) PM= - myPresentations(i).Presentation()->PresentationManager(); - - if(PM->IsDisplayed(this,aMode) || - PM->IsHighlighted(this,aMode)){ - PM->Update(this,aMode); - myPresentations(i).Presentation()->SetUpdateStatus(Standard_False); - - } - else - SetToUpdate(myPresentations(i).Mode()); - } - - } - if(ClearOther) { - PrsMgr_Presentations save; - save = myPresentations; - myPresentations.Clear(); - for (Standard_Integer i=1; i <= l; i++) { - if( save(i).Mode() == aMode) myPresentations.Append(save(i)); - } - } - -} - -//======================================================================= -//function : SetToUpdate -//purpose : -//======================================================================= -void PrsMgr_PresentableObject::SetToUpdate(const Standard_Integer aMode) -{ - for(Standard_Integer IP =1; IP<=myPresentations.Length();IP++){ - if(myPresentations(IP).Mode()==aMode) - myPresentations(IP).Presentation()->SetUpdateStatus(Standard_True); - } -} - -//======================================================================= -//function : SetToUpdate +//function : ToBeUpdated //purpose : //======================================================================= -void PrsMgr_PresentableObject::SetToUpdate() +Standard_Boolean PrsMgr_PresentableObject::ToBeUpdated (Standard_Boolean theToIncludeHidden) const { - for(Standard_Integer IP =1; IP<=myPresentations.Length();IP++){ - myPresentations(IP).Presentation()->SetUpdateStatus(Standard_True); + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) + { + const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value(); + if (aModedPrs.Presentation()->MustBeUpdated()) + { + if (theToIncludeHidden) + { + return Standard_True; + } + + Handle(PrsMgr_PresentationManager) aPrsMgr = aModedPrs.Presentation()->PresentationManager(); + if (aPrsMgr->IsDisplayed (this, aModedPrs.Mode()) + || aPrsMgr->IsHighlighted(this, aModedPrs.Mode())) + { + return Standard_True; + } + } + } + return Standard_False; +} + +//======================================================================= +//function : UpdatePresentations +//purpose : +//======================================================================= +Standard_Boolean PrsMgr_PresentableObject::UpdatePresentations (Standard_Boolean theToIncludeHidden) +{ + Standard_Boolean hasUpdates = Standard_False; + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) + { + const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value(); + if (aModedPrs.Presentation()->MustBeUpdated()) + { + Handle(PrsMgr_PresentationManager) aPrsMgr = aModedPrs.Presentation()->PresentationManager(); + if (theToIncludeHidden + || aPrsMgr->IsDisplayed (this, aModedPrs.Mode()) + || aPrsMgr->IsHighlighted(this, aModedPrs.Mode())) + { + hasUpdates = Standard_True; + aPrsMgr->Update (this, aModedPrs.Mode()); + } + } + } + return hasUpdates; +} + +//======================================================================= +//function : Update +//purpose : +//======================================================================= +void PrsMgr_PresentableObject::Update (Standard_Integer theMode, Standard_Boolean theToClearOther) +{ + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More();) + { + if (aPrsIter.Value().Mode() == theMode) + { + Handle(PrsMgr_PresentationManager) aPrsMgr = aPrsIter.Value().Presentation()->PresentationManager(); + if (aPrsMgr->IsDisplayed (this, theMode) + || aPrsMgr->IsHighlighted(this, theMode)) + { + aPrsMgr->Update (this, theMode); + aPrsIter.Value().Presentation()->SetUpdateStatus (Standard_False); + } + else + { + SetToUpdate (aPrsIter.Value().Mode()); + } + } + else if (theToClearOther) + { + myPresentations.Remove (aPrsIter); + continue; + } + aPrsIter.Next(); + } +} + +//======================================================================= +//function : SetToUpdate +//purpose : +//======================================================================= +void PrsMgr_PresentableObject::SetToUpdate (Standard_Integer theMode) +{ + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) + { + if (theMode == -1 + || aPrsIter.Value().Mode() == theMode) + { + aPrsIter.ChangeValue().Presentation()->SetUpdateStatus(Standard_True); + } } } @@ -196,19 +217,18 @@ void PrsMgr_PresentableObject::SetToUpdate() //function : ToBeUpdated //purpose : gets the list of modes to be updated //======================================================================= -void PrsMgr_PresentableObject::ToBeUpdated(TColStd_ListOfInteger& OutList) const +void PrsMgr_PresentableObject::ToBeUpdated (TColStd_ListOfInteger& theOutList) const { - OutList.Clear(); - // on dimensionne les buckets a la taille de la seq. + theOutList.Clear(); TColStd_MapOfInteger MI(myPresentations.Length()); - - for(Standard_Integer IP =1; IP<=myPresentations.Length();IP++){ - const PrsMgr_ModedPresentation& MP = myPresentations(IP); - if(MP.Presentation()->MustBeUpdated()) - if(!MI.Contains(MP.Mode())){ - OutList.Append(MP.Mode()); - MI.Add(MP.Mode()); - } + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) + { + const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value(); + if (aModedPrs.Presentation()->MustBeUpdated() + && MI.Add (aModedPrs.Mode())) + { + theOutList.Append (aModedPrs.Mode()); + } } } @@ -219,9 +239,9 @@ void PrsMgr_PresentableObject::ToBeUpdated(TColStd_ListOfInteger& OutList) const void PrsMgr_PresentableObject::SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d theType) { myTypeOfPresentation3d = theType; - for(Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) { - const Handle(PrsMgr_Presentation)& aPrs = myPresentations (aPrsIter).Presentation(); + const Handle(PrsMgr_Presentation)& aPrs = aPrsIter.Value().Presentation(); aPrs->Presentation()->SetVisual (myTypeOfPresentation3d == PrsMgr_TOP_ProjectorDependant ? Graphic3d_TOS_COMPUTED : Graphic3d_TOS_ALL); @@ -285,9 +305,9 @@ void PrsMgr_PresentableObject::UpdateTransformation() myInvTransformation = myLocalTransformation->Trsf().Inverted(); } - for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) { - myPresentations (aPrsIter).Presentation()->SetTransformation (myTransformation); + aPrsIter.ChangeValue().Presentation()->SetTransformation (myTransformation); } for (PrsMgr_ListOfPresentableObjectsIter aChildIter (myChildren); aChildIter.More(); aChildIter.Next()) @@ -302,9 +322,9 @@ void PrsMgr_PresentableObject::UpdateTransformation() //======================================================================= void PrsMgr_PresentableObject::recomputeComputed() const { - for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) { - const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation(); + const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value().Presentation(); if (!aPrs3d.IsNull() && !aPrs3d->Presentation().IsNull()) { @@ -320,9 +340,9 @@ void PrsMgr_PresentableObject::recomputeComputed() const void PrsMgr_PresentableObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTransformPersistence = theTrsfPers; - for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) { - const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation(); + const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.Value().Presentation(); if (!aPrs3d.IsNull() && !aPrs3d->Presentation().IsNull()) { @@ -422,9 +442,9 @@ void PrsMgr_PresentableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId) } myDrawer->SetZLayer (theLayerId); - for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) { - const PrsMgr_ModedPresentation& aModedPrs = myPresentations (aPrsIter); + const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value(); if (aModedPrs.Presentation().IsNull() || aModedPrs.Presentation()->Presentation().IsNull()) { @@ -501,19 +521,14 @@ void PrsMgr_PresentableObject::SetClipPlanes (const Handle(Graphic3d_SequenceOfH // ======================================================================= void PrsMgr_PresentableObject::UpdateClipping() { - // affect generated structures - for (Standard_Integer aPrsIt = 1; aPrsIt <= myPresentations.Length(); ++aPrsIt) + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) { - // pass over presentation manager 3d mechanism right to the structures - - // we do not interested in display mode collections. - const PrsMgr_ModedPresentation& aModedPrs = myPresentations (aPrsIt); - if (aModedPrs.Presentation().IsNull() - || aModedPrs.Presentation()->Presentation().IsNull()) + const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value(); + if (!aModedPrs.Presentation().IsNull() + && !aModedPrs.Presentation()->Presentation().IsNull()) { - continue; + aModedPrs.Presentation()->Presentation()->SetClipPlanes (myClipPlanes); } - - aModedPrs.Presentation()->Presentation()->SetClipPlanes (myClipPlanes); } } @@ -529,16 +544,14 @@ void PrsMgr_PresentableObject::SetMutable (const Standard_Boolean theIsMutable) } myIsMutable = theIsMutable; - for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) + for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next()) { - const PrsMgr_ModedPresentation& aModedPrs = myPresentations (aPrsIter); - if (aModedPrs.Presentation().IsNull() - || aModedPrs.Presentation()->Presentation().IsNull()) + const PrsMgr_ModedPresentation& aModedPrs = aPrsIter.Value(); + if (!aModedPrs.Presentation().IsNull() + && !aModedPrs.Presentation()->Presentation().IsNull()) { - continue; + aModedPrs.Presentation()->Presentation()->SetMutable (theIsMutable); } - - aModedPrs.Presentation()->Presentation()->SetMutable (theIsMutable); } } diff --git a/src/PrsMgr/PrsMgr_PresentableObject.hxx b/src/PrsMgr/PrsMgr_PresentableObject.hxx index 1cb8ffc3f0..a044ac8754 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.hxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.hxx @@ -109,14 +109,19 @@ public: Standard_EXPORT void SetTypeOfPresentation (const PrsMgr_TypeOfPresentation3d aType); - //! flags the Prs of mode to be Updated. - //! the Update will be done when needed. - Standard_EXPORT void SetToUpdate (const Standard_Integer aMode); - + //! Returns TRUE if any active presentation has invalidation flag. + //! @param theToIncludeHidden when TRUE, also checks hidden presentations + Standard_EXPORT Standard_Boolean ToBeUpdated (Standard_Boolean theToIncludeHidden = Standard_False) const; + + //! Flags presentation to be updated; UpdatePresentations() will recompute these presentations. + //! @param theMode presentation (display mode) to invalidate, or -1 to invalidate them all + Standard_EXPORT void SetToUpdate (Standard_Integer theMode); + //! flags all the Presentations to be Updated. - Standard_EXPORT void SetToUpdate(); - + void SetToUpdate() { SetToUpdate (-1); } + //! gives the list of modes which are flagged "to be updated". + Standard_DEPRECATED("This method is deprecated - UpdatePresentations() should be called instead") Standard_EXPORT void ToBeUpdated (TColStd_ListOfInteger& ListOfMode) const; //! Return the local transformation. @@ -297,12 +302,24 @@ Standard_EXPORT virtual ~PrsMgr_PresentableObject(); //! object before computation. Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation); - //! recomputes all presentations of the object. - Standard_EXPORT void Update (const Standard_Boolean AllModes = Standard_False); - + //! Recomputes invalidated presentations of the object. + //! @param theToIncludeHidden if TRUE, then even hidden invalidated presentations will be updated + //! @return TRUE if some presentations were recomputed + Standard_EXPORT Standard_Boolean UpdatePresentations (Standard_Boolean theToIncludeHidden = Standard_False); + + //! Recomputes all presentations of the object. + Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead") + void Update (Standard_Boolean theToIncludeHidden = Standard_False) + { + SetToUpdate(); + UpdatePresentations (theToIncludeHidden); + } + //! Recomputes the presentation in the given mode. - //! If ClearOther is true, other presentation will be cleared. - Standard_EXPORT void Update (const Standard_Integer aMode, const Standard_Boolean ClearOther); + //! @param theMode presentation (display mode) to recompute + //! @param theToClearOther when TRUE, other presentations (display modes) will be removed + Standard_DEPRECATED("This method is deprecated - SetToUpdate() + UpdatePresentations() should be called instead") + Standard_EXPORT void Update (Standard_Integer theMode, Standard_Boolean theToClearOther); //! High-level interface for controlling polygon offsets Standard_EXPORT virtual void Fill (const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode); diff --git a/src/StdSelect/StdSelect_BRepOwner.cxx b/src/StdSelect/StdSelect_BRepOwner.cxx index 194f1924f4..281723196e 100644 --- a/src/StdSelect/StdSelect_BRepOwner.cxx +++ b/src/StdSelect/StdSelect_BRepOwner.cxx @@ -105,12 +105,10 @@ void StdSelect_BRepOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana } // do the update flag check - if (!myPrsSh.IsNull()) + if (!myPrsSh.IsNull() + && myPrsSh->ToBeUpdated (true)) { - TColStd_ListOfInteger aModesList; - myPrsSh->ToBeUpdated (aModesList); - if (!aModesList.IsEmpty()) - myPrsSh.Nullify(); + myPrsSh.Nullify(); } // generate new presentable shape diff --git a/src/XCAFPrs/XCAFPrs_AISObject.cxx b/src/XCAFPrs/XCAFPrs_AISObject.cxx index d4010debbf..46c7bf4785 100644 --- a/src/XCAFPrs/XCAFPrs_AISObject.cxx +++ b/src/XCAFPrs/XCAFPrs_AISObject.cxx @@ -180,7 +180,8 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles) aShapeCur = aComp; } - Handle(AIS_ColoredDrawer) aDrawer = CustomAspects (aShapeCur); + Handle(AIS_ColoredDrawer) aDrawer = new AIS_ColoredDrawer (myDrawer); + myShapeColors.Bind (aShapeCur, aDrawer); const XCAFPrs_Style& aStyle = aStyleGroupIter.Key(); aDrawer->SetHidden (!aStyle.IsVisible());