X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationFeatureEdit.cpp;h=16e2b44370ae89345e43b8faf42c09064ad472c9;hb=29083ee3765ce3f564eb4fa6c93620084acfb067;hp=7975baa652d223a39a1765023498965bc8b29277;hpb=cb9afcaeb3a576dcc428d4fe1741be99347ed486;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 7975baa65..16e2b4437 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -11,14 +11,15 @@ #include #include #include +#include #include #include #include + #include #include - #include #include @@ -38,66 +39,64 @@ using namespace std; PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId, - QObject* theParent, - FeaturePtr theFeature) -: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false) + QObject* theParent, + CompositeFeaturePtr theFeature) + : PartSet_OperationFeatureBase(theId, theParent, theFeature), + myIsBlockedSelection(false) { + myIsEditing = true; } 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(ObjectPtr 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; + ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); + if(aActiveWgt && aActiveWgt->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(); + 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()) { - commit(); - emit featureConstructed(feature(), FM_Deactivation); - - bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - if(aHasShift && !theHighlighted.empty()) { - QList aSelected; - aSelected.push_back(feature()); - aSelected.push_back(theHighlighted.front().object()); - emit setSelection(aSelected); - } - else if (aFeature) { - restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); + 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); @@ -113,34 +112,51 @@ 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()); - aSketchFeature->move(aDeltaX, aDeltaY); + boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(feature()); + // MPV: added condition because it could be external edge of some object, not sketch + if (aSketchFeature && aSketchFeature->sketch() == sketch().get()) { + 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); + ModuleBase_ModelWidget* aActiveWgt = 0; + if (myPropertyPanel) + aActiveWgt = myPropertyPanel->activeWidget(); + if(aActiveWgt && aActiveWgt->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(); @@ -177,15 +193,15 @@ void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isR if (isBlocked) { emit setSelection(QList()); emit stopSelection(aFeatureList, true); - } - else { + } else { emit stopSelection(aFeatureList, false); if (isRestoreSelection) emit setSelection(aFeatureList); } } -FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool /*theFlushMessage*/) +FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool theFlushMessage, + CompositeFeaturePtr theCompositeFeature) { // do nothing in order to do not create a new feature return FeaturePtr();