X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationFeatureEditMulti.cpp;h=cd0de892541cc01ab7374816c9431d9f165cf55a;hb=02bc870879ae19215d5ef6f721acd5b12d245473;hp=e5feef62d5a40f3a02fa2435625a4311793d7078;hpb=12621bb509825d0eb1fb0847a7f9c8011021ca5a;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index e5feef62d..cd0de8925 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -7,9 +7,9 @@ #include #include -#include +#include -#include +#include #include #include @@ -33,9 +33,11 @@ using namespace std; PartSet_OperationFeatureEditMulti::PartSet_OperationFeatureEditMulti(const QString& theId, - QObject* theParent, - FeaturePtr theFeature) -: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false) + QObject* theParent, + FeaturePtr theFeature) + : PartSet_OperationSketchBase(theId, theParent), + mySketch(theFeature), + myIsBlockedSelection(false) { } @@ -43,13 +45,10 @@ PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti() { } -bool PartSet_OperationFeatureEditMulti::isGranted(ModuleBase_IOperation* theOperation) const -{ - return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); -} -void PartSet_OperationFeatureEditMulti::initSelection(const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationFeatureEditMulti::initSelection( + const std::list& theSelected, + const std::list& theHighlighted) { if (!theHighlighted.empty()) { // if there is highlighted object, we check whether it is in the list of selected objects @@ -57,16 +56,16 @@ void PartSet_OperationFeatureEditMulti::initSelection(const std::list::const_iterator anIt = theSelected.begin(), aLast = theSelected.end(); + std::list::const_iterator anIt = theSelected.begin(), aLast = theSelected + .end(); for (; anIt != aLast && !isSelected; anIt++) { - isSelected = (*anIt).feature() == feature(); + isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature(); } if (!isSelected) myFeatures = theHighlighted; else myFeatures = theSelected; - } - else + } else myFeatures = theSelected; } @@ -80,15 +79,16 @@ FeaturePtr PartSet_OperationFeatureEditMulti::sketch() const return mySketch; } -void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& theHighlighted) +void PartSet_OperationFeatureEditMulti::mousePressed( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& /*theSelected*/, + const std::list& theHighlighted) { } void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { - if (!(theEvent->buttons() & Qt::LeftButton)) + if (!(theEvent->buttons() & Qt::LeftButton)) return; gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); @@ -104,17 +104,22 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; - boost::shared_ptr aSketchFeature = - boost::dynamic_pointer_cast(feature()); + boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(feature()); aSketchFeature->move(aDeltaX, aDeltaY); - std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); + std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures + .end(); for (; anIt != aLast; anIt++) { - FeaturePtr aFeature = (*anIt).feature(); - if (!aFeature || aFeature == feature()) + ObjectPtr aObject = (*anIt).object(); + if (!aObject || aObject == feature()) continue; - aSketchFeature = boost::dynamic_pointer_cast(aFeature); - aSketchFeature->move(aDeltaX, aDeltaY); + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (aFeature) { + aSketchFeature = boost::dynamic_pointer_cast(aFeature); + if (aSketchFeature) + aSketchFeature->move(aDeltaX, aDeltaY); + } } } sendFeatures(); @@ -122,18 +127,21 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle myCurPoint.setPoint(aPoint); } -void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureEditMulti::mouseReleased( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& /*theSelected*/, + const std::list& /*theHighlighted*/) { - std::list aFeatures = myFeatures; - commit(); - std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); - for (; anIt != aLast; anIt++) { - FeaturePtr aFeature = (*anIt).feature(); - if (aFeature) { - emit featureConstructed(aFeature, FM_Deactivation); - } + if (commit()) { + std::list aFeatures = myFeatures; + std::list::const_iterator anIt = aFeatures.begin(), aLast = + aFeatures.end(); + for (; anIt != aLast; anIt++) { + ObjectPtr aFeature = (*anIt).object(); + if (aFeature) { + emit featureConstructed(aFeature, FM_Deactivation); + } + } } } @@ -156,22 +164,22 @@ void PartSet_OperationFeatureEditMulti::stopOperation() myFeatures.clear(); } -void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const bool isRestoreSelection) +void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, + const bool isRestoreSelection) { if (myIsBlockedSelection == isBlocked) return; myIsBlockedSelection = isBlocked; - QFeatureList aFeatureList; - std::list::const_iterator anIt = myFeatures.begin(), - aLast = myFeatures.end(); - for(; anIt != aLast; anIt++) - aFeatureList.append((*anIt).feature()); + QList aFeatureList; + std::list::const_iterator anIt = myFeatures.begin(), aLast = + myFeatures.end(); + /*for(; anIt != aLast; anIt++) + aFeatureList.append((*anIt).feature());*/ if (isBlocked) { - emit setSelection(QFeatureList()); + emit setSelection(QList()); emit stopSelection(aFeatureList, true); - } - else { + } else { emit stopSelection(aFeatureList, false); if (isRestoreSelection) { emit setSelection(aFeatureList); @@ -181,12 +189,13 @@ void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const boo void PartSet_OperationFeatureEditMulti::sendFeatures() { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); - std::list aFeatures; - std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); + std::list aFeatures; + std::list::const_iterator anIt = myFeatures.begin(), aLast = + myFeatures.end(); for (; anIt != aLast; anIt++) { - FeaturePtr aFeature = (*anIt).feature(); + ObjectPtr aFeature = (*anIt).object(); if (!aFeature) continue;