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 <ModuleBase_IPropertyPanel.h>
10 #include <ModuleBase_ModelWidget.h>
11 #include <ModuleBase_WidgetValueFeature.h>
13 #include <SketchPlugin_Feature.h>
14 #include <V3d_View.hxx>
15 #include <AIS_Shape.hxx>
16 #include <AIS_DimensionSelectionMode.hxx>
19 #include <QMessageBox>
20 #include <QApplication>
28 PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent)
29 : ModuleBase_Operation(theId, theParent)
33 PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
37 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(FeaturePtr theFeature)
39 boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<
40 SketchPlugin_Feature>(theFeature);
42 ResultPtr aRes = aFeature->firstResult();
43 ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
45 return aBody->shape();
47 return boost::shared_ptr<GeomAPI_Shape>();
50 std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
52 return std::list<FeaturePtr>();
55 std::list<int> PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const
57 //TODO: Define position of selection modes definition
58 std::list<int> aModes;
59 FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
60 if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
61 aModes.push_back(AIS_DSM_Text);
62 aModes.push_back(AIS_DSM_Line);
64 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
65 aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
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::restartOperation(const std::string& theType, ObjectPtr theFeature)
101 FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
103 QStringList aNested = this->nestedFeatures();
104 if (!aNested.isEmpty()) {
105 if (!aNested.contains(QString(aFeature->getKind().c_str())))
109 emit restartRequired(theType, theFeature);
114 void PartSet_OperationSketchBase::activateByPreselection()
116 if (!myPropertyPanel)
118 ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
119 if ((myPreSelection.size() > 0) && aActiveWgt) {
120 const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
121 ModuleBase_WidgetValueFeature aValue;
122 aValue.setObject(aPrs.object());
123 if (aActiveWgt->setValue(&aValue)) {
124 myPreSelection.remove(aPrs);
126 //myActiveWidget = NULL;
129 myPropertyPanel->activateNextWidget();
130 //emit activateNextWidget(myActiveWidget);
133 // If preselection is enough to make a valid feature - apply it immediately