// create associated data (unless already there)
Handle(TDataXtd_Presentation) aData = TDataXtd_Presentation::Set (theLabel, theDriver);
if(aData.IsNull())
- Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
+ throw Standard_NoMoreObject(NO_MORE_OBJECT);
if ( !theLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), aPresentation) )
{
aPresentation = new TPrsStd_AISPresentation();
- theLabel.AddAttribute(aPresentation);
+ theLabel.AddAttribute(aPresentation, Standard_True);
}
return aPresentation;
{
Handle(TDataXtd_Presentation) aData;
if (!Label().FindAttribute(TDataXtd_Presentation::GetID(), aData))
- Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
+ throw Standard_NoMoreObject(NO_MORE_OBJECT);
return aData;
}
{
Backup();
if ( getData()->HasOwnColor() && getData()->Color() == theColor )
- if ( !myAIS.IsNull() && myAIS->HasColor() && myAIS->Color() == theColor )
- return;
+ {
+ if (!myAIS.IsNull() && myAIS->HasColor())
+ {
+ Quantity_Color aColor;
+ myAIS->Color (aColor);
+ if (aColor.Name() == theColor)
+ {
+ return;
+ }
+ }
+ }
getData()->SetColor(theColor);
if ( !myAIS.IsNull() )
{
- if ( myAIS->HasColor() && myAIS->Color() == theColor )
- return; // AIS has already had that color
+ if (myAIS->HasColor())
+ {
+ Quantity_Color aColor;
+ myAIS->Color (aColor);
+ if (aColor.Name() == theColor)
+ {
+ return; // AIS has already had that color
+ }
+ }
Handle(AIS_InteractiveContext) aContext = getAISContext();
//function : SetSelectionMode
//purpose :
//=======================================================================
-void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelectionMode)
+void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction)
{
- Backup();
- getData()->SetSelectionMode (theSelectionMode);
- AISUpdate();
+ if (theTransaction)
+ Backup();
+ getData()->SetSelectionMode (theSelectionMode, theTransaction);
+
+ if ( myAIS.IsNull() )
+ AISUpdate();
+ else
+ ActivateSelectionMode();
}
//=======================================================================
Handle(TPrsStd_AISPresentation)::DownCast(theInto);
anInto->Backup();
+ if (!anInto->myAIS.IsNull())
+ {
+ // Save displayed flag.
+ Standard_Boolean displayed = anInto->IsDisplayed();
+ // Erase the interactive object.
+ anInto->AISErase(Standard_True);
+ // Restore the displayed flag.
+ if (displayed)
+ anInto->SetDisplayed(displayed);
+ }
+ // Nullify the interactive object.
+ // It will be restored on the next call to AISUpdate().
anInto->myAIS.Nullify();
}
if ( !(anObj == myAIS) )
{
if ( !aContext.IsNull() )
- aContext->Remove(myAIS);
+ aContext->Remove (myAIS, Standard_False);
// Driver has built new AIS.
myAIS = anObj;
if ( HasOwnColor() )
{
Quantity_NameOfColor aColor = Color();
- if ( !(myAIS->HasColor()) || (myAIS->HasColor() && myAIS->Color() != aColor) )
+ Quantity_Color aPrsColor;
+ myAIS->Color (aPrsColor);
+ if ( !(myAIS->HasColor()) || (myAIS->HasColor() && aPrsColor.Name() != aColor) )
{
if ( !aContext.IsNull() )
aContext->SetColor(myAIS, aColor, Standard_False);
myAIS->SetDisplayMode(aMode);
}
- if ( !aContext.IsNull() && IsDisplayed() )
- aContext->Redisplay(myAIS, Standard_False);
-
- if (HasOwnSelectionMode()) {
- if (!aContext.IsNull())
- {
- TColStd_ListOfInteger anActivatedModes;
- aContext->ActivatedModes (myAIS, anActivatedModes);
- 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);
- }
- }
- }
-
+ ActivateSelectionMode();
}
if (IsDisplayed() && !aContext.IsNull())
if ( !myAIS.IsNull() )
{
if ( !(myAIS->GetContext()).IsNull() && (myAIS->GetContext()) != aContext )
- myAIS->GetContext()->Remove(myAIS);
+ myAIS->GetContext()->Remove (myAIS, Standard_False);
if ( IsDisplayed() && aContext->IsDisplayed(myAIS) )
return;
return Handle_AIS_InteractiveContext();
}
+
+//=======================================================================
+//function : ActivateSelectionMode
+//purpose : Activates selection mode of the interactive object.
+// It is called internally on change of selection mode and AISUpdate().
+//=======================================================================
+void TPrsStd_AISPresentation::ActivateSelectionMode()
+{
+ if (!myAIS.IsNull() && HasOwnSelectionMode())
+ {
+ Handle(AIS_InteractiveContext) aContext = getAISContext();
+ if (!aContext.IsNull())
+ {
+ TColStd_ListOfInteger anActivatedModes;
+ aContext->ActivatedModes (myAIS, anActivatedModes);
+ 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);
+ }
+ }
+ }
+}