]> OCCT Git - occt-copy.git/commitdiff
0031452: Impossible to get Backup of the attribute and status that attribute was...
authorgka <gka@opencascade.com>
Mon, 14 Sep 2020 18:46:11 +0000 (21:46 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 18 Sep 2020 14:46:50 +0000 (17:46 +0300)
Method TObj_Object::HasModifications() was added to get flag that object or it's children was modified in the current open transaction

src/TObj/TObj_Object.cxx
src/TObj/TObj_Object.hxx
src/TObjDRAW/TObjDRAW.cxx
tests/bugs/caf/bug31452 [new file with mode: 0644]

index a15951d4b9cc590ac466293de847b99f90fe80e8..afdd460b0f1e294ec9c59c9542f0b1e303a0198f 100644 (file)
@@ -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
index 8afecf0a46902236b7622866d2ad34c52e491016..ab5d31935d28dc1f67a9ea0c5a5761f31271ae44 100644 (file)
@@ -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
index 30ceb8b25d554ea3e8f7f96d4d371bd21921a12e..9c6482ba432b6349effba9eb5f9fe3c0c1005fe0 100644 (file)
@@ -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 (file)
index 0000000..f53fb81
--- /dev/null
@@ -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                                                          
+
+