// general sub-labels
/// where the reference to the current feature label is located (or no attribute if null feature)
-static const int TAG_CURRENT_FEATURE = 1;
+static const int TAG_CURRENT_FEATURE = 1; ///< reference to the current feature
static const int TAG_CURRENT_TRANSACTION = 2; ///< integer, index of the transaction
static const int TAG_SELECTION_FEATURE = 3; ///< integer, tag of the selection feature label
+static const int TAG_NODES_STATE = 4; ///< array, tag of the Object Browser nodes states
Model_Document::Model_Document(const int theID, const std::string theKind)
: myID(theID), myKind(theKind), myIsActive(false),
{
return myObjs->isLater(theLater, theCurrent);
}
+
+void Model_Document::storeNodesState(const std::list<bool>& theStates)
+{
+ TDF_Label aLab = generalLabel().FindChild(TAG_NODES_STATE);
+ aLab.ForgetAllAttributes();
+ if (!theStates.empty()) {
+ Handle(TDataStd_BooleanArray) anArray =
+ TDataStd_BooleanArray::Set(aLab, 0, int(theStates.size()) - 1);
+ std::list<bool>::const_iterator aState = theStates.begin();
+ for(int anIndex = 0; aState != theStates.end(); aState++, anIndex++) {
+ anArray->SetValue(anIndex, *aState);
+ }
+ }
+}
+
+void Model_Document::restoreNodesState(std::list<bool>& theStates) const
+{
+ TDF_Label aLab = generalLabel().FindChild(TAG_NODES_STATE);
+ Handle(TDataStd_BooleanArray) anArray;
+ if (aLab.FindAttribute(TDataStd_BooleanArray::GetID(), anArray)) {
+ int anUpper = anArray->Upper();
+ for(int anIndex = 0; anIndex <= anUpper; anIndex++) {
+ theStates.push_back(anArray->Value(anIndex) == Standard_True);
+ }
+ }
+}
//! for calculation of selection externally from the document
std::shared_ptr<ModelAPI_AttributeSelectionList> selectionInPartFeature();
+ /// Stores in the document boolean flags: states of the nodes in the object browser.
+ /// Normally is called outside of the transaction, just before "save".
+ void storeNodesState(const std::list<bool>& theStates);
+
+ /// Returns the stored nodes states. Normally it is calles just after "open".
+ /// Appends the values to theStates list.
+ void restoreNodesState(std::list<bool>& theStates) const;
+
friend class Model_Application;
friend class Model_Session;
friend class Model_Update;
//! 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 void storeNodesState(const std::list<bool>& theStates);
+
+ /// Returns the stored nodes states. Normally it is calles just after "open".
+ /// Appends the values to theStates list.
+ MODELAPI_EXPORT void restoreNodesState(std::list<bool>& theStates) const;
+
protected:
//! Only for SWIG wrapping it is here
MODELAPI_EXPORT ModelAPI_Document();