#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_Object.h>
#include <Events_Loop.h>
#include <Events_Error.h>
myActionsMgr = new XGUI_ActionsMgr(this);
myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
myContextMenuMgr = new XGUI_ContextMenuMgr(this);
+ connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)),
+ this, SLOT(onContextMenuCommand(const QString&, bool)));
myViewerProxy = new XGUI_ViewerProxy(this);
connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
+ connect(myOperationMgr, SIGNAL(operationResumed()), this, SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
//******************************************************
void XGUI_Workshop::initMenu()
{
+ myContextMenuMgr->createActions();
+
if (isSalomeMode()) {
// Create only Undo, Redo commands
- salomeConnector()->addEditCommand("UNDO_CMD",
+ QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD",
tr("Undo"), tr("Undo last command"),
QIcon(":pictures/undo.png"),
- false, this, SLOT(onUndo()),
- QKeySequence::Undo);
- salomeConnector()->addEditCommand("REDO_CMD",
+ QKeySequence::Undo, false);
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo()));
+ aAction = salomeConnector()->addEditCommand("REDO_CMD",
tr("Redo"), tr("Redo last command"),
QIcon(":pictures/redo.png"),
- false, this, SLOT(onRedo()),
- QKeySequence::Redo);
+ QKeySequence::Redo, false);
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo()));
salomeConnector()->addEditMenuSeparator();
return;
}
aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
QIcon(":pictures/close.png"), QKeySequence::Close);
aCommand->connectTo(this, SLOT(onExit()));
-
- myContextMenuMgr->createActions();
}
//******************************************************
{
const Model_FeatureUpdatedMessage* anUpdateMsg =
dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
- boost::shared_ptr<ModelAPI_Feature> aNewFeature = anUpdateMsg->feature();
- boost::shared_ptr<ModelAPI_Feature> aCurrentFeature = myOperationMgr->currentOperation()->feature();
+ FeaturePtr aNewFeature = anUpdateMsg->feature();
+ FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
if(aNewFeature == aCurrentFeature) {
myPropertyPanel->updateContentWidget(aCurrentFeature);
}
bool isUsePropPanel = theMessage->isUseInput();
if (isSalomeMode()) {
QString aId = QString::fromStdString(theMessage->id());
- salomeConnector()->addFeature(aWchName,
- QString::fromStdString(theMessage->id()),
- aId,
- QString::fromStdString(theMessage->tooltip()),
- QIcon(theMessage->icon().c_str()),
- isUsePropPanel, this,
- SLOT(onFeatureTriggered()), QKeySequence());
- myActionsMgr->addCommand(aId, salomeConnector()->command(aId));
+ QAction* aAction = salomeConnector()->addFeature(aWchName,
+ aId,
+ QString::fromStdString(theMessage->text()),
+ QString::fromStdString(theMessage->tooltip()),
+ QIcon(theMessage->icon().c_str()),
+ QKeySequence(), isUsePropPanel);
+ myActionsMgr->addCommand(aAction);
salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
-
+ myPartSetModule->featureCreated(aAction);
} else {
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
*/
void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
{
- QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
- connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
- QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
- connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
-
QAction* aCommand = 0;
if (isSalomeMode()) {
aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
void XGUI_Workshop::saveDocument(QString theName)
{
QApplication::restoreOverrideCursor();
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
aDoc->save(theName.toLatin1().constData());
QApplication::restoreOverrideCursor();
}
//******************************************************
void XGUI_Workshop::onExit()
{
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
if(aDoc->isModified()) {
int anAnswer = QMessageBox::question(
myMainWindow, tr("Save current file"),
void XGUI_Workshop::onOpen()
{
//save current file before close if modified
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
if(aDoc->isModified()) {
//TODO(sbh): re-launch the app?
int anAnswer = QMessageBox::question(
//******************************************************
void XGUI_Workshop::onUndo()
{
- objectBrowser()->setCurrentIndex(QModelIndex());
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
if (aDoc->isOperation())
operationMgr()->abortOperation();
aDoc->undo();
//******************************************************
void XGUI_Workshop::onRedo()
{
- objectBrowser()->setCurrentIndex(QModelIndex());
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
aDoc->redo();
updateCommandStatus();
}
//******************************************************
void XGUI_Workshop::updateCommandStatus()
{
- if (isSalomeMode()) // TODO: update commands in SALOME
- return;
- XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
-
- QList<XGUI_Command*> aCommands = aMenuBar->features();
- QList<XGUI_Command*>::const_iterator aIt;
-
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ QList<QAction*> aCommands;
+ if (isSalomeMode()) { // update commands in SALOME mode
+ aCommands = salomeConnector()->commandList();
+ } else {
+ XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
+ foreach (XGUI_Command* aCmd, aMenuBar->features())
+ aCommands.append(aCmd);
+ }
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
if (aMgr->hasRootDocument()) {
- XGUI_Command* aUndoCmd;
- XGUI_Command* aRedoCmd;
- foreach(XGUI_Command* aCmd, aCommands) {
- if (aCmd->id() == "UNDO_CMD")
+ QAction* aUndoCmd;
+ QAction* aRedoCmd;
+ foreach(QAction* aCmd, aCommands) {
+ QString aId = aCmd->data().toString();
+ if (aId == "UNDO_CMD")
aUndoCmd = aCmd;
- else if (aCmd->id() == "REDO_CMD")
+ else if (aId == "REDO_CMD")
aRedoCmd = aCmd;
else // Enable all commands
- aCmd->enable();
+ aCmd->setEnabled(true);
}
- boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ DocumentPtr aDoc = aMgr->rootDocument();
aUndoCmd->setEnabled(aDoc->canUndo());
aRedoCmd->setEnabled(aDoc->canRedo());
} else {
- foreach(XGUI_Command* aCmd, aCommands) {
- if (aCmd->id() == "NEW_CMD")
- aCmd->enable();
- else if (aCmd->id() == "EXIT_CMD")
- aCmd->enable();
+ foreach(QAction* aCmd, aCommands) {
+ QString aId = aCmd->data().toString();
+ if (aId == "NEW_CMD")
+ aCmd->setEnabled(true);
+ else if (aId == "EXIT_CMD")
+ aCmd->setEnabled(true);
else
- aCmd->disable();
+ aCmd->setEnabled(false);
}
}
}
hidePropertyPanel(); //<! Invisible by default
hideObjectBrowser();
aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
+
+ QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+ connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
+ QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+ connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
}
//******************************************************
//******************************************************
void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
{
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
if (thePart) {
boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
if (aDocRef)
{
return mySalomeConnector->viewer();
}
+
+//**************************************************************
+void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
+{
+ if (theId == "ACTIVATE_PART_CMD")
+ activatePart(true);
+ else if (theId == "DEACTIVATE_PART_CMD")
+ activatePart(false);
+
+}
+
+//**************************************************************
+void XGUI_Workshop::activatePart(bool toActivate)
+{
+ if (toActivate) {
+ QFeatureList aFeatures = mySelector->selectedFeatures();
+ if (aFeatures.size() > 0) {
+ changeCurrentDocument(aFeatures.first());
+ myObjectBrowser->activateCurrentPart(true);
+ }
+ } else {
+ changeCurrentDocument(FeaturePtr());
+ myObjectBrowser->activateCurrentPart(false);
+ }
+}
+