#include "XGUI_Viewer.h"
#include "XGUI_WidgetFactory.h"
#include "XGUI_SelectionMgr.h"
+#include "XGUI_ObjectsBrowser.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_OperationMgr.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
+#include <ModuleBase_PropPanelOperation.h>
#include <ModuleBase_Operation.h>
#include <Config_FeatureMessage.h>
#include <Config_PointerMessage.h>
XGUI_Workshop::XGUI_Workshop()
: QObject(),
- myCurrentOperation(NULL),
myPartSetModule(NULL)
{
myMainWindow = new XGUI_MainWindow();
mySelector = new XGUI_SelectionMgr(this);
+ myDisplayer = new XGUI_Displayer(myMainWindow->viewer());
+ myOperationMgr = new XGUI_OperationMgr(this);
+ connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
+ connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
+ this, SLOT(onOperationStopped(ModuleBase_Operation*)));
}
//******************************************************
{
initMenu();
//Initialize event listening
- Event_Loop* aLoop = Event_Loop::loop();
+ Events_Loop* aLoop = Events_Loop::loop();
//TODO(sbh): Implement static method to extract event id [SEID]
- Event_ID aFeatureId = aLoop->eventByName("FeatureEvent");
+ Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
aLoop->registerListener(this, aFeatureId);
- Event_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
+ Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
aLoop->registerListener(this, aPartSetId);
activateModule();
myMainWindow->show();
updateCommandStatus();
+ onNew();
// Testing of document creation
- //std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- //std::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
- //std::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
+ //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ //boost::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
+ //boost::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
//aPart->execute();
//aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
- //std::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
+ //boost::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
//aPoint2 = aMgr->rootDocument()->addFeature("Point");
//aPart = aMgr->rootDocument()->addFeature("Part");
QIcon(":pictures/open.png"), QKeySequence::Open);
aCommand->connectTo(this, SLOT(onOpen()));
- aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
- QIcon(":pictures/new.png"), QKeySequence::New);
- aCommand->connectTo(this, SLOT(onNew()));
+ //aCommand = aGroup->addFeature("NEW_CMD", tr("New"), tr("Create a new document"),
+ // QIcon(":pictures/new.png"), QKeySequence::New);
+ //aCommand->connectTo(this, SLOT(onNew()));
aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
QIcon(":pictures/close.png"), QKeySequence::Close);
}
//******************************************************
-void XGUI_Workshop::processEvent(const Event_Message* theMessage)
+void XGUI_Workshop::processEvent(const Events_Message* theMessage)
{
- static Event_ID aFeatureId = Event_Loop::loop()->eventByName("FeatureEvent");
+ static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
if (theMessage->eventID() == aFeatureId) {
const Config_FeatureMessage* aFeatureMsg =
dynamic_cast<const Config_FeatureMessage*>(theMessage);
const Config_PointerMessage* aPartSetMsg =
dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
- ModuleBase_Operation* aOperation = (ModuleBase_Operation*)(aPartSetMsg->pointer());
- setCurrentOperation(aOperation);
- if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
- myCurrentOperation->start();
- myCurrentOperation->commit();
- updateCommandStatus();
- } else {
- fillPropertyPanel(aOperation);
+ ModuleBase_PropPanelOperation* anOperation =
+ (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
+
+ if (myOperationMgr->startOperation(anOperation)) {
+ if (anOperation->isPerformedImmediately()) {
+ anOperation->commit();
+ updateCommandStatus();
+ }
}
return;
}
}
+//******************************************************
+void XGUI_Workshop::onOperationStarted()
+{
+ ModuleBase_PropPanelOperation* aOperation =
+ (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
+
+ if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
+ } else {
+ connectWithOperation(aOperation);
+ QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
+ qDeleteAll(aPropWidget->children());
+
+ myMainWindow->showPropertyPanel();
+
+ XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aOperation);
+ aFactory.createWidget(aPropWidget);
+ myMainWindow->setPropertyPannelTitle(aOperation->description());
+ }
+}
+
+//******************************************************
+void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
+{
+ myMainWindow->hidePropertyPanel();
+ updateCommandStatus();
+
+ XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+ aMenu->restoreCommandState();
+}
+
/*
*
*/
if (!aGroup) {
aGroup = aPage->addGroup(aGroupName);
}
+ bool isUsePropPanel = theMessage->isUseInput();
//Create feature...
- QString aFeatureId = QString::fromStdString(theMessage->id());
XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
QString::fromStdString(theMessage->text()),
QString::fromStdString(theMessage->tooltip()),
- QIcon(theMessage->icon().c_str())
- //TODO(sbh): QKeySequence
- );
+ QIcon(theMessage->icon().c_str()),
+ QKeySequence(), isUsePropPanel);
+
+ connect(aCommand, SIGNAL(toggled(bool)),
+ myMainWindow->menuObject(), SLOT(onFeatureChecked(bool)));
myPartSetModule->featureCreated(aCommand);
}
-/*
- *
- */
-void XGUI_Workshop::fillPropertyPanel(ModuleBase_Operation* theOperation)
-{
- connectToPropertyPanel(theOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
- qDeleteAll(aPropWidget->children());
- theOperation->start();
- XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(theOperation);
- aFactory.fillWidget(aPropWidget);
-}
-
-void XGUI_Workshop::setCurrentOperation(ModuleBase_Operation* theOperation)
-{
- //FIXME: Ask user about aborting of current operation?
- if (myCurrentOperation) {
- //TODO get isOperation from document
- if (myCurrentOperation->isRunning())
- myCurrentOperation->abort();
-
- myCurrentOperation->deleteLater();
- }
- myCurrentOperation = theOperation;
-}
-
/*
* Makes a signal/slot connections between Property Panel
* and given operation. The given operation becomes a
* current operation and previous operation if exists
*/
-void XGUI_Workshop::connectToPropertyPanel(ModuleBase_Operation* theOperation)
+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* aCancelBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
- connect(theOperation, SIGNAL(started()), myMainWindow, SLOT(showPropertyPanel()));
- connect(theOperation, SIGNAL(stopped()), myMainWindow, SLOT(hidePropertyPanel()));
+ XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+ XGUI_Command* aCommand = aMenu->feature(theOperation->operationId());
+ //Abort operation on uncheck the command
+ connect(aCommand, SIGNAL(toggled(bool)), theOperation, SLOT(setRunning(bool)));
+
}
//******************************************************
//******************************************************
void XGUI_Workshop::onUndo()
{
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aDoc->undo();
updateCommandStatus();
}
//******************************************************
void XGUI_Workshop::onRedo()
{
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aDoc->redo();
updateCommandStatus();
}
-
//******************************************************
XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
{
err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
else
{
- crtInst = (CREATE_FUNC)dlsym( modLib, GET_MODULE_NAME );
+ crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
if ( !crtInst )
err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
}
QList<XGUI_Command*> aCommands = aMenuBar->features();
QList<XGUI_Command*>::const_iterator aIt;
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
if (aMgr->hasRootDocument()) {
XGUI_Command* aUndoCmd;
XGUI_Command* aRedoCmd;
else // Enable all commands
(*aIt)->enable();
}
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aUndoCmd->setEnabled(aDoc->canUndo());
aRedoCmd->setEnabled(aDoc->canRedo());
} else {
(*aIt)->disable();
}
}
-}
\ No newline at end of file
+}