]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.4. Ability to modify the radius of circles and arcs of circle with the mouse
authorazv <azv@opencascade.com>
Fri, 5 May 2017 07:16:15 +0000 (10:16 +0300)
committerazv <azv@opencascade.com>
Fri, 5 May 2017 07:16:15 +0000 (10:16 +0300)
Code cleanup and debug of features movement.

14 files changed:
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.h
src/SketchSolver/SketchSolver_ConstraintFixed.cpp
src/SketchSolver/SketchSolver_ConstraintFixed.h
src/SketchSolver/SketchSolver_ConstraintMovement.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SketchSolver_Manager.cpp
src/SketchSolver/SketchSolver_Manager.h

index b086cd6281f4568a5293e8e9d67e280e3b839da7..88172984eb2abdc736ba3ab848d7c4b2a3ed0059 100644 (file)
@@ -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()
 {
index b13d90aeba8afe260164eb732614ed777d7bb68b..0b409e6feedb9ce02cd32e60c6224b8e84a938e1 100644 (file)
@@ -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;
 
index 40625ee9e4ce5476d11c4b3ee50d99c38595d5ba..5bbd61c107f7d2f9a628e584de3476ed2ad63ba8 100755 (executable)
@@ -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<GeomAPI_Pnt2d> anOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(
                             new GeomAPI_Pnt2d(myCurrentPoint.myCurX, myCurrentPoint.myCurY));
     std::shared_ptr<GeomAPI_Pnt2d> aCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(
                             new GeomAPI_Pnt2d(aMousePnt.myCurX, aMousePnt.myCurY));
-#endif
+
     ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
     XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
@@ -565,17 +562,14 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
               std::dynamic_pointer_cast<GeomDataAPI_Point2D>(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<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
                        <ModelAPI_ObjectMovedMessage>(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<SketchPlugin_Feature> aSketchFeature =
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature) {
-#ifndef SUPPORT_NEW_MOVE
-          aSketchFeature->move(dX, dY);
-          ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
-#else
           std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
                     <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
           aMessage->setMovedObject(aFeature);
           aMessage->setOriginalPosition(anOriginalPosition);
           aMessage->setCurrentPosition(aCurrentPosition);
           Events_Loop::loop()->send(aMessage);
-#endif
           isModified = true;
         }
       }
index f099f04a309c099dc65dc3a6afd1c3d0c439e0e7..5d3d7c9a7ea7894bcc4f7cc9e4b05bc3d6e2e038 100644 (file)
@@ -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<ModelAPI_ObjectMovedMessage> 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);
 
index 8640e513ae0add011fbc80298d6c625d5a6de129..88020df90d3c0f8635db3df16b1a217dadb74c6d 100644 (file)
@@ -389,6 +389,9 @@ void PlaneGCSSolver_Storage::refresh() const
 
   std::map<AttributePtr, EntityWrapperPtr>::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))
index 0e609ceee196d8f318942656bc0fd34dec546c45..fb7e70919a11b043e246468789bb2979ff0d0002 100644 (file)
@@ -123,7 +123,6 @@ SolverConstraintPtr PlaneGCSSolver_Tools::createConstraint(ConstraintPtr theCons
   return SolverConstraintPtr(new SketchSolver_Constraint(theConstraint));
 }
 
-#ifdef SUPPORT_NEW_MOVE
 std::shared_ptr<SketchSolver_ConstraintMovement> PlaneGCSSolver_Tools::createMovementConstraint(
     FeaturePtr theMovedFeature)
 {
@@ -137,14 +136,6 @@ std::shared_ptr<SketchSolver_ConstraintMovement> PlaneGCSSolver_Tools::createMov
   return std::shared_ptr<SketchSolver_ConstraintMovement>(
       new SketchSolver_ConstraintMovement(theMovedAttribute));
 }
-#else
-std::shared_ptr<SketchSolver_ConstraintFixed> PlaneGCSSolver_Tools::createMovementConstraint(
-    FeaturePtr theMovedFeature)
-{
-  return std::shared_ptr<SketchSolver_ConstraintFixed>(
-      new SketchSolver_ConstraintFixed(theMovedFeature));
-}
-#endif
 
 
 
index dc520695f36454de8f959dc5cf720d04766cd0fa..ce4ee9981b4687ad28fa0e2fbcb192a51b0bc6ef 100644 (file)
@@ -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<SketchSolver_ConstraintMovement>
       createMovementConstraint(FeaturePtr theMovedFeature);
   /// \brief Creates temporary constraint to fix the attribute after movement
   std::shared_ptr<SketchSolver_ConstraintMovement>
       createMovementConstraint(AttributePtr theMovedAttribute);
-#else
-  /// \brief Creates temporary constraint to fix the feature after movement
-  std::shared_ptr<SketchSolver_ConstraintFixed>
-      createMovementConstraint(FeaturePtr theMovedFeature);
-#endif
 
   /// \brief Creates new constraint using given parameters
   /// \param theConstraint [in]  original constraint
index 5ea43291508d68ffae39f80936416b04b67c626d..ab58762a4612d41a2031c57c2cf768d1c8e08e2a 100644 (file)
@@ -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<SketchPlugin_Feature> aSketchFeature =
-        std::dynamic_pointer_cast<SketchPlugin_Feature>(myBaseFeature);
-    if (aSketchFeature && aSketchFeature->isCopy()) {
-      myStorage->setNeedToResolve(true);
-      return;
-    }
-
-    // The feature is fixed.
-    PlaneGCSSolver_FeatureBuilder aBuilder;
-    std::list<AttributePtr> aBaseAttr = myBaseFeature->data()->attributes(std::string());
-    std::list<AttributePtr>::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<EntityWrapperPtr> anAttributes;
-    SketchSolver_Constraint::getAttributes(aValue, anAttributes);
-    std::vector<EntityWrapperPtr>::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<PlaneGCSSolver_Storage>(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<GCS::Circle>(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<GCS::Arc> anArc = std::dynamic_pointer_cast<GCS::Arc>(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
index 13ec1d160c4d1dd5c1639c0a7b2ebede8f6e1c04..7d20a432058cdaba748bea0e3d12f3c9d8867e27 100644 (file)
@@ -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<EntityWrapperPtr>& )
   {}
 
-#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<double> myFixedValues;
 };
 
index 850a8c92d1964f44c566aceb91de3f7d75006917..44efdafe9ce1aa3a78a4748ba2bca0b22e6762b9 100644 (file)
@@ -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<GeomAPI_Pnt2d>& 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);
+  }
 }
index 6f855c97601e4f104516520f3764b4545c063de0..840c7b736ca94ed52c3b6d968d8e1f2d790043bc 100644 (file)
@@ -115,7 +115,6 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature)
   return myStorage->update(theFeature);
 }
 
-#ifdef SUPPORT_NEW_MOVE
 template <class Type>
 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<SketchSolver_ConstraintFixed> 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
index ae10ff58b551ac02b17772e105a913add1604b35..58755019267281335e1521a121d1b6dda4e63e93 100644 (file)
@@ -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<GeomAPI_Pnt2d>& theFrom,
                  const std::shared_ptr<GeomAPI_Pnt2d>& 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
index f0d6eb21045fab8c72a8063df93e48500e594248..4973c483de34158cdc68272de55c1fd68297b103 100644 (file)
@@ -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<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     std::set<ObjectPtr> 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<ObjectPtr>::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<ModelAPI_ObjectMovedMessage> aMoveMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectMovedMessage>(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<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
       std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(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<SketchPlugin_Feature>& theFeature)
-#else
-bool SketchSolver_Manager::updateFeature(std::shared_ptr<SketchPlugin_Feature> 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<SketchPlugin_Feature> 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
index f88e92a3a832309735ae63dfa726ad0c8a98dabf..4bfa2f116d9efa11017e99b9a901f9868e012416 100644 (file)
@@ -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<GeomDataAPI_Point2D>& theMovedAttribute,
                      const std::shared_ptr<GeomAPI_Pnt2d>& theFromPoint,
                      const std::shared_ptr<GeomAPI_Pnt2d>& 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<SketchPlugin_Feature> theFeature, bool theMoved = false);
-#endif
 
   /** \brief Removes a constraint from the manager
    *  \param[in] theConstraint constraint to be removed