X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_Document.h;h=525805b1d575251736573fcc9d3f27cb7da11eb9;hb=e333d88c6c87b8e41f127aa55b1583a98b683bff;hp=5f344ea085160b4f18000328183db249ea526a73;hpb=d55b77c58ab5b0dd258319a32dea3ad2565eb36f;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 5f344ea08..525805b1d 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -1,13 +1,29 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModelAPI_Document.cxx -// Created: 28 Feb 2014 -// 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 ModelAPI_Document_H_ #define ModelAPI_Document_H_ -#include +#include "ModelAPI.h" +#include "ModelAPI_Entity.h" + #include #include #include @@ -15,14 +31,17 @@ #include class ModelAPI_Feature; +class ModelAPI_Folder; class ModelAPI_Object; class ModelAPI_Result; class ModelAPI_ResultConstruction; class ModelAPI_ResultBody; class ModelAPI_ResultPart; class ModelAPI_ResultGroup; +class ModelAPI_ResultField; class ModelAPI_ResultParameter; class ModelAPI_Data; +class GeomAPI_Shape; /**\class ModelAPI_Document * \ingroup DataModel @@ -30,7 +49,7 @@ class ModelAPI_Data; * Document contains all data that must be stored/retrived in the file. * Also it provides acces to this data: open/save, transactions management etc. */ -class ModelAPI_Document +class ModelAPI_Document: public ModelAPI_Entity { public: //! Returns the kind of the document: "PartSet", "Part", or something else. @@ -39,13 +58,14 @@ public: virtual const std::string& kind() const = 0; //! Removes document data - //! \param theForever if it is false, document is just hiden (to keep possibility make it back on Undo/Redo) + //! \param theForever if it is false, document is just hiden + //! (to keep possibility make it back on Undo/Redo) virtual void close(const bool theForever = false) = 0; //! Adds to the document the new feature of the given feature id //! \param theID creates feature and puts it in the document (if it is not action) //! \param theMakeCurrent to make current this new feature in this document - virtual std::shared_ptr addFeature(std::string theID, + virtual std::shared_ptr addFeature(std::string theID, const bool theMakeCurrent = true) = 0; //! Return a list of features, which refers to the feature @@ -60,17 +80,20 @@ public: //! \param theFeature a feature to be removed virtual void removeFeature(std::shared_ptr theFeature) = 0; - ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist - virtual std::shared_ptr subDocument(std::string theDocID) = 0; + //! Moves the feature to make it after the given one in the history. + virtual void moveFeature(std::shared_ptr theMoved, + std::shared_ptr theAfterThis) = 0; ///! Returns the id of the document - virtual const std::string& id() const = 0; + virtual const int id() const = 0; //! Returns the object in the group by the index (started from zero) //! \param theGroupID group that contains an object //! \param theIndex zero-based index of feature in the group + //! \param theAllowFolder take into account grouping feature by folders virtual std::shared_ptr object(const std::string& theGroupID, - const int theIndex) = 0; + const int theIndex, + const bool theAllowFolder = false) = 0; //! Returns the first found object in the group by the object name //! \param theGroupID group that contains an object @@ -81,11 +104,15 @@ public: //! 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 - virtual const int index(std::shared_ptr theObject) = 0; + virtual const int index(std::shared_ptr theObject, + const bool theAllowFolder = false) = 0; //! Returns the number of objects in the group of objects - virtual int size(const std::string& theGroupID) = 0; + //! \param theGroupID group of objects + //! \param theAllowFolder take into account grouping feature by folders + virtual int size(const std::string& theGroupID, const bool theAllowFolder = false) = 0; //! Returns the feature that is currently edited in this document, normally //! this is the latest created feature @@ -94,7 +121,8 @@ public: virtual std::shared_ptr currentFeature(const bool theVisible) = 0; //! Sets the current feature: all features below will be disabled, new features - //! will be appended after this one. + //! 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 theVisible use visible features only: flag is true for Object Browser functionality virtual void setCurrentFeature(std::shared_ptr theCurrent, @@ -102,22 +130,42 @@ public: //! Makes the current feature one feature upper virtual void setCurrentFeatureUp() = 0; - /// To virtually destroy the fields of successors + //! Returns the number of all features: in the history or not + virtual int numInternalFeatures() = 0; + //! Returns the feature by zero-based index: features in the history or not + 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 + 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(); - /// Creates a construction cresults + //! Creates a construction result virtual std::shared_ptr createConstruction( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; - /// Creates a body results + //! Creates a body result virtual std::shared_ptr createBody( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; - /// Creates a part results + //! Creates a part result virtual std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; - /// Creates a group results + //! Copies a part result, keeping the reference to the origin + virtual std::shared_ptr copyPart( + const std::shared_ptr& theOrigin, + const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; + //! Creates a group result virtual std::shared_ptr createGroup( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; - + //! Creates a field result + virtual std::shared_ptr createField( + const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; + //! Creates a parameter result virtual std::shared_ptr createParameter( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; @@ -125,14 +173,81 @@ public: virtual std::shared_ptr feature( const std::shared_ptr& theResult) = 0; + //! Returns all features of the document including the hidden features which are not in + //! history. Not very fast method, for calling once, not in big cycles. + virtual std::list > allFeatures() = 0; + + //! 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. + virtual std::list > allObjects() = 0; + + //! Creates a folder (group of the features in the object browser) + virtual std::shared_ptr addFolder( + std::shared_ptr theAddBefore) = 0; + //! Removes the folder from the document (all features in the folder will be kept). + virtual void removeFolder(std::shared_ptr theFolder) = 0; + //! Search a folder above the list of features applicable to store them + //! (it means the list of features stored in the folder should be consequential) + //! \return Empty pointer if there is no applicable folder + virtual std::shared_ptr findFolderAbove( + const std::list >& theFeatures) = 0; + //! Search a folder below the list of features applicable to store them + //! (it means the list of features stored in the folder should be consequential) + //! \return Empty pointer if there is no applicable folder + virtual std::shared_ptr findFolderBelow( + const std::list >& theFeatures) = 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 + virtual bool moveToFolder(const std::list >& theFeatures, + const std::shared_ptr& theFolder) = 0; + //! 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 + virtual bool removeFromFolder( + const std::list >& theFeatures, + const bool theBefore = true) = 0; + + //! Informs the document that it becomes active and some actions must be performed + virtual void setActive(const bool theFlag) = 0; + //! Returns true if this document is currently active + virtual bool isActive() const = 0; + + /// Returns true if document is opened and valid + virtual bool isOpened() = 0; + + /// Returns the feature that produced the given face of the given result. + virtual std::shared_ptr producedByFeature( + std::shared_ptr theResult, + const std::shared_ptr& theShape) = 0; + + /// Returns true if theLater is in history of features creation later than theCurrent + virtual bool isLater(std::shared_ptr theLater, + std::shared_ptr theCurrent) const = 0; + + //! Internally makes document know that feature was removed or added in history after creation + MODELAPI_EXPORT virtual void updateHistory(const std::string theGroup) = 0; + + /// Stores in the document boolean flags: states of the nodes in the object browser. + /// 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". + /// Appends the values to theStates list. + MODELAPI_EXPORT virtual void restoreNodesState(std::list& theStates) const = 0; + + /// Just removes all features without touching the document data (to be able undo) + MODELAPI_EXPORT virtual void eraseAllFeatures() = 0; + protected: - /// Only for SWIG wrapping it is here + //! Only for SWIG wrapping it is here MODELAPI_EXPORT ModelAPI_Document(); - /// Internally makes document know that feature was removed or added in history after creation + //! Internally makes document know that feature was removed or added in history after creation MODELAPI_EXPORT virtual void updateHistory(const std::shared_ptr theObject) = 0; - /// Internally makes document know that feature was removed or added in history after creation - MODELAPI_EXPORT virtual void updateHistory(const std::string theGroup) = 0; friend class ModelAPI_Object; // to add or remove from the history friend class ModelAPI_Result; // to add or remove from the history