Salome HOME
8bb9e3be213209ebb45a420f67f4304c7aae31be
[modules/shaper.git] / src / PartSet / PartSet_OperationSketchBase.cpp
1 // File:        PartSet_OperationSketchBase.cpp
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #include <PartSet_OperationSketchBase.h>
6
7 #include <SketchPlugin_Feature.h>
8
9 #include <V3d_View.hxx>
10
11 #include <QKeyEvent>
12
13 #ifdef _DEBUG
14 #include <QDebug>
15 #endif
16
17 using namespace std;
18
19 PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
20                                                              QObject* theParent)
21 : ModuleBase_Operation(theId, theParent)
22 {
23 }
24
25 PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
26 {
27 }
28
29 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
30                                       FeaturePtr theFeature)
31 {
32   boost::shared_ptr<SketchPlugin_Feature> aFeature = 
33                               boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
34   if (!aFeature)
35     return boost::shared_ptr<GeomAPI_Shape>();
36   return aFeature->preview();
37 }
38
39 std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
40                                                      PartSet_OperationSketchBase::subPreview() const
41 {
42   return std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >();
43 }
44
45 std::list<int> PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const
46 {
47   std::list<int> aModes;
48   aModes.push_back(TopAbs_VERTEX);
49   aModes.push_back(TopAbs_EDGE);
50   return aModes;
51 }
52 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
53 {
54   FeaturePtr aFeature = ModuleBase_Operation::createFeature(theFlushMessage);
55   if (aFeature)
56     emit featureConstructed(aFeature, FM_Activation);
57   return aFeature;
58 }
59
60
61 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
62                                                const std::list<XGUI_ViewerPrs>& theSelected,
63                                                const std::list<XGUI_ViewerPrs>& theHighlighted)
64 {
65 }
66 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
67                                                 const std::list<XGUI_ViewerPrs>& theSelected,
68                                                 const std::list<XGUI_ViewerPrs>& theHighlighted)
69 {
70 }
71 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
72 {
73 }
74
75 void PartSet_OperationSketchBase::keyReleased(const int theKey)
76 {
77   switch (theKey) {
78     case Qt::Key_Escape: {
79       abort();
80     }
81     break;
82     default:
83     break;
84   }
85 }
86
87 void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* theEvent)
88 {
89   keyReleased(theEvent->key());
90 }
91
92 void PartSet_OperationSketchBase::restartOperation(const std::string& theType,
93                                                    FeaturePtr theFeature)
94 {
95   emit launchOperation(theType, theFeature);
96 }