#include "NewGeom_Module.h"
#include "NewGeom_DataModel.h"
+#include <XGUI_Workshop.h>
+
#include <LightApp_Application.h>
#include <OCCViewer_ViewModel.h>
+#include <SUIT_Desktop.h>
+#include <QtxActionMenuMgr.h>
extern "C" {
}
-
+//******************************************************
NewGeom_Module::NewGeom_Module()
: LightApp_Module( "NewGeom" )
{
+ myWorkshop = new XGUI_Workshop(this);
}
-
+//******************************************************
NewGeom_Module::~NewGeom_Module()
{
}
+//******************************************************
void NewGeom_Module::initialize(CAM_Application* theApp)
{
LightApp_Module::initialize(theApp);
+
+ myWorkshop->startApplication();
}
+//******************************************************
void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
{
theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
}
+//******************************************************
void NewGeom_Module::viewManagers(QStringList& theList) const
{
theList.append( OCCViewer_Viewer::Type() );
}
+//******************************************************
bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
{
- return LightApp_Module::activateModule(theStudy);
+ bool isDone = LightApp_Module::activateModule(theStudy);
+ if (isDone) {
+ setMenuShown( true );
+ setToolShown( true );
+ }
+ return isDone;
}
+//******************************************************
bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
{
+ setMenuShown( false );
+ setToolShown( false );
return LightApp_Module::deactivateModule(theStudy);
}
+//******************************************************
CAM_DataModel* NewGeom_Module::createDataModel()
{
- return new NewGeom_DataModel(this);
+ return new NewGeom_DataModel( this );
+}
+
+//******************************************************
+void NewGeom_Module::addFeature(const QString& theWBName,
+ const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ bool isCheckable,
+ QObject* theReciever,
+ const char* theMember,
+ const QKeySequence& theKeys)
+{
+ int aMenu = createMenu(theWBName, -1, -1, 50);
+ int aTool = createTool(theWBName);
+
+ int aId = myActionsList.size();
+ myActionsList.append(theId);
+ SUIT_Desktop* aDesk = application()->desktop();
+ int aKeys = 0;
+ for (int i = 0; i < theKeys.count(); i++)
+ aKeys += theKeys[i];
+ createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
+ isCheckable, theReciever, theMember);
+ int aItemId = createMenu( aId, aMenu, -1, 10 );
+ int aToolId = createTool( aId, aTool );
+}
+
+//******************************************************
+void NewGeom_Module::addEditCommand(const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ bool isCheckable,
+ QObject* theReciever,
+ const char* theMember,
+ const QKeySequence& theKeys)
+{
+ int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
+
+ int aId = myActionsList.size();
+ myActionsList.append(theId);
+ SUIT_Desktop* aDesk = application()->desktop();
+ int aKeys = 0;
+ for (int i = 0; i < theKeys.count(); i++)
+ aKeys += theKeys[i];
+ createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
+ isCheckable, theReciever, theMember);
+ createMenu( aId, aMenu, 10 );
}
+//******************************************************
+void NewGeom_Module::addEditMenuSeparator()
+{
+ int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
+ createMenu( separator(), aMenu, -1, 10 );
+}
+
+//******************************************************
+QMainWindow* NewGeom_Module::desktop() const
+{
+ return application()->desktop();
+}
+
+//******************************************************
+QString NewGeom_Module::commandId(const QAction* theCmd) const
+{
+ int aId = actionId(theCmd);
+ if (aId < myActionsList.size())
+ return myActionsList[aId];
+ return QString();
+}
+
+//******************************************************
+QAction* NewGeom_Module::command(const QString& theId) const
+{
+ int aId = myActionsList.indexOf(theId);
+ if ((aId != -1) && (aId < myActionsList.size())) {
+ return action(aId);
+ }
+ return 0;
+}
\ No newline at end of file
#define NewGeom_Module_H
#include "NewGeom.h"
+
#include <LightApp_Module.h>
+#include <XGUI_SalomeConnector.h>
+
+#include <QStringList>
+
+class XGUI_Workshop;
-class NewGeom_EXPORT NewGeom_Module: public LightApp_Module
+class NewGeom_EXPORT NewGeom_Module: public LightApp_Module, public XGUI_SalomeConnector
{
Q_OBJECT
public:
virtual void windows( QMap<int, int>& theWndMap) const;
virtual void viewManagers( QStringList& theList) const;
+ //--- XGUI connector interface -----
+ virtual void addFeature(const QString& theWBName,
+ const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ bool isCheckable = false,
+ QObject* reciever = 0,
+ const char* member = 0,
+ const QKeySequence& theKeys = QKeySequence());
+
+ virtual void addEditCommand(const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ bool isCheckable,
+ QObject* reciever,
+ const char* member,
+ const QKeySequence& theKeys);
+
+ virtual void addEditMenuSeparator();
+
+ virtual QMainWindow* desktop() const;
+
+ virtual QString commandId(const QAction* theCmd) const;
+
+ virtual QAction* command(const QString& theId) const;
+
public slots:
bool activateModule( SUIT_Study* theStudy);
bool deactivateModule( SUIT_Study* theStudy);
private:
+ QStringList myActionsList;
+ XGUI_Workshop* myWorkshop;
};
#endif
connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
- connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
- this, SLOT(onViewSelectionChanged()));
+ if (!myWorkshop->isSalomeMode())
+ connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
+ this, SLOT(onViewSelectionChanged()));
}
PartSet_Module::~PartSet_Module()
void PartSet_Module::onFeatureTriggered()
{
XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
- QString aCmdId = aCmd->id();
- std::string aStdCmdId = aCmdId.toStdString();
+ launchOperation(aCmd->id());
+}
+
+void PartSet_Module::launchOperation(const QString& theCmdId)
+{
+ std::string aStdCmdId = theCmdId.toStdString();
std::string aPluginFileName = featureFile(aStdCmdId);
Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
aWdgReader.readAll();
std::string aXmlCfg = aWdgReader.featureWidgetCfg(aStdCmdId);
std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
ModuleBase_PropPanelOperation* aPartSetOp;
- if (aCmdId == "Sketch" ) {
- aPartSetOp = new PartSet_OperationSketch(aCmdId, this);
+ if (theCmdId == "Sketch" ) {
+ aPartSetOp = new PartSet_OperationSketch(theCmdId, this);
} else {
- aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this);
+ aPartSetOp = new ModuleBase_PropPanelOperation(theCmdId, this);
}
aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
aPartSetOp->setDescription(QString::fromStdString(aDescription));
virtual void featureCreated(XGUI_Command* theFeature);
std::string featureFile(const std::string&);
+ virtual void launchOperation(const QString& theCmdId);
+
public slots:
void onFeatureTriggered();
/// SLOT, that is called after the operation is started. Perform some specific for module
XGUI_DataTreeModel.h
XGUI_SelectionMgr.h
XGUI_SwitchWidget.h
+ XGUI_SalomeConnector.h
)
SET(PROJECT_AUTOMOC
XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
: QMainWindow(parent),
- myObjectBrowser(0),
- myPythonConsole(0),
- myPropertyPanelDock(0)
+ myPythonConsole(0)
{
setWindowTitle(tr("New Geom"));
myMenuBar = new XGUI_MainMenu(this);
setCentralWidget(aMdiArea);
myViewer = new XGUI_Viewer(this);
-
- //createDockWidgets();
}
XGUI_MainWindow::~XGUI_MainWindow(void)
return static_cast<QMdiArea*>(centralWidget());
}
-//******************************************************
-void XGUI_MainWindow::showObjectBrowser()
-{
- myObjectBrowser->parentWidget()->show();
-}
-
-//******************************************************
-void XGUI_MainWindow::hideObjectBrowser()
-{
- myObjectBrowser->parentWidget()->hide();
-}
-
//******************************************************
void XGUI_MainWindow::showPythonConsole()
{
myPythonConsole->parentWidget()->hide();
}
-void XGUI_MainWindow::showPropertyPanel()
-{
- QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
- //<! Restore ability to close panel from the window's menu
- aViewAct->setEnabled(true);
- myPropertyPanelDock->show();
- myPropertyPanelDock->raise();
-}
-
-void XGUI_MainWindow::hidePropertyPanel()
-{
- QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
- //<! Do not allow to show empty property panel
- aViewAct->setEnabled(false);
- myPropertyPanelDock->hide();
-}
-/*
- * Creates dock widgets, places them in corresponding area
- * and tabifies if necessary.
- */
-void XGUI_MainWindow::createDockWidgets()
-{
- QDockWidget* aObjDock = createObjectBrowser();
- addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
- myPropertyPanelDock = createPropertyPanel();
- addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
- hidePropertyPanel(); //<! Invisible by default
- hideObjectBrowser();
- tabifyDockWidget(aObjDock, myPropertyPanelDock);
-}
-
-void XGUI_MainWindow::setPropertyPannelTitle(const QString& theTitle)
-{
- myPropertyPanelDock->setWindowTitle(theTitle);
-}
-
-
-QDockWidget* XGUI_MainWindow::createPropertyPanel()
-{
- QDockWidget* aPropPanel = new QDockWidget(this);
- aPropPanel->setWindowTitle(tr("Property Panel"));
- QAction* aViewAct = aPropPanel->toggleViewAction();
- aPropPanel->setObjectName(XGUI::PROP_PANEL);
-
- QWidget* aContent = new QWidget(aPropPanel);
- QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
- aMainLay->setContentsMargins(3, 3, 3, 3);
- aPropPanel->setWidget(aContent);
-
- QFrame* aFrm = new QFrame(aContent);
- aFrm->setFrameStyle(QFrame::Sunken);
- aFrm->setFrameShape(QFrame::Panel);
- QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
- aBtnLay->setContentsMargins(0, 0, 0, 0);
- aMainLay->addWidget(aFrm);
-
- QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
- aBtn->setFlat(true);
- //connect(aBtn, SIGNAL(clicked()), this, SIGNAL(propertyHelpPressed()));
- aBtnLay->addWidget(aBtn);
- aBtnLay->addStretch(1);
- aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
- aBtn->setObjectName(XGUI::PROP_PANEL_OK);
- aBtn->setFlat(true);
- //connect(aBtn, SIGNAL(clicked()), this, SIGNAL(propertyOkPressed()));
- aBtnLay->addWidget(aBtn);
- aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
- aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
- aBtn->setFlat(true);
- //connect(aBtn, SIGNAL(clicked()), this, SIGNAL(propertyClosePressed()));
- aBtnLay->addWidget(aBtn);
-
- QWidget* aCustomWidget = new QWidget(aContent);
- aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
- aMainLay->addWidget(aCustomWidget);
- aMainLay->addStretch(1);
-
- return aPropPanel;
-}
-
-QDockWidget* XGUI_MainWindow::createObjectBrowser()
-{
- QDockWidget* aObjDock = new QDockWidget(this);
- aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- aObjDock->setWindowTitle(tr("Object browser"));
- myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
- aObjDock->setWidget(myObjectBrowser);
- return aObjDock;
-}
class XGUI_MainMenu;
class XGUI_Viewer;
-class XGUI_ObjectsBrowser;
class QMdiArea;
class PyConsole_EnhConsole;
return myMenuBar;
}
- //! Returns Object browser
- XGUI_ObjectsBrowser* objectBrowser() const
- {
- return myObjectBrowser;
- }
-
//! Returns MDI area
QMdiArea* mdiArea() const;
return myViewer;
}
- // Creates Dock widgets: Object broewser and Property panel
- void createDockWidgets();
- void setPropertyPannelTitle(const QString& theTitle);
-
public slots:
void showPythonConsole();
void hidePythonConsole();
- void showPropertyPanel();
- void hidePropertyPanel();
- void showObjectBrowser();
- void hideObjectBrowser();
private:
- QDockWidget* createObjectBrowser();
- QDockWidget* createPropertyPanel();
-
XGUI_MainMenu* myMenuBar;
- XGUI_ObjectsBrowser* myObjectBrowser;
- QDockWidget* myPropertyPanelDock;
XGUI_Viewer* myViewer;
#define XGUI_Module_H\r
\r
#include <XGUI_Workshop.h>\r
+#include <QString>\r
\r
class XGUI_Command;\r
\r
public:\r
virtual void createFeatures() = 0;\r
virtual void featureCreated(XGUI_Command*) = 0;\r
+ virtual void launchOperation(const QString& theCmdId) = 0;\r
\r
virtual ~XGUI_Module() {};\r
};\r
--- /dev/null
+#ifndef XGUI_SALOMECONNECTOR_H
+#define XGUI_SALOMECONNECTOR_H
+
+#include "XGUI.h"
+
+#include <QString>
+
+class QMainWindow;
+
+class XGUI_EXPORT XGUI_SalomeConnector
+{
+public:
+ virtual void addFeature(const QString& theWBName,
+ const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ bool isCheckable,
+ QObject* reciever,
+ const char* member,
+ const QKeySequence& theKeys) = 0;
+
+ virtual void addEditCommand(const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ bool isCheckable,
+ QObject* reciever,
+ const char* member,
+ const QKeySequence& theKeys) = 0;
+ virtual void addEditMenuSeparator() = 0;
+
+ virtual QMainWindow* desktop() const = 0;
+
+ virtual QString commandId(const QAction* theCmd) const = 0;
+ virtual QAction* command(const QString& theId) const = 0;
+};
+
+#endif
\ No newline at end of file
void XGUI_SelectionMgr::onSelectionChanged()
{
- XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
+ XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->objectBrowser();
mySelectedData = aObjBrowser->selectedData();
// Set current document
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_Displayer.h"
#include "XGUI_OperationMgr.h"
+#include "XGUI_SalomeConnector.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Feature.h>
#include <QMdiSubWindow>
#include <QPushButton>
#include <QDockWidget>
+#include <QLayout>
#ifdef _DEBUG
#include <QDebug>
#include <dlfcn.h>
#endif
-XGUI_Workshop::XGUI_Workshop()
+XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
: QObject(),
- myPartSetModule(NULL)
+ myPartSetModule(NULL),
+ mySalomeConnector(theConnector),
+ myPropertyPanelDock(0),
+ myObjectBrowser(0)
{
- myMainWindow = new XGUI_MainWindow();
+ myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
mySelector = new XGUI_SelectionMgr(this);
- myDisplayer = new XGUI_Displayer(myMainWindow->viewer());
+ myDisplayer = myMainWindow? new XGUI_Displayer(myMainWindow->viewer()) : 0;
myOperationMgr = new XGUI_OperationMgr(this);
connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
aLoop->registerListener(this, aPartSetId);
activateModule();
- myMainWindow->show();
-
- updateCommandStatus();
+ if (myMainWindow) {
+ myMainWindow->show();
+ updateCommandStatus();
+ }
onNew();
// Testing of document creation
//boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
//******************************************************
void XGUI_Workshop::initMenu()
{
+ if (isSalomeMode()) {
+ // Create only Undo, Redo commands
+ salomeConnector()->addEditCommand("UNDO_CMD",
+ tr("Undo"), tr("Undo last command"),
+ QIcon(":pictures/undo.png"),
+ false, this, SLOT(onUndo()),
+ QKeySequence::Undo);
+ salomeConnector()->addEditCommand("REDO_CMD",
+ tr("Redo"), tr("Redo last command"),
+ QIcon(":pictures/redo.png"),
+ false, this, SLOT(onRedo()),
+ QKeySequence::Redo);
+ salomeConnector()->addEditMenuSeparator();
+ return;
+ }
XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
// File commands group
ModuleBase_PropPanelOperation* aOperation =
(ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
- if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
- } else {
+ if(!aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
connectWithOperation(aOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
+ QWidget* aPropWidget = myPropertyPanelDock->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
qDeleteAll(aPropWidget->children());
- myMainWindow->showPropertyPanel();
+ showPropertyPanel();
XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aOperation);
aFactory.createWidget(aPropWidget);
- myMainWindow->setPropertyPannelTitle(aOperation->description());
+ setPropertyPannelTitle(aOperation->description());
}
}
//******************************************************
void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
{
- myMainWindow->hidePropertyPanel();
+ hidePropertyPanel();
updateCommandStatus();
- XGUI_MainMenu* aMenu = myMainWindow->menuObject();
- aMenu->restoreCommandState();
+ if (myMainWindow) {
+ XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+ aMenu->restoreCommandState();
+ }
}
/*
return;
}
//Find or create Workbench
- XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
QString aWchName = QString::fromStdString(theMessage->workbenchId());
- XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
- if (!aPage) {
- aPage = addWorkbench(aWchName);
- }
- //Find or create Group
- QString aGroupName = QString::fromStdString(theMessage->groupId());
- XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
- if (!aGroup) {
- aGroup = aPage->addGroup(aGroupName);
+ if (isSalomeMode()) {
+ salomeConnector()->addFeature(aWchName,
+ QString::fromStdString(theMessage->id()),
+ QString::fromStdString(theMessage->text()),
+ QString::fromStdString(theMessage->tooltip()),
+ QIcon(theMessage->icon().c_str()),
+ false, this,
+ SLOT(onFeatureTriggered()), QKeySequence());
+ } else {
+ XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
+ XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
+ if (!aPage) {
+ aPage = addWorkbench(aWchName);
+ }
+ //Find or create Group
+ QString aGroupName = QString::fromStdString(theMessage->groupId());
+ XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
+ if (!aGroup) {
+ aGroup = aPage->addGroup(aGroupName);
+ }
+ bool isUsePropPanel = theMessage->isUseInput();
+ //Create feature...
+ XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
+ QString::fromStdString(theMessage->text()),
+ QString::fromStdString(theMessage->tooltip()),
+ QIcon(theMessage->icon().c_str()),
+ QKeySequence(), isUsePropPanel);
+
+ connect(aCommand, SIGNAL(toggled(bool)),
+ myMainWindow->menuObject(), SLOT(onFeatureChecked(bool)));
+ myPartSetModule->featureCreated(aCommand);
}
- bool isUsePropPanel = theMessage->isUseInput();
- //Create feature...
- XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
- QString::fromStdString(theMessage->text()),
- QString::fromStdString(theMessage->tooltip()),
- QIcon(theMessage->icon().c_str()),
- QKeySequence(), isUsePropPanel);
-
- connect(aCommand, SIGNAL(toggled(bool)),
- myMainWindow->menuObject(), SLOT(onFeatureChecked(bool)));
- myPartSetModule->featureCreated(aCommand);
}
/*
*/
void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
{
- QDockWidget* aPanel = myMainWindow->findChild<QDockWidget*>(XGUI::PROP_PANEL);
- QPushButton* aOkBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+ QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
- QPushButton* aCancelBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+ QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
- XGUI_MainMenu* aMenu = myMainWindow->menuObject();
- XGUI_Command* aCommand = aMenu->feature(theOperation->operationId());
+ QAction* aCommand = 0;
+ if (isSalomeMode()) {
+ aCommand = salomeConnector()->command(theOperation->operationId());
+ } else {
+ XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+ aCommand = aMenu->feature(theOperation->operationId());
+ }
//Abort operation on uncheck the command
connect(aCommand, SIGNAL(toggled(bool)), theOperation, SLOT(setRunning(bool)));
-
}
//******************************************************
void XGUI_Workshop::onNew()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
- if (myMainWindow->objectBrowser() == 0) {
- myMainWindow->createDockWidgets();
- mySelector->connectObjectBrowser(myMainWindow->objectBrowser());
+ if (objectBrowser() == 0) {
+ createDockWidgets();
+ mySelector->connectObjectBrowser(objectBrowser());
+ }
+ showObjectBrowser();
+ if (!isSalomeMode()) {
+ myMainWindow->showPythonConsole();
+ QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
+ aWnd->showMaximized();
+ updateCommandStatus();
}
- myMainWindow->showObjectBrowser();
- myMainWindow->showPythonConsole();
- QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
- aWnd->showMaximized();
- updateCommandStatus();
QApplication::restoreOverrideCursor();
}
//******************************************************
void XGUI_Workshop::onUndo()
{
- myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
+ objectBrowser()->setCurrentIndex(QModelIndex());
boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aDoc->undo();
//******************************************************
void XGUI_Workshop::onRedo()
{
- myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
+ objectBrowser()->setCurrentIndex(QModelIndex());
boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aDoc->redo();
//******************************************************
void XGUI_Workshop::updateCommandStatus()
{
+ if (isSalomeMode()) // TODO: update commands in SALOME
+ return;
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
QList<XGUI_Command*> aCommands = aMenuBar->features();
}
}
}
+
+//******************************************************
+QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
+{
+ QDockWidget* aObjDock = new QDockWidget(theParent);
+ aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+ aObjDock->setWindowTitle(tr("Object browser"));
+ myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
+ aObjDock->setWidget(myObjectBrowser);
+ return aObjDock;
+}
+
+//******************************************************
+QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
+{
+ QDockWidget* aPropPanel = new QDockWidget(theParent);
+ aPropPanel->setWindowTitle(tr("Property Panel"));
+ QAction* aViewAct = aPropPanel->toggleViewAction();
+ aPropPanel->setObjectName(XGUI::PROP_PANEL);
+
+ QWidget* aContent = new QWidget(aPropPanel);
+ QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
+ aMainLay->setContentsMargins(3, 3, 3, 3);
+ aPropPanel->setWidget(aContent);
+
+ QFrame* aFrm = new QFrame(aContent);
+ aFrm->setFrameStyle(QFrame::Sunken);
+ aFrm->setFrameShape(QFrame::Panel);
+ QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
+ aBtnLay->setContentsMargins(0, 0, 0, 0);
+ aMainLay->addWidget(aFrm);
+
+ QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
+ aBtn->setFlat(true);
+ aBtnLay->addWidget(aBtn);
+ aBtnLay->addStretch(1);
+ aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
+ aBtn->setObjectName(XGUI::PROP_PANEL_OK);
+ aBtn->setFlat(true);
+ aBtnLay->addWidget(aBtn);
+ aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
+ aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
+ aBtn->setFlat(true);
+ aBtnLay->addWidget(aBtn);
+
+ QWidget* aCustomWidget = new QWidget(aContent);
+ aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
+ aMainLay->addWidget(aCustomWidget);
+ aMainLay->addStretch(1);
+
+ return aPropPanel;
+}
+
+//******************************************************
+void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
+{
+ myPropertyPanelDock->setWindowTitle(theTitle);
+}
+
+//******************************************************
+/*
+ * Creates dock widgets, places them in corresponding area
+ * and tabifies if necessary.
+ */
+void XGUI_Workshop::createDockWidgets()
+{
+ QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() :
+ myMainWindow;
+ QDockWidget* aObjDock = createObjectBrowser(aDesktop);
+ aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
+ myPropertyPanelDock = createPropertyPanel(aDesktop);
+ aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
+ hidePropertyPanel(); //<! Invisible by default
+ hideObjectBrowser();
+ aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
+}
+
+//******************************************************
+void XGUI_Workshop::showPropertyPanel()
+{
+ QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ //<! Restore ability to close panel from the window's menu
+ aViewAct->setEnabled(true);
+ myPropertyPanelDock->show();
+ myPropertyPanelDock->raise();
+}
+
+//******************************************************
+void XGUI_Workshop::hidePropertyPanel()
+{
+ QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ //<! Do not allow to show empty property panel
+ aViewAct->setEnabled(false);
+ myPropertyPanelDock->hide();
+}
+
+//******************************************************
+void XGUI_Workshop::showObjectBrowser()
+{
+ myObjectBrowser->parentWidget()->show();
+}
+
+//******************************************************
+void XGUI_Workshop::hideObjectBrowser()
+{
+ myObjectBrowser->parentWidget()->hide();
+}
+
+//******************************************************
+void XGUI_Workshop::onFeatureTriggered()
+{
+ QAction* aCmd = dynamic_cast<QAction*>(sender());
+ if (aCmd) {
+ QString aId = salomeConnector()->commandId(aCmd);
+ if (!aId.isNull())
+ myPartSetModule->launchOperation(aId);
+ }
+}
class XGUI_SelectionMgr;
class XGUI_Displayer;
class XGUI_OperationMgr;
+class XGUI_SalomeConnector;
+class XGUI_ObjectsBrowser;
class ModuleBase_Operation;
class ModuleBase_PropPanelOperation;
class Config_FeatureMessage;
class Config_PointerMessage;
+class QWidget;
+class QDockWidget;
+
/**\class XGUI_Workshop
* \ingroup GUI
* \brief Class which defines a configuration of the application (Workshop) and launches it.
Q_OBJECT
public:
- XGUI_Workshop();
+ XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
virtual ~XGUI_Workshop();
//! Starting of the application
//! Redefinition of Events_Listener method
virtual void processEvent(const Events_Message* theMessage);
+ XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
+
+ //! Returns true if the application works as SALOME module
+ bool isSalomeMode() const { return mySalomeConnector != 0; }
+
+ //! Returns Object browser
+ XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
+
public slots:
void updateCommandStatus();
void onUndo();
void onRedo();
+ void showPropertyPanel();
+ void hidePropertyPanel();
+ void showObjectBrowser();
+ void hideObjectBrowser();
+
+ void onFeatureTriggered();
+
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
XGUI_Module* loadModule(const QString& theModule);
bool activateModule();
+ QDockWidget* createObjectBrowser(QWidget* theParent);
+ QDockWidget* createPropertyPanel(QWidget* theParent);
+
+ // Creates Dock widgets: Object browser and Property panel
+ void createDockWidgets();
+ void setPropertyPannelTitle(const QString& theTitle);
+
+
XGUI_MainWindow* myMainWindow;
XGUI_Module* myPartSetModule;
+ XGUI_ObjectsBrowser* myObjectBrowser;
+ QDockWidget* myPropertyPanelDock;
+
XGUI_SelectionMgr* mySelector;
XGUI_Displayer* myDisplayer;
XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
+
+ XGUI_SalomeConnector* mySalomeConnector;
};
#endif