From 0a733ffd18077043b631fc1c953fe4976bef6e1a Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 18 Jan 2019 14:46:21 +0100 Subject: [PATCH] fixes 0002706: Box selection does not select dimension or text --- src/Gui/CommandView.cpp | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index d714b93ae2..c683d52c95 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -25,6 +25,7 @@ #ifndef _PreComp_ # include +# include # include # include # include @@ -2551,32 +2552,31 @@ static void selectionCallback(void * ud, SoEventCallback * cb) Gui::Selection().clearSelection(doc->getName()); } - std::vector geom = doc->getObjectsOfType(); - for (std::vector::iterator it = geom.begin(); it != geom.end(); ++it) { + std::vector geom = doc->getObjectsOfType(); + for (std::vector::iterator it = geom.begin(); it != geom.end(); ++it) { Gui::ViewProvider* vp = Application::Instance->getViewProvider(*it); if (!vp->isVisible()) continue; - std::vector props; - (*it)->getPropertyList(props); - for (std::vector::iterator jt = props.begin(); jt != props.end(); ++jt) { - if ((*jt)->isDerivedFrom(App::PropertyGeometry::getClassTypeId())) { - App::PropertyGeometry* prop = static_cast(*jt); - Base::BoundBox3d bbox = prop->getBoundingBox(); + // 0002706: For box selection use SoGetBoundingBoxAction for + // the view provider of an object + SoGetBoundingBoxAction bboxAction(view->getViewportRegion()); + bboxAction.apply(vp->getRoot()); + SbBox3f bbox = bboxAction.getBoundingBox(); + Base::BoundBox3d bbox3; + bbox3.Add(Base::convertTo(bbox.getMax())); + bbox3.Add(Base::convertTo(bbox.getMin())); - if (selectionMode == CENTER) { - Base::Vector3d pt2d; - pt2d = proj(bbox.GetCenter()); - if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) { - Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument()); - } - } - else { - Base::BoundBox2d bbox2 = bbox.ProjectBox(&proj); - if (bbox2.Intersect(polygon)) { - Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument()); - } - } - break; + if (selectionMode == CENTER) { + Base::Vector3d pt2d; + pt2d = proj(bbox3.GetCenter()); + if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) { + Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument()); + } + } + else { + Base::BoundBox2d bbox2 = bbox3.ProjectBox(&proj); + if (bbox2.Intersect(polygon)) { + Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument()); } } }