mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0030451: Selection mode of TPrsStd_AISPresentation attribute is restricted to one value
Two classes TDataXtd_Presentation and TPrsStd_AISPresentation were improved so that they accept a list of selection modes. A new non-regression test is added: caf presentation N1
This commit is contained in:
@@ -569,13 +569,23 @@ void TPrsStd_AISPresentation::UnsetMode()
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetNbSelectionModes
|
||||
//purpose : Returns selection mode(s) of the attribute.
|
||||
// : It starts with 1 .. GetNbSelectionModes().
|
||||
//=======================================================================
|
||||
Standard_Integer TPrsStd_AISPresentation::GetNbSelectionModes() const
|
||||
{
|
||||
return getData()->GetNbSelectionModes();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SelectionMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer TPrsStd_AISPresentation::SelectionMode() const
|
||||
Standard_Integer TPrsStd_AISPresentation::SelectionMode(const Standard_Integer index) const
|
||||
{
|
||||
return getData()->SelectionMode();
|
||||
return getData()->SelectionMode(index);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -603,13 +613,29 @@ void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelecti
|
||||
ActivateSelectionMode();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddSelectionMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TPrsStd_AISPresentation::AddSelectionMode(const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction)
|
||||
{
|
||||
if (theTransaction)
|
||||
Backup();
|
||||
getData()->AddSelectionMode (theSelectionMode, theTransaction);
|
||||
|
||||
if (myAIS.IsNull())
|
||||
AISUpdate();
|
||||
else
|
||||
ActivateSelectionMode();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetSelectionMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TPrsStd_AISPresentation::UnsetSelectionMode()
|
||||
{
|
||||
getData()->UnsetSelectionMode ();
|
||||
getData()->UnsetSelectionMode();
|
||||
AISUpdate();
|
||||
}
|
||||
|
||||
@@ -1006,24 +1032,37 @@ void TPrsStd_AISPresentation::ActivateSelectionMode()
|
||||
{
|
||||
TColStd_ListOfInteger anActivatedModes;
|
||||
aContext->ActivatedModes (myAIS, anActivatedModes);
|
||||
Standard_Boolean isActivated = Standard_False;
|
||||
Standard_Integer aSelectionMode = SelectionMode();
|
||||
if (aSelectionMode == -1)
|
||||
Standard_Integer nbSelModes = GetNbSelectionModes();
|
||||
if (nbSelModes == 1)
|
||||
{
|
||||
aContext->Deactivate(myAIS);
|
||||
Standard_Boolean isActivated = Standard_False;
|
||||
Standard_Integer aSelectionMode = SelectionMode();
|
||||
if (aSelectionMode == -1)
|
||||
{
|
||||
aContext->Deactivate(myAIS);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter(anActivatedModes); aModeIter.More(); aModeIter.Next())
|
||||
{
|
||||
if (aModeIter.Value() == aSelectionMode)
|
||||
{
|
||||
isActivated = Standard_True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isActivated)
|
||||
aContext->Activate(myAIS, aSelectionMode, Standard_False);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
|
||||
for (Standard_Integer iSelMode = 1; iSelMode <= nbSelModes; iSelMode++)
|
||||
{
|
||||
if (aModeIter.Value() == aSelectionMode)
|
||||
{
|
||||
isActivated = Standard_True;
|
||||
break;
|
||||
}
|
||||
const Standard_Integer aSelectionMode = SelectionMode (iSelMode);
|
||||
aContext->SetSelectionModeActive (myAIS, aSelectionMode, Standard_True/*activate*/,
|
||||
iSelMode == 1 ? AIS_SelectionModesConcurrency_Single : AIS_SelectionModesConcurrency_GlobalOrLocal);
|
||||
}
|
||||
if (!isActivated)
|
||||
aContext->Activate (myAIS, aSelectionMode, Standard_False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -155,19 +155,23 @@ public:
|
||||
Standard_EXPORT Standard_Boolean HasOwnMode() const;
|
||||
|
||||
Standard_EXPORT void UnsetMode();
|
||||
|
||||
Standard_EXPORT Standard_Integer SelectionMode() const;
|
||||
|
||||
//! Returns selection mode(s) of the attribute.
|
||||
//! It starts with 1 .. GetNbSelectionModes().
|
||||
Standard_EXPORT Standard_Integer GetNbSelectionModes() const;
|
||||
Standard_EXPORT Standard_Integer SelectionMode(const int index = 1) const;
|
||||
|
||||
//! Sets selection mode.
|
||||
//! If "theTransaction" flag is OFF, modification of the attribute doesn't influence the transaction mechanism
|
||||
//! (the attribute doesn't participate in undo/redo).
|
||||
//! (the attribute doesn't participate in undo/redo because of this modification).
|
||||
//! Certainly, if any other data of the attribute is modified (display mode, color, ...),
|
||||
//! the attribute will be included into transaction.
|
||||
//! Obsolete method (may be removed later).
|
||||
Standard_EXPORT void SetSelectionMode (const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction = Standard_True);
|
||||
|
||||
//! the attribute will be included into undo/redo.
|
||||
Standard_EXPORT void SetSelectionMode(const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction = Standard_True);
|
||||
Standard_EXPORT void AddSelectionMode(const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction = Standard_True);
|
||||
|
||||
Standard_EXPORT Standard_Boolean HasOwnSelectionMode() const;
|
||||
|
||||
//! Clears all selection modes of the attribute.
|
||||
Standard_EXPORT void UnsetSelectionMode();
|
||||
|
||||
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
|
||||
|
Reference in New Issue
Block a user