diff --git a/src/TObj/TObj_Object.cxx b/src/TObj/TObj_Object.cxx index a15951d4b9..afdd460b0f 100644 --- a/src/TObj/TObj_Object.cxx +++ b/src/TObj/TObj_Object.cxx @@ -1631,3 +1631,13 @@ Standard_Integer TObj_Object::GetOrder() const order = GetLabel().Tag(); return order; } + +//======================================================================= +//function : HasModifications +//purpose : +//======================================================================= + +Standard_Boolean TObj_Object::HasModifications() const +{ + return (!IsAlive() ? Standard_False : GetLabel().MayBeModified() ); +} \ No newline at end of file diff --git a/src/TObj/TObj_Object.hxx b/src/TObj/TObj_Object.hxx index 8afecf0a46..ab5d31935d 100644 --- a/src/TObj/TObj_Object.hxx +++ b/src/TObj/TObj_Object.hxx @@ -365,6 +365,14 @@ class TObj_Object : public Standard_Transient //! sets order of object virtual Standard_EXPORT Standard_Boolean SetOrder( const Standard_Integer& theIndx ); + public: + /** + * Public methods to check modifications of the object since last commit + */ + //! Returns true if object attributes or or his children were modified in the current open transaction + Standard_EXPORT Standard_Boolean HasModifications() const; + + protected: /** * Protected Methods copy data of object to other object diff --git a/src/TObjDRAW/TObjDRAW.cxx b/src/TObjDRAW/TObjDRAW.cxx index 30ceb8b25d..9c6482ba43 100644 --- a/src/TObjDRAW/TObjDRAW.cxx +++ b/src/TObjDRAW/TObjDRAW.cxx @@ -447,6 +447,28 @@ static Standard_Integer getChild (Draw_Interpretor& di, Standard_Integer argc, c return 0; } +//======================================================================= +//function : hasModifications +//purpose : +//======================================================================= +static Standard_Integer hasModifications(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc < 3) + { + di << "Use " << argv[0] << "DocName ObjName\n"; + return 1; + } + + Handle(TObjDRAW_Object) tObj = getObjByName(argv[1], argv[2]); + if (tObj.IsNull()) + { + di << "Error: Object " << argv[2] << " not found\n"; + return 1; + } + di << "Status modifications : " << (tObj->HasModifications() ? 1 : 0) << "\n"; + + return 0; +} //======================================================================= //function : Init //purpose : @@ -500,6 +522,8 @@ void TObjDRAW::Init(Draw_Interpretor& di) di.Add ("TObjGetChildren","DocName ObjName \t: Returns list of children objects", __FILE__, getChild, g); + di.Add("TObjHasModifications", "DocName ObjName \t: Returns status of modification of the object (if object has been modified 1, otherwise 0)", __FILE__, hasModifications, g); + } diff --git a/tests/bugs/caf/bug31452 b/tests/bugs/caf/bug31452 new file mode 100644 index 0000000000..f53fb81d6b --- /dev/null +++ b/tests/bugs/caf/bug31452 @@ -0,0 +1,50 @@ +puts "============" +puts "OCC31452" +puts "0031452: Impossible to get Backup of the attribute and status that attribute was modified before commit transaction" +puts "============" + +set BugNumber OCC31452 +set status 0 + +pload TOBJ + +# Create a new document +TObjNew TD1 +UndoLimit TD1 10 +TObjAddObj TD1 obj1 +TObjAddObj TD1 obj2 +TObjAddObj TD1 obj3 + +set parent "obj1 obj2 obj2" +set children "ch11 ch21 ch22" +for { set i 0} {$i <= 2} {incr i} { + set p [lindex $parent $i] + set ch [lindex $children $i] + TObjAddChild TD1 $p $ch +} + +TObjSetRef TD1 obj1 obj2 + +TObjSetVal TD1 ch11 200 +TObjSetVal TD1 ch21 110 +TObjSetVal TD1 obj2 -r 3 3.14 2.78 0.123 +OpenCommand TD1 + +TObjSetVal TD1 ch11 150 +TObjSetVal TD1 obj2 -r 3 3.14 2.78 0.150 + +for {set i 1} {$i <=2} {incr i} { + set out [TObjHasModifications TD1 obj$i] + set fields [split $out ":"] + set status [lindex $fields 1] + if {$status != 1} { + puts "Error : status of the modification of the object incorrect" + } + +} + + +TObjClose TD1 +unset TD1 + +