#include <XGUI_Displayer.h>
#include <XGUI_DataModel.h>
#include <XGUI_OperationMgr.h>
+#include <XGUI_ObjectsBrowser.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Session.h>
-#include <ModelAPI_ResultPart.h>
#include <ModelAPI_ResultParameter.h>
#include <QMainWindow>
aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aPartFeature->firstResult());
}
}
- if (aPart.get())
- aPart->activate();
+ if (aPart.get()) {
+ activatePart(aPart);
myModule->workshop()->updateCommandStatus();
+ }
+ }
+}
+
+void PartSet_MenuMgr::activatePart(ResultPartPtr thePart) const
+{
+ bool isFirstLoad = !thePart->partDoc().get();
+ thePart->activate();
+ if (isFirstLoad) {
+ XGUI_Workshop* aWorkshop = myModule->getWorkshop();
+ XGUI_ObjectsBrowser* aObjBrowser = aWorkshop->objectBrowser();
+ DocumentPtr aDoc = thePart->partDoc();
+ std::list<bool> aStates;
+ aDoc->restoreNodesState(aStates);
+ aObjBrowser->setStateForDoc(aDoc, aStates);
}
}
SessionPtr aMgr = ModelAPI_Session::get();
bool isNewTransaction = !aMgr->isOperation();
// activation may cause changes in current features in document, so it must be in transaction
- if (isNewTransaction) aMgr->startOperation("Activation");
+ if (isNewTransaction)
+ aMgr->startOperation("Activation");
aMgr->setActiveDocument(aMgr->moduleDocument());
if (isNewTransaction) aMgr->finishOperation();
#define PartSet_MenuMgr_H
#include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultPart.h>
#include <QObject>
#include <QMap>
/// Returns list of granted operation indices
virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
+ /// Activates a Part document
+ void activatePart(ResultPartPtr thePart) const;
+
public slots:
/// Processes the context menu action click
/// \param isChecked a state of toggle if the action is checkable
if (aPart->partDoc() == aMgr->activeDocument()) {
myMenuMgr->activatePartSet();
} else {
- aPart->activate();
+ myMenuMgr->activatePart(aPart);
}
}
}
/// \return theAttribute
virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape);
+ /// Returns the workshop
+ XGUI_Workshop* getWorkshop() const;
+
public slots:
/// Redefines the parent method in order to customize the next case:
/// If the sketch nested operation is active and the presentation is not visualized in the viewer,
//! Delete features
virtual bool deleteObjects();
- /// Returns the workshop
- XGUI_Workshop* getWorkshop() const;
-
void setDefaultConstraintShown();
private:
myTreeView->setExpanded(aIndex, true);
}
}
+
+std::list<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const
+{
+ std::list<bool> aStates;
+ XGUI_DataModel* aModel = dataModel();
+ QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
+ int aNbChild = aModel->rowCount(aRootIdx);
+ for (int i = 0; i < aNbChild; i++) {
+ QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
+ aStates.push_back(myTreeView->isExpanded(aIdx));
+ }
+ return aStates;
+}
+
+void XGUI_ObjectsBrowser::setStateForDoc(DocumentPtr theDoc, const std::list<bool>& theStates)
+{
+ if (theStates.size() == 0)
+ return;
+ XGUI_DataModel* aModel = dataModel();
+ QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
+ int aNbChild = aModel->rowCount(aRootIdx);
+
+ std::list<bool>::const_iterator aIt;
+ int i = 0;
+ for (aIt = theStates.cbegin(); aIt != theStates.cend(); aIt++, i++) {
+ if (i >= aNbChild )
+ break;
+ QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
+ myTreeView->setExpanded(aIdx, (*aIt));
+ }
+}
/// \param theReader the reader object
void setXMLReader(Config_DataModelReader* theReader);
+ /// Returns list of folders opened state for the given document
+ /// \param theDoc the document
+ /// \return list of booleans with state expanded or not
+ std::list<bool> getStateForDoc(DocumentPtr theDoc) const;
+
+ /// Set folders opened state for the given document
+ /// \param theDoc the document
+ /// \param theStates list of booleans with state expanded or not
+ void setStateForDoc(DocumentPtr theDoc, const std::list<bool>& theStates);
+
public slots:
//! Called on Edit command request
void onEditItem();
{
QApplication::restoreOverrideCursor();
SessionPtr aMgr = ModelAPI_Session::get();
+
+ std::list<DocumentPtr> aDocList = aMgr->allOpenedDocuments();
+ std::list<DocumentPtr>::const_iterator aIt;
+ for (aIt = aDocList.cbegin(); aIt != aDocList.cend(); aIt++) {
+ std::list<bool> aState = myObjectBrowser->getStateForDoc(*aIt);
+ (*aIt)->storeNodesState(aState);
+ }
+
aMgr->save(theName.toLatin1().constData(), theFileNames);
+
QApplication::restoreOverrideCursor();
}
aSession->closeAll();
aSession->load(myCurrentDir.toLatin1().constData());
myObjectBrowser->rebuildDataTree();
+
+ // Open first level of data tree
+ DocumentPtr aRootDoc = aSession->moduleDocument();
+ std::list<bool> aStates;
+ aRootDoc->restoreNodesState(aStates);
+ myObjectBrowser->setStateForDoc(aRootDoc, aStates);
+
updateCommandStatus();
#ifndef HAVE_SALOME
myMainWindow->setCurrentDir(myCurrentDir, true);