X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_Objects.h;h=856d3c90b12f87cb96a40e91ada6c4dec8ac0327;hb=36c012079cecd007cd09c9192f06fcba9d8982f6;hp=c4bc24476d0c6debef193b6edfa8bee62ccd55eb;hpb=1b169f78f27c437be2291249ab89788f36df7250;p=modules%2Fshaper.git diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index c4bc24476..856d3c90b 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: Model_Objects.h -// Created: 15 May 2015 -// Author: Mikhail PONIKAROV +// 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 +// #ifndef Model_Objects_H_ #define Model_Objects_H_ @@ -10,6 +24,7 @@ #include #include #include +#include #include #include @@ -76,16 +91,23 @@ 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 //! \param theIndex zero-based index of feature in the group - ObjectPtr object(const std::string& theGroupID, const int theIndex); + //! \param theAllowFolder take into account grouping feature by folders + ObjectPtr object(const std::string& theGroupID, + const int theIndex, + const bool theAllowFolder = false); //! Returns the number of features in the group - int size(const std::string& theGroupID); + //! \param theGroupID group of objects + //! \param theAllowFolder take into account grouping feature by folders + int size(const std::string& theGroupID, const bool theAllowFolder = false); //! Returns all (and disabled) results of the given type. //! Not fast method (iterates all features). @@ -127,6 +149,41 @@ class Model_Objects std::shared_ptr feature(const std::shared_ptr& theResult); + /// 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); @@ -145,6 +202,9 @@ class Model_Objects //! feature type + "_" + index void setUniqueName(FeaturePtr theFeature); + //! Initializes the foldet with an unique name ("Folder_" + index) + void setUniqueName(FolderPtr theFolder); + //! Synchronizes myFeatures list with the updated document //! \param theUpdated list of labels that are marked as modified, so featrues must be also //! \param theUpdateReferences causes the update of back-references @@ -200,6 +260,11 @@ class Model_Objects /// Returns true if theLater is in history of features creation later than theCurrent bool isLater(FeaturePtr theLater, FeaturePtr theCurrent) const; + /// Returns the next or previous label + /// \param theCurrent given label + /// \param theReverse if it is true, iterates in reverced order (next becomes previous) + TDF_Label nextLabel(TDF_Label theCurrent, const bool theReverse = false); + /// Returns the result group identifier of the given feature (for this at least one result must /// be created before) std::string featureResultGroup(FeaturePtr theFeature); @@ -208,10 +273,27 @@ class Model_Objects //! history. Not very fast method, for calling once, not in big cycles. std::list > allFeatures(); + //! Returns all objects of the document including the hidden features which are not in + //! history. Not very fast method, for calling once, not in big cycles. + std::list > allObjects(); + //! synchronises back references for the given object basing on the collected data void synchronizeBackRefsForObject( const std::set>& theNewRefs, ObjectPtr theObject); + /// Just removes all features without touching the document data (to be able undo) + virtual void eraseAllFeatures(); + + // Check whether the pre-image of the result had user-defined name. + // If yes, return this name. + bool hasCustomName(DataPtr theFeatureData, + ResultPtr theResult, + int theResultIndex, + std::string& theParentName) const; + + /// Return object representing a folder or empty pointer + ObjectPtr folder(TDF_Label theLabel) const; + private: TDF_Label myMain; ///< main label of the data storage @@ -221,6 +303,9 @@ class Model_Objects /// For optimization mapped by labels NCollection_DataMap myFeatures; + /// Managed folders + NCollection_DataMap myFolders; + /// Map from group id to the array that contains all objects located in history. /// Each array is updated by demand from scratch, by browing all the features in the history. std::map > myHistory;