mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0027619: Improvement on manuipulation of data by TPrsStd_AISPresentation attribute.
The branch contains a fix on Undo/Redo for TPrsStd_AISPresentation attribute + an opportunity to deselect the interactive object. getData() now calls FindAttribute(), the field myData disappeared. A fix of regression on bug73_3. A cleverer solution.
This commit is contained in:
parent
0f5ea4b5f8
commit
c4a2f61e57
@ -39,6 +39,8 @@
|
|||||||
#include <TDF_Tool.hxx>
|
#include <TDF_Tool.hxx>
|
||||||
#include <TDF_ChildIterator.hxx>
|
#include <TDF_ChildIterator.hxx>
|
||||||
#include <TDF_Tool.hxx>
|
#include <TDF_Tool.hxx>
|
||||||
|
#include <TPrsStd_AISViewer.hxx>
|
||||||
|
#include <AIS_InteractiveContext.hxx>
|
||||||
// pour propagate
|
// pour propagate
|
||||||
#include <TDocStd_XLinkTool.hxx>
|
#include <TDocStd_XLinkTool.hxx>
|
||||||
|
|
||||||
@ -228,6 +230,11 @@ static Standard_Integer DDocStd_Undo (Draw_Interpretor& di,Standard_Integer n, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redraw the viewer.
|
||||||
|
Handle(AIS_InteractiveContext) IC;
|
||||||
|
if (TPrsStd_AISViewer::Find(D->Main(), IC))
|
||||||
|
IC->UpdateCurrentViewer();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,6 @@ Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set
|
|||||||
if ( !theLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), aPresentation) )
|
if ( !theLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), aPresentation) )
|
||||||
{
|
{
|
||||||
aPresentation = new TPrsStd_AISPresentation();
|
aPresentation = new TPrsStd_AISPresentation();
|
||||||
aPresentation->myData = aData;
|
|
||||||
theLabel.AddAttribute(aPresentation);
|
theLabel.AddAttribute(aPresentation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,19 +77,7 @@ Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set(const Handle(TDF_Attribute)& theMaster)
|
Handle(TPrsStd_AISPresentation) TPrsStd_AISPresentation::Set(const Handle(TDF_Attribute)& theMaster)
|
||||||
{
|
{
|
||||||
Handle(TPrsStd_AISPresentation) aPresentation;
|
return TPrsStd_AISPresentation::Set(theMaster->Label(), theMaster->ID());
|
||||||
// create associated data (unless already there)
|
|
||||||
Handle(TDataXtd_Presentation) aData = TDataXtd_Presentation::Set (theMaster->Label(), theMaster->ID());
|
|
||||||
if(aData.IsNull())
|
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
if ( !theMaster->Label().FindAttribute(TPrsStd_AISPresentation::GetID(), aPresentation) )
|
|
||||||
{
|
|
||||||
aPresentation = new TPrsStd_AISPresentation ();
|
|
||||||
aPresentation->myData = aData;
|
|
||||||
theMaster->Label().AddAttribute(aPresentation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return aPresentation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -114,7 +101,8 @@ void TPrsStd_AISPresentation::Unset (const TDF_Label& theLabel)
|
|||||||
Handle(TDataXtd_Presentation) TPrsStd_AISPresentation::getData () const
|
Handle(TDataXtd_Presentation) TPrsStd_AISPresentation::getData () const
|
||||||
{
|
{
|
||||||
Handle(TDataXtd_Presentation) aData;
|
Handle(TDataXtd_Presentation) aData;
|
||||||
Label().FindAttribute(TDataXtd_Presentation::GetID(), aData);
|
if (!Label().FindAttribute(TDataXtd_Presentation::GetID(), aData))
|
||||||
|
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
||||||
return aData;
|
return aData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +116,6 @@ const Standard_GUID& TPrsStd_AISPresentation::GetID()
|
|||||||
return TPrsStd_AISPresentationID;
|
return TPrsStd_AISPresentationID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Display
|
//function : Display
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -141,7 +128,6 @@ void TPrsStd_AISPresentation::Display(const Standard_Boolean theIsUpdate)
|
|||||||
AISDisplay();
|
AISDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Erase
|
//function : Erase
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -151,7 +137,6 @@ void TPrsStd_AISPresentation::Erase(const Standard_Boolean theIsRemove)
|
|||||||
if ( IsDisplayed() )
|
if ( IsDisplayed() )
|
||||||
{
|
{
|
||||||
AISErase(theIsRemove);
|
AISErase(theIsRemove);
|
||||||
//SetDisplayed (Standard_False);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,19 +149,15 @@ void TPrsStd_AISPresentation::Update()
|
|||||||
AISUpdate();
|
AISUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : IsDisplayed
|
//function : IsDisplayed
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean TPrsStd_AISPresentation::IsDisplayed() const
|
Standard_Boolean TPrsStd_AISPresentation::IsDisplayed() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->IsDisplayed();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->IsDisplayed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetDisplayed
|
//function : SetDisplayed
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -185,45 +166,36 @@ void TPrsStd_AISPresentation::SetDisplayed(const Standard_Boolean theIsDisplayed
|
|||||||
{
|
{
|
||||||
// this method can be called by AISUpdate() in the process of removal,
|
// this method can be called by AISUpdate() in the process of removal,
|
||||||
// while data attribute may be already removed
|
// while data attribute may be already removed
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
getData()->SetDisplayed(theIsDisplayed);
|
||||||
myData->SetDisplayed(theIsDisplayed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :SetDriverGUID
|
//function :SetDriverGUID
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::SetDriverGUID(const Standard_GUID& theGUID)
|
void TPrsStd_AISPresentation::SetDriverGUID(const Standard_GUID& theGUID)
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
getData()->SetDriverGUID (theGUID);
|
||||||
myData->SetDriverGUID (theGUID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :GetDriverGUID
|
//function :GetDriverGUID
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_GUID TPrsStd_AISPresentation::GetDriverGUID() const
|
Standard_GUID TPrsStd_AISPresentation::GetDriverGUID() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->GetDriverGUID();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->GetDriverGUID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :Material
|
//function :Material
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Graphic3d_NameOfMaterial TPrsStd_AISPresentation::Material() const
|
Graphic3d_NameOfMaterial TPrsStd_AISPresentation::Material() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return (Graphic3d_NameOfMaterial)getData()->MaterialIndex();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return (Graphic3d_NameOfMaterial)myData->MaterialIndex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -232,9 +204,7 @@ Graphic3d_NameOfMaterial TPrsStd_AISPresentation::Material() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean TPrsStd_AISPresentation::HasOwnMaterial() const
|
Standard_Boolean TPrsStd_AISPresentation::HasOwnMaterial() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->HasOwnMaterial();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->HasOwnMaterial();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -243,12 +213,10 @@ Standard_Boolean TPrsStd_AISPresentation::HasOwnMaterial() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::UnsetMaterial()
|
void TPrsStd_AISPresentation::UnsetMaterial()
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
if ( !getData()->HasOwnMaterial() && !myAIS.IsNull() && !myAIS->HasMaterial() )
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
if ( ! myData->HasOwnMaterial() && ! myAIS.IsNull() && !myAIS->HasMaterial() )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->UnsetMaterial();
|
getData()->UnsetMaterial();
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -271,14 +239,12 @@ void TPrsStd_AISPresentation::UnsetMaterial()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::SetMaterial(const Graphic3d_NameOfMaterial theName)
|
void TPrsStd_AISPresentation::SetMaterial(const Graphic3d_NameOfMaterial theName)
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
if ( getData()->HasOwnMode() && getData()->MaterialIndex() == theName )
|
||||||
|
|
||||||
if ( myData->HasOwnMode() && myData->MaterialIndex() == theName )
|
|
||||||
if ( !myAIS.IsNull() && myAIS->HasMaterial() && myAIS->Material() == theName )
|
if ( !myAIS.IsNull() && myAIS->HasMaterial() && myAIS->Material() == theName )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->SetMaterialIndex(theName);
|
getData()->SetMaterialIndex(theName);
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -303,9 +269,7 @@ void TPrsStd_AISPresentation::SetMaterial(const Graphic3d_NameOfMaterial theName
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Real TPrsStd_AISPresentation::Transparency() const
|
Standard_Real TPrsStd_AISPresentation::Transparency() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->Transparency();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->Transparency();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -314,13 +278,12 @@ Standard_Real TPrsStd_AISPresentation::Transparency() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::SetTransparency(const Standard_Real theValue)
|
void TPrsStd_AISPresentation::SetTransparency(const Standard_Real theValue)
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
if (getData()->HasOwnTransparency() && getData()->Transparency() == theValue)
|
||||||
if (myData->HasOwnTransparency() && myData->Transparency() == theValue)
|
|
||||||
if ( !myAIS.IsNull() && myAIS->Transparency() == theValue )
|
if ( !myAIS.IsNull() && myAIS->Transparency() == theValue )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->SetTransparency(theValue);
|
getData()->SetTransparency(theValue);
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -339,19 +302,16 @@ void TPrsStd_AISPresentation::SetTransparency(const Standard_Real theValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :UnsetTransparency
|
//function :UnsetTransparency
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::UnsetTransparency()
|
void TPrsStd_AISPresentation::UnsetTransparency()
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
if (!getData()->HasOwnTransparency())
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
if (! myData->HasOwnTransparency())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->UnsetTransparency();
|
getData()->UnsetTransparency();
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -373,21 +333,16 @@ void TPrsStd_AISPresentation::UnsetTransparency()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean TPrsStd_AISPresentation::HasOwnTransparency() const
|
Standard_Boolean TPrsStd_AISPresentation::HasOwnTransparency() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->HasOwnTransparency();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->HasOwnTransparency();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Color
|
//function : Color
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Quantity_NameOfColor TPrsStd_AISPresentation::Color() const
|
Quantity_NameOfColor TPrsStd_AISPresentation::Color() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->Color();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->Color();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -396,9 +351,7 @@ Quantity_NameOfColor TPrsStd_AISPresentation::Color() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean TPrsStd_AISPresentation::HasOwnColor() const
|
Standard_Boolean TPrsStd_AISPresentation::HasOwnColor() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->HasOwnColor();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->HasOwnColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -407,11 +360,9 @@ Standard_Boolean TPrsStd_AISPresentation::HasOwnColor() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::UnsetColor()
|
void TPrsStd_AISPresentation::UnsetColor()
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
if (!getData()->HasOwnColor() && ! myAIS.IsNull() && !myAIS->HasColor())
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
if (!myData->HasOwnColor() && ! myAIS.IsNull() && !myAIS->HasColor())
|
|
||||||
return;
|
return;
|
||||||
myData->UnsetColor();
|
getData()->UnsetColor();
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -433,13 +384,12 @@ void TPrsStd_AISPresentation::UnsetColor()
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor theColor)
|
void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor theColor)
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
if ( getData()->HasOwnColor() && getData()->Color() == theColor )
|
||||||
if ( myData->HasOwnColor() && myData->Color() == theColor )
|
|
||||||
if ( !myAIS.IsNull() && myAIS->HasColor() && myAIS->Color() == theColor )
|
if ( !myAIS.IsNull() && myAIS->HasColor() && myAIS->Color() == theColor )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->SetColor(theColor);
|
getData()->SetColor(theColor);
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -458,16 +408,13 @@ void TPrsStd_AISPresentation::SetColor(const Quantity_NameOfColor theColor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :Width
|
//function :Width
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Real TPrsStd_AISPresentation::Width() const
|
Standard_Real TPrsStd_AISPresentation::Width() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->Width();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->Width();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -476,9 +423,7 @@ Standard_Real TPrsStd_AISPresentation::Width() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean TPrsStd_AISPresentation::HasOwnWidth() const
|
Standard_Boolean TPrsStd_AISPresentation::HasOwnWidth() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->HasOwnWidth();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->HasOwnWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -487,13 +432,12 @@ Standard_Boolean TPrsStd_AISPresentation::HasOwnWidth() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::SetWidth(const Standard_Real theWidth)
|
void TPrsStd_AISPresentation::SetWidth(const Standard_Real theWidth)
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
if ( getData()->HasOwnWidth() && getData()->Width() == theWidth )
|
||||||
if ( myData->HasOwnWidth() && myData->Width() == theWidth )
|
|
||||||
if ( !myAIS.IsNull() && myAIS->HasWidth() && myAIS->Width() == theWidth )
|
if ( !myAIS.IsNull() && myAIS->HasWidth() && myAIS->Width() == theWidth )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->SetWidth(theWidth);
|
getData()->SetWidth(theWidth);
|
||||||
|
|
||||||
if( !myAIS.IsNull() )
|
if( !myAIS.IsNull() )
|
||||||
{
|
{
|
||||||
@ -515,13 +459,11 @@ void TPrsStd_AISPresentation::SetWidth(const Standard_Real theWidth)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::UnsetWidth()
|
void TPrsStd_AISPresentation::UnsetWidth()
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
if ( !getData()->HasOwnWidth() )
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
if ( !myData->HasOwnWidth() )
|
|
||||||
if ( !myAIS.IsNull() && !myAIS->HasWidth() )
|
if ( !myAIS.IsNull() && !myAIS->HasWidth() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->UnsetWidth();
|
getData()->UnsetWidth();
|
||||||
|
|
||||||
if( myAIS.IsNull() )
|
if( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -537,17 +479,13 @@ void TPrsStd_AISPresentation::UnsetWidth()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Mode
|
//function : Mode
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Integer TPrsStd_AISPresentation::Mode() const
|
Standard_Integer TPrsStd_AISPresentation::Mode() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->Mode();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->Mode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -556,25 +494,21 @@ Standard_Integer TPrsStd_AISPresentation::Mode() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean TPrsStd_AISPresentation::HasOwnMode() const
|
Standard_Boolean TPrsStd_AISPresentation::HasOwnMode() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->HasOwnMode();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->HasOwnMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetMode
|
//function : SetMode
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::SetMode(const Standard_Integer theMode)
|
void TPrsStd_AISPresentation::SetMode(const Standard_Integer theMode)
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
if ( getData()->HasOwnMode() && getData()->Mode() == theMode )
|
||||||
if ( myData->HasOwnMode() && myData->Mode() == theMode )
|
|
||||||
if ( !myAIS.IsNull() && myAIS->DisplayMode() == theMode )
|
if ( !myAIS.IsNull() && myAIS->DisplayMode() == theMode )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->SetMode(theMode);
|
getData()->SetMode(theMode);
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -593,20 +527,17 @@ void TPrsStd_AISPresentation::SetMode(const Standard_Integer theMode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : UnsetMode
|
//function : UnsetMode
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::UnsetMode()
|
void TPrsStd_AISPresentation::UnsetMode()
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
if ( !getData()->HasOwnMode() )
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
if ( !myData->HasOwnMode() )
|
|
||||||
if ( !myAIS.IsNull() && !myAIS->HasDisplayMode() )
|
if ( !myAIS.IsNull() && !myAIS->HasDisplayMode() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
myData->UnsetMode();
|
getData()->UnsetMode();
|
||||||
|
|
||||||
if ( myAIS.IsNull() )
|
if ( myAIS.IsNull() )
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
@ -626,12 +557,9 @@ void TPrsStd_AISPresentation::UnsetMode()
|
|||||||
//function : SelectionMode
|
//function : SelectionMode
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Integer TPrsStd_AISPresentation::SelectionMode() const
|
Standard_Integer TPrsStd_AISPresentation::SelectionMode() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->SelectionMode();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->SelectionMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -640,9 +568,7 @@ Standard_Integer TPrsStd_AISPresentation::SelectionMode() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Boolean TPrsStd_AISPresentation::HasOwnSelectionMode() const
|
Standard_Boolean TPrsStd_AISPresentation::HasOwnSelectionMode() const
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
return getData()->HasOwnSelectionMode();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
return myData->HasOwnSelectionMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -651,10 +577,8 @@ Standard_Boolean TPrsStd_AISPresentation::HasOwnSelectionMode() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelectionMode)
|
void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelectionMode)
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
Backup();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
getData()->SetSelectionMode (theSelectionMode);
|
||||||
myData->SetSelectionMode (theSelectionMode);
|
|
||||||
|
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,10 +588,7 @@ void TPrsStd_AISPresentation::SetSelectionMode(const Standard_Integer theSelecti
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::UnsetSelectionMode()
|
void TPrsStd_AISPresentation::UnsetSelectionMode()
|
||||||
{
|
{
|
||||||
if(myData.IsNull())
|
getData()->UnsetSelectionMode ();
|
||||||
Standard_NoMoreObject::Raise (NO_MORE_OBJECT);
|
|
||||||
myData->UnsetSelectionMode ();
|
|
||||||
|
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -708,7 +629,6 @@ void TPrsStd_AISPresentation::Restore(const Handle(TDF_Attribute)& /*theWith*/)
|
|||||||
myAIS.Nullify();
|
myAIS.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Paste
|
//function : Paste
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -721,10 +641,8 @@ void TPrsStd_AISPresentation::Paste (const Handle(TDF_Attribute)& theInto,
|
|||||||
|
|
||||||
anInto->Backup();
|
anInto->Backup();
|
||||||
anInto->myAIS.Nullify();
|
anInto->myAIS.Nullify();
|
||||||
anInto->myData.Nullify();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AfterAddition
|
//function : AfterAddition
|
||||||
//purpose : erase if displayed
|
//purpose : erase if displayed
|
||||||
@ -753,18 +671,15 @@ void TPrsStd_AISPresentation::BeforeForget()
|
|||||||
{ // Remove AISObject from context.
|
{ // Remove AISObject from context.
|
||||||
AISErase(Standard_True);
|
AISErase(Standard_True);
|
||||||
myAIS.Nullify();
|
myAIS.Nullify();
|
||||||
myData.Nullify();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AfterResume
|
//function : AfterResume
|
||||||
//purpose : display if displayed
|
//purpose : display if displayed
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void TPrsStd_AISPresentation::AfterResume()
|
void TPrsStd_AISPresentation::AfterResume()
|
||||||
{
|
{
|
||||||
myData = getData();
|
|
||||||
AISUpdate();
|
AISUpdate();
|
||||||
if ( IsDisplayed() )
|
if ( IsDisplayed() )
|
||||||
AISDisplay();
|
AISDisplay();
|
||||||
@ -776,7 +691,6 @@ void TPrsStd_AISPresentation::AfterResume()
|
|||||||
//function : BeforeUndo
|
//function : BeforeUndo
|
||||||
//purpose : le NamedShape associe doit etre present
|
//purpose : le NamedShape associe doit etre present
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Boolean TPrsStd_AISPresentation::BeforeUndo (const Handle(TDF_AttributeDelta)& AD,
|
Standard_Boolean TPrsStd_AISPresentation::BeforeUndo (const Handle(TDF_AttributeDelta)& AD,
|
||||||
const Standard_Boolean )
|
const Standard_Boolean )
|
||||||
{
|
{
|
||||||
@ -799,12 +713,10 @@ Standard_Boolean TPrsStd_AISPresentation::BeforeUndo (const Handle(TDF_Attribute
|
|||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AfterUndo
|
//function : AfterUndo
|
||||||
//purpose : le NamedShape associe doit etre present
|
//purpose : le NamedShape associe doit etre present
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Boolean TPrsStd_AISPresentation::AfterUndo (const Handle(TDF_AttributeDelta)& AD,
|
Standard_Boolean TPrsStd_AISPresentation::AfterUndo (const Handle(TDF_AttributeDelta)& AD,
|
||||||
const Standard_Boolean )
|
const Standard_Boolean )
|
||||||
{
|
{
|
||||||
@ -827,7 +739,6 @@ Standard_Boolean TPrsStd_AISPresentation::AfterUndo (const Handle(TDF_AttributeD
|
|||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AISUpdate
|
//function : AISUpdate
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -835,7 +746,7 @@ Standard_Boolean TPrsStd_AISPresentation::AfterUndo (const Handle(TDF_AttributeD
|
|||||||
void TPrsStd_AISPresentation::AISUpdate()
|
void TPrsStd_AISPresentation::AISUpdate()
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
myData->Backup();
|
getData()->Backup();
|
||||||
Handle(AIS_InteractiveContext) aContext;
|
Handle(AIS_InteractiveContext) aContext;
|
||||||
if ( !Label().IsNull() )
|
if ( !Label().IsNull() )
|
||||||
{
|
{
|
||||||
@ -851,7 +762,6 @@ void TPrsStd_AISPresentation::AISUpdate()
|
|||||||
if ( aDriver->Update(Label(), aNewObj) )
|
if ( aDriver->Update(Label(), aNewObj) )
|
||||||
{
|
{
|
||||||
myAIS = aNewObj;
|
myAIS = aNewObj;
|
||||||
myData = getData();
|
|
||||||
aNewObj->SetOwner(this);
|
aNewObj->SetOwner(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -866,7 +776,6 @@ void TPrsStd_AISPresentation::AISUpdate()
|
|||||||
|
|
||||||
// Driver has built new AIS.
|
// Driver has built new AIS.
|
||||||
myAIS = anObj;
|
myAIS = anObj;
|
||||||
myData = getData();
|
|
||||||
anObj->SetOwner(this);
|
anObj->SetOwner(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -936,13 +845,18 @@ void TPrsStd_AISPresentation::AISUpdate()
|
|||||||
aContext->Redisplay(myAIS, Standard_False);
|
aContext->Redisplay(myAIS, Standard_False);
|
||||||
|
|
||||||
if (HasOwnSelectionMode()) {
|
if (HasOwnSelectionMode()) {
|
||||||
//aContext = aContext.IsNull() ? myAIS->GetContext() : aContext;
|
|
||||||
if (!aContext.IsNull())
|
if (!aContext.IsNull())
|
||||||
{
|
{
|
||||||
TColStd_ListOfInteger anActivatedModes;
|
TColStd_ListOfInteger anActivatedModes;
|
||||||
aContext->ActivatedModes (myAIS, anActivatedModes);
|
aContext->ActivatedModes (myAIS, anActivatedModes);
|
||||||
Standard_Boolean isActivated = Standard_False;
|
Standard_Boolean isActivated = Standard_False;
|
||||||
Standard_Integer aSelectionMode = SelectionMode();
|
Standard_Integer aSelectionMode = SelectionMode();
|
||||||
|
if (aSelectionMode == -1)
|
||||||
|
{
|
||||||
|
aContext->Deactivate(myAIS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
|
for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
|
||||||
{
|
{
|
||||||
if (aModeIter.Value() == aSelectionMode)
|
if (aModeIter.Value() == aSelectionMode)
|
||||||
@ -951,11 +865,11 @@ void TPrsStd_AISPresentation::AISUpdate()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isActivated)
|
if (!isActivated)
|
||||||
aContext->Activate (myAIS, aSelectionMode, Standard_False);
|
aContext->Activate (myAIS, aSelectionMode, Standard_False);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -992,7 +906,6 @@ void TPrsStd_AISPresentation::AISDisplay()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : AISErase
|
//function : AISErase
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -1004,10 +917,11 @@ void TPrsStd_AISPresentation::AISErase(const Standard_Boolean theIsRemove)
|
|||||||
if ( !myAIS.IsNull() )
|
if ( !myAIS.IsNull() )
|
||||||
{
|
{
|
||||||
Backup();
|
Backup();
|
||||||
myData->Backup();
|
|
||||||
SetDisplayed(Standard_False);
|
|
||||||
if ( !Label().IsNull() )
|
if ( !Label().IsNull() )
|
||||||
{
|
{
|
||||||
|
if (IsAttribute(TDataXtd_Presentation::GetID()))
|
||||||
|
SetDisplayed(Standard_False);
|
||||||
|
|
||||||
Handle(TPrsStd_AISViewer) viewer;
|
Handle(TPrsStd_AISViewer) viewer;
|
||||||
if( !TPrsStd_AISViewer::Find(Label(), viewer) )
|
if( !TPrsStd_AISViewer::Find(Label(), viewer) )
|
||||||
return;
|
return;
|
||||||
@ -1048,7 +962,6 @@ void TPrsStd_AISPresentation::AISErase(const Standard_Boolean theIsRemove)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function :GetAIS
|
//function :GetAIS
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -1058,7 +971,6 @@ Handle(AIS_InteractiveObject) TPrsStd_AISPresentation::GetAIS() const
|
|||||||
return myAIS;
|
return myAIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : getAISContext
|
//function : getAISContext
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@ -189,10 +189,12 @@ public:
|
|||||||
|
|
||||||
DEFINE_STANDARD_RTTIEXT(TPrsStd_AISPresentation,TDF_Attribute)
|
DEFINE_STANDARD_RTTIEXT(TPrsStd_AISPresentation,TDF_Attribute)
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
//! Returns attribute storing presentation data
|
//! Returns attribute storing presentation data
|
||||||
Handle(TDataXtd_Presentation) getData () const;
|
Standard_EXPORT virtual Handle(TDataXtd_Presentation) getData () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
Handle(AIS_InteractiveContext) getAISContext() const;
|
Handle(AIS_InteractiveContext) getAISContext() const;
|
||||||
|
|
||||||
@ -210,7 +212,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Handle(AIS_InteractiveObject) myAIS;
|
Handle(AIS_InteractiveObject) myAIS;
|
||||||
Handle(TDataXtd_Presentation) myData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _TPrsStd_AISPresentation_HeaderFile
|
#endif // _TPrsStd_AISPresentation_HeaderFile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user