]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Coincident with objects
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 21 Apr 2015 13:15:18 +0000 (16:15 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 21 Apr 2015 13:15:18 +0000 (16:15 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/SketcherPrs/SketcherPrs_Coincident.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp

index 91b6f859e32c9ba101dce6d18885978fc8b9cb44..42f95fb3343b62fafbb6941d423923fc77f86768 100644 (file)
@@ -99,10 +99,6 @@ std::shared_ptr<GeomAPI_Pnt2d> getPoint(std::shared_ptr<ModelAPI_Feature>& theFe
     aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
 
-  else if (aFeature &&  aFeature->getKind() == SketchPlugin_Circle::ID())
-    aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
-
   else if (anAttr->attr()) {
     aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
   }
@@ -121,6 +117,8 @@ void findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList, std::
   FeaturePtr aObj = ModelAPI_Feature::feature(aPnt->object());
   if (!theList.contains(aObj)) {
     std::shared_ptr<GeomAPI_Pnt2d> aOrig = getPoint(theStartCoin, theAttr);
+    if (aOrig.get() == NULL)
+      return;
     theList.append(aObj);
     const std::set<AttributePtr>& aRefsList = aObj->data()->refsToMe();
     std::set<AttributePtr>::const_iterator aIt;
@@ -129,7 +127,7 @@ void findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList, std::
       FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
       if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
         std::shared_ptr<GeomAPI_Pnt2d> aPnt = getPoint(aConstrFeature, theAttr);
-        if (aOrig->isEqual(aPnt)) {
+        if (aPnt.get() && aOrig->isEqual(aPnt)) {
           findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_A());
           findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_B());
         }
@@ -191,11 +189,18 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMap<QString, QAction
           std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
           FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
           if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
-            std::shared_ptr<GeomAPI_Pnt2d> a2dPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A());
-            if (aSelPnt->isEqual(a2dPnt)) { 
+            std::shared_ptr<GeomAPI_Pnt2d> a2dPnt = 
+              getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A());
+            if (a2dPnt.get() && aSelPnt->isEqual(a2dPnt)) { 
               aCoincident = aConstrFeature;
               break;
-            } 
+            } else {
+              a2dPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_B());
+              if (a2dPnt.get() && aSelPnt->isEqual(a2dPnt)) { 
+                aCoincident = aConstrFeature;
+                break;
+              }
+            }
           }
         }
         // If we have coincidence then add Detach menu
@@ -269,6 +274,9 @@ void PartSet_MenuMgr::onLineDetach(QAction* theAction)
   int aId = theAction->data().toInt();
   FeaturePtr aLine = myCoinsideLines.at(aId);
   std::shared_ptr<GeomAPI_Pnt2d> aOrig = getPoint(mySelectedFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A());
+  if (aOrig.get() == NULL)
+    aOrig = getPoint(mySelectedFeature, SketchPlugin_ConstraintCoincidence::ENTITY_B());
+  
   gp_Pnt aOr = aOrig->impl<gp_Pnt>();
   const std::set<AttributePtr>& aRefsList = aLine->data()->refsToMe();
 
@@ -280,6 +288,10 @@ void PartSet_MenuMgr::onLineDetach(QAction* theAction)
     FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
     if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { 
       std::shared_ptr<GeomAPI_Pnt2d> aPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A());
+      if (aPnt.get() == NULL)
+        aPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_B());
+      if (aPnt.get() == NULL)
+        return;
       gp_Pnt aP = aPnt->impl<gp_Pnt>();
       if (aOrig->isEqual(aPnt)) {
         aToDelFeatures.append(aConstrFeature);
index b85d018b361da4502cfa8bbbc51b465261de0799..bc7d7824e5ae351e2565964b46f6bb9d1fbdbb4b 100644 (file)
@@ -46,6 +46,8 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)&
 {
   std::shared_ptr<GeomAPI_Pnt2d> aPnt = SketcherPrs_Tools::getPoint(myConstraint, 
                                                                     SketchPlugin_Constraint::ENTITY_A());
+  if (aPnt.get() == NULL)
+    aPnt = SketcherPrs_Tools::getPoint(myConstraint, SketchPlugin_Constraint::ENTITY_B());
   if (aPnt.get() == NULL)
     return;
 
index aeefdb8e7f867e6f1d80fccf3b08b20ca183941c..f8891b2253bdf2025369ea887e7c5e977ae99b4b 100644 (file)
@@ -58,10 +58,6 @@ std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
     aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
 
-  else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID())
-    aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
-
   else if (anAttr->attr()) {
     aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
   }
@@ -89,10 +85,6 @@ std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
     aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
         aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
 
-  else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID())
-    aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
-
   else if (anAttr->attr()) {
     aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
   }