]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Simplified calculation of fly out distance and creation of constraints limited only...
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 11 Sep 2015 09:44:26 +0000 (12:44 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 11 Sep 2015 09:44:46 +0000 (12:44 +0300)
src/PartSet/PartSet_WidgetPoint2d.cpp
src/SketcherPrs/SketcherPrs_Angle.cpp

index 61749d78fc0226a9d8bc19711a9edfd11f95daf6..60e826b4223c55649c23918418f4895e43d82b08 100644 (file)
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Point.h>
 
 #include <QGroupBox>
 #include <QGridLayout>
@@ -46,6 +50,7 @@
 
 const double MaxCoordinate = 1e12;
 
+static QStringList MyFeaturesForCoincedence;
 
 PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, 
                                              ModuleBase_IWorkshop* theWorkshop,
@@ -53,6 +58,12 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
                                              const std::string& theParentId)
  : ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop)
 {
+  if (MyFeaturesForCoincedence.isEmpty()) {
+    MyFeaturesForCoincedence << SketchPlugin_Line::ID().c_str()
+      << SketchPlugin_Arc::ID().c_str()
+      << SketchPlugin_Point::ID().c_str()
+      << SketchPlugin_Circle::ID().c_str();
+  }
   myLockApplyMgr = new PartSet_LockApplyMgr(theParent, myWorkshop);
 
   // the control should accept the focus, so the boolen flag is corrected to be true
@@ -348,9 +359,10 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
         // the same constraints for the same points, oterwise the result line has zero length.
         if (getPoint2d(aView, aShape, aX, aY))
           PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
-        else if (aShape.ShapeType() == TopAbs_EDGE)
-          setConstraintWith(aObject);
-
+        else if (aShape.ShapeType() == TopAbs_EDGE) {
+          if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str()))
+            setConstraintWith(aObject);
+        }
         // it is important to perform updateObject() in order to the current value is 
         // processed by Sketch Solver. Test case: line is created from a previous point
         // to some distance, but in the area of the highlighting of the point. Constraint
index 8603dd444b790c0801d15a8dcc34b0db2bd56a87..40133d9cb8124f1c7ce76cea27fd39cb68cf60df 100644 (file)
@@ -82,21 +82,7 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
   TopoDS_Edge aEdge2 = TopoDS::Edge(aTEdge2);
   SetMeasuredGeometry(aEdge1, aEdge2);
 
-  // Compute intersection point
-  TopoDS_Vertex aV1, aV2;
-  TopExp::Vertices(aEdge1, aV1, aV2);
-  gp_Pnt aPnt1 = BRep_Tool::Pnt(aV1);
-  gp_Pnt aPnt2 = BRep_Tool::Pnt(aV2);
-  std::shared_ptr<GeomAPI_Lin> aL1(new GeomAPI_Lin(aPnt1.X(), aPnt1.Y(), aPnt1.Z(),
-                                                   aPnt2.X(), aPnt2.Y(), aPnt2.Z()));
-  TopExp::Vertices(aEdge2, aV1, aV2);
-  aPnt1 = BRep_Tool::Pnt(aV1);
-  aPnt2 = BRep_Tool::Pnt(aV2);
-  std::shared_ptr<GeomAPI_Lin> aL2(new GeomAPI_Lin(aPnt1.X(), aPnt1.Y(), aPnt1.Z(),
-                                                   aPnt2.X(), aPnt2.Y(), aPnt2.Z()));
-
-  std::shared_ptr<GeomAPI_Pnt> aInter = aL1->intersect(aL2);
-  gp_Pnt aCenter = aInter->impl<gp_Pnt>();
+  gp_Pnt aCenter = CenterPoint();
 
   gp_Pnt aFLyPnt(aFlyoutPnt->x(), aFlyoutPnt->y(), aFlyoutPnt->z());
   double aDist = aCenter.Distance(aFLyPnt);