]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_IModule.cpp
Salome HOME
773c84b5a32542459a3078a08108c60aa94a4c37
[modules/shaper.git] / src / ModuleBase / ModuleBase_IModule.cpp
1
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"
7
8 #include <Events_Loop.h>
9
10 #include <ModelAPI_Events.h>
11
12 #include <Config_PointerMessage.h>
13
14
15 ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
16   : QObject(theParent), myWorkshop(theParent) 
17 {
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*)));
29 }
30
31
32 void ModuleBase_IModule::launchOperation(const QString& theCmdId)
33 {
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);
41 }
42
43
44 void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation)
45 {
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);
51 }