From: vsv Date: Fri, 28 Nov 2014 14:37:35 +0000 (+0300) Subject: Fix for sketcher abort problem X-Git-Tag: V_0.6.0^2~48 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6e961b67d7ebf0954263766bc07a6c4a2fa2297;p=modules%2Fshaper.git Fix for sketcher abort problem --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 0ab84bf82..44deb41e4 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -56,7 +56,7 @@ //#include //#include //#include -//#include +#include //#include //#include @@ -195,10 +195,15 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) { if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) { + DataPtr aData = myCurrentSketch->data(); + if ((!aData) || (!aData->isValid())) { + // The sketch was aborted + myCurrentSketch = CompositeFeaturePtr(); + return; + } // Hide all sketcher sub-Objects XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); std::list aResults = aFeature->results(); @@ -235,7 +240,7 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation) if (aPoint) { aPnt2dWgt->setPoint(aPoint->x(), aPoint->y()); PartSet_Tools::setConstraints(myCurrentSketch, theOperation->feature(), - SketchPlugin_Line::START_ID(), aPoint->x(), aPoint->y()); + aWgt->attributeID(), aPoint->x(), aPoint->y()); theOperation->propertyPanel()->activateNextWidget(aPnt2dWgt); } } @@ -341,7 +346,6 @@ void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* // This is necessary in order to finalize previous operation QApplication::processEvents(); launchEditing(); - //QTimer::singleShot(10, this, SLOT(launchEditing())); } } } @@ -382,22 +386,34 @@ void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { if (myIsDragging) { + ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); + if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()) + return; // No edit operation activated + + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); Handle(V3d_View) aView = theWnd->v3dView(); gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); double aX, aY; PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY); - double dX = myCurX - aX; - double dY = myCurY - aY; - - ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); - ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); - QList aWidgets = aPanel->modelWidgets(); - foreach(ModuleBase_ModelWidget* aWgt, aWidgets) { - PartSet_WidgetPoint2D* aWgt2d = dynamic_cast(aWgt); - if (aWgt2d) { - aWgt2d->setPoint(aWgt2d->x() - dX, aWgt2d->y() - dY); + double dX = aX - myCurX; + double dY = aY - myCurY; + + std::shared_ptr aSketchFeature = + std::dynamic_pointer_cast(aOperation->feature()); + if (aSketchFeature) { + aSketchFeature->move(dX, dY); + ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + }/* else { // Alternative case for moving + ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); + QList aWidgets = aPanel->modelWidgets(); + foreach(ModuleBase_ModelWidget* aWgt, aWidgets) { + PartSet_WidgetPoint2D* aWgt2d = dynamic_cast(aWgt); + if (aWgt2d) { + aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY); + } } - } + }*/ myDragDone = true; myCurX = aX; myCurY = aY; @@ -430,9 +446,6 @@ void PartSet_Module::onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& t const QList& aWidgets = aPanel->modelWidgets(); if (aWidgets.last() == aPanel->activeWidget()) { breakOperationSequence(); - PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast(aPanel->activeWidget()); - PartSet_Tools::setConstraints(myCurrentSketch, aOperation->feature(), - SketchPlugin_Line::END_ID(), aPnt2dWgt->x(), aPnt2dWgt->y()); } } } diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 70b21db9e..4e73b4b4c 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -231,6 +231,8 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous double aX, aY; PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY); setPoint(aX, aY); + + PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY); emit vertexSelected(aObjects.front(), aShape); QApplication::processEvents(); emit focusOutWidget(this);