X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationSketch.cpp;h=e5290aa77eb9bc3cbd86ec285cb4b6afdf623019;hb=1d7a043abfadf964bf38802e8adb5a4773fec900;hp=b583c1e808eabb794953ee6385b88525504316fe;hpb=55e582d99100282870295dcf5373c329866b75bb;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index b583c1e80..e5290aa77 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -4,25 +4,34 @@ #include +#include +#include + #include + #include #include #include #include #include +#include + #include #include +#include #ifdef _DEBUG #include #endif +#include + using namespace std; PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId, QObject* theParent) -: PartSet_OperationSketchBase(theId, theParent) +: PartSet_OperationSketchBase(theId, theParent), myIsEditMode(false) { } @@ -30,26 +39,54 @@ PartSet_OperationSketch::~PartSet_OperationSketch() { } -int PartSet_OperationSketch::getSelectionMode(boost::shared_ptr theFeature) const +std::list PartSet_OperationSketch::getSelectionModes(boost::shared_ptr theFeature) const +{ + std::list aModes; + if (!myIsEditMode) + aModes.push_back(TopAbs_FACE); + else { + aModes.push_back(TopAbs_VERTEX); + aModes.push_back(TopAbs_EDGE); + } + return aModes; +} + +void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected) { - int aMode = TopAbs_FACE; - if (isEditMode()) - aMode = TopAbs_VERTEX; - return aMode; + if (theSelected.empty()) + return; + + if (!myIsEditMode) { + XGUI_ViewerPrs aPrs = theSelected.front(); + const TopoDS_Shape& aShape = aPrs.shape(); + if (!aShape.IsNull()) { + setSketchPlane(aShape); + myIsEditMode = true; + } + } } -void PartSet_OperationSketch::setSelectedShapes(const NCollection_List& theList) +void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected) { - if (theList.IsEmpty()) + if (!myIsEditMode || !(theEvent->buttons() & Qt::LeftButton) || theSelected.empty()) return; - if (isEditMode()) + boost::shared_ptr aFeature = PartSet_Tools::NearestFeature(theEvent->pos(), + theView, feature(), theSelected); + if (aFeature) + emit launchOperation(PartSet_OperationEditLine::Type(), aFeature); +} + +void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) +{ + if (theShape.IsNull()) return; // get selected shape - const TopoDS_Shape& aShape = theList.First(); boost::shared_ptr aGShape(new GeomAPI_Shape); - aGShape->setImpl(new TopoDS_Shape(aShape)); + aGShape->setImpl(new TopoDS_Shape(theShape)); // get plane parameters boost::shared_ptr aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape); @@ -79,10 +116,6 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List aDirY = boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_DIRY)); aDirY->setValue(aC, anA, aB); - boost::shared_ptr aDir = aPlane->direction(); emit planeSelected(aDir->x(), aDir->y(), aDir->z()); - - //commit(); - //SketchPlugin_Sketch::setActive(myFeature); }