-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "ModelHighAPI_Folder.h"
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_Document.h>
+#include <ModelAPI_Events.h>
//--------------------------------------------------------------------------------------
return true;
}
+void ModelHighAPI_Folder::setName(const std::wstring& theName)
+{
+ if (myFolder && myFolder->data() && myFolder->data()->isValid())
+ myFolder->data()->setName(theName);
+}
+
+std::wstring ModelHighAPI_Folder::name() const
+{
+ return myFolder->data()->name();
+}
+
void ModelHighAPI_Folder::dump(ModelHighAPI_Dumper& theDumper) const
{
const std::string& aDocName = theDumper.name(myFolder->document());
- AttributeReferencePtr aStartRef = myFolder->reference(ModelAPI_Folder::FIRST_FEATURE_ID());
- AttributeReferencePtr aEndRef = myFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID());
+ AttributeReferencePtr aStartRef = firstFeature();
+ AttributeReferencePtr aEndRef = lastFeature();
- // Dump folder if it is empty or when its features have been already dumped.
- // Otherwise, store the folder postponed.
+ // do not dump empty folders
if (!aEndRef->value())
- theDumper << myFolder << " = model.addFolder(" << aDocName << ")" << std::endl;
- else if (theDumper.isDumped(aEndRef->value()))
+ return;
+
+ // Dump folder when its features have been already dumped.
+ // Otherwise, store the folder postponed.
+ if (theDumper.isDumped(EntityPtr(aEndRef->value())))
theDumper << myFolder << " = model.addFolder(" << aDocName << ", "
<< aStartRef << ", " << aEndRef << ")" << std::endl;
else
AttributeReferencePtr aLastFeatAttr = aFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID());
fillAttribute(theLastFeature.feature(), aLastFeatAttr);
+ // to update the folder state in the Object Browser
+ theDoc->updateHistory(ModelAPI_Feature::group());
+
return std::shared_ptr<ModelHighAPI_Folder>(new ModelHighAPI_Folder(aFolder));
}
+
+void removeFolder(std::shared_ptr<ModelHighAPI_Folder>& theFolder)
+{
+ theFolder->folder()->document()->removeFolder(theFolder->folder());
+}