Salome HOME
Improve coverage for ModelAPI and Config packages
authormpv <mpv@opencascade.com>
Wed, 12 Dec 2018 14:18:21 +0000 (17:18 +0300)
committermpv <mpv@opencascade.com>
Wed, 12 Dec 2018 14:18:21 +0000 (17:18 +0300)
15 files changed:
src/Config/Config_PointerMessage.cpp
src/Config/Config_Translator.cpp
src/Model/Model_Application.cpp
src/Model/Model_Application.h
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/Model/Model_Document.cpp
src/Model/Model_ResultField.cpp
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_Events.cpp
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_ResultBody.cpp
src/ModelAPI/ModelAPI_Tools.cpp

index 3c840787646a6e7a45aa3b291672f6e01f99efac..28bd58bd42af404652aabf6c08fd12d798dc15ac 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <Config_PointerMessage.h>
 
+// LCOV_EXCL_START
 Config_PointerMessage::Config_PointerMessage(const Events_ID theId, const void* theParent)
     : Events_Message(theId, theParent),
       myPointer(0)
@@ -41,3 +42,4 @@ void Config_PointerMessage::setPointer(void* pointer)
 {
   myPointer = pointer;
 }
+// LCOV_EXCL_STOP
index 5edd8d3dd6e3aa432566b54738b7d961f87154d2..f215213e1b040b5cdb68464ea58b47bb304d7f15 100644 (file)
@@ -29,6 +29,7 @@
 #pragma warning(disable : 4996) // for sprintf
 #endif
 
+// LCOV_EXCL_START
 /**
  * \class Config_TSReader
  * \ingroup Config
@@ -76,6 +77,7 @@ void Config_TSReader::processNode(xmlNodePtr theNode)
       myTranslator[aName][aSource] = aTranslat;
   }
 }
+// LCOV_EXCL_STOP
 
 //******************************************************************************
 //******************************************************************************
index a5688b66e5e7f1150ec8bec91434ae16c32cc82c..6248cf0693609171b441425626aea4338ecb24a5 100644 (file)
@@ -143,26 +143,6 @@ bool Model_Application::isLoadByDemand(std::string theID, const int theDocIndex)
 }
 
 //=======================================================================
-void Model_Application::removeUselessDocuments(
-  std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs)
-{
-  std::map<int, std::shared_ptr<Model_Document> >::iterator aDoc = myDocs.begin();
-  while(aDoc != myDocs.end()) {
-    bool aFound = false;
-    std::list<std::shared_ptr<ModelAPI_Document> >::iterator aUsed = theUsedDocs.begin();
-    for(; !aFound && aUsed != theUsedDocs.end(); aUsed++) {
-      aFound = aDoc->second == *aUsed;
-    }
-    if (!aFound) { // remove the useless
-      aDoc->second->close();
-      myDocs.erase(aDoc);
-      aDoc = myDocs.begin();
-    } else {
-      aDoc++;
-    }
-  }
-}
-
 int Model_Application::generateDocumentId()
 {
   int aResult;
index b91f69a81f98d1c2ed73dcfab282c502c9bd207f..a4e3c5475ade669d260e58de146312ff30a88def 100644 (file)
@@ -77,9 +77,6 @@ public:
   void setLoadByDemand(std::string theID, const int theDocID);
   //! Returns true if specified document must be loaded by demand
   bool isLoadByDemand(std::string theID, const int theDocIndex);
-  //! Closes and removes the documents that are not loaded by demand and
-  //! not in the given list
-  void removeUselessDocuments(std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs);
 
   //! produces new unique identifier of the document
   int generateDocumentId();
index e6564b60a7a2d12dc5ef11e4781758e4bbc30aa7..4dca9ad93a1e1fb4c938d73217028191b01f362e 100644 (file)
@@ -251,38 +251,6 @@ void Model_AttributeRefList::substitute(const ObjectPtr& theCurrent, const Objec
   }
 }
 
-void Model_AttributeRefList::exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2)
-{
-  std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
-      owner()->document());
-  if (aDoc) {
-    std::shared_ptr<Model_Data> aData1 = std::dynamic_pointer_cast<Model_Data>(theObject1->data());
-    if (aData1.get() && aData1->isValid()) {
-      TDF_Label aLab1 = aData1->label().Father();
-      if (theObject2.get() && theObject2->data()->isValid()) { // the new may be null
-        std::shared_ptr<Model_Data> aData2 =
-          std::dynamic_pointer_cast<Model_Data>(theObject2->data());
-        if (aData2.get() && aData2->isValid()) {
-          eraseHash();
-          TDF_Label aLab2 = aData2->label().Father();
-          // do the substitution: use the temporary label, as usually in exchange
-          TDF_Label aTmpLab = aLab1.Root();
-          if (myRef->InsertAfter(aTmpLab, aLab1)) {
-            myRef->Remove(aLab1);
-          }
-          if (myRef->InsertAfter(aLab1, aLab2)) {
-            myRef->Remove(aLab2);
-          }
-          if (myRef->InsertAfter(aLab2, aTmpLab)) {
-            myRef->Remove(aTmpLab);
-          }
-          owner()->data()->sendAttributeUpdated(this);
-        }
-      }
-    }
-  }
-}
-
 void Model_AttributeRefList::removeLast()
 {
   std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
index da674ff49f2b4a9d0c76693518ba9241574d2112..9780013ef40159a4b45cdb38a1bf161afab3dd97 100644 (file)
@@ -75,10 +75,6 @@ public:
   /// Does not support the external documents objects yet.
   MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
 
-  /// Substitutes the object by another one and back. So, features will become exchanged in the list
-  /// Does not support the external documents objects yet.
-  MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
-
   /// Removes the last element in the list.
   /// Does not support the external documents objects yet.
   MODEL_EXPORT virtual void removeLast();
index 6ba5fd91083871e1491d79a6bcb0b1373d330aab..6b8eaffd04a09c33e741d1d5b4e5f588ec039921 100755 (executable)
@@ -144,6 +144,7 @@ bool Model_Document::isRoot() const
   return this == Model_Session::get()->moduleDocument().get();
 }
 
+// LCOV_EXCL_START
 /// Makes all modification and generation naming shapes that have old shapes corresponding to
 /// shapes in a root document be equal to this root document
 static void updateShapesFromRoot(const TDF_Label theThisAccess, const TDF_Label theRootAccess)
@@ -219,6 +220,7 @@ static void updateShapesFromRoot(const TDF_Label theThisAccess, const TDF_Label
     }
   }
 }
+// LCOV_EXCL_STOP
 
 bool Model_Document::load(const char* theDirName, const char* theFileName, DocumentPtr theThis)
 {
@@ -238,6 +240,7 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum
   }
   bool isError = aStatus != PCDM_RS_OK;
   if (isError) {
+    // LCOV_EXCL_START
     switch (aStatus) {
       case PCDM_RS_UnknownDocument:
         Events_InfoMessage("Model_Document", "Can not open document").send();
@@ -292,6 +295,7 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum
         Events_InfoMessage("Model_Document", "Can not open document: unknown error").send();
         break;
     }
+    // LCOV_EXCL_STOP
   }
   std::shared_ptr<Model_Session> aSession =
     std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
@@ -949,7 +953,8 @@ void Model_Document::redo()
   // update the current features status
   setCurrentFeature(currentFeature(false), false);
 }
-
+// this is used for creation of undo/redo1-list by GUI
+// LCOV_EXCL_START
 std::list<std::string> Model_Document::undoList() const
 {
   std::list<std::string> aResult;
@@ -975,6 +980,7 @@ std::list<std::string> Model_Document::redoList() const
   }
   return aResult;
 }
+// LCOV_EXCL_STOP
 
 void Model_Document::operationId(const std::string& theId)
 {
@@ -1988,6 +1994,8 @@ bool Model_Document::isLater(FeaturePtr theLater, FeaturePtr theCurrent) const
   return myObjs->isLater(theLater, theCurrent);
 }
 
+// Object Browser nodes states
+// LCOV_EXCL_START
 void Model_Document::storeNodesState(const std::list<bool>& theStates)
 {
   TDF_Label aLab = generalLabel().FindChild(TAG_NODES_STATE);
@@ -2013,6 +2021,7 @@ void Model_Document::restoreNodesState(std::list<bool>& theStates) const
     }
   }
 }
+// LCOV_EXCL_STOP
 
 void Model_Document::eraseAllFeatures()
 {
index 40f7aa5a48ce26ca99e6ff8c6dd73ee3189eb488..11498517665be5e9f5da91e0c22ac16a134c10e7 100644 (file)
@@ -43,6 +43,7 @@ Model_ResultField::~Model_ResultField()
   }
 }
 
+// LCOV_EXCL_START
 void Model_ResultField::colorConfigInfo(std::string& theSection, std::string& theName,
                                        std::string& theDefault)
 {
@@ -50,6 +51,7 @@ void Model_ResultField::colorConfigInfo(std::string& theSection, std::string& th
   theName = "result_field_color";
   theDefault = DEFAULT_COLOR();
 }
+// LCOV_EXCL_STOP
 
 std::shared_ptr<GeomAPI_Shape> Model_ResultField::shape()
 {
@@ -140,7 +142,8 @@ std::string Model_ResultField::textLine(int theLine) const
   return "";
 }
 
-
+// used by GUI only
+// LCOV_EXCL_START
 ModelAPI_ResultField::ModelAPI_FieldStep* Model_ResultField::step(int theId) const
 {
   if (theId < mySteps.size()) {
@@ -148,3 +151,4 @@ ModelAPI_ResultField::ModelAPI_FieldStep* Model_ResultField::step(int theId) con
   }
   return NULL;
 }
+// LCOV_EXCL_STOP
index 5e2ccff5f8726e77de59cbef4692acd2857e95ad..4f6828473988d533a271f606d29ca3e1016d3fba 100755 (executable)
@@ -987,6 +987,8 @@ void Model_Update::executeFeature(FeaturePtr theFeature)
   redisplayWithResults(theFeature, aState);
 }
 
+// it is called on GUI edit of feature start
+// LCOV_EXCL_START
 void Model_Update::updateStability(void* theSender)
 {
   static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
@@ -1039,6 +1041,7 @@ void Model_Update::updateStability(void* theSender)
     }
   }
 }
+// LCOV_EXCL_STOP
 
 void Model_Update::updateSelection(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects)
 {
index 27b2427b968674ba6bb44e4afc86a7575db66205..9b326bbe42f9d30de424ea0e6b5034d3703ce0f2 100644 (file)
@@ -69,9 +69,6 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute
   /// Substitutes the object by another one. Does nothing if such object is not found.
   virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0;
 
-  /// Substitutes the object by another one and back. So, features wil become exchanged in the list
-  virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2) = 0;
-
   /// Removes the last element in the list.
   virtual void removeLast() = 0;
 
index 0a425d8c2eb5e67a4e558c2c9759ce6667633009..8ed07b5fb232ca6e342ae2b727c3c52c5666e377 100644 (file)
 ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
                                                              const void* theSender)
     : Events_MessageGroup(theID, theSender)
-{
-
-}
+{}
 
 ModelAPI_ObjectUpdatedMessage::~ModelAPI_ObjectUpdatedMessage()
-{
-
-}
+{}
 
 ModelAPI_ObjectDeletedMessage::ModelAPI_ObjectDeletedMessage(const Events_ID theID,
                                                              const void* theSender)
     : Events_MessageGroup(theID, theSender)
-{
-
-}
+{}
 
 ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
-{
-
-}
+{}
 
 ModelAPI_OrderUpdatedMessage::ModelAPI_OrderUpdatedMessage(const Events_ID theID,
                                                            const void* theSender)
     : Events_Message(theID, theSender)
-{
-
-}
+{}
 
 ModelAPI_OrderUpdatedMessage::~ModelAPI_OrderUpdatedMessage()
-{
-
-}
+{}
 
+// used by GUI only
+// LCOV_EXCL_START
 ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
                                                            const void* theSender)
  : Events_Message(theID, theSender)
@@ -72,9 +62,7 @@ ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID
 }
 
 ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
-{
-
-}
+{}
 
 std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
 {
@@ -113,7 +101,7 @@ std::list<std::string> ModelAPI_FeatureStateMessage::features() const
   }
   return result;
 }
-
+// LCOV_EXCL_STOP
 
 ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(
   const Events_ID theID, const void* theSender)
@@ -240,14 +228,10 @@ const std::list<std::pair<int, int> >& ModelAPI_ComputePositionsMessage::positio
 ModelAPI_ObjectRenamedMessage::ModelAPI_ObjectRenamedMessage(const Events_ID theID,
                                                              const void* theSender)
 : Events_Message(theID, theSender)
-{
-
-}
+{}
 
 ModelAPI_ObjectRenamedMessage::~ModelAPI_ObjectRenamedMessage()
-{
-
-}
+{}
 
 void ModelAPI_ObjectRenamedMessage::send(ObjectPtr theObject,
                                          const std::string& theOldName,
@@ -295,14 +279,10 @@ void ModelAPI_ObjectRenamedMessage::setNewName(const std::string& theNewName)
 ModelAPI_ReplaceParameterMessage::ModelAPI_ReplaceParameterMessage(const Events_ID theID,
                                                                    const void* theSender)
 : Events_Message(theID, theSender)
-{
-
-}
+{}
 
 ModelAPI_ReplaceParameterMessage::~ModelAPI_ReplaceParameterMessage()
-{
-
-}
+{}
 
 void ModelAPI_ReplaceParameterMessage::send(ObjectPtr theObject,
                                             const void* theSender)
@@ -329,12 +309,10 @@ ModelAPI_SolverFailedMessage::ModelAPI_SolverFailedMessage(const Events_ID theID
                                                            const void* theSender)
   : Events_Message(theID, theSender),
     myDOF(-1)
-{
-}
+{}
 
 ModelAPI_SolverFailedMessage::~ModelAPI_SolverFailedMessage()
-{
-}
+{}
 
 void ModelAPI_SolverFailedMessage::setObjects(const std::set<ObjectPtr>& theObjects)
 {
@@ -350,8 +328,7 @@ const std::set<ObjectPtr>& ModelAPI_SolverFailedMessage::objects() const
 // =====   ModelAPI_ObjectMovedMessage   =====
 ModelAPI_ObjectMovedMessage::ModelAPI_ObjectMovedMessage(const void* theSender)
   : Events_Message(Events_Loop::eventByName(EVENT_OBJECT_MOVED), theSender)
-{
-}
+{}
 
 void ModelAPI_ObjectMovedMessage::setMovedObject(const ObjectPtr& theMovedObject)
 {
index 5f1e3c989c8f4ae5c3b66be2b54927ac6730fa29..d02bded7f5e95531f393af20adf6282a8a78e47c 100644 (file)
@@ -88,15 +88,6 @@ void ModelAPI_Feature::setResult(const std::shared_ptr<ModelAPI_Result>& theResu
   theResult->setDisabled(theResult, false);
 }
 
-void ModelAPI_Feature::removeResult(const std::shared_ptr<ModelAPI_Result>& theResult)
-{
-  theResult->setDisabled(theResult, true);
-  // flush visualization changes
-  static Events_Loop* aLoop = Events_Loop::loop();
-  static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-  aLoop->flush(aRedispEvent);
-}
-
 void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr<ModelAPI_Result>& theResult)
 {
   std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = myResults.begin();
@@ -234,6 +225,7 @@ bool ModelAPI_Feature::isDisabled()
   return myIsDisabled;
 }
 
+// LCOV_EXCL_START
 bool ModelAPI_Feature::setStable(const bool theFlag)
 {
   if (myIsStable != theFlag) {
@@ -247,6 +239,7 @@ bool ModelAPI_Feature::setStable(const bool theFlag)
   }
   return false;
 }
+// LCOV_EXCL_STOP
 
 bool ModelAPI_Feature::isStable()
 {
index 1e44a2b9e434929e175269311d3a50c5b16c3210..c563765629754ade76911693484eebe2295cb74a 100644 (file)
@@ -97,8 +97,6 @@ class ModelAPI_Feature : public ModelAPI_Object
   /// sets the result by index (zero based), results before this must be set before
   MODELAPI_EXPORT void setResult(const std::shared_ptr<ModelAPI_Result>& theResult,
                                  const int theIndex);
-  /// removes the result from the feature
-  MODELAPI_EXPORT void removeResult(const std::shared_ptr<ModelAPI_Result>& theResult);
   /// removes all results starting from the given index (zero-based)
   /// \param theSinceIndex - index of the deleted result and all after also will be deleted
   /// \param theForever - removes results for long period (not just because of feature disabling)
index 9129f0638ad1a0a4c73fac6b1a859f7221c11764..ab0e703e757950db86317e19fd13e542311f0ac2 100644 (file)
@@ -116,6 +116,7 @@ void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape,
   myBuilder->loadFirstLevel(theShape, theName);
 }
 
+// LCOV_EXCL_START
 bool ModelAPI_ResultBody::isConnectedTopology()
 {
   if (myConnect == ConnectionNotComputed) {
@@ -130,3 +131,4 @@ void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
   for (int i = 0; i < numberOfSubs(); i++)
     subResult(i)->setDisplayed(theDisplay);
 }
+// LCOV_EXCL_STOP
index 0b58e55968c5d69d71cc1a0fce20c0fa16016fdc..9dc5e4e9a36fb8d4aa85676609251888532662c6 100755 (executable)
@@ -119,6 +119,7 @@ const char* toString(ModelAPI_ExecState theExecState)
   }
 }
 
+// LCOV_EXCL_START
 std::string getFeatureError(const FeaturePtr& theFeature)
 {
   std::string anError;
@@ -159,6 +160,7 @@ std::string getFeatureError(const FeaturePtr& theFeature)
 
   return anError;
 }
+// LCOV_EXCL_STOP
 
 ObjectPtr objectByName(const DocumentPtr& theDocument, const std::string& theGroup,
                        const std::string& theName)