X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationSketch.cpp;h=e57a113b73ebc39cc1a6cd82a708afc48c8c795d;hb=ad247cf594a7a560b656c70c96e1b1a360b8c1c3;hp=e5290aa77eb9bc3cbd86ec285cb4b6afdf623019;hpb=1d7a043abfadf964bf38802e8adb5a4773fec900;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index e5290aa77..e57a113b7 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include #include @@ -44,39 +46,80 @@ std::list PartSet_OperationSketch::getSelectionModes(boost::shared_ptr aModes; if (!myIsEditMode) aModes.push_back(TopAbs_FACE); - else { - aModes.push_back(TopAbs_VERTEX); - aModes.push_back(TopAbs_EDGE); - } + else + aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature); return aModes; } -void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected) +boost::shared_ptr PartSet_OperationSketch::sketch() const { - if (theSelected.empty()) - return; + return feature(); +} +void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& /*theSelected*/, + const std::list& theHighlighted) +{ if (!myIsEditMode) { - XGUI_ViewerPrs aPrs = theSelected.front(); + XGUI_ViewerPrs aPrs = theHighlighted.front(); const TopoDS_Shape& aShape = aPrs.shape(); if (!aShape.IsNull()) { setSketchPlane(aShape); myIsEditMode = true; } } + else { + if (theHighlighted.size() == 1) { + boost::shared_ptr aFeature = theHighlighted.front().feature(); + if (aFeature) + emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); + } + else + myFeatures = theHighlighted; + } } -void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected) +void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { - if (!myIsEditMode || !(theEvent->buttons() & Qt::LeftButton) || theSelected.empty()) + if (!myIsEditMode || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty()) return; - boost::shared_ptr aFeature = PartSet_Tools::NearestFeature(theEvent->pos(), - theView, feature(), theSelected); - if (aFeature) - emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); + if (myFeatures.size() != 1) { + boost::shared_ptr aFeature = PartSet_Tools::NearestFeature(theEvent->pos(), + theView, feature(), myFeatures); + if (aFeature) + emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); + } +} + +std::map, boost::shared_ptr > + PartSet_OperationSketch::subPreview() const +{ + std::map, boost::shared_ptr > aPreviewMap; + + boost::shared_ptr aFeature; + + boost::shared_ptr aData = feature()->data(); + boost::shared_ptr aRefList = + boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_FEATURES)); + + std::list > aFeatures = aRefList->list(); + std::list >::const_iterator anIt = aFeatures.begin(), + aLast = aFeatures.end(); + for (; anIt != aLast; anIt++) { + aFeature = boost::dynamic_pointer_cast(*anIt); + boost::shared_ptr aPreview = aFeature->preview(); + if (aPreview) + aPreviewMap[aFeature] = aPreview; + } + return aPreviewMap; +} + +void PartSet_OperationSketch::stopOperation() +{ + PartSet_OperationSketchBase::stopOperation(); + emit featureConstructed(feature(), FM_Hide); + emit closeLocalContext(); } void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) @@ -117,5 +160,10 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_DIRY)); aDirY->setValue(aC, anA, aB); boost::shared_ptr aDir = aPlane->direction(); + + flushUpdated(); + + emit featureConstructed(feature(), FM_Hide); + emit closeLocalContext(); emit planeSelected(aDir->x(), aDir->y(), aDir->z()); }