X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationSketchBase.cpp;h=e8f081e4d581d19beab5a3cf4f46dc48dd91e42d;hb=e30796dab1aa68c01201b2b89d4292d3fcbbc4d4;hp=dd66393219a8f95dafba59a4bb06944551b843fb;hpb=11496be069750941ff9cbcef21088a56bfd32cdf;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index dd6639321..e8f081e4d 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -20,9 +21,8 @@ using namespace std; -PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, - QObject* theParent) -: ModuleBase_Operation(theId, theParent) +PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent) + : ModuleBase_Operation(theId, theParent) { } @@ -30,14 +30,17 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase() { } -boost::shared_ptr PartSet_OperationSketchBase::preview( - FeaturePtr theFeature) +boost::shared_ptr PartSet_OperationSketchBase::preview(FeaturePtr theFeature) { - boost::shared_ptr aFeature = - boost::dynamic_pointer_cast(theFeature); - if (!aFeature) - return boost::shared_ptr(); - return aFeature->preview(); + boost::shared_ptr aFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(theFeature); + if (aFeature) { + ResultPtr aRes = aFeature->firstResult(); + ResultBodyPtr aBody = boost::dynamic_pointer_cast(aRes); + if (aBody) + return aBody->shape(); + } + return boost::shared_ptr(); } std::list PartSet_OperationSketchBase::subFeatures() const @@ -45,75 +48,59 @@ std::list PartSet_OperationSketchBase::subFeatures() const return std::list(); } -std::list PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const +std::list PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const { + //TODO: Define position of selection modes definition std::list aModes; - if (PartSet_Tools::isConstraintFeature(theFeature->getKind())) { - aModes.clear(); - aModes.push_back(AIS_DSM_Text); - aModes.push_back(AIS_DSM_Line); - } - else { - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX)); - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE)); + FeaturePtr aFeature = boost::dynamic_pointer_cast(theFeature); + if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind())) { + aModes.push_back(AIS_DSM_Text); + aModes.push_back(AIS_DSM_Line); + } else { + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX)); + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE)); } return aModes; } FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) { - FeaturePtr aFeature = ModuleBase_Operation::createFeature(theFlushMessage); - if (aFeature) - emit featureConstructed(aFeature, FM_Activation); - return aFeature; + ModuleBase_Operation::createFeature(theFlushMessage); + if (myFeature) + emit featureConstructed(myFeature, FM_Activation); + return myFeature; } - -void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketchBase::mousePressed( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } -void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketchBase::mouseReleased( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { } -void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketchBase::mouseDoubleClick( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } -void PartSet_OperationSketchBase::keyReleased(const int theKey) +void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature) { - switch (theKey) { - case Qt::Key_Escape: { - bool toAbort = true; - if (isModified()) { - int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Cancel operation"), - tr("Operation %1 will be cancelled. Continue?").arg(id()), - QMessageBox::Yes, QMessageBox::No); - toAbort = (anAnswer == QMessageBox::Yes); - } - if (toAbort) - abort(); + FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature); + if (aFeature) { + QStringList aNested = this->nestedFeatures(); + if (!aNested.isEmpty()) { + if (!aNested.contains(QString(aFeature->getKind().c_str()))) + return; } - break; - default: - break; } -} - -void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* theEvent) -{ - keyReleased(theEvent->key()); -} - -void PartSet_OperationSketchBase::restartOperation(const std::string& theType, - FeaturePtr theFeature) -{ - emit launchOperation(theType, theFeature); + emit restartRequired(theType, theFeature); }