Salome HOME
Merge branch 'Pre_2.8.0_development'
[modules/shaper.git] / src / PartSet / PartSet_WidgetPoint2d.cpp
index 9d3345e1d8046cb9d6c9a5b27bdc6ba5aeb82e3c..c7dde30bf0c3420ad90d6f24be573fc0a8147186 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_WidgetPoint2D.cpp
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include "PartSet_WidgetPoint2d.h"
 #include <PartSet_Tools.h>
@@ -344,10 +358,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
-  moveObject(myFeature);
+  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);
 
@@ -684,13 +711,15 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo
   }
   // The selection could be a center of an external circular object
   else if (aFirstValue.get() && (!aFirstValue->interactive().IsNull())) {
-    Handle(PartSet_CenterPrs) aAIS = Handle(PartSet_CenterPrs)::DownCast(aFirstValue->interactive());
+    Handle(PartSet_CenterPrs) aAIS =
+        Handle(PartSet_CenterPrs)::DownCast(aFirstValue->interactive());
     if (!aAIS.IsNull()) {
       gp_Pnt aPntComp = aAIS->Component()->Pnt();
       GeomVertexPtr aVertPtr(new GeomAPI_Vertex(aPntComp.X(), aPntComp.Y(), aPntComp.Z()));
       TopoDS_Shape aShape = aVertPtr->impl<TopoDS_Shape>();
 
-      ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aAIS->object(), mySketch);
+      ResultPtr aFixedObject =
+          PartSet_Tools::findFixedObjectByExternal(aShape, aAIS->object(), mySketch);
       if (!aFixedObject.get())
         aFixedObject = PartSet_Tools::createFixedByExternalCenter(aAIS->object(), aAIS->edge(),
                                                                   aAIS->centerType(), mySketch);
@@ -867,10 +896,13 @@ bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature,
       if (aCoincidence.get()) {
         QList<FeaturePtr> aCoinsideLines;
         QList<FeaturePtr> aCoins;
+        QList<bool> anIsAttributes;
         PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines, aCoins,
-                                        SketchPlugin_ConstraintCoincidence::ENTITY_A());
+                                        SketchPlugin_ConstraintCoincidence::ENTITY_A(),
+                                        anIsAttributes);
         PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines, aCoins,
-                                        SketchPlugin_ConstraintCoincidence::ENTITY_B());
+                                        SketchPlugin_ConstraintCoincidence::ENTITY_B(),
+                                        anIsAttributes);
         QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(),
                                           aLast = aCoinsideLines.end();
         for (; anIt != aLast && anOrphanPoint; anIt++) {