aPartRes = ModelAPI.modelAPI_ResultPart(ModelAPI.modelAPI_Result(aPartObject))
aPartDoc = aPartRes.partDoc()
if aPartDoc is None and aPartObject is not None:
- EventsAPI.Events_InfoMessage("PublishToStudy", "For publish to SHAPER-STUDY some Part is not activated", self).send()
+ EventsAPI.Events_InfoMessage("PublishToStudy", "To publish to SHAPER-STUDY, activate Parts in SHAPER", self).send()
break
aPartFeatureId = aPartSet.feature(aPartRes).data().featureId()
# Collects all features of exported results to find results of the same features and extend id.
<translation>Toutes les pièces de l'assemblage ne sont pas à jour, rien n'est publié. Veuillez mettre la dernière fonctionnalité à jour.</translation>
</message>
<message>
- <source>For publish to SHAPER-STUDY some Part is not activated</source>
- <translation>Pour la publication sur SHAPER-STUDY, une pièce n'est pas activée</translation>
+ <source>To publish to SHAPER-STUDY, activate Parts in SHAPER</source>
+ <translation>Pour publier dans SHAPER-STUDY, activez les pièces dans SHAPER</translation>
</message>
</context>
</TS>
aCalculatedValue[1]);
}
}
+
+void InitializationPlugin_EvalListener::initDataModel()
+{
+ myInterp->runString("salome_iapp.register_module_in_study(\"Shaper\")");
+}
INITIALIZATIONPLUGIN_EXPORT
virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+ // performs the python call to initialize high level data model on internal data model creation
+ void initDataModel();
+
protected:
/// Evaluates theExpression and returns its value.
double evaluate(std::shared_ptr<ModelAPI_Feature> theParameter,
if (aDoc != ModelAPI_Session::get()->moduleDocument())
return;
+ myEvalListener->initDataModel();
+
std::list<FeaturePtr> aFeatures;
// the viewer update should be blocked in order to avoid the features blinking before they are
Py_XDECREF(_local_context);
PyInterp_Interp::closeContext();
}
+
+bool InitializationPlugin_PyInterp::runString(std::string theString)
+{
+ PyLockWrapper lck; // Acquire GIL until the end of the method
+ return PyRun_SimpleString(theString.c_str());
+}
/// Evaluates theExpression and returns its value.
double evaluate(const std::string& theExpression, std::string& theError);
+ /// Runs the string command in the python interpreter. Returns true if no error is in result.
+ bool runString(std::string theString);
+
protected:
/// Returns error message.
std::string errorMessage();
{
std::shared_ptr<Model_Session> aSession =
std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get());
+ if (!aSession->hasModuleDocument() || !myObjs)
+ return FeaturePtr(); // this may be on close of the document
FeaturePtr aFeature = aSession->createFeature(theID, this);
if (!aFeature)
return aFeature;
{
Model_Application::getApplication()->deleteAllDocuments();
static const Events_ID aDocChangeEvent = Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED);
+ myCurrentDoc = NULL;
static std::shared_ptr<Events_Message> aMsg(new Events_Message(aDocChangeEvent));
Events_Loop::loop()->send(aMsg);
Events_Loop::loop()->flush(aDocChangeEvent);
anApp->createDocument(0); // 0 is a root ID
// creation of the root document is always outside of the transaction, so, avoid checking it
setCheckTransactions(true);
+ if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id())) {
+ myCurrentDoc = moduleDocument();
+ static std::shared_ptr<Events_Message> aMsg(
+ new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)));
+ Events_Loop::loop()->send(aMsg);
+ }
}
return anApp->rootDocument();
}
std::shared_ptr<ModelAPI_Document> Model_Session::activeDocument()
{
- if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id()))
- myCurrentDoc = moduleDocument();
+ if (!myCurrentDoc || !Model_Application::getApplication()->hasDocument(myCurrentDoc->id())) {
+ return moduleDocument();
+ }
return myCurrentDoc;
}
void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMessage)
{
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ if (!aMgr->hasModuleDocument()) // if document is closed, do not call the document creation
+ return;
// Do not change activation of parts if an operation active
static QStringList aAllowActivationList;
if (aAllowActivationList.isEmpty())
(!aAllowActivationList.contains(myWorkshop->currentOperation()->id())))
return;
XGUI_Workshop* aWorkshop = getWorkshop();
- XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView();
- QLabel* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
- QPalette aPalet = aLabel->palette();
+ bool needUpdate = false;
+ XGUI_DataTree* aTreeView;
+ if (aWorkshop->objectBrowser()) {
+ aTreeView = aWorkshop->objectBrowser()->treeView();
+ QLabel* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
+ QPalette aPalet = aLabel->palette();
- SessionPtr aMgr = ModelAPI_Session::get();
- DocumentPtr aActiveDoc = aMgr->activeDocument();
+ DocumentPtr aActiveDoc = aMgr->activeDocument();
- // Clear active part index if there is no Part documents
- // It could be not null if document was closed and opened a new
- // without closeDocument call
- if (aMgr->allOpenedDocuments().size() <= 1)
- myActivePartIndex = QModelIndex();
+ // Clear active part index if there is no Part documents
+ // It could be not null if document was closed and opened a new
+ // without closeDocument call
+ if (aMgr->allOpenedDocuments().size() <= 1)
+ myActivePartIndex = QModelIndex();
- XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
- QModelIndex aOldActive = myActivePartIndex;
- myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
- bool needUpdate = false;
- if (myActivePartIndex.isValid()) {
- needUpdate = aTreeView->isExpanded(myActivePartIndex);
- if (!needUpdate)
- aTreeView->setExpanded(myActivePartIndex, true);
- }
- if ((aOldActive != myActivePartIndex) && (aOldActive.isValid()))
- aTreeView->setExpanded(aOldActive, false);
+ XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
+ QModelIndex aOldActive = myActivePartIndex;
+ myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
+ if (myActivePartIndex.isValid()) {
+ needUpdate = aTreeView->isExpanded(myActivePartIndex);
+ if (!needUpdate)
+ aTreeView->setExpanded(myActivePartIndex, true);
+ }
+ if ((aOldActive != myActivePartIndex) && (aOldActive.isValid()))
+ aTreeView->setExpanded(aOldActive, false);
- aLabel->setPalette(aPalet);
+ aLabel->setPalette(aPalet);
+ }
aWorkshop->updateCommandStatus();
// Update displayed objects in order to update active color
#include <QMenu>
#include <QToolBar>
+#include <ModelAPI_Session.h>
+
#if OCC_VERSION_HEX < 0x070400
#define SALOME_PATCH_FOR_CTRL_WHEEL
#endif
#endif
createMenu(aId, aEditMenu);
+ if (!myInspectionPanel) {
+ myInspectionPanel = myWorkshop->inspectionPanel();
+ connect(myInspectionPanel->toggleViewAction(), SIGNAL(toggled(bool)),
+ this, SLOT(onWhatIs(bool)));
+ }
+ hideInternalWindows();
+
// Initialize viewer proxy if OCC viewer is already exist
ViewManagerList aOCCViewManagers;
application()->viewManagers(OCCViewer_Viewer::Type(), aOCCViewManagers);
}
}
}
+ SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
+ aDataModel->initRootObject();
}
//******************************************************
//******************************************************
bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
{
- bool isDone = LightApp_Module::activateModule(theStudy);
- loadToolbarsConfig();
+ ModelAPI_Session::get()->moduleDocument(); // initialize a root document if not done yet
+ // this must be done in the initialization and in activation (on the second activation initialization
+ // in not called, so SComponent must be added anyway
SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
aDataModel->initRootObject();
+
+ bool isDone = LightApp_Module::activateModule(theStudy);
+ loadToolbarsConfig();
+
if (isDone) {
setMenuShown(true);
setToolShown(true);
aObjDoc->toggleViewAction()->setVisible(true);
}
- if (!myInspectionPanel) {
- myInspectionPanel = myWorkshop->inspectionPanel();
- connect(myInspectionPanel->toggleViewAction(), SIGNAL(toggled(bool)),
- this, SLOT(onWhatIs(bool)));
- }
myInspectionPanel->toggleViewAction()->setVisible(true);
myWorkshop->facesPanel()->toggleViewAction()->setVisible(true);
}
//******************************************************
-bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
+void SHAPERGUI::hideInternalWindows()
{
- saveToolbarsConfig();
-
myProxyViewer->activateViewer(false);
setMenuShown(false);
setToolShown(false);
- myWorkshop->deactivateModule();
-
QObject* aObj = myWorkshop->objectBrowser()->parent();
QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
if (aObjDoc) {
aObjDoc->toggleViewAction()->setVisible(false);
}
- myIsInspectionVisible = myInspectionPanel->isVisible();
myInspectionPanel->hide();
myInspectionPanel->toggleViewAction()->setVisible(false);
- myIsFacesPanelVisible = myWorkshop->facesPanel()->isVisible();
myWorkshop->facesPanel()->hide();
myWorkshop->facesPanel()->toggleViewAction()->setVisible(false);
myWorkshop->propertyPanel()->hide();
myWorkshop->propertyPanel()->toggleViewAction()->setVisible(false);
+ myWorkshop->hidePanel(myWorkshop->facesPanel());
+}
+
+
+//******************************************************
+bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
+{
+ saveToolbarsConfig();
+ myWorkshop->deactivateModule();
+
+ myIsInspectionVisible = myInspectionPanel->isVisible();
+ myIsFacesPanelVisible = myWorkshop->facesPanel()->isVisible();
+ hideInternalWindows();
+
+
// the active operation should be stopped for the next activation.
// There should not be active operation and visualized preview.
// Abort operation should be performed before the selection's remove
mySelector = 0;
}
- myWorkshop->hidePanel(myWorkshop->facesPanel());
//myWorkshop->contextMenuMgr()->disconnectViewer();
SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
void SHAPERGUI::publishToStudy()
{
- if (isActiveModule())
+ if (isActiveModule() && ModelAPI_Session::get()->hasModuleDocument())
myWorkshop->module()->launchOperation("PublishToStudy", false);
}
void saveToolbarsConfig();
void loadToolbarsConfig();
+
+ void hideInternalWindows();
+
/// List of registered nested actions
QStringList myNestedActionsList;
/// Creates a module root object if it has not been created yet
/// and append it to the active study. It is necessary for correct persistent
/// of the model.
- void initRootObject();
+ virtual void initRootObject() override;
/// Update data object
/// \param theObj an data object
}
}
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
- DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument();
- ModuleBase_ITreeNode* aRoot = myRoot->findRoot(aDoc);
- if (aRoot) {
- updateSubTree(aRoot);
+ if (ModelAPI_Session::get()->hasModuleDocument()) {
+ DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument();
+ ModuleBase_ITreeNode* aRoot = myRoot->findRoot(aDoc);
+ if (aRoot) {
+ updateSubTree(aRoot);
+ }
}
}
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {