Salome HOME
Make list not initialized if it is empty: on sketch add and then remove element sketc...
authormpv <mpv@opencascade.com>
Mon, 13 Apr 2015 08:24:19 +0000 (11:24 +0300)
committermpv <mpv@opencascade.com>
Mon, 13 Apr 2015 08:24:19 +0000 (11:24 +0300)
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_AttributeSelectionList.h
src/ModelAPI/ModelAPI_Attribute.h

index 13233fb9c4e0128becbf03d324014051ceb4539e..b1fcda04632516822a6a4ae3c9abdbd4d95320dd 100644 (file)
@@ -54,6 +54,14 @@ int Model_AttributeRefList::size() const
   return myRef->Extent();
 }
 
+bool Model_AttributeRefList::isInitialized()
+{
+  if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
+    return false;
+  }
+  return ModelAPI_AttributeRefList::isInitialized();
+}
+
 list<ObjectPtr> Model_AttributeRefList::list()
 {
   std::list<ObjectPtr> aResult;
index 2a4550a80bfd376c3437b5c5aaadfc2e82967863..f59229a1a697f73b231f78e6de162ad8b4a7a334 100644 (file)
@@ -37,6 +37,8 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList
   /// Returns the list of features
   MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const;
 
+  /// Returns true if attribute was  initialized by some value
+  MODEL_EXPORT virtual bool isInitialized();
  protected:
   /// Objects are created for features automatically
   MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel);
index 79eb5c714e12ee2e5565c209dfb271f3d793b389..3b67df9eb0a9063e23a7874fde696432fdaa9857 100644 (file)
@@ -102,6 +102,14 @@ void Model_AttributeSelectionList::clear()
   }
 }
 
+bool Model_AttributeSelectionList::isInitialized()
+{
+  if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
+    return false;
+  }
+  return ModelAPI_AttributeSelectionList::isInitialized();
+}
+
 Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel)
 {
   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True;
index 584c170e9c7cb10d5c0b255ba34b691a511968b0..5865b8562b6d447cd1828856194ccf6cdf7ea183 100644 (file)
@@ -50,6 +50,9 @@ public:
   /// Returns all attributes
   MODEL_EXPORT virtual void clear();
 
+  /// Returns true if attribute was  initialized by some value
+  MODEL_EXPORT virtual bool isInitialized();
+
 protected:
   /// Objects are created for features automatically
   MODEL_EXPORT Model_AttributeSelectionList(TDF_Label& theLabel);
index e3b1b056df9514052fe2bfebd6f256c5320b56e9..442e4e4a05065fa93dedaecb8721c5959a362232 100644 (file)
@@ -44,7 +44,7 @@ class ModelAPI_Attribute
   MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& owner() const;
 
   /// Returns true if attribute was  initialized by some value
-  MODELAPI_EXPORT bool isInitialized();
+  MODELAPI_EXPORT virtual bool isInitialized();
 
   /// Makes attribute initialized
   MODELAPI_EXPORT void setInitialized();