mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0031452: Impossible to get Backup of the attribute and status that attribute was modified before commit transaction
Method TObj_Object::HasModifications() was added to get flag that object or it's children was modified in the current open transaction
This commit is contained in:
parent
7f7d121f90
commit
65da6e2e3e
@ -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() );
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
50
tests/bugs/caf/bug31452
Normal file
50
tests/bugs/caf/bug31452
Normal file
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user