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 //TODO: Define position of selection modes definition
54 std::list<int> aModes;
55 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
56 if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
57 aModes.push_back(AIS_DSM_Text);
58 aModes.push_back(AIS_DSM_Line);
60 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
61 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
65 FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
67 ModuleBase_Operation::createFeature(theFlushMessage);
69 emit featureConstructed(myFeature, FM_Activation);
73 void PartSet_OperationSketchBase::mousePressed(
74 QMouseEvent* theEvent, Handle_V3d_View theView,
75 const std::list<ModuleBase_ViewerPrs>& theSelected,
76 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
79 void PartSet_OperationSketchBase::mouseReleased(
80 QMouseEvent* theEvent, Handle_V3d_View theView,
81 const std::list<ModuleBase_ViewerPrs>& theSelected,
82 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
85 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
88 void PartSet_OperationSketchBase::mouseDoubleClick(
89 QMouseEvent* theEvent, Handle_V3d_View theView,
90 const std::list<ModuleBase_ViewerPrs>& theSelected,
91 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
95 void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
97 FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
99 QStringList aNested = this->nestedFeatures();
100 if (!aNested.isEmpty()) {
101 if (aNested.contains(QString(aFeature->getKind().c_str())))
102 emit restartRequired(theType, theFeature);
107 emit restartRequired(theType, theFeature);