]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationSketchBase.cpp
Salome HOME
37b92f35d62b26093b8329f78f2d68b96797b8f1
[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::preview() 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   if (aFeature)
59     emit featureConstructed(aFeature, FM_Activation);
60   return aFeature;
61 }
62
63
64 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
65                                                const std::list<XGUI_ViewerPrs>& theSelected)
66 {
67 }
68 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
69                                                 const std::list<XGUI_ViewerPrs>& theSelected)
70 {
71 }
72 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
73 {
74 }
75
76 void PartSet_OperationSketchBase::keyReleased(const int theKey)
77 {
78   switch (theKey) {
79     case Qt::Key_Escape: {
80       abort();
81     }
82     break;
83     default:
84     break;
85   }
86 }