X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationFeatureEdit.cpp;h=2036d55760d69e3bf540dd47eef848aafea8f1a8;hb=5886d3bb6adb74533e2dbac1bcb0addcad68014a;hp=5b107d34dcba5b93336278c02222f8f04c450558;hpb=bcadd40668f422db6c5ade201ac630052db91da9;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 5b107d34d..2036d5576 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -16,9 +16,9 @@ #include #include + #include #include - #include #include @@ -38,9 +38,10 @@ using namespace std; PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId, - QObject* theParent, - FeaturePtr theFeature) -: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false) + QObject* theParent, + FeaturePtr theFeature) + : PartSet_OperationFeatureBase(theId, theParent, theFeature), + myIsBlockedSelection(false) { } @@ -48,60 +49,54 @@ PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit() { } -bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation) const -{ - return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); -} - -std::list PartSet_OperationFeatureEdit::getSelectionModes(FeaturePtr theFeature) const -{ - return PartSet_OperationSketchBase::getSelectionModes(theFeature); -} - void PartSet_OperationFeatureEdit::initFeature(FeaturePtr theFeature) { setEditingFeature(theFeature); } - -FeaturePtr PartSet_OperationFeatureEdit::sketch() const -{ - return mySketch; -} - void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& theHighlighted) + const std::list& theSelected, + const std::list& theHighlighted) { - ObjectPtr aFeature; + if(myActiveWidget && myActiveWidget->isViewerSelector()) { + // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased + PartSet_OperationFeatureBase::mousePressed(theEvent, theView, theSelected, theHighlighted); + return; + } + ObjectPtr aObject; if (!theHighlighted.empty()) - aFeature = theHighlighted.front().object(); - if (!aFeature && !theSelected.empty()) // changed for a constrain - aFeature = theSelected.front().object(); - // TODO - /*if (!aFeature || aFeature != feature()) - { - commit(); - emit featureConstructed(feature(), FM_Deactivation); - - bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - if(aHasShift && !theHighlighted.empty()) { - QResultList aSelected; - // TODO - aSelected.push_back(feature()); - aSelected.push_back(theHighlighted.front().result()); - emit setSelection(aSelected); - } - // TODO - else if (aFeature) { - restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); + aObject = theHighlighted.front().object(); + if (!aObject && !theSelected.empty()) // changed for a constrain + aObject = theSelected.front().object(); + + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (!aFeature || aFeature != feature()) { + if (commit()) { + emit featureConstructed(feature(), FM_Deactivation); + + bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); + if (aHasShift && !theHighlighted.empty()) { + QList aSelected; + std::list::const_iterator aIt; + for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt) + aSelected.append((*aIt).object()); + /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) { + if (!aSelected.contains((*aIt).object())) + aSelected.append((*aIt).object()); + }*/ + //aSelected.push_back(feature()); + //aSelected.push_back(theHighlighted.front().object()); + emit setSelection(aSelected); + } else if (aFeature) { + restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); + } } - }*/ + } } void PartSet_OperationFeatureEdit::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); @@ -117,34 +112,45 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_ 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); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); + ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent); } sendFeatures(); myCurPoint.setPoint(aPoint); } -void PartSet_OperationFeatureEdit::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureEdit::mouseReleased( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected, + const std::list& theHighlighted) { - blockSelection(false); + if(myActiveWidget && myActiveWidget->isViewerSelector()) { + // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased + PartSet_OperationFeatureBase::mouseReleased(theEvent, theView, theSelected, theHighlighted); + } else { + blockSelection(false); + } } -void PartSet_OperationFeatureEdit::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationFeatureEdit::mouseDoubleClick( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { // TODO the functionality is important only for constraint feature. Should be moved in another place if (!theSelected.empty()) { ModuleBase_ViewerPrs aFeaturePrs = theSelected.front(); if (!aFeaturePrs.owner().IsNull()) { - Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aFeaturePrs.owner()); + Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast( + aFeaturePrs.owner()); if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) { bool isValid; - double aValue = PartSet_Tools::featureValue(feature(), SketchPlugin_Constraint::VALUE(), isValid); + double aValue = PartSet_Tools::featureValue(feature(), SketchPlugin_Constraint::VALUE(), + isValid); if (isValid) { ModuleBase_WidgetEditor::editFeatureValue(feature(), SketchPlugin_Constraint::VALUE()); flushUpdated(); @@ -175,14 +181,13 @@ void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isR return; myIsBlockedSelection = isBlocked; - QFeatureList aFeatureList; + QList aFeatureList; aFeatureList.append(feature()); if (isBlocked) { - emit setSelection(QFeatureList()); + emit setSelection(QList()); emit stopSelection(aFeatureList, true); - } - else { + } else { emit stopSelection(aFeatureList, false); if (isRestoreSelection) emit setSelection(aFeatureList);