issue #0000353: Graphical selection
This commit is contained in:
parent
cb996431e6
commit
761d684c79
|
@ -2265,6 +2265,9 @@ static void selectionCallback(void * ud, SoEventCallback * cb)
|
||||||
SoNode* root = view->getSceneGraph();
|
SoNode* root = view->getSceneGraph();
|
||||||
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
|
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
|
||||||
|
|
||||||
|
typedef enum { CENTER, INTERSECT } SelectionMode;
|
||||||
|
SelectionMode selectionMode = CENTER;
|
||||||
|
|
||||||
std::vector<SbVec2f> picked = view->getGLPolygon();
|
std::vector<SbVec2f> picked = view->getGLPolygon();
|
||||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||||
SbViewVolume vv = cam->getViewVolume();
|
SbViewVolume vv = cam->getViewVolume();
|
||||||
|
@ -2277,6 +2280,11 @@ static void selectionCallback(void * ud, SoEventCallback * cb)
|
||||||
polygon.Add(Base::Vector2D(pt1[0], pt2[1]));
|
polygon.Add(Base::Vector2D(pt1[0], pt2[1]));
|
||||||
polygon.Add(Base::Vector2D(pt2[0], pt2[1]));
|
polygon.Add(Base::Vector2D(pt2[0], pt2[1]));
|
||||||
polygon.Add(Base::Vector2D(pt2[0], pt1[1]));
|
polygon.Add(Base::Vector2D(pt2[0], pt1[1]));
|
||||||
|
|
||||||
|
// when selecting from right to left then select by intersection
|
||||||
|
// oterwise if the center is inside the rectangle
|
||||||
|
if (picked[0][0] > picked[1][0])
|
||||||
|
selectionMode = INTERSECT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
||||||
|
@ -2303,10 +2311,19 @@ static void selectionCallback(void * ud, SoEventCallback * cb)
|
||||||
if ((*jt)->isDerivedFrom(App::PropertyGeometry::getClassTypeId())) {
|
if ((*jt)->isDerivedFrom(App::PropertyGeometry::getClassTypeId())) {
|
||||||
App::PropertyGeometry* prop = static_cast<App::PropertyGeometry*>(*jt);
|
App::PropertyGeometry* prop = static_cast<App::PropertyGeometry*>(*jt);
|
||||||
Base::BoundBox3d bbox = prop->getBoundingBox();
|
Base::BoundBox3d bbox = prop->getBoundingBox();
|
||||||
Base::Vector3d pt2d;
|
|
||||||
pt2d = proj(bbox.GetCenter());
|
if (selectionMode == CENTER) {
|
||||||
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y))) {
|
Base::Vector3d pt2d;
|
||||||
Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument());
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user