From: mpv Date: Wed, 12 Dec 2018 09:11:57 +0000 (+0300) Subject: Improve Model package coverage: remove unused methods, open/save tests improvements X-Git-Tag: End2018~74 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=87bb3bb183012fd6ad662c785e575fff56897905;p=modules%2Fshaper.git Improve Model package coverage: remove unused methods, open/save tests improvements --- diff --git a/lcov_reports.sh b/lcov_reports.sh index 0fc2f13f8..5474115e4 100755 --- a/lcov_reports.sh +++ b/lcov_reports.sh @@ -53,7 +53,7 @@ cp -f covfile covElse NEED='BuildPlugin CollectionPlugin Config ConstructionPlugin Events ExchangePlugin FeaturesPlugin GDMLPlugin GeomData GeomDataAPLI GeomValidators InitializationPlugin Model_ ModelAPI ModelGeomAlgo ParametersPlugin PartSetPlugin PrimitivesPlugin Selector SketchPlugin SketchSolver' for MASK in $ALL; do if ! [[ " $NEED " =~ " $MASK " ]]; then - lcov -r covElse *${MASK}API* --output-file covElse_res -q + lcov -r covElse *${MASK}* --output-file covElse_res -q mv -f covElse_res covElse fi done diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index b8b864acc..c40bffec0 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -201,13 +201,6 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) aSelectionList->setSelectionType(aSelectionType); for (int anElementIndex = 0; anElementIndex < aXaoGroup->count(); ++anElementIndex) { aSelectionList->append(aResultBody, GeomShapePtr()); - // complex conversion of element index to reference id - int anElementID = aXaoGroup->get(anElementIndex); - std::string aReferenceString = - aXaoGeometry->getElementReference(aXaoGroup->getDimension(), anElementID); - int aReferenceID = XAO::XaoUtils::stringToInt(aReferenceString); - - aSelectionList->value(anElementIndex)->setId(aReferenceID); } } // Create new fields diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 1db965d23..e088c9a44 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -1020,76 +1020,6 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, } } -int Model_AttributeSelection::Id() -{ - int anID = 0; - std::shared_ptr aSelection = value(); - ResultPtr aContextRes = context(); - // support for compsolids: - while(ModelAPI_Tools::bodyOwner(aContextRes).get()) { - aContextRes = ModelAPI_Tools::bodyOwner(aContextRes); - } - std::shared_ptr aContext = aContextRes->shape(); - - - TopoDS_Shape aMainShape = aContext->impl(); - const TopoDS_Shape& aSubShape = aSelection->impl(); - // searching for the latest main shape - if (aSelection && !aSelection->isNull() && aContext && !aContext->isNull()) - { - std::shared_ptr aDoc = - std::dynamic_pointer_cast(context()->document()); - if (aDoc.get()) { - Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aMainShape, aDoc->generalLabel()); - if (!aNS.IsNull()) { - aMainShape = TNaming_Tool::CurrentShape(aNS); - } - } - - TopTools_IndexedMapOfShape aSubShapesMap; - TopExp::MapShapes(aMainShape, aSubShapesMap); - anID = aSubShapesMap.FindIndex(aSubShape); - } - return anID; -} - -void Model_AttributeSelection::setId(int theID) -{ - std::shared_ptr aSelection; - - ResultPtr aContextRes = context(); - // support for compsolids: - while(ModelAPI_Tools::bodyOwner(aContextRes).get()) { - aContextRes = ModelAPI_Tools::bodyOwner(aContextRes); - } - std::shared_ptr aContext = aContextRes->shape(); - - TopoDS_Shape aMainShape = aContext->impl(); - // searching for the latest main shape - if (theID > 0 && aContext && !aContext->isNull()) - { - std::shared_ptr aDoc = - std::dynamic_pointer_cast(aContextRes->document()); - if (aDoc.get()) { - Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aMainShape, aDoc->generalLabel()); - if (!aNS.IsNull()) { - aMainShape = TNaming_Tool::CurrentShape(aNS); - } - } - - TopTools_IndexedMapOfShape aSubShapesMap; - TopExp::MapShapes(aMainShape, aSubShapesMap); - const TopoDS_Shape& aSelShape = aSubShapesMap.FindKey(theID); - - std::shared_ptr aResult(new GeomAPI_Shape); - aResult->setImpl(new TopoDS_Shape(aSelShape)); - - aSelection = aResult; - } - - setValue(aContextRes, aSelection); -} - std::string Model_AttributeSelection::contextName(const ResultPtr& theContext) const { std::string aResult; diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 9512a3a73..6c8d66d73 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -100,16 +100,6 @@ public: /// \param theDefaultValue a name, which is returned if the naming name can not be obtained MODEL_EXPORT virtual std::string namingName(const std::string& theDefaultValue = ""); - /// Returns an Id of the selection - /// NOTE: This method has been added for temporary export of groups towards old GEOM - /// It should then be removed when a direct use of objects from SHAPER - /// will be possible from SMESH module of SALOME. - MODEL_EXPORT virtual int Id(); - - /// Defines the sub-shape by Id - /// NOTE: This method is opposite to Id() method. - MODEL_EXPORT virtual void setId(int theID); - /// Selects (i.e. creates Naming data structure) of sub-shape specified by textual name MODEL_EXPORT virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName); diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index bfc463057..cd3cf88cc 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -96,15 +96,6 @@ void Model_Data::setLabel(TDF_Label theLab) myFlags->SetValue(kFlagInHistory, Standard_True); // is in history by default is true myFlags->SetValue(kFlagDisplayed, Standard_True); // is displayed by default is true myFlags->SetValue(kFlagDeleted, Standard_False); // is deleted by default is false - } else if (myFlags->Length() != 3) { // for old formats support - Standard_Boolean aFlag0 = myFlags->Upper() >= 0 ? myFlags->Value(0) : Standard_True; - Standard_Boolean aFlag1 = myFlags->Upper() >= 1 ? myFlags->Value(1) : Standard_True; - Standard_Boolean aFlag2 = myFlags->Upper() >= 2 ? myFlags->Value(2) : Standard_True; - Handle(TColStd_HArray1OfByte) aNewArray = new TColStd_HArray1OfByte(0, 2); - myFlags->SetInternalArray(aNewArray); - myFlags->SetValue(0, aFlag0); - myFlags->SetValue(1, aFlag1); - myFlags->SetValue(2, aFlag2); } } @@ -344,12 +335,6 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) if (myWasChangedButBlocked.empty() || *(myWasChangedButBlocked.rbegin()) != theAttr) myWasChangedButBlocked.push_back(theAttr); } - } else { - // trim: need to redisplay - /*if (myObject) { - static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); - ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); - }*/ } } @@ -417,7 +402,7 @@ enum StatesIndexes { STATE_INDEX_TRANSACTION = 2, // transaction ID }; -/// Returns the label array, initialises it by default values if not exists +/// Returns the label array, initializes it by default values if not exists static Handle(TDataStd_IntegerArray) stateArray(TDF_Label& theLab) { Handle(TDataStd_IntegerArray) aStateArray; @@ -481,15 +466,6 @@ int Model_Data::featureId() const return myLab.Father().Tag(); // tag of the feature label } -void Model_Data::eraseBackReferences() -{ - myRefsToMe.clear(); - std::shared_ptr aRes = std::dynamic_pointer_cast(myObject); - if (aRes) { - aRes->setIsConcealed(false); - } -} - void Model_Data::removeBackReference(ObjectPtr theObject, std::string theAttrID) { AttributePtr anAttribute = theObject->data()->attribute(theAttrID); @@ -503,7 +479,7 @@ void Model_Data::removeBackReference(AttributePtr theAttr) myRefsToMe.erase(theAttr); - // remove concealment immideately: on deselection it must be posible to reselect in GUI the same + // remove concealment immediately: on deselection it must be possible to reselect in GUI the same FeaturePtr aFeatureOwner = std::dynamic_pointer_cast(theAttr->owner()); if (aFeatureOwner.get() && ModelAPI_Session::get()->validators()->isConcealed(aFeatureOwner->getKind(), theAttr->id())) { @@ -741,7 +717,7 @@ void Model_Data::copyTo(std::shared_ptr theTarget) // reinitialize Model_Attributes by TDF_Attributes set std::shared_ptr aTData = std::dynamic_pointer_cast(theTarget); aTData->myAttrs.clear(); - theTarget->owner()->initAttributes(); // reinit feature attributes + theTarget->owner()->initAttributes(); // reinitialize feature attributes } bool Model_Data::isInHistory() diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 2ed26625f..b4cc048a7 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -168,7 +168,7 @@ class Model_Data : public ModelAPI_Data MODEL_EXPORT virtual const std::string& id(const std::shared_ptr& theAttr); /// Returns true if data belongs to same features MODEL_EXPORT virtual bool isEqual(const std::shared_ptr& theData); - /// Returns true if it is correctly connected t othe data model + /// Returns true if it is correctly connected to the data model MODEL_EXPORT virtual bool isValid(); /// Returns the label where the shape must be stored (used in ResultBody) @@ -236,10 +236,10 @@ class Model_Data : public ModelAPI_Data MODEL_EXPORT virtual void referencesToObjects( std::list > >& theRefs); - /// Copies all atributes content into theTarget data + /// Copies all attributes content into theTarget data MODEL_EXPORT virtual void copyTo(std::shared_ptr theTarget); - /// Returns the invalid data pointer (to avoid working with NULL shared ptrs in swig) + /// Returns the invalid data pointer (to avoid working with NULL shared pointers in swig) MODEL_EXPORT virtual std::shared_ptr invalidPtr(); /// Returns the invalid data pointer: static method @@ -263,15 +263,13 @@ protected: /// Defines the custom "is in history" behavior MODEL_EXPORT virtual void setIsInHistory(const bool theFlag); - /// Returns true if the object is deleted, but some data is still keept in memory + /// Returns true if the object is deleted, but some data is still kept in memory MODEL_EXPORT virtual bool isDeleted(); - /// Sets true if the object is deleted, but some data is still keept in memory + /// Sets true if the object is deleted, but some data is still kept in memory MODEL_EXPORT virtual void setIsDeleted(const bool theFlag); private: - /// Removes all information about back references - void eraseBackReferences(); /// Removes a back reference (with identifier which attribute references to this object) /// \param theFeature feature referenced to this /// \param theAttrID identifier of the attribute that is references from theFeature to this @@ -282,7 +280,7 @@ private: /// Adds a back reference (with identifier which attribute references to this object /// \param theFeature feature referenced to this /// \param theAttrID identifier of the attribute that is references from theFeature to this - /// \param theApplyConcealment applies consealment flag changes + /// \param theApplyConcealment applies concealment flag changes void addBackReference(FeaturePtr theFeature, std::string theAttrID, const bool theApplyConcealment = true); /// Adds a back reference to an object @@ -295,7 +293,7 @@ private: /// Returns true if object must be displayed in the viewer: flag is stored in the /// data model, so on undo/redo, open/save or recreation of object by history-playing it keeps - /// the original state i nthe current transaction. + /// the original state in the current transaction. MODEL_EXPORT virtual bool isDisplayed(); /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay" diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 99a624ae0..6ba5fd910 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -1435,16 +1434,6 @@ std::shared_ptr Model_Document::feature( return myObjs->feature(theResult); } -Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper) -{ - return TDF_LabelMapHasher::HashCode(theLab, theUpper); - -} -Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2) -{ - return TDF_LabelMapHasher::IsEqual(theLab1, theLab2); -} - FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) { TDF_Label aCurrentLab = theLab; while(aCurrentLab.Depth() > 3) @@ -1759,11 +1748,6 @@ void Model_Document::incrementTransactionID() int aNewVal = transactionID() + 1; TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal); } -void Model_Document::decrementTransactionID() -{ - int aNewVal = transactionID() - 1; - TDataStd_Integer::Set(generalLabel().FindChild(TAG_CURRENT_TRANSACTION), aNewVal); -} TDF_Label Model_Document::extConstructionsLabel() const { @@ -1785,11 +1769,6 @@ std::shared_ptr Model_Document::internalFeature(const int theI return myObjs->internalFeature(theIndex); } -std::shared_ptr Model_Document::featureById(const int theId) -{ - return myObjs->featureById(theId); -} - void Model_Document::synchronizeTransactions() { Model_Document* aRoot = diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index f4c6233d1..45b0923ad 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -180,10 +180,6 @@ class Model_Document : public ModelAPI_Document //! without this participation MODEL_EXPORT virtual void synchronizeTransactions(); - //! Returns feature by the id of the feature (produced by the Data "featureId" method) - MODEL_EXPORT virtual std::shared_ptr featureById(const int theId); - - /// Creates construction results MODEL_EXPORT virtual std::shared_ptr createConstruction( const std::shared_ptr& theFeatureData, const int theIndex = 0); @@ -285,8 +281,6 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual int transactionID(); /// Increases the transaction ID MODEL_EXPORT virtual void incrementTransactionID(); - /// Decreases the transaction ID - MODEL_EXPORT virtual void decrementTransactionID(); /// Returns true if document is opened and valid MODEL_EXPORT virtual bool isOpened(); diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index d7ecf7187..0d6479c3f 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -798,15 +798,6 @@ void Model_Objects::initData(ObjectPtr theObj, TDF_Label theLab, const int theTa theObj->initAttributes(); } -std::shared_ptr Model_Objects::featureById(const int theId) -{ - if (theId > 0) { - TDF_Label aLab = featuresLabel().FindChild(theId, Standard_False); - return feature(aLab); - } - return std::shared_ptr(); // not found -} - void Model_Objects::synchronizeFeatures( const TDF_LabelList& theUpdated, const bool theUpdateReferences, const bool theExecuteFeatures, const bool theOpen, const bool theFlush) diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index 26e6e6d19..64afceda8 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -124,10 +124,6 @@ class Model_Objects //! Returns the feature by zero-based index: features in the history or not std::shared_ptr internalFeature(const int theIndex); - //! Returns feature by the id of the feature (produced by the Data "featureId" method) - std::shared_ptr featureById(const int theId); - - /// Creates a construction result std::shared_ptr createConstruction( const std::shared_ptr& theFeatureData, const int theIndex = 0); diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index dbad51c7b..3c53dc54e 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -56,7 +56,7 @@ void Model_ResultPart::initAttributes() data()->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId()); - if (aDocRef->isInitialized() && // initialized immideately means already exist and will be loaded + if (aDocRef->isInitialized() && // initialized immediately means already exist and will be loaded !Model_Application::getApplication()->hasDocument(aDocRef->docId())) Model_Application::getApplication()->setLoadByDemand(data()->name(), aDocRef->docId()); } @@ -139,7 +139,7 @@ bool Model_ResultPart::setDisabled(std::shared_ptr theThis, if (!myTrsf.get()) { // disable of base result part DocumentPtr aDoc = Model_ResultPart::partDoc(); if (aDoc.get() && aDoc->isOpened()) { - // make the current feature the last in any case: to update shapes defore deactivation too + // make the current feature the last in any case: to update shapes before deactivation too int aSize = aDoc->size(ModelAPI_Feature::group()); FeaturePtr aLastFeature; if (aSize) @@ -170,7 +170,7 @@ std::shared_ptr Model_ResultPart::shape() std::shared_ptr aResult(new GeomAPI_Shape); if (myShape.IsNull()) { // shape is not produced yet, create it SessionPtr aMgr = ModelAPI_Session::get(); - bool aToSendUpdate = aMgr->isOperation(); // inside of operation may send an update evnet + bool aToSendUpdate = aMgr->isOperation(); // inside of operation may send an update event if (myTrsf.get()) { // get shape of the base result and apply the transformation ResultPtr anOrigResult = baseRef(); std::shared_ptr anOrigShape = anOrigResult->shape(); diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 22b949c54..55fc4a99f 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -232,5 +232,6 @@ ADD_UNIT_TESTS(TestConstants.py TestGeomNamingSketchPlane.py TestGeomNamingBoxWithFillet.py TestContainerSelector.py - TestSaveOpen.py + TestSaveOpen1.py + TestSaveOpen2.py ) diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index db3acb539..179037e02 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -182,8 +182,8 @@ template std::shared_ptr shared_ptr_cast(std::shared_ptr %template(modelAPI_ResultBody) shared_ptr_cast; %template(modelAPI_ResultPart) shared_ptr_cast; %template(modelAPI_ResultParameter) shared_ptr_cast; -%template(modelAPI_ResultGroup) shared_ptr_cast; -%template(modelAPI_ResultField) shared_ptr_cast; +%template(modelAPI_ResultGroup) shared_ptr_cast; +%template(modelAPI_ResultField) shared_ptr_cast; // Attribute casts %template(modelAPI_AttributeDocRef) shared_ptr_cast; diff --git a/src/ModelAPI/ModelAPI_AttributeDocRef.h b/src/ModelAPI/ModelAPI_AttributeDocRef.h index 1a9d5abc0..8dc5122ff 100644 --- a/src/ModelAPI/ModelAPI_AttributeDocRef.h +++ b/src/ModelAPI/ModelAPI_AttributeDocRef.h @@ -38,7 +38,7 @@ class ModelAPI_AttributeDocRef : public ModelAPI_Attribute /// Returns document referenced from this attribute MODELAPI_EXPORT virtual std::shared_ptr value() = 0; - /// Returns the persisten ID of the document + /// Returns the persistent ID of the document MODELAPI_EXPORT virtual int docId() = 0; /// Returns the type of this class of attributes diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index d2dec5bc4..a1df51888 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -95,12 +95,6 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// \param theDefaultValue a value, which is used if the naming name can not be obtained virtual std::string namingName(const std::string& theDefaultValue = "") = 0; - /// Returns an id of the selection - virtual int Id() = 0; - - /// Defines an id of the selection - virtual void setId(int theID) = 0; - /// Selects sub-shape by the textual Name virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName) = 0; diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index 2fc8fbfc8..810558e41 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -181,7 +181,7 @@ class MODELAPI_EXPORT ModelAPI_Data /// Copies all attributes content into theTarget data virtual void copyTo(std::shared_ptr theTarget) = 0; - /// Returns the invalid data pointer (to avoid working with NULL shared ptrs in swig) + /// Returns the invalid data pointer (to avoid working with NULL shared pointers in swig) virtual std::shared_ptr invalidPtr() = 0; /// Identifier of the transaction when object (feature or result) was updated last time. @@ -191,13 +191,13 @@ class MODELAPI_EXPORT ModelAPI_Data /// This method is called by the updater. virtual void setUpdateID(const int theID) = 0; - /// Returns the owner of htis data + /// Returns the owner of this data virtual std::shared_ptr owner() = 0; - /// Returns true if the object is deleted, but some data is still keept in memory + /// Returns true if the object is deleted, but some data is still kept in memory virtual bool isDeleted() = 0; - /// Sets true if the object is deleted, but some data is still keept in memory + /// Sets true if the object is deleted, but some data is still kept in memory virtual void setIsDeleted(const bool theFlag) = 0; /// Returns \c true if theAttribute1 is going earlier than theAttribute2 in the data @@ -216,7 +216,7 @@ class MODELAPI_EXPORT ModelAPI_Data /// Returns true if object must be displayed in the viewer: flag is stored in the /// data model, so on undo/redo, open/save or recreation of object by history-playing it keeps - /// the original state i nthe current transaction. + /// the original state in the current transaction. virtual bool isDisplayed() = 0; /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay" diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index be23056ae..b49803013 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -46,8 +46,8 @@ class GeomAPI_Shape; /**\class ModelAPI_Document * \ingroup DataModel * \brief Document for internal data structure of any object storage. - * Document contains all data that must be stored/retrived in the file. - * Also it provides acces to this data: open/save, transactions management etc. + * Document contains all data that must be stored/retrieved in the file. + * Also it provides access to this data: open/save, transactions management etc. */ class ModelAPI_Document: public ModelAPI_Entity { @@ -58,7 +58,7 @@ public: virtual const std::string& kind() const = 0; //! Removes document data - //! \param theForever if it is false, document is just hiden + //! \param theForever if it is false, document is just hidden //! (to keep possibility make it back on Undo/Redo) virtual void close(const bool theForever = false) = 0; @@ -128,7 +128,7 @@ public: //! Sets the current feature: all features below will be disabled, new features //! will be appended after this one. This method does not flushes the events appeared: //! it will be done by the finishOperation, or direct flushes - //! \param theCurrent the selected feature as current: blow it everythin become disabled + //! \param theCurrent the selected feature as current: blow it everything become disabled //! \param theVisible use visible features only: flag is true for Object Browser functionality virtual void setCurrentFeature(std::shared_ptr theCurrent, const bool theVisible) = 0; @@ -141,13 +141,10 @@ public: virtual std::shared_ptr internalFeature(const int theIndex) = 0; //! Performs synchronization of transactions with the module document: //! If some document is not active (by undo of activation) but in memory, - //! on activation the transactions must be synchronised because all redos performed - //! wihtout this participation + //! on activation the transactions must be synchronized because all redo-s performed + //! without this participation virtual void synchronizeTransactions() = 0; - //! Returns feature by the id of the feature (produced by the Data "featureId" method) - virtual std::shared_ptr featureById(const int theId) = 0; - //! To virtually destroy the fields of successors MODELAPI_EXPORT virtual ~ModelAPI_Document(); @@ -204,7 +201,7 @@ public: virtual std::shared_ptr findFolderBelow( const std::list >& theFeatures) = 0; //! Search a folder containing the given feature. - //! Addtionally calculates a zero-based index of the feature in this folder. + //! Additionally calculates a zero-based index of the feature in this folder. //! \param theFeature feature to search //! \param theIndexInFolder zero-based index in the folder or -1 if the feature is top-level. //! \return the folder containing the feature or empty pointer if the feature is top-level. @@ -213,7 +210,7 @@ public: int& theIndexInFolder) = 0; //! Add a list of features to the folder. The correctness of the adding is not performed //! (such checks have been done in corresponding find.. method). - //! \return \c true if the movement is successfull + //! \return \c true if the movement is successful virtual bool moveToFolder(const std::list >& theFeatures, const std::shared_ptr& theFolder) = 0; //! Remove features from the folder @@ -250,7 +247,7 @@ public: /// Normally is called outside of the transaction, just before "save". MODELAPI_EXPORT virtual void storeNodesState(const std::list& theStates) = 0; - /// Returns the stored nodes states. Normally it is calles just after "open". + /// Returns the stored nodes states. Normally it is calls just after "open". /// Appends the values to theStates list. MODELAPI_EXPORT virtual void restoreNodesState(std::list& theStates) const = 0; diff --git a/src/ModelAPI/ModelAPI_ResultBody.cpp b/src/ModelAPI/ModelAPI_ResultBody.cpp index 22284d1ee..9129f0638 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.cpp +++ b/src/ModelAPI/ModelAPI_ResultBody.cpp @@ -87,12 +87,6 @@ GeomShapePtr ModelAPI_ResultBody::shape() return myBuilder->shape(); } -bool ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape, - const std::string& theName, const bool theCheckIsInResult) -{ - return myBuilder->generated(theNewShape, theName, theCheckIsInResult); -} - void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape, const GeomShapePtr& theNewShape, const std::string& theName) @@ -116,22 +110,6 @@ void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude); } -void ModelAPI_ResultBody::loadModifiedShapes(const GeomMakeShapePtr& theAlgo, - const GeomShapePtr& theOldShape, - const GeomAPI_Shape::ShapeType theShapeTypeToExplore, - const std::string& theName) -{ - myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); -} - -void ModelAPI_ResultBody::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, - const GeomShapePtr& theOldShape, - const GeomAPI_Shape::ShapeType theShapeTypeToExplore, - const std::string& theName) -{ - myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); -} - void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape, const std::string& theName) { diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 1ad95f5d1..c41854f9d 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -114,7 +114,7 @@ public: /// As an example, consider the case of a face generated in construction of a box. /// Returns true if it is stored correctly (the final shape contains this new sub-shape) MODELAPI_EXPORT virtual bool generated(const GeomShapePtr& theNewShape, - const std::string& theName, const bool theCheckIsInResult = true); + const std::string& theName, const bool theCheckIsInResult = true) = 0; /// Records the shape newShape which was generated from the shape oldShape during a topological /// construction. As an example, consider the case of a face generated from an edge in @@ -141,14 +141,14 @@ public: virtual void loadModifiedShapes(const std::shared_ptr& theAlgo, const GeomShapePtr& theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, - const std::string& theName = ""); + const std::string& theName = "") = 0; /// load and orient generated shapes MODELAPI_EXPORT virtual void loadGeneratedShapes(const std::shared_ptr& theAlgo, const GeomShapePtr& theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, - const std::string& theName = ""); + const std::string& theName = "") = 0; /// load shapes of the first level (to be used during shape import) MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, diff --git a/src/ModelAPI/Test/TestSaveOpen.py b/src/ModelAPI/Test/TestSaveOpen.py deleted file mode 100644 index 5bc57a292..000000000 --- a/src/ModelAPI/Test/TestSaveOpen.py +++ /dev/null @@ -1,50 +0,0 @@ -## Copyright (C) 2014-2017 CEA/DEN, EDF R&D -## -## This library is free software; you can redistribute it and/or -## modify it under the terms of the GNU Lesser General Public -## License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## -## This library is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. -## -## You should have received a copy of the GNU Lesser General Public -## License along with this library; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -## -## See http:##www.salome-platform.org/ or -## email : webmaster.salome@opencascade.com -## - -# -*- coding: utf-8 -*- - -from salome.shaper import model -from ModelAPI import * - -model.begin() -partSet = model.moduleDocument() -Point_2 = model.addPoint(partSet, 1, 2, 3) -Point_name = Point_2.name() -model.end() - -# check save document in a current folder -aSession = ModelAPI_Session.get() -aFiles = StringList() -aSession.save(".", aFiles) -assert(len(aFiles) == 1) - -# check open of the same document -assert(aSession.load(".") == False) # error because this document is already opened - -# close the current document -aSession.closeAll() - -# open again: it must be correct now -assert(aSession.load(".")) - -# check the created point is opened -partSet = model.moduleDocument() -assert(partSet.size("Features") == 1) -assert(partSet.object("Features", 0).data().name() == Point_name) diff --git a/src/ModelAPI/Test/TestSaveOpen1.py b/src/ModelAPI/Test/TestSaveOpen1.py new file mode 100644 index 000000000..5bc57a292 --- /dev/null +++ b/src/ModelAPI/Test/TestSaveOpen1.py @@ -0,0 +1,50 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from ModelAPI import * + +model.begin() +partSet = model.moduleDocument() +Point_2 = model.addPoint(partSet, 1, 2, 3) +Point_name = Point_2.name() +model.end() + +# check save document in a current folder +aSession = ModelAPI_Session.get() +aFiles = StringList() +aSession.save(".", aFiles) +assert(len(aFiles) == 1) + +# check open of the same document +assert(aSession.load(".") == False) # error because this document is already opened + +# close the current document +aSession.closeAll() + +# open again: it must be correct now +assert(aSession.load(".")) + +# check the created point is opened +partSet = model.moduleDocument() +assert(partSet.size("Features") == 1) +assert(partSet.object("Features", 0).data().name() == Point_name) diff --git a/src/ModelAPI/Test/TestSaveOpen2.py b/src/ModelAPI/Test/TestSaveOpen2.py new file mode 100644 index 000000000..133ba146c --- /dev/null +++ b/src/ModelAPI/Test/TestSaveOpen2.py @@ -0,0 +1,73 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from ModelAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")]) +Field_1 = model.addField(Part_1_doc, 1, "DOUBLE", 1, ["Comp 1"], [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Top]")]) +Field_1.addStep(0, 5, [[0], [3], [4]]) +model.do() +Translation_1 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OY"), 20) +model.end() + +# check save document in a current folder +aSession = ModelAPI_Session.get() +aFiles = StringList() +aSession.save(".", aFiles) +assert(len(aFiles) == 3) + +# check open of the same document +assert(aSession.load(".") == False) # error because this document is already opened + +# close the current document +aSession.closeAll() + +# open again: it must be correct now +assert(aSession.load(".")) + +# activate the Part of session +model.begin() +partSet = model.moduleDocument() +assert(partSet.size("Features") == 2) +aPart = objectToFeature(partSet.object("Features", 0)) +aPartResult = modelAPI_ResultPart(aPart.results()[0]) +aPartResult.activate() +aPartDoc = aPartResult.partDoc() +aSession.setActiveDocument(aPartDoc, True) +model.do() +# check the field result data +aFieldFeature = aPartDoc.objectByName("Features", "Field_1") +aFieldResult = modelAPI_ResultField(objectToFeature(aFieldFeature).results()[0]) +assert(aFieldResult.textLine(0) == "5") +aSession.setActiveDocument(partSet, True) +aTranslation = objectToFeature(partSet.objectByName("Features", "Translation_1")) +partSet.setCurrentFeature(aTranslation, True) +model.end() + +# check the translation feature has a correct result +assert(not aTranslation.firstResult().shape().isNull()) \ No newline at end of file