X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationFeatureCreate.cpp;h=d1d5d409b42d33d6fef7bc2c638862227450ed61;hb=47c18d4de2719126f6b045b5c37525cd8f170aa1;hp=fb36405b09dca3ccf9e07c284beddf7526a734ff;hpb=975c481c4d5b3c2def28b6674b9c58e47f25ee95;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index fb36405b0..d1d5d409b 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -6,10 +6,6 @@ #include #include -#include -#include -#include -#include #include #include @@ -21,15 +17,15 @@ #include #include #include +#include #include #include #include -#include -#include +#include +#include -#include #include #include @@ -59,13 +55,14 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate() bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId) { return theId == SKETCH_LINE_KIND || theId == SKETCH_POINT_KIND || - theId == SKETCH_CIRCLE_KIND /*|| - theId == SKETCH_ARC_KIND*/ || + theId == SKETCH_CIRCLE_KIND || + theId == SKETCH_ARC_KIND || theId == SKETCH_CONSTRAINT_DISTANCE_KIND || theId == SKETCH_CONSTRAINT_LENGTH_KIND || theId == SKETCH_CONSTRAINT_RADIUS_KIND || theId == SKETCH_CONSTRAINT_PARALLEL_KIND || - theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND; + theId == SKETCH_CONSTRAINT_PERPENDICULAR_KIND || + theId == SKETCH_CONSTRAINT_COINCIDENCE_KIND; } bool PartSet_OperationFeatureCreate::canBeCommitted() const @@ -86,23 +83,26 @@ std::list PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theF return aModes; } -void PartSet_OperationFeatureCreate::init(FeaturePtr theFeature, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureCreate::initSelection(const std::list& theSelected, + const std::list& /*theHighlighted*/) +{ + myPreSelection = theSelected; +} + +void PartSet_OperationFeatureCreate::initFeature(FeaturePtr theFeature) { - if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND) - return; myInitFeature = theFeature; } + FeaturePtr PartSet_OperationFeatureCreate::sketch() const { return mySketch; } void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& /*theHighlighted*/) + const std::list& theSelected, + const std::list& /*theHighlighted*/) { if (canBeCommitted()) { @@ -113,14 +113,14 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle return; } - double aX, anY; - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); + double aX = aPoint.X(), anY = aPoint.Y(); + if (theSelected.empty()) { PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); } else { - XGUI_ViewerPrs aPrs = theSelected.front(); + ModuleBase_ViewerPrs aPrs = theSelected.front(); const TopoDS_Shape& aShape = aPrs.shape(); if (!aShape.IsNull()) // the point is selected { @@ -139,36 +139,25 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); // move to selected line if (feature()->getKind() == SKETCH_LINE_KIND) { - //boost::shared_ptr aLinePrs = - // boost::dynamic_pointer_cast(myFeaturePrs); - //if (aLinePrs) { - // FeaturePtr aFeature = aPrs.feature(); - //aLinePrs->projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY); - //} + //FeaturePtr aFeature = aPrs.feature(); + //projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY); } } } } - /*if (feature()->getKind() == SKETCH_ARC_KIND) { - boost::shared_ptr anArcPrs = - boost::dynamic_pointer_cast(myFeaturePrs); - if (anArcPrs) { - anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY); - } - }*/ - bool isApplyed = false; - if (isPointWidget()) - isApplyed = setWidgetPoint(aX, anY); - else { - if (!theSelected.empty()) { - XGUI_ViewerPrs aPrs = theSelected.front(); - FeaturePtr aFeature = aPrs.feature(); - if (aFeature) - isApplyed = setWidgetFeature(aFeature); - } + FeaturePtr aFeature; + if (!theSelected.empty()) { + ModuleBase_ViewerPrs aPrs = theSelected.front(); + aFeature = aPrs.feature(); + } + else + aFeature = feature(); // for the widget distance only + + bool isApplyed = setWidgetValue(aFeature, aX, anY); + if (isApplyed) { + flushUpdated(); + emit activateNextWidget(myActiveWidget); } - flushUpdated(); - emit activateNextWidget(myActiveWidget); } void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) @@ -181,16 +170,7 @@ void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3 double aX, anY; gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); - /*if (myPointSelectionMode == SM_ThirdPoint) { - if (feature()->getKind() == SKETCH_ARC_KIND) { - boost::shared_ptr anArcPrs = - boost::dynamic_pointer_cast(myFeaturePrs); - if (anArcPrs) { - anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY); - } - } - }*/ - setWidgetPoint(aX, anY); + setWidgetValue(feature(), aX, anY); flushUpdated(); } } @@ -209,14 +189,21 @@ void PartSet_OperationFeatureCreate::keyReleased(std::string theName, QKeyEvent* void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget) { myActiveWidget = theWidget; - + if ((myPreSelection.size() > 0) && myActiveWidget) { + const ModuleBase_ViewerPrs& aPrs = myPreSelection.front(); + ModuleBase_WidgetValueFeature aValue; + aValue.setFeature(aPrs.feature()); + if (myActiveWidget->setValue(&aValue)) { + myPreSelection.remove(aPrs); + emit activateNextWidget(myActiveWidget); + } + } if (myInitFeature && myActiveWidget) { - // TODO: to be realized in the custom point selector. The last point values of the init feature - // should be to to the start point of a new feature - //myActiveWidget->init(myInitFeature); - //PartSet_FeatureLinePrs::setFeature(myInitFeature, SM_FirstPoint); - myInitFeature = FeaturePtr(); - emit activateNextWidget(myActiveWidget); + ModuleBase_WidgetPoint2D* aWgt = dynamic_cast(myActiveWidget); + if (aWgt && aWgt->initFromPrevious(myInitFeature)) { + myInitFeature = FeaturePtr(); + emit activateNextWidget(myActiveWidget); + } } } @@ -291,46 +278,14 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess return aNewFeature; } -/*void PartSet_OperationFeatureCreate::setPointSelectionMode(const PartSet_SelectionMode& theMode, - const bool isToEmitSignal) -{ - myPointSelectionMode = theMode; - if (isToEmitSignal) { - std::string aName = myFeaturePrs->getAttribute(theMode); - if (aName.empty() && theMode == SM_DonePoint) { - aName = XGUI::PROP_PANEL_OK; - } - emit focusActivated(aName); - } -}*/ - -bool PartSet_OperationFeatureCreate::isPointWidget() const -{ - return dynamic_cast(myActiveWidget); -} - -bool PartSet_OperationFeatureCreate::setWidgetPoint(double theX, double theY) -{ - boost::shared_ptr aPoint(new GeomAPI_Pnt2d(theX, theY)); - ModuleBase_WidgetPoint2D* aWidget = dynamic_cast(myActiveWidget); - if (aWidget) { - aWidget->setPoint(aPoint); - return true; - } else { - ModuleBase_WidgetPoint2dDistance* aWgt = dynamic_cast(myActiveWidget); - if (aWgt) { - aWgt->setPoint(feature(), aPoint); - return true; - } - } - return false; -} - -bool PartSet_OperationFeatureCreate::setWidgetFeature(const FeaturePtr& theFeature) +bool PartSet_OperationFeatureCreate::setWidgetValue(FeaturePtr theFeature, double theX, double theY) { - ModuleBase_WidgetFeature* aWidget = dynamic_cast(myActiveWidget); - if (!aWidget) - return false; - - return aWidget->setFeature(theFeature); + ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature(); + aValue->setFeature(theFeature); + aValue->setPoint(boost::shared_ptr(new GeomAPI_Pnt2d(theX, theY))); + bool isApplyed = myActiveWidget->setValue(aValue); + + delete aValue; + myIsModified = (myIsModified || isApplyed); + return isApplyed; }