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, QObject* theParent)
25 : ModuleBase_Operation(theId, theParent)
29 PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
33 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(FeaturePtr theFeature)
35 boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<
36 SketchPlugin_Feature>(theFeature);
38 ResultPtr aRes = aFeature->firstResult();
39 ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
41 return aBody->shape();
43 return boost::shared_ptr<GeomAPI_Shape>();
46 std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
48 return std::list<FeaturePtr>();
51 std::list<int> PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const
53 std::list<int> aModes;
54 //FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
56 // if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
58 // aModes.push_back(AIS_DSM_Text);
59 // aModes.push_back(AIS_DSM_Line);
63 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
64 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
65 aModes.push_back(AIS_DSM_Text);
66 aModes.push_back(AIS_DSM_Line);
69 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
71 ModuleBase_Operation::createFeature(theFlushMessage);
73 emit featureConstructed(myFeature, FM_Activation);
77 void PartSet_OperationSketchBase::mousePressed(
78 QMouseEvent* theEvent, Handle_V3d_View theView,
79 const std::list<ModuleBase_ViewerPrs>& theSelected,
80 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
83 void PartSet_OperationSketchBase::mouseReleased(
84 QMouseEvent* theEvent, Handle_V3d_View theView,
85 const std::list<ModuleBase_ViewerPrs>& theSelected,
86 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
89 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
92 void PartSet_OperationSketchBase::mouseDoubleClick(
93 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(
106 qApp->activeWindow(), tr("Cancel operation"),
107 tr("Operation %1 will be cancelled. Continue?").arg(id()), QMessageBox::Yes,
109 toAbort = (anAnswer == QMessageBox::Yes);
120 void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* theEvent)
122 keyReleased(theEvent->key());
125 void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
127 FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
129 QStringList aNested = this->nestedFeatures();
130 if (!aNested.isEmpty()) {
131 if (aNested.contains(QString(aFeature->getKind().c_str())))
132 emit launchOperation(theType, theFeature);
137 emit launchOperation(theType, theFeature);