]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationSketchBase.cpp
Salome HOME
Restore default value
[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 #include <PartSet_Tools.h>
7
8 #include <SketchPlugin_Feature.h>
9 #include <V3d_View.hxx>
10 #include <AIS_Shape.hxx>
11 #include <AIS_DimensionSelectionMode.hxx>
12
13 #include <QKeyEvent>
14
15 #ifdef _DEBUG
16 #include <QDebug>
17 #endif
18
19 using namespace std;
20
21 PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
22                                                              QObject* theParent)
23 : ModuleBase_Operation(theId, theParent)
24 {
25 }
26
27 PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
28 {
29 }
30
31 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
32                                       FeaturePtr theFeature)
33 {
34   boost::shared_ptr<SketchPlugin_Feature> aFeature = 
35                               boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
36   if (!aFeature)
37     return boost::shared_ptr<GeomAPI_Shape>();
38   return aFeature->preview();
39 }
40
41 std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
42 {
43   return std::list<FeaturePtr>();
44 }
45
46 std::list<int> PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const
47 {
48   std::list<int> aModes;
49   if (PartSet_Tools::isConstraintFeature(theFeature->getKind())) {
50       aModes.clear();
51       aModes.push_back(AIS_DSM_Text);
52       aModes.push_back(AIS_DSM_Line);
53   }
54   else {
55     aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX));
56     aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE));
57   }
58   return aModes;
59 }
60 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
61 {
62   FeaturePtr aFeature = ModuleBase_Operation::createFeature(theFlushMessage);
63   if (aFeature)
64     emit featureConstructed(aFeature, FM_Activation);
65   return aFeature;
66 }
67
68
69 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
70                                                const std::list<XGUI_ViewerPrs>& theSelected,
71                                                const std::list<XGUI_ViewerPrs>& theHighlighted)
72 {
73 }
74 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
75                                                 const std::list<XGUI_ViewerPrs>& theSelected,
76                                                 const std::list<XGUI_ViewerPrs>& theHighlighted)
77 {
78 }
79 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
80 {
81 }
82 void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
83                                                    const std::list<XGUI_ViewerPrs>& theSelected,
84                                                    const std::list<XGUI_ViewerPrs>& theHighlighted)
85 {
86 }
87
88 void PartSet_OperationSketchBase::keyReleased(const int theKey)
89 {
90   switch (theKey) {
91     case Qt::Key_Escape: {
92       abort();
93     }
94     break;
95     default:
96     break;
97   }
98 }
99
100 void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* theEvent)
101 {
102   keyReleased(theEvent->key());
103 }
104
105 void PartSet_OperationSketchBase::restartOperation(const std::string& theType,
106                                                    FeaturePtr theFeature)
107 {
108   emit launchOperation(theType, theFeature);
109 }