From: azv Date: Fri, 5 May 2017 07:16:15 +0000 (+0300) Subject: Task 2.4. Ability to modify the radius of circles and arcs of circle with the mouse X-Git-Tag: V_2.7.1.1~3^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3cc30e50fe4846a7e32b0047f91b9df8422c3040;p=modules%2Fshaper.git Task 2.4. Ability to modify the radius of circles and arcs of circle with the mouse Code cleanup and debug of features movement. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index b086cd628..88172984e 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -399,7 +399,6 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject) } } -#ifndef SUPPORT_NEW_MOVE void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) { //blockUpdateViewer(true); @@ -407,13 +406,12 @@ void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) qDebug("ModuleBase_ModelWidget::moveObject"); #endif - static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent); Events_Loop::loop()->flush(anEvent); //blockUpdateViewer(false); } -#endif bool ModuleBase_ModelWidget::processEnter() { diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index b13d90aeb..0b409e6fe 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -235,12 +235,10 @@ Q_OBJECT /// \param theObj is updating object void updateObject(ObjectPtr theObj); -#ifndef SUPPORT_NEW_MOVE /// Sends Move event for the given object /// \param theObj is object for moving static void moveObject(ObjectPtr theObj); -#endif /// Translate passed string with widget context() virtual QString translate(const std::string& theStr) const; diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 40625ee9e..5bbd61c10 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -523,15 +523,12 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); Point aMousePnt; get2dPoint(theWnd, theEvent, aMousePnt); -#ifndef SUPPORT_NEW_MOVE - double dX = aMousePnt.myCurX - myCurrentPoint.myCurX; - double dY = aMousePnt.myCurY - myCurrentPoint.myCurY; -#else + std::shared_ptr anOriginalPosition = std::shared_ptr( new GeomAPI_Pnt2d(myCurrentPoint.myCurX, myCurrentPoint.myCurY)); std::shared_ptr aCurrentPosition = std::shared_ptr( new GeomAPI_Pnt2d(aMousePnt.myCurX, aMousePnt.myCurY)); -#endif + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); @@ -565,17 +562,14 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve std::dynamic_pointer_cast(aData->attribute(aAttrId)); if (aPoint.get() != NULL) { bool isImmutable = aPoint->setImmutable(true); -#ifndef SUPPORT_NEW_MOVE - aPoint->move(dX, dY); - ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent); -#else + std::shared_ptr aMessage = std::shared_ptr (new ModelAPI_ObjectMovedMessage(this)); aMessage->setMovedAttribute(aPoint); aMessage->setOriginalPosition(anOriginalPosition); aMessage->setCurrentPosition(aCurrentPosition); Events_Loop::loop()->send(aMessage); -#endif + isModified = true; aPoint->setImmutable(isImmutable); } @@ -586,17 +580,12 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(aFeature); if (aSketchFeature) { -#ifndef SUPPORT_NEW_MOVE - aSketchFeature->move(dX, dY); - ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent); -#else std::shared_ptr aMessage = std::shared_ptr (new ModelAPI_ObjectMovedMessage(this)); aMessage->setMovedObject(aFeature); aMessage->setOriginalPosition(anOriginalPosition); aMessage->setCurrentPosition(aCurrentPosition); Events_Loop::loop()->send(aMessage); -#endif isModified = true; } } diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index f099f04a3..5d3d7c9a7 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -344,14 +344,23 @@ bool PartSet_WidgetPoint2D::storeValueCustom() // myYSpin->hasVariable() ? myYSpin->text().toStdString() : ""); //aPoint->setValue(!myXSpin->hasVariable() ? myXSpin->value() : aPoint->x(), // !myYSpin->hasVariable() ? myYSpin->value() : aPoint->y()); - aPoint->setValue(myXSpin->value(), myYSpin->value()); - - // after movement the solver will call the update event: optimization -#ifndef SUPPORT_NEW_MOVE - moveObject(myFeature); -#else - updateObject(myFeature); -#endif + + if (myFeature->isMacro()) { + // Moving points of macro-features has been processed directly (without solver) + aPoint->setValue(myXSpin->value(), myYSpin->value()); + moveObject(myFeature); + } else { + if (!aPoint->isInitialized()) + aPoint->setValue(0., 0.); + + std::shared_ptr aMessage( + new ModelAPI_ObjectMovedMessage(this)); + aMessage->setMovedAttribute(aPoint); + aMessage->setOriginalPosition(aPoint->pnt()); + aMessage->setCurrentPosition(myXSpin->value(), myYSpin->value()); + Events_Loop::loop()->send(aMessage); + } + aPoint->setImmutable(isImmutable); that->blockSignals(isBlocked); diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 8640e513a..88020df90 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -389,6 +389,9 @@ void PlaneGCSSolver_Storage::refresh() const std::map::const_iterator anIt = myAttributeMap.begin(); for (; anIt != myAttributeMap.end(); ++anIt) { + if (!anIt->first->isInitialized()) + continue; + // the external feature always should keep the up to date values, so, // refresh from the solver is never needed if (isExternalAttribute(anIt->first)) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp index 0e609ceee..fb7e70919 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp @@ -123,7 +123,6 @@ SolverConstraintPtr PlaneGCSSolver_Tools::createConstraint(ConstraintPtr theCons return SolverConstraintPtr(new SketchSolver_Constraint(theConstraint)); } -#ifdef SUPPORT_NEW_MOVE std::shared_ptr PlaneGCSSolver_Tools::createMovementConstraint( FeaturePtr theMovedFeature) { @@ -137,14 +136,6 @@ std::shared_ptr PlaneGCSSolver_Tools::createMov return std::shared_ptr( new SketchSolver_ConstraintMovement(theMovedAttribute)); } -#else -std::shared_ptr PlaneGCSSolver_Tools::createMovementConstraint( - FeaturePtr theMovedFeature) -{ - return std::shared_ptr( - new SketchSolver_ConstraintFixed(theMovedFeature)); -} -#endif diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h index dc520695f..ce4ee9981 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h @@ -24,18 +24,12 @@ namespace PlaneGCSSolver_Tools /// or returns empty pointer if not all attributes are correct SolverConstraintPtr createConstraint(ConstraintPtr theConstraint); -#ifdef SUPPORT_NEW_MOVE /// \brief Creates temporary constraint to fix the feature after movement std::shared_ptr createMovementConstraint(FeaturePtr theMovedFeature); /// \brief Creates temporary constraint to fix the attribute after movement std::shared_ptr createMovementConstraint(AttributePtr theMovedAttribute); -#else - /// \brief Creates temporary constraint to fix the feature after movement - std::shared_ptr - createMovementConstraint(FeaturePtr theMovedFeature); -#endif /// \brief Creates new constraint using given parameters /// \param theConstraint [in] original constraint diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp index 5ea432915..ab58762a4 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp @@ -24,62 +24,27 @@ SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(ConstraintPtr theCons myType = CONSTRAINT_FIXED; } -#ifndef SUPPORT_NEW_MOVE -SketchSolver_ConstraintFixed::SketchSolver_ConstraintFixed(FeaturePtr theFeature) - : SketchSolver_Constraint(), - myBaseFeature(theFeature) -{ - myType = CONSTRAINT_FIXED; -} -#endif - void SketchSolver_ConstraintFixed::blockEvents(bool isBlocked) { -#ifndef SUPPORT_NEW_MOVE - if (myBaseFeature) - myBaseFeature->data()->blockSendAttributeUpdated(isBlocked); - if (myBaseConstraint) -#endif SketchSolver_Constraint::blockEvents(isBlocked); } void SketchSolver_ConstraintFixed::process() { cleanErrorMsg(); -#ifdef SUPPORT_NEW_MOVE if (!myBaseConstraint || !myStorage) { -#else - if ((!myBaseConstraint && !myBaseFeature) || !myStorage) { -#endif // Not enough parameters are assigned return; } -#ifdef SUPPORT_NEW_MOVE EntityWrapperPtr aBaseEntity = entityToFix(); if (!aBaseEntity) myErrorMsg = SketchSolver_Error::ALREADY_FIXED(); -#else - EntityWrapperPtr aBaseEntity; - getAttributes(aBaseEntity, myFixedEntity); - if (!aBaseEntity) { - moveFeature(); // remove myFixed entity - myErrorMsg = SketchSolver_Error::ALREADY_FIXED(); - } -#endif if (!myErrorMsg.empty()) return; -#ifdef SUPPORT_NEW_MOVE ConstraintWrapperPtr aConstraint = fixFeature(aBaseEntity); myStorage->addConstraint(myBaseConstraint, aConstraint); -#else - myConstraint = fixFeature(aBaseEntity); - if (myBaseConstraint) - myStorage->addConstraint(myBaseConstraint, myConstraint); - else - myStorage->addMovementConstraint(myConstraint); -#endif } ConstraintWrapperPtr SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr theFeature) @@ -100,7 +65,6 @@ ConstraintWrapperPtr SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr t new PlaneGCSSolver_ConstraintWrapper(aConstraints, getType())); } -#ifdef SUPPORT_NEW_MOVE EntityWrapperPtr SketchSolver_ConstraintFixed::entityToFix() { // Constraint Fixed is added by user. @@ -114,63 +78,6 @@ EntityWrapperPtr SketchSolver_ConstraintFixed::entityToFix() return *anIt; return EntityWrapperPtr(); } -#else -void SketchSolver_ConstraintFixed::getAttributes(EntityWrapperPtr& theBaseEntity, - EntityWrapperPtr& theFixedEntity) -{ - if (myBaseFeature) { - // if the feature is copy, do not move it - std::shared_ptr aSketchFeature = - std::dynamic_pointer_cast(myBaseFeature); - if (aSketchFeature && aSketchFeature->isCopy()) { - myStorage->setNeedToResolve(true); - return; - } - - // The feature is fixed. - PlaneGCSSolver_FeatureBuilder aBuilder; - std::list aBaseAttr = myBaseFeature->data()->attributes(std::string()); - std::list::const_iterator anIt = aBaseAttr.begin(); - for (; anIt != aBaseAttr.end(); ++anIt) - aBuilder.createAttribute(*anIt); - theFixedEntity = aBuilder.createFeature(myBaseFeature); - - theBaseEntity = myStorage->entity(myBaseFeature); - if (isEqual(theBaseEntity, theFixedEntity)) - theBaseEntity = EntityWrapperPtr(); // do not want to fix already fixed entity - - } else if (myBaseConstraint) { - // Constraint Fixed is added by user. - // Get the attribute of constraint (it should be alone in the list of constraints). - EntityWrapperPtr aValue; - std::vector anAttributes; - SketchSolver_Constraint::getAttributes(aValue, anAttributes); - std::vector::const_iterator anIt = anAttributes.begin(); - for (; anIt != anAttributes.end(); ++anIt) - if (*anIt) - theBaseEntity = *anIt; - } else - myErrorMsg = SketchSolver_Error::NOT_INITIALIZED(); -} - -void SketchSolver_ConstraintFixed::moveFeature() -{ - if (!myFixedEntity) - return; - - GCS::VEC_pD aFixedParams = toParameters(myFixedEntity); - for (int i = 0; i < aFixedParams.size() && i < myFixedValues.size(); ++i) - myFixedValues[i] = *(aFixedParams[i]); - - // Remove fixed entity due to its parameters already copied into the constraint - PlaneGCSSolver_EntityDestroyer aDestroyer; - aDestroyer.remove(myFixedEntity); - std::dynamic_pointer_cast(myStorage)->removeParameters( - aDestroyer.parametersToRemove()); - - myFixedEntity = EntityWrapperPtr(); -} -#endif GCS::VEC_pD SketchSolver_ConstraintFixed::toParameters(const EntityWrapperPtr& theEntity) { @@ -203,20 +110,12 @@ GCS::VEC_pD SketchSolver_ConstraintFixed::toParameters(const EntityWrapperPtr& t std::dynamic_pointer_cast(anEntity->entity()); aParameters.push_back(aCircle->center.x); aParameters.push_back(aCircle->center.y); -#ifndef SUPPORT_NEW_MOVE - aParameters.push_back(aCircle->rad); -#endif break; } case ENTITY_ARC: { std::shared_ptr anArc = std::dynamic_pointer_cast(anEntity->entity()); aParameters.push_back(anArc->center.x); aParameters.push_back(anArc->center.y); -#ifndef SUPPORT_NEW_MOVE - aParameters.push_back(anArc->rad); - aParameters.push_back(anArc->startAngle); - aParameters.push_back(anArc->endAngle); -#endif break; } default: @@ -225,20 +124,3 @@ GCS::VEC_pD SketchSolver_ConstraintFixed::toParameters(const EntityWrapperPtr& t return aParameters; } - -#ifndef SUPPORT_NEW_MOVE -// ==================== Auxiliary functions =============================== -bool isEqual(const EntityWrapperPtr& theEntity1, const EntityWrapperPtr& theEntity2) -{ - GCS::VEC_pD aParamList1 = SketchSolver_ConstraintFixed::toParameters(theEntity1); - GCS::VEC_pD aParamList2 = SketchSolver_ConstraintFixed::toParameters(theEntity2); - - GCS::VEC_pD::const_iterator anIt1 = aParamList1.begin(); - GCS::VEC_pD::const_iterator anIt2 = aParamList2.begin(); - for (; anIt1 != aParamList1.end() && anIt2 != aParamList2.end(); ++anIt1, ++anIt2) - if (fabs((**anIt1) - (**anIt2)) > tolerance) - return false; - - return anIt1 == aParamList1.end() && anIt2 == aParamList2.end(); -} -#endif diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.h b/src/SketchSolver/SketchSolver_ConstraintFixed.h index 13ec1d160..7d20a4320 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.h +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.h @@ -18,20 +18,10 @@ class SketchSolver_ConstraintFixed : public SketchSolver_Constraint public: /// Creates constraint to manage the given constraint from plugin SketchSolver_ConstraintFixed(ConstraintPtr theConstraint); -#ifndef SUPPORT_NEW_MOVE - /// Creates temporary constraint based on feature (useful while the feature is being moved) - SketchSolver_ConstraintFixed(FeaturePtr theFeature); -#endif /// \brief Block or unblock events from this constraint virtual void blockEvents(bool isBlocked); -#ifndef SUPPORT_NEW_MOVE - /// \brief Set coordinates of fixed feature to the values where it has been dragged. - /// Useful when the feature is being moved. - void moveFeature(); -#endif - protected: /// \brief Converts SketchPlugin constraint to a list of SolveSpace constraints virtual void process(); @@ -42,37 +32,18 @@ protected: virtual void getAttributes(EntityWrapperPtr& , std::vector& ) {} -#ifdef SUPPORT_NEW_MOVE /// \brief Obtain entity to be fixed virtual EntityWrapperPtr entityToFix(); -#else - /// \brief Generate list of attributes of constraint in order useful for constraints - /// \param[out] theBaseEntity the entity which coordinates should be fixed - /// \param[out] theFixedEntity the entity containing fixed values - virtual void getAttributes(EntityWrapperPtr& theBaseEntity, - EntityWrapperPtr& theFixedEntity); -#endif /// \brief Create Fixed constraint for the feature basing on its type /// \param theFeature [in] feature, converted to solver specific format /// \return Fixed constraint virtual ConstraintWrapperPtr fixFeature(EntityWrapperPtr theFeature); -#ifndef SUPPORT_NEW_MOVE -public: -#endif /// \brief Get list of parameters of current entity static GCS::VEC_pD toParameters(const EntityWrapperPtr& theEntity); -#ifdef SUPPORT_NEW_MOVE protected: -#else -private: - FeaturePtr myBaseFeature; ///< fixed feature (when it is set, myBaseConstraint should be NULL) - - ConstraintWrapperPtr myConstraint; - EntityWrapperPtr myFixedEntity; -#endif std::vector myFixedValues; }; diff --git a/src/SketchSolver/SketchSolver_ConstraintMovement.cpp b/src/SketchSolver/SketchSolver_ConstraintMovement.cpp index 850a8c92d..44efdafe9 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMovement.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMovement.cpp @@ -49,8 +49,8 @@ void SketchSolver_ConstraintMovement::process() return; } - ConstraintWrapperPtr aConstraint = fixFeature(aMovedEntity); - myStorage->addMovementConstraint(aConstraint); + mySolverConstraint = fixFeature(aMovedEntity); + myStorage->addMovementConstraint(mySolverConstraint); } @@ -64,14 +64,20 @@ EntityWrapperPtr SketchSolver_ConstraintMovement::entityToFix() return EntityWrapperPtr(); } - return myStorage->entity(myMovedFeature); + EntityWrapperPtr anEntity = + myDraggedPoint ? myStorage->entity(myDraggedPoint) : myStorage->entity(myMovedFeature); + if (!anEntity) { + myStorage->update(myMovedFeature, true); + anEntity = myStorage->entity(myMovedFeature); + } + return anEntity; } void SketchSolver_ConstraintMovement::moveTo( const std::shared_ptr& theDestinationPoint) { -#ifdef SUPPORT_NEW_MOVE - EntityWrapperPtr aMovedEntity = myStorage->entity(myMovedFeature); + EntityWrapperPtr aMovedEntity = + myDraggedPoint ? myStorage->entity(myDraggedPoint) : myStorage->entity(myMovedFeature); if (!aMovedEntity) return; @@ -82,5 +88,10 @@ void SketchSolver_ConstraintMovement::moveTo( for (int i = 0; i < aFixedParams.size() && i < myFixedValues.size(); ++i) myFixedValues[i] = *(aFixedParams[i]) + aDelta[i % 2]; -#endif + // no persistent constraints in the storage, thus store values directly to the feature + if (myStorage->isEmpty()) { + for (int i = 0; i < aFixedParams.size() && i < myFixedValues.size(); ++i) + *(aFixedParams[i]) = myFixedValues[i]; + myStorage->setNeedToResolve(true); + } } diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 6f855c976..840c7b736 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -115,7 +115,6 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature) return myStorage->update(theFeature); } -#ifdef SUPPORT_NEW_MOVE template static SolverConstraintPtr move(StoragePtr theStorage, SolverPtr theSketchSolver, @@ -170,35 +169,6 @@ bool SketchSolver_Group::movePoint(AttributePtr theAttribute, setTemporary(aConstraint); return true; } -#else -bool SketchSolver_Group::moveFeature(FeaturePtr theFeature) -{ - bool isFeatureExists = (myStorage->entity(theFeature).get() != 0); - if (myDOF == 0 && isFeatureExists) { - // avoid moving elements of fully constrained sketch - myStorage->refresh(); - return true; - } - - // Create temporary Fixed constraint - std::shared_ptr aConstraint = - PlaneGCSSolver_Tools::createMovementConstraint(theFeature); - if (!aConstraint) - return false; - SolverConstraintPtr(aConstraint)->process(myStorage, myIsEventsBlocked); - if (aConstraint->error().empty()) { - setTemporary(aConstraint); - if (!myStorage->isEmpty()) - myStorage->setNeedToResolve(true); - - mySketchSolver->initialize(); - aConstraint->moveFeature(); - } else - myStorage->notify(theFeature); - - return true; -} -#endif // ============================================================================ // Function: resolveConstraints diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index ae10ff58b..587550192 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -59,7 +59,6 @@ class SketchSolver_Group */ bool updateFeature(FeaturePtr theFeature); -#ifdef SUPPORT_NEW_MOVE /** \brief Updates the data corresponding the specified feature moved in GUI. * Special kind of Fixed constraints is created. * \param[in] theFeature the feature to be updated @@ -80,14 +79,6 @@ class SketchSolver_Group bool movePoint(AttributePtr thePoint, const std::shared_ptr& theFrom, const std::shared_ptr& theTo); -#else - /** \brief Updates the data corresponding the specified feature moved in GUI. - * Additional Fixed constraints are created. - * \param[in] theFeature the feature to be updated - * \return \c true, if the feature is moved - */ - bool moveFeature(FeaturePtr theFeature); -#endif /// Returns the current workplane inline const CompositeFeaturePtr& getWorkplane() const diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index f0d6eb210..4973c483d 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -91,28 +91,14 @@ void SketchSolver_Manager::processEvent( return; myIsComputed = true; -#ifdef SUPPORT_NEW_MOVE if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) || theMessage->eventID() == anUpdateEvent) { -#else - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) - || theMessage->eventID() == anUpdateEvent - || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) { -#endif std::shared_ptr anUpdateMsg = std::dynamic_pointer_cast(theMessage); std::set aFeatures = anUpdateMsg->objects(); isUpdateFlushed = stopSendUpdate(); -#ifndef SUPPORT_NEW_MOVE - isMovedEvt = theMessage->eventID() - == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED); - - // Shows that the message has at least one feature applicable for solver - bool hasProperFeature = false; -#endif - // update sketch features only std::set::iterator aFeatIter; for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) { @@ -121,18 +107,9 @@ void SketchSolver_Manager::processEvent( if (!aFeature || aFeature->isMacro()) continue; -#ifdef SUPPORT_NEW_MOVE updateFeature(aFeature); -#else - hasProperFeature = updateFeature(aFeature, isMovedEvt) || hasProperFeature; -#endif } -#ifndef SUPPORT_NEW_MOVE - if (isMovedEvt && hasProperFeature) - needToResolve = true; - -#else } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) { std::shared_ptr aMoveMsg = std::dynamic_pointer_cast(theMessage); @@ -153,7 +130,6 @@ void SketchSolver_Manager::processEvent( } else if (aMovedPoint) needToResolve = moveAttribute(aMovedPoint, aFrom, aTo); -#endif } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { std::shared_ptr aDeleteMsg = std::dynamic_pointer_cast(theMessage); @@ -202,12 +178,7 @@ void SketchSolver_Manager::processEvent( // Function: updateFeature // Purpose: create/update constraint or feature in appropriate group // ============================================================================ -#ifdef SUPPORT_NEW_MOVE bool SketchSolver_Manager::updateFeature(const std::shared_ptr& theFeature) -#else -bool SketchSolver_Manager::updateFeature(std::shared_ptr theFeature, - bool theMoved) -#endif { // Check feature validity and find a group to place it. // If the feature is not valid, the returned group will be empty. @@ -223,16 +194,11 @@ bool SketchSolver_Manager::updateFeature(std::shared_ptr t bool isOk = false; if (aConstraint) isOk = aGroup->changeConstraint(aConstraint); -#ifndef SUPPORT_NEW_MOVE - else if (theMoved) - isOk = aGroup->moveFeature(theFeature); -#endif else isOk = aGroup->updateFeature(theFeature); return isOk; } -#ifdef SUPPORT_NEW_MOVE // ============================================================================ // Function: moveFeature // Purpose: move given feature in appropriate group @@ -265,13 +231,14 @@ bool SketchSolver_Manager::moveAttribute( SketchGroupPtr aGroup; if (aSketchFeature) aGroup = findGroup(aSketchFeature); - if (!aGroup) + if (!aGroup) { + theMovedAttribute->setValue(theTo); return false; + } aGroup->blockEvents(true); return aGroup->movePoint(theMovedAttribute, theFrom, theTo); } -#endif // ============================================================================ // Function: findGroup diff --git a/src/SketchSolver/SketchSolver_Manager.h b/src/SketchSolver/SketchSolver_Manager.h index f88e92a3a..4bfa2f116 100644 --- a/src/SketchSolver/SketchSolver_Manager.h +++ b/src/SketchSolver/SketchSolver_Manager.h @@ -48,7 +48,6 @@ protected: SketchSolver_Manager(); ~SketchSolver_Manager(); -#ifdef SUPPORT_NEW_MOVE /** \brief Adds or updates a constraint or an entity in the suitable group * \param[in] theFeature sketch feature to be changed * \return \c true if the feature changed successfully @@ -74,14 +73,6 @@ protected: bool moveAttribute(const std::shared_ptr& theMovedAttribute, const std::shared_ptr& theFromPoint, const std::shared_ptr& theToPoint); -#else - /** \brief Adds or updates a constraint or an entity in the suitable group - * \param[in] theFeature sketch feature to be changed - * \param[in] theMoved \c true if the feature has been moved in the viewer - * \return \c true if the feature changed successfully - */ - bool updateFeature(std::shared_ptr theFeature, bool theMoved = false); -#endif /** \brief Removes a constraint from the manager * \param[in] theConstraint constraint to be removed