From 42ddd0028c99bbadc1ca9656f7e50af71b61d480 Mon Sep 17 00:00:00 2001 From: kgv Date: Mon, 1 Mar 2021 13:20:58 +0300 Subject: [PATCH] 0032184: Visualization - remove ambiguous AIS_GlobalStatus constructor Auxiliary AIS_GlobalStatus constructor has been removed. AIS_InteractiveContext::setObjectStatus() no more adds an invalid -1 mode to AIS_GlobalStatus. Never updated property AIS_GlobalStatus::GetLayerIndex() has been removed; AIS_InteractiveContext::SetTransformPersistence() has been corrected to use ZLayer defined within object itself. --- src/AIS/AIS_GlobalStatus.cxx | 59 +++------------------- src/AIS/AIS_GlobalStatus.hxx | 80 +++++++++++++++--------------- src/AIS/AIS_InteractiveContext.cxx | 18 ++++--- src/QABugs/QABugs_11.cxx | 23 --------- tests/bugs/vis/bug166 | 14 ------ 5 files changed, 60 insertions(+), 134 deletions(-) delete mode 100644 tests/bugs/vis/bug166 diff --git a/src/AIS/AIS_GlobalStatus.cxx b/src/AIS/AIS_GlobalStatus.cxx index 012ed5e5b1..63245c50e8 100644 --- a/src/AIS/AIS_GlobalStatus.cxx +++ b/src/AIS/AIS_GlobalStatus.cxx @@ -16,58 +16,15 @@ #include -#include -#include -#include - IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient) -AIS_GlobalStatus::AIS_GlobalStatus(): -myDispMode(AIS_WireFrame), -myLayerIndex(0), -myIsHilit(Standard_False), -mySubInt(Standard_False) +// ======================================================================= +// function : AIS_GlobalStatus +// purpose : +// ======================================================================= +AIS_GlobalStatus::AIS_GlobalStatus() +: myDispMode (0), + myIsHilit(Standard_False), + mySubInt (Standard_False) { } - -AIS_GlobalStatus::AIS_GlobalStatus (const Standard_Integer theDMode, - const Standard_Integer theSMode, - const Standard_Integer theLayer): -myDispMode (theDMode), -myLayerIndex (theLayer), -myIsHilit (Standard_False), -mySubInt (Standard_False) -{ - mySelModes.Append (theSMode); -} - -void AIS_GlobalStatus::RemoveSelectionMode(const Standard_Integer aMode) -{ - TColStd_ListIteratorOfListOfInteger anIt (mySelModes); - for (; anIt.More(); anIt.Next()) - { - if (anIt.Value() == aMode) - { - mySelModes.Remove (anIt); - return; - } - } -} - -void AIS_GlobalStatus::ClearSelectionModes() -{ - mySelModes.Clear(); -} - -Standard_Boolean AIS_GlobalStatus::IsSModeIn(const Standard_Integer aMode) const -{ - TColStd_ListIteratorOfListOfInteger anIt (mySelModes); - for (; anIt.More(); anIt.Next()) - { - if (anIt.Value() == aMode) - { - return Standard_True; - } - } - return Standard_False; -} diff --git a/src/AIS/AIS_GlobalStatus.hxx b/src/AIS/AIS_GlobalStatus.hxx index df7cf8847c..9a1585a015 100644 --- a/src/AIS/AIS_GlobalStatus.hxx +++ b/src/AIS/AIS_GlobalStatus.hxx @@ -29,34 +29,25 @@ DEFINE_STANDARD_HANDLE(AIS_GlobalStatus, Standard_Transient) -//! Stores information about objects in graphic context: -//! - Status Of Display : in the main viewer -//! hidden in the main viewer -//! - Displayed Modes -//! - Active Selection Modes -//! - is the Interactive Object Current ? -//! - Layer Index +//! Stores information about objects in graphic context: class AIS_GlobalStatus : public Standard_Transient { DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient) public: + //! Default constructor. Standard_EXPORT AIS_GlobalStatus(); - - Standard_EXPORT AIS_GlobalStatus (const Standard_Integer theDispMode, - const Standard_Integer theSelMode, - const Standard_Integer theLayerIndex = 0); - - void AddSelectionMode (const Standard_Integer theMode) { if (!IsSModeIn (theMode)) mySelModes.Append (theMode); } - - //! Sets display mode. - void SetDisplayMode (const Standard_Integer theMode) { myDispMode = theMode; } //! Returns the display mode. Standard_Integer DisplayMode() const { return myDispMode; } - void SetLayerIndex (const Standard_Integer theIndex) { myLayerIndex = theIndex; } + //! Sets display mode. + void SetDisplayMode (const Standard_Integer theMode) { myDispMode = theMode; } + //! Returns TRUE if object is highlighted + Standard_Boolean IsHilighted() const { return myIsHilit; } + + //! Sets highlighted state. void SetHilightStatus (const Standard_Boolean theStatus) { myIsHilit = theStatus; } //! Changes applied highlight style for a particular object @@ -65,36 +56,47 @@ public: //! Returns applied highlight style for a particular object const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; } + //! Returns active selection modes of the object. + const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; } + + //! Return TRUE if selection mode was registered. + Standard_Boolean IsSModeIn (Standard_Integer theMode) const + { + return mySelModes.Contains (theMode); + } + + //! Add selection mode. + Standard_Boolean AddSelectionMode (const Standard_Integer theMode) + { + if (!mySelModes.Contains (theMode)) + { + mySelModes.Append (theMode); + return Standard_True; + } + return Standard_False; + } + + //! Remove selection mode. + Standard_Boolean RemoveSelectionMode (const Standard_Integer theMode) + { + return mySelModes.Remove (theMode); + } + + //! Remove all selection modes. + void ClearSelectionModes() + { + mySelModes.Clear(); + } + Standard_Boolean IsSubIntensityOn() const { return mySubInt; } - void SubIntensityOn() { mySubInt = Standard_True; } - - void SubIntensityOff() { mySubInt = Standard_False; } - - Standard_EXPORT void RemoveSelectionMode (const Standard_Integer aMode); - - Standard_EXPORT void ClearSelectionModes(); - - //! keeps the active selection modes of the object - //! in the main viewer. - const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; } - - Standard_Boolean IsHilighted() const { return myIsHilit; } - - Standard_EXPORT Standard_Boolean IsSModeIn (const Standard_Integer aMode) const; - - //! Returns layer index. - Standard_Integer GetLayerIndex() const - { - return myLayerIndex; - } + void SetSubIntensity (Standard_Boolean theIsOn) { mySubInt = theIsOn; } private: TColStd_ListOfInteger mySelModes; Handle(Prs3d_Drawer) myHiStyle; Standard_Integer myDispMode; - Standard_Integer myLayerIndex; Standard_Boolean myIsHilit; Standard_Boolean mySubInt; diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index ad09da4d5d..ba42fb6f8a 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -495,8 +495,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO } if (!mgrSelector->IsActivated (theIObj, theSelectionMode)) { - if (!aStatus->IsSModeIn (theSelectionMode)) - aStatus->AddSelectionMode (theSelectionMode); + aStatus->AddSelectionMode (theSelectionMode); mgrSelector->Activate (theIObj, theSelectionMode); } } @@ -2402,7 +2401,7 @@ void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_Interacti mgrSelector->UpdateSelection (theObject); - const Standard_Integer aLayerId = myObjects.Find (theObject)->GetLayerIndex(); + const Graphic3d_ZLayerId aLayerId = theObject->ZLayer(); const Handle(V3d_Viewer)& aCurViewer = CurrentViewer(); for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next()) { @@ -2432,7 +2431,12 @@ void AIS_InteractiveContext::setObjectStatus (const Handle(AIS_InteractiveObject theIObj->SetDisplayStatus (theStatus); if (theStatus != PrsMgr_DisplayStatus_None) { - Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (theDispMode, theSelectionMode); + Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus(); + aStatus->SetDisplayMode (theDispMode); + if (theSelectionMode != -1) + { + aStatus->AddSelectionMode (theSelectionMode); + } myObjects.Bind (theIObj, aStatus); } else @@ -2647,7 +2651,7 @@ void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObj continue; } - aStatus->SubIntensityOn(); + aStatus->SetSubIntensity (true); myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode()); } } @@ -2664,7 +2668,7 @@ void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObj return; } - aStatus->SubIntensityOn(); + aStatus->SetSubIntensity (true); myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode()); } } @@ -3992,7 +3996,7 @@ void AIS_InteractiveContext::SubIntensityOff (const Handle(AIS_InteractiveObject return; } - (*aStatus)->SubIntensityOff(); + (*aStatus)->SetSubIntensity (false); Standard_Boolean toUpdateMain = Standard_False; if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed) { diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 57681786d8..4001d71067 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -671,28 +671,6 @@ for(;wex.More();wex.Next()) } -static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv) -{ - - Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); - if(myAISContext.IsNull()) { - di << "use 'vinit' command before " << argv[0]; - return 1; - } - - BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100); - Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape()); - myAISContext->SetAutoActivateSelection (Standard_False); - myAISContext->Display(anAISBox, 1); - - TColStd_ListOfInteger anActivatedModes; - myAISContext->ActivatedModes (anAISBox, anActivatedModes); - if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 ) - return 1; - - return 0; -} - #include #include #include @@ -4992,7 +4970,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) { theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group); // New commands: - theCommands.Add("OCC166", "OCC166", __FILE__, OCC166, group); theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group); theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group); diff --git a/tests/bugs/vis/bug166 b/tests/bugs/vis/bug166 deleted file mode 100644 index ddba098d2d..0000000000 --- a/tests/bugs/vis/bug166 +++ /dev/null @@ -1,14 +0,0 @@ -puts "=================" -puts "OCC166" -puts "=================" -puts "" - -vinit - -if [ catch { OCC166 } res ] then { - puts "OCC166: Error" -} else { - puts "OCC166: OK" -} - -checkview -screenshot -3d -path ${imagedir}/${test_image}.png