]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Rectangle correction to have coincidence with point/line selected for the first point...
authornds <nds@opencascade.com>
Thu, 3 Mar 2016 13:20:14 +0000 (16:20 +0300)
committernds <nds@opencascade.com>
Thu, 3 Mar 2016 13:58:12 +0000 (16:58 +0300)
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index 14294830cee2f669f2870ae1f59d7fbb3fb39d2c..49940a310567f0c462debbe3ae114def42888cbc 100644 (file)
@@ -384,7 +384,7 @@ bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
   return false;
 }
 
-void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
+bool PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
 {
   std::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint;
   if (feature()->isMacro()) {
@@ -403,7 +403,7 @@ void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
     aFeaturePoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
   }
   if (!aFeaturePoint.get())
-    return;
+    return false;
 
   // Create point-edge coincedence
   FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
@@ -420,6 +420,8 @@ void PartSet_WidgetPoint2D::setConstraintWith(const ObjectPtr& theObject)
 
   // we need to flush created signal in order to coincidence is processed by solver
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+
+  return true;
 }
 
 void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
@@ -505,7 +507,11 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
           PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
         }
         else if (aShape.ShapeType() == TopAbs_EDGE) {
-          setConstraintWith(aObject);
+          if (!setConstraintWith(aObject)) {
+            gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
+            PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY);
+            setPoint(aX, aY);
+          }
           setValueState(Stored); // in case of edge selection, Apply state should also be updated
 
           FeaturePtr anObjectFeature = ModelAPI_Feature::feature(aObject);
index d4271e5589c6c4d8319a8b29427d37f9b4af21a5..4395b6eb291588c696fbff30a8fd12fe15cbdae2 100755 (executable)
@@ -164,7 +164,8 @@ protected:
 
    /// Create a coincidence constraint between the attribute and the parameter object
    /// \theObject a result object
-   void setConstraintWith(const ObjectPtr& theObject);
+   /// \return true if succed
+   bool setConstraintWith(const ObjectPtr& theObject);
 
    /// Returns if the feature is an orphan point, circle or an arc. Returns true if it
    /// has no a coincident to other lines. It processes point, circle and arc features