Salome HOME
0527d9c6829a0ef6992b23c42fb1657cc942c198
[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 #include <ModelAPI_Object.h>
9
10 #include <V3d_View.hxx>
11
12 #ifdef _DEBUG
13 #include <QDebug>
14 #endif
15
16 using namespace std;
17
18 PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
19                                                              QObject* theParent)
20 : ModuleBase_Operation(theId, theParent)
21 {
22 }
23
24 PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
25 {
26 }
27
28 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
29                                       boost::shared_ptr<ModelAPI_Feature> theFeature) const
30 {
31   boost::shared_ptr<SketchPlugin_Feature> aFeature = 
32                               boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
33   if (!aFeature) { // if it is reference to a object feature
34     boost::shared_ptr<ModelAPI_Object> anObj = 
35       boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
36     if (anObj) 
37       aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(anObj->featureRef());
38   }
39   return aFeature->preview();
40 }
41
42 std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
43                                                      PartSet_OperationSketchBase::subPreview() const
44 {
45   return std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >();
46 }
47
48 std::list<int> PartSet_OperationSketchBase::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
49 {
50   std::list<int> aModes;
51   aModes.push_back(TopAbs_VERTEX);
52   aModes.push_back(TopAbs_EDGE);
53   return aModes;
54 }
55 boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature()
56 {
57   boost::shared_ptr<ModelAPI_Feature> aFeature = ModuleBase_Operation::createFeature();
58   emit featureConstructed(aFeature, FM_Activation);
59   return aFeature;
60 }
61
62
63 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
64                                                const std::list<XGUI_ViewerPrs>& theSelected,
65                                                const std::list<XGUI_ViewerPrs>& theHighlighted)
66 {
67 }
68 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
69                                                 const std::list<XGUI_ViewerPrs>& theSelected,
70                                                 const std::list<XGUI_ViewerPrs>& theHighlighted)
71 {
72 }
73 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
74 {
75 }
76
77 void PartSet_OperationSketchBase::keyReleased(const int theKey)
78 {
79   switch (theKey) {
80     case Qt::Key_Escape: {
81       abort();
82     }
83     break;
84     default:
85     break;
86   }
87 }