1 // File: PartSet_OperationSketchBase.cpp
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_OperationSketchBase.h>
6 #include <PartSet_Tools.h>
7 #include <ModelAPI_ResultBody.h>
9 #include <SketchPlugin_Feature.h>
10 #include <V3d_View.hxx>
11 #include <AIS_Shape.hxx>
12 #include <AIS_DimensionSelectionMode.hxx>
15 #include <QMessageBox>
16 #include <QApplication>
24 PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
26 : ModuleBase_Operation(theId, theParent)
30 PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
34 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
35 FeaturePtr theFeature)
37 boost::shared_ptr<SketchPlugin_Feature> aFeature =
38 boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
40 ResultPtr aRes = aFeature->firstResult();
41 ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
43 return aBody->shape();
45 return boost::shared_ptr<GeomAPI_Shape>();
48 std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
50 return std::list<FeaturePtr>();
53 std::list<int> PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const
55 std::list<int> aModes;
56 //FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
58 // if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
60 // aModes.push_back(AIS_DSM_Text);
61 // aModes.push_back(AIS_DSM_Line);
65 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX));
66 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE));
67 aModes.push_back(AIS_DSM_Text);
68 aModes.push_back(AIS_DSM_Line);
71 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
73 ModuleBase_Operation::createFeature(theFlushMessage);
75 emit featureConstructed(myFeature, FM_Activation);
80 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
81 const std::list<ModuleBase_ViewerPrs>& theSelected,
82 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
85 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
86 const std::list<ModuleBase_ViewerPrs>& theSelected,
87 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
90 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
93 void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
94 const std::list<ModuleBase_ViewerPrs>& theSelected,
95 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
99 void PartSet_OperationSketchBase::keyReleased(const int theKey)
102 case Qt::Key_Escape: {
105 int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Cancel operation"),
106 tr("Operation %1 will be cancelled. Continue?").arg(id()),
107 QMessageBox::Yes, QMessageBox::No);
108 toAbort = (anAnswer == QMessageBox::Yes);
119 void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* theEvent)
121 keyReleased(theEvent->key());
124 void PartSet_OperationSketchBase::restartOperation(const std::string& theType,
125 ObjectPtr theFeature)
127 emit launchOperation(theType, theFeature);