]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix errors under Linux
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 13 Apr 2015 08:22:50 +0000 (11:22 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 13 Apr 2015 08:22:50 +0000 (11:22 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h

index 7e0442d5157b35de44ef3bd628566f602b177672..da3bd6836d178dcea9b56c3b47c995b7254ff2c8 100644 (file)
@@ -159,48 +159,48 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMap<QString, QAction
     if (aShape.ShapeType() == TopAbs_VERTEX) {
       // Find 2d coordinates
       FeaturePtr aSketchFea = myModule->sketchMgr()->activeSketch();
-      std::shared_ptr<SketchPlugin_Sketch> aSketch = 
-        std::dynamic_pointer_cast<SketchPlugin_Sketch>(aSketchFea);
-      gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
-      std::shared_ptr<GeomAPI_Pnt> aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
-      std::shared_ptr<GeomAPI_Pnt2d> aSelPnt = aSketch->to2D(aPnt3d);
-
-      // Find coincident in these coordinates
-      ObjectPtr aObj = aObjectsList.front();
-      FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
-      const std::set<AttributePtr>& aRefsList = aFeature->data()->refsToMe();
-      std::set<AttributePtr>::const_iterator aIt;
-      FeaturePtr aCoincident;
-      for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
-        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)) {
-            aCoincident = aConstrFeature;
-            break;
+      if (aSketchFea->getKind() == SketchPlugin_Sketch::ID()) {
+        gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
+        std::shared_ptr<GeomAPI_Pnt> aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
+        std::shared_ptr<GeomAPI_Pnt2d> aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d);
+
+        // Find coincident in these coordinates
+        ObjectPtr aObj = aObjectsList.front();
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+        const std::set<AttributePtr>& aRefsList = aFeature->data()->refsToMe();
+        std::set<AttributePtr>::const_iterator aIt;
+        FeaturePtr aCoincident;
+        for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+          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)) { 
+              aCoincident = aConstrFeature;
+              break;
+            } 
           }
         }
-      }
-      // If we have coincidence then add Detach menu
-      if (aCoincident.get() != NULL) {
-        mySelectedFeature = aCoincident;
-        findCoincidences(mySelectedFeature, myCoinsideLines, SketchPlugin_ConstraintCoincidence::ENTITY_A());
-        findCoincidences(mySelectedFeature, myCoinsideLines, SketchPlugin_ConstraintCoincidence::ENTITY_B());
-        if (myCoinsideLines.size() > 0) {
-          aIsDetach = true;
-          QMenu* aSubMenu = theMenu->addMenu(tr("Detach"));
-          QAction* aAction;
-          int i = 0;
-          foreach (FeaturePtr aCoins, myCoinsideLines) {
-            aAction = aSubMenu->addAction(aCoins->data()->name().c_str());
-            aAction->setData(QVariant(i));
-            i++;
-          }
-          connect(aSubMenu, SIGNAL(hovered(QAction*)), SLOT(onLineHighlighted(QAction*)));
-          connect(aSubMenu, SIGNAL(aboutToHide()), SLOT(onDetachMenuHide()));
-          connect(aSubMenu, SIGNAL(triggered(QAction*)), SLOT(onLineDetach(QAction*)));
-        } 
+        // If we have coincidence then add Detach menu
+        if (aCoincident.get() != NULL) {
+          mySelectedFeature = aCoincident;
+          findCoincidences(mySelectedFeature, myCoinsideLines, SketchPlugin_ConstraintCoincidence::ENTITY_A());
+          findCoincidences(mySelectedFeature, myCoinsideLines, SketchPlugin_ConstraintCoincidence::ENTITY_B());
+          if (myCoinsideLines.size() > 0) {
+            aIsDetach = true;
+            QMenu* aSubMenu = theMenu->addMenu(tr("Detach"));
+            QAction* aAction;
+            int i = 0;
+            foreach (FeaturePtr aCoins, myCoinsideLines) {
+              aAction = aSubMenu->addAction(aCoins->data()->name().c_str());
+              aAction->setData(QVariant(i));
+              i++;
+            }
+            connect(aSubMenu, SIGNAL(hovered(QAction*)), SLOT(onLineHighlighted(QAction*)));
+            connect(aSubMenu, SIGNAL(aboutToHide()), SLOT(onDetachMenuHide()));
+            connect(aSubMenu, SIGNAL(triggered(QAction*)), SLOT(onLineDetach(QAction*)));
+          } 
+        }
       }
     }
   }
index b488201750a4866ff82aa1ff3d150af14b2a2223..7fdc816a3e24f5167c46e6763dbb0e6272cf348a 100644 (file)
@@ -131,6 +131,23 @@ Handle(V3d_View) theView,
   theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();
 }
 
+std::shared_ptr<GeomAPI_Pnt2d> PartSet_Tools::convertTo2D(FeaturePtr theSketch, 
+                                                    const std::shared_ptr<GeomAPI_Pnt>& thePnt)
+{
+  std::shared_ptr<GeomAPI_Pnt2d> aRes;
+  if (theSketch->getKind() != SketchPlugin_Sketch::ID())
+    return aRes;
+  std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+      theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
+  std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
+  return thePnt->to2D(aC->pnt(), aX->dir(), aY);
+}
+
+
 std::shared_ptr<GeomAPI_Pnt> PartSet_Tools::convertTo3D(const double theX, const double theY, FeaturePtr theSketch)
 {
   std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
index e614074a828550745b584f46ec607058121c9045..84b2311a6e7b5bf5e8377c7b19230dd7e9244961 100644 (file)
@@ -55,6 +55,12 @@ class PARTSET_EXPORT PartSet_Tools
                           Handle(V3d_View) theView,
                           double& theX, double& theY);
 
+  /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
+  /// \param theSketch the sketch feature
+  /// \param thePnt the 3D point in the viewer
+  /// \returns the converted point object
+  static std::shared_ptr<GeomAPI_Pnt2d> convertTo2D(FeaturePtr theSketch, const std::shared_ptr<GeomAPI_Pnt>& thePnt);
+
   /// \brief Converts the 2D projected coodinates on the sketch plane to the 3D point.
   /// \param theX the X coordinate
   /// \param theY the Y coordinate