1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026462: Visualization - selection does not adapt to line width change

- added interface for changing sensitivity of a particular selection through both interactive and local context;
- added corresponding methods for changing sensitivity to SelectMgr_SelectionManager, SelectMgr_Selection and SelectBasics_SensitiveEntity;
- option -setSensitivity was implemented in vaspects Draw command;
- test case for issue #26462
This commit is contained in:
vpa
2015-08-28 22:25:45 +03:00
committed by bugmaster
parent cc5f85f8c9
commit 8a1170ad46
15 changed files with 317 additions and 20 deletions

View File

@@ -27,7 +27,8 @@ SelectMgr_Selection::SelectMgr_Selection (const Standard_Integer theModeIdx)
: myMode (theModeIdx),
mySelectionState (SelectMgr_SOS_Unknown),
myBVHUpdateStatus (SelectMgr_TBU_None),
mySensFactor (2)
mySensFactor (2),
myIsCustomSens (Standard_False)
{}
SelectMgr_Selection::~SelectMgr_Selection()
@@ -71,8 +72,15 @@ void SelectMgr_Selection::Add (const Handle(SelectBasics_SensitiveEntity)& theSe
anEntity->SetActiveForSelection();
}
mySensFactor = Max (mySensFactor,
anEntity->BaseSensitive()->SensitivityFactor());
if (myIsCustomSens)
{
anEntity->BaseSensitive()->SetSensitivityFactor (mySensFactor);
}
else
{
mySensFactor = Max (mySensFactor,
anEntity->BaseSensitive()->SensitivityFactor());
}
}
}
@@ -136,3 +144,20 @@ Standard_Integer SelectMgr_Selection::Sensitivity() const
{
return mySensFactor;
}
//==================================================
// function: SetSensitivity
// purpose : Changes sensitivity of the selection and all its entities to the given value.
// IMPORTANT: This method does not update any outer selection structures, so for
// proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
//==================================================
void SelectMgr_Selection::SetSensitivity (const Standard_Integer theNewSens)
{
mySensFactor = theNewSens;
myIsCustomSens = Standard_True;
for (Standard_Integer anIdx = 0; anIdx < myEntities.Size(); ++anIdx)
{
Handle(SelectMgr_SensitiveEntity)& anEntity = myEntities.ChangeValue (anIdx);
anEntity->BaseSensitive()->SetSensitivityFactor (theNewSens);
}
}

View File

@@ -132,6 +132,11 @@ public:
//! Returns sensitivity of the selection
Standard_EXPORT Standard_Integer Sensitivity() const;
//! Changes sensitivity of the selection and all its entities to the given value.
//! IMPORTANT: This method does not update any outer selection structures, so for
//! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
DEFINE_STANDARD_RTTI (SelectMgr_Selection, MMgt_TShared)
protected:
@@ -148,6 +153,7 @@ private:
mutable SelectMgr_StateOfSelection mySelectionState;
mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
Standard_Integer mySensFactor;
Standard_Boolean myIsCustomSens;
};
DEFINE_STANDARD_HANDLE(SelectMgr_Selection, MMgt_TShared)

View File

@@ -905,3 +905,51 @@ void SelectMgr_SelectionManager::SetUpdateMode (const Handle(SelectMgr_Selectabl
theObject->Selection (theMode)->UpdateStatus (theType);
}
//=======================================================================
//function : SetSelectionSensitivity
//purpose : Allows to manage sensitivity of a particular selection of interactive object theObject and
// changes previous sensitivity value of all sensitive entities in selection with theMode
// to the given theNewSensitivity.
//=======================================================================
void SelectMgr_SelectionManager::SetSelectionSensitivity (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Standard_Integer theNewSens)
{
Standard_ASSERT_RAISE (theNewSens > 0,
"Error! Selection sensitivity have positive value.");
if (theObject.IsNull() || !theObject->HasSelection (theMode))
return;
Handle(SelectMgr_Selection) aSel = theObject->Selection (theMode);
const Standard_Integer aPrevSens = aSel->Sensitivity();
aSel->SetSensitivity (theNewSens);
if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
return;
if (myGlobal.Contains (theObject))
{
for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
Handle(SelectMgr_ViewerSelector) aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
if (aSelector->Contains (theObject))
{
aSelector->myTolerances.Decrement (aPrevSens);
aSelector->myTolerances.Add (theNewSens);
aSelector->myToUpdateTolerance = Standard_True;
}
}
}
if (myLocal.IsBound (theObject))
{
const SelectMgr_SequenceOfSelector& aSelectors = myLocal (theObject);
for (SelectMgr_SequenceOfSelector::Iterator aLocalIter (aSelectors); aLocalIter.More(); aLocalIter.Next())
{
Handle(SelectMgr_ViewerSelector)& aCurSel = aLocalIter.ChangeValue();
aCurSel->myTolerances.Decrement (aPrevSens);
aCurSel->myTolerances.Add (theNewSens);
aCurSel->myToUpdateTolerance = Standard_True;
}
}
}

View File

@@ -118,8 +118,12 @@ public:
//! Sets type of update of selection with theMode of theObject to the given theType.
Standard_EXPORT void SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode, const SelectMgr_TypeOfUpdate theType);
//! Allows to manage sensitivity of a particular selection of interactive object theObject and
//! changes previous sensitivity value of all sensitive entities in selection with theMode
//! to the given theNewSensitivity.
Standard_EXPORT void SetSelectionSensitivity (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Standard_Integer theNewSens);
DEFINE_STANDARD_RTTI(SelectMgr_SelectionManager,MMgt_TShared)