Salome HOME
refs #156: Behavior of the Sketch during edition
[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 #include <ModelAPI_ResultBody.h>
8
9 #include <ModuleBase_IPropertyPanel.h>
10 #include <ModuleBase_IViewer.h>
11 #include <ModuleBase_ModelWidget.h>
12 #include <ModuleBase_WidgetValueFeature.h>
13
14 #include <SketchPlugin_Feature.h>
15 #include <V3d_View.hxx>
16 #include <AIS_Shape.hxx>
17 #include <AIS_DimensionSelectionMode.hxx>
18
19 #include <QKeyEvent>
20 #include <QMessageBox>
21 #include <QApplication>
22
23 #ifdef _DEBUG
24 #include <QDebug>
25 #endif
26
27 using namespace std;
28
29 PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent)
30     : ModuleBase_Operation(theId, theParent)
31 {
32 }
33
34 PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
35 {
36 }
37
38 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(FeaturePtr theFeature)
39 {
40   boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<
41       SketchPlugin_Feature>(theFeature);
42   if (aFeature) {
43     ResultPtr aRes = aFeature->firstResult();
44     ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
45     if (aBody)
46       return aBody->shape();
47   }
48   return boost::shared_ptr<GeomAPI_Shape>();
49 }
50
51 std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
52 {
53   return std::list<FeaturePtr>();
54 }
55
56 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
57 {
58   ModuleBase_Operation::createFeature(theFlushMessage);
59   if (myFeature)
60     emit featureConstructed(myFeature, FM_Activation);
61   return myFeature;
62 }
63
64 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
65 {
66 }
67 void PartSet_OperationSketchBase::mouseReleased(
68     QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
69     ModuleBase_ISelection* theSelection)
70 {
71 }
72 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
73 {
74 }
75 void PartSet_OperationSketchBase::mouseDoubleClick(
76     QMouseEvent* theEvent, Handle_V3d_View theView,
77     ModuleBase_ISelection* theSelection)
78 {
79 }
80
81 void PartSet_OperationSketchBase::selectionChanged(ModuleBase_ISelection* theSelection)
82 {
83 }
84
85 void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
86 {
87   FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
88   if (aFeature) {
89     QStringList aNested = this->nestedFeatures();
90     if (!aNested.isEmpty()) {
91       if (!aNested.contains(QString(aFeature->getKind().c_str())))
92         return;
93     }
94   }
95   emit restartRequired(theType, theFeature);
96 }
97
98