X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Objects.h;h=0991cf21077dba0fe2b3bcc38a0caafd91f4ebbf;hb=b0196aeefbaa53754b1052fab904386707caad87;hp=532b161ad1cf34a2b1299ff6587880423aeeb66b;hpb=93d2d70f5dd018318be3e157dabc4a920b1da6ba;p=modules%2Fshaper.git diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index 532b161ad..0991cf210 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -91,8 +91,10 @@ class Model_Objects //! Returns the object index in the group. Object must be visible. Otherwise returns -1. //! \param theObject object of this document + //! \param theAllowFolder take into account grouping feature by folders //! \returns index started from zero, or -1 if object is invisible or belongs to another document - const int index(std::shared_ptr theObject); + const int index(std::shared_ptr theObject, + const bool theAllowFolder = false); //! Returns the feature in the group by the index (started from zero) //! \param theGroupID group that contains a feature @@ -107,6 +109,10 @@ class Model_Objects //! \param theAllowFolder take into account grouping feature by folders int size(const std::string& theGroupID, const bool theAllowFolder = false); + //! Returns the parent object of this child. This may be result or feature, parent of a + //! top result. Fast method, that uses internal data structure specifics. + std::shared_ptr parent(const std::shared_ptr theChild); + //! Returns all (and disabled) results of the given type. //! Not fast method (iterates all features). void allResults(const std::string& theGroupID, std::list& theResults); @@ -150,6 +156,37 @@ class Model_Objects /// Creates a folder (group of the features in the object browser) std::shared_ptr createFolder( const std::shared_ptr& theBeforeThis); + //! Removes the folder from the document (all features in the folder will be kept). + void removeFolder(std::shared_ptr theFolder); + //! Search a folder applicable for the list of features + //! (it means the list of features stored in the folder should be consequential) + //! \param theFeatures list of features to be added to folder + //! \param theBelow search the folder below the features (if \c false, search above) + //! \return Empty pointer if there is no applicable folder + std::shared_ptr findFolder( + const std::list >& theFeatures, + const bool theBelow); + //! Search a folder containing the given feature. + //! Addtionally 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. + std::shared_ptr findContainingFolder( + const std::shared_ptr& theFeature, + int& theIndexInFolder); + //! 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 + bool moveToFolder(const std::list >& theFeatures, + const std::shared_ptr& theFolder); + //! Remove features from the folder + //! \param theFeatures list of features to be removed + //! \param theBefore extract features before the folder (this parameter is applicable only + //! when all features in the folder are taking out, + //! in other cases the direction is taken automatically) + //! \return \c true if the features have been moved out + bool removeFromFolder(const std::list >& theFeatures, + const bool theBefore = true); //! Sets the owner of this manager void setOwner(DocumentPtr theDoc); @@ -259,7 +296,7 @@ class Model_Objects std::string& theParentName) const; /// Return object representing a folder or empty pointer - ObjectPtr folder(TDF_Label theLabel) const; + const ObjectPtr& folder(TDF_Label theLabel) const; private: TDF_Label myMain; ///< main label of the data storage