X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPartSet%2FPartSet_OperationFeatureEditMulti.cpp;h=4b10858a0bc40ff31371022d816479a616c610e3;hb=9c037e806d4fb7a1c6129713020962a2e6f52411;hp=cd0de892541cc01ab7374816c9431d9f165cf55a;hpb=853952fd4ddc93c0cd6a7122d37b618199864396;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index cd0de8925..4b10858a0 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include #include @@ -24,21 +26,21 @@ #include +#include #ifdef _DEBUG #include #endif -#include - -using namespace std; +//using namespace std; PartSet_OperationFeatureEditMulti::PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent, - FeaturePtr theFeature) + CompositeFeaturePtr theFeature) : PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false) { + myIsEditing = true; } PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti() @@ -46,60 +48,78 @@ PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti() } -void PartSet_OperationFeatureEditMulti::initSelection( - const std::list& theSelected, - const std::list& theHighlighted) +bool isContains(const QList& theSelected, const ModuleBase_ViewerPrs& thePrs) { - if (!theHighlighted.empty()) { - // if there is highlighted object, we check whether it is in the list of selected objects - // in that case this object is a handle of the moved lines. If there no such object in the selection, - // the hightlighted object should moved and the selection is skipped. The skipped selection will be - // deselected in the viewer by blockSelection signal in the startOperation method. - bool isSelected = false; - std::list::const_iterator anIt = theSelected.begin(), aLast = theSelected - .end(); - for (; anIt != aLast && !isSelected; anIt++) { - isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature(); - } - if (!isSelected) - myFeatures = theHighlighted; - else - myFeatures = theSelected; - } else - myFeatures = theSelected; + foreach (ModuleBase_ViewerPrs aPrs, theSelected) { + if (aPrs.object() == thePrs.object()) + return true; + } + return false; } -void PartSet_OperationFeatureEditMulti::initFeature(FeaturePtr theFeature) + +void PartSet_OperationFeatureEditMulti::initSelection(ModuleBase_ISelection* theSelection) { - setEditingFeature(theFeature); + //if (!theHighlighted.empty()) { + // // if there is highlighted object, we check whether it is in the list of selected objects + // // in that case this object is a handle of the moved lines. If there no such object in the selection, + // // the hightlighted object should moved and the selection is skipped. The skipped selection will be + // // deselected in the viewer by blockSelection signal in the startOperation method. + // bool isSelected = false; + // std::list::const_iterator anIt = theSelected.begin(), + // aLast = theSelected.end(); + // for (; anIt != aLast && !isSelected; anIt++) { + // isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature(); + // } + // if (!isSelected) + // myFeatures = theHighlighted; + // else + // myFeatures = theSelected; + //} else + myFeatures = theSelection->getSelected(); + QList aHighlighted = theSelection->getHighlighted(); + // add highlighted elements if they are not selected + foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) { + if (!isContains(myFeatures, aPrs)) + myFeatures.append(aPrs); + } + // Remove current feature if it is in the list (it will be moved as main feature) + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + FeaturePtr aF = ModelAPI_Feature::feature(aPrs.object()); + if (ModelAPI_Feature::feature(aPrs.object()) == feature()) { + myFeatures.removeOne(aPrs); + break; + } + } } -FeaturePtr PartSet_OperationFeatureEditMulti::sketch() const +CompositeFeaturePtr 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, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection) +//{ +//} -void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) +void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer) { if (!(theEvent->buttons() & Qt::LeftButton)) return; - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); + if (theViewer->isSelectionEnabled()) + theViewer->enableSelection(false); + + Handle(V3d_View) aView = theViewer->activeView(); + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); - blockSelection(true); + //blockSelection(true); if (myCurPoint.myIsInitialized) { double aCurX, aCurY; - PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY); + PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), aView, aCurX, aCurY); double aX, anY; - PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY); double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; @@ -108,10 +128,8 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle SketchPlugin_Feature>(feature()); aSketchFeature->move(aDeltaX, aDeltaY); - std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures - .end(); - for (; anIt != aLast; anIt++) { - ObjectPtr aObject = (*anIt).object(); + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + ObjectPtr aObject = aPrs.object(); if (!aObject || aObject == feature()) continue; FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); @@ -128,16 +146,13 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle } void PartSet_OperationFeatureEditMulti::mouseReleased( - QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) + QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, + ModuleBase_ISelection* theSelection) { + theViewer->enableSelection(true); if (commit()) { - std::list aFeatures = myFeatures; - std::list::const_iterator anIt = aFeatures.begin(), aLast = - aFeatures.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr aFeature = (*anIt).object(); + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + ObjectPtr aFeature = aPrs.object(); if (aFeature) { emit featureConstructed(aFeature, FM_Deactivation); } @@ -148,54 +163,51 @@ void PartSet_OperationFeatureEditMulti::mouseReleased( void PartSet_OperationFeatureEditMulti::startOperation() { PartSet_OperationSketchBase::startOperation(); - emit multiSelectionEnabled(false); + //emit multiSelectionEnabled(false); - blockSelection(true); + //blockSelection(true); myCurPoint.clear(); } void PartSet_OperationFeatureEditMulti::stopOperation() { - emit multiSelectionEnabled(true); + //emit multiSelectionEnabled(true); - blockSelection(false, true); + //blockSelection(false, true); myFeatures.clear(); } -void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, - const bool isRestoreSelection) -{ - if (myIsBlockedSelection == isBlocked) - return; - - myIsBlockedSelection = isBlocked; - QList aFeatureList; - std::list::const_iterator anIt = myFeatures.begin(), aLast = - myFeatures.end(); - /*for(; anIt != aLast; anIt++) - aFeatureList.append((*anIt).feature());*/ - if (isBlocked) { - emit setSelection(QList()); - emit stopSelection(aFeatureList, true); - } else { - emit stopSelection(aFeatureList, false); - if (isRestoreSelection) { - emit setSelection(aFeatureList); - } - } -} +//void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, +// const bool isRestoreSelection) +//{ +// if (myIsBlockedSelection == isBlocked) +// return; +// +// myIsBlockedSelection = isBlocked; +// QList aFeatureList; +//// std::list::const_iterator anIt = myFeatures.begin(), aLast = +//// myFeatures.end(); +// /*for(; anIt != aLast; anIt++) +// aFeatureList.append((*anIt).feature());*/ +// //if (isBlocked) { +// // emit setSelection(QList()); +// // emit stopSelection(aFeatureList, true); +// //} else { +// // emit stopSelection(aFeatureList, false); +// // if (isRestoreSelection) { +// // emit setSelection(aFeatureList); +// // } +// //} +//} void PartSet_OperationFeatureEditMulti::sendFeatures() { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); - std::list aFeatures; - std::list::const_iterator anIt = myFeatures.begin(), aLast = - myFeatures.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr aFeature = (*anIt).object(); + foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { + ObjectPtr aFeature = aPrs.object(); if (!aFeature) continue;