From: vsv Date: Mon, 13 Apr 2015 08:22:50 +0000 (+0300) Subject: Fix errors under Linux X-Git-Tag: V_1.1.0~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=15fa3e2d3cd8187334795fbf9740c356b2d4e85e;p=modules%2Fshaper.git Fix errors under Linux --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 7e0442d51..da3bd6836 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -159,48 +159,48 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMapsketchMgr()->activeSketch(); - std::shared_ptr aSketch = - std::dynamic_pointer_cast(aSketchFea); - gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); - std::shared_ptr aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z())); - std::shared_ptr aSelPnt = aSketch->to2D(aPnt3d); - - // Find coincident in these coordinates - ObjectPtr aObj = aObjectsList.front(); - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - const std::set& aRefsList = aFeature->data()->refsToMe(); - std::set::const_iterator aIt; - FeaturePtr aCoincident; - for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) { - std::shared_ptr aAttr = (*aIt); - FeaturePtr aConstrFeature = std::dynamic_pointer_cast(aAttr->owner()); - if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { - std::shared_ptr 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 aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z())); + std::shared_ptr aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d); + + // Find coincident in these coordinates + ObjectPtr aObj = aObjectsList.front(); + FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); + const std::set& aRefsList = aFeature->data()->refsToMe(); + std::set::const_iterator aIt; + FeaturePtr aCoincident; + for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) { + std::shared_ptr aAttr = (*aIt); + FeaturePtr aConstrFeature = std::dynamic_pointer_cast(aAttr->owner()); + if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { + std::shared_ptr 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*))); + } + } } } } diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index b48820175..7fdc816a3 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -131,6 +131,23 @@ Handle(V3d_View) theView, theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z(); } +std::shared_ptr PartSet_Tools::convertTo2D(FeaturePtr theSketch, + const std::shared_ptr& thePnt) +{ + std::shared_ptr aRes; + if (theSketch->getKind() != SketchPlugin_Sketch::ID()) + return aRes; + std::shared_ptr aC = std::dynamic_pointer_cast( + theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr aX = std::dynamic_pointer_cast( + theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID())); + std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); + return thePnt->to2D(aC->pnt(), aX->dir(), aY); +} + + std::shared_ptr PartSet_Tools::convertTo3D(const double theX, const double theY, FeaturePtr theSketch) { std::shared_ptr aData = theSketch->data(); diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index e614074a8..84b2311a6 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -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 convertTo2D(FeaturePtr theSketch, const std::shared_ptr& 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