if (myArray.IsNull() || !myArray->IsValid()) {
// this could be on undo and then redo creation of the attribute
// in result creation it may be uninitialized
- myIsInitialized = myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray);
+ myIsInitialized = myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray) == Standard_True;
}
// checking the validity because attribute (as a field) may be presented,
// but without label: it is undoed
#include <string>
+#ifdef WNT // to avoid too long decorated name warning
+#pragma warning( disable : 4503 )
+#endif
+
// myLab contains:
// TDataStd_Name - name of the object
// TDataStd_IntegerArray - state of the object execution, transaction ID of update
return kInvalid;
}
-bool Model_Data::isOwner(ModelAPI_Object* theOwner)
+std::shared_ptr<ModelAPI_Object> Model_Data::owner()
{
- return theOwner == myObject.get();
+ return myObject;
}
/// Returns true if the given object is owner of this data (needed for correct erase of object
/// with duplicated data)
- MODEL_EXPORT virtual bool isOwner(ModelAPI_Object* theOwner);
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Object> owner();
protected:
/// Returns true if "is in history" custom behaviors is defined for the feature
std::list<ResultPtr>::iterator aPartRes = aPartResults.begin();
for(; aPartRes != aPartResults.end(); aPartRes++) {
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aPartRes);
- if (aPart && (!theActivatedOnly || aPart->isActivated()))
- aResult.insert(aPart->data()->name());
+ if (aPart && (!theActivatedOnly || aPart->isActivated())) {
+ aResult.insert(aPart->original()->data()->name());
+ }
}
return aResult;
}
}
}
+std::shared_ptr<ModelAPI_ResultPart> Model_ResultPart::original()
+{
+ if (myTrsf.get()) {
+ return baseRef()->original();
+ }
+ return std::dynamic_pointer_cast<ModelAPI_ResultPart>(data()->owner());
+}
+
bool Model_ResultPart::isActivated()
{
if (myTrsf.get()) {
/// Returns the part-document of this result
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> partDoc();
+ /// Returns the original part result: for transfomration features results this is
+ /// the original Part feature result
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> original();
+
/// Sets this document as current and if it is not loaded yet, loads it
MODEL_EXPORT virtual void activate();
/// This method is called by the updater.
virtual void setUpdateID(const int theID) = 0;
- /// Returns true if the given object is owner of this data (needed for correct erase of object
- /// with duplicated data)
- virtual bool isOwner(ModelAPI_Object* theOwner) = 0;
+ /// Returns the owner of htis data
+ virtual std::shared_ptr<ModelAPI_Object> owner() = 0;
protected:
/// Objects are created for features automatically
void ModelAPI_Object::erase()
{
- if (myData->isValid() && myData != myData->invalidPtr() && myData->isOwner(this))
+ if (myData->isValid() && myData != myData->invalidPtr())
myData->erase();
setData(myData->invalidPtr());
}
// Author: Mikhail PONIKAROV
#include "ModelAPI_ResultBody.h"
+#include <ModelAPI_BodyBuilder.h>
ModelAPI_ResultBody::ModelAPI_ResultBody()
: myBuilder(0)
/// Returns the part-document of this result
virtual std::shared_ptr<ModelAPI_Document> partDoc() = 0;
+ /// Returns the original part result: for transfomration features results this is
+ /// the original Part feature result
+ virtual std::shared_ptr<ModelAPI_ResultPart> original() = 0;
+
/// Sets this document as current and if it is not loaded yet, loads it
virtual void activate() = 0;