2 #include "ModuleBase_IModule.h"
3 #include "ModuleBase_IViewer.h"
4 #include "ModuleBase_ViewerPrs.h"
5 #include "ModuleBase_Operation.h"
6 #include "ModuleBase_ISelection.h"
8 #include <Events_Loop.h>
10 #include <ModelAPI_Events.h>
12 #include <Config_PointerMessage.h>
15 ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
16 : QObject(theParent), myWorkshop(theParent)
18 connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
19 connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this,
20 SLOT(onMousePressed(QMouseEvent*)));
21 connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this,
22 SLOT(onMouseReleased(QMouseEvent*)));
23 connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this,
24 SLOT(onMouseMoved(QMouseEvent*)));
25 connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this,
26 SLOT(onKeyRelease(QKeyEvent*)));
27 connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
28 SLOT(onMouseDoubleClick(QMouseEvent*)));
32 void ModuleBase_IModule::launchOperation(const QString& theCmdId)
34 ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
35 ModuleBase_ISelection* aSelection = myWorkshop->selection();
36 // Initialise operation with preliminary selection
37 QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
38 QList<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
39 anOperation->initSelection(aSelected, aHighlighted);
40 sendOperation(anOperation);
44 void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation)
46 static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
47 boost::shared_ptr<Config_PointerMessage> aMessage =
48 boost::shared_ptr<Config_PointerMessage>(new Config_PointerMessage(aModuleEvent, this));
49 aMessage->setPointer(theOperation);
50 Events_Loop::loop()->send(aMessage);