0000353: Graphical selection
This commit is contained in:
parent
8794441e87
commit
106afe48ea
|
@ -58,6 +58,7 @@
|
|||
#include "SceneInspector.h"
|
||||
#include "DemoMode.h"
|
||||
#include "TextureMapping.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
|
@ -1900,6 +1901,79 @@ void StdViewBoxZoom::activated(int iMsg)
|
|||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_BoxSelection
|
||||
//===========================================================================
|
||||
DEF_3DV_CMD(StdBoxSelection);
|
||||
|
||||
StdBoxSelection::StdBoxSelection()
|
||||
: Command("Std_BoxSelection")
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Standard-View");
|
||||
sMenuText = QT_TR_NOOP("Box selection");
|
||||
sToolTipText = QT_TR_NOOP("Box selection");
|
||||
sWhatsThis = "Std_ViewBoxZoom";
|
||||
sStatusTip = QT_TR_NOOP("Box selection");
|
||||
eType = AlterSelection;
|
||||
}
|
||||
|
||||
static void selectionCallback(void * ud, SoEventCallback * cb)
|
||||
{
|
||||
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(cb->getUserData());
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback, ud);
|
||||
std::vector<SbVec2f> picked = view->getGLPolygon();
|
||||
SoCamera* cam = view->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
if (picked.size() == 2) {
|
||||
SbVec2f pt1 = picked[0];
|
||||
SbVec2f pt2 = picked[1];
|
||||
polygon.Add(Base::Vector2D(pt1[0], pt1[1]));
|
||||
polygon.Add(Base::Vector2D(pt1[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2D(pt2[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2D(pt2[0], pt1[1]));
|
||||
}
|
||||
else {
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
||||
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
}
|
||||
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
if (doc) {
|
||||
cb->setHandled();
|
||||
std::vector<App::GeoFeature*> geom = doc->getObjectsOfType<App::GeoFeature>();
|
||||
for (std::vector<App::GeoFeature*>::iterator it = geom.begin(); it != geom.end(); ++it) {
|
||||
std::vector<App::Property*> props;
|
||||
(*it)->getPropertyList(props);
|
||||
for (std::vector<App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
|
||||
if ((*jt)->isDerivedFrom(App::PropertyGeometry::getClassTypeId())) {
|
||||
App::PropertyGeometry* prop = static_cast<App::PropertyGeometry*>(*jt);
|
||||
Base::BoundBox3d bbox = prop->getBoundingBox();
|
||||
Base::Vector3d pt2d;
|
||||
pt2d = proj(bbox.CalcCenter());
|
||||
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y))) {
|
||||
Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StdBoxSelection::activated(int iMsg)
|
||||
{
|
||||
View3DInventor* view = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow());
|
||||
if ( view ) {
|
||||
View3DInventorViewer* viewer = view->getViewer();
|
||||
if (!viewer->isSelecting()) {
|
||||
viewer->startSelection(View3DInventorViewer::Rectangle);
|
||||
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), selectionCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_TreeSelection
|
||||
//===========================================================================
|
||||
|
@ -2113,6 +2187,7 @@ void CreateViewStdCommands(void)
|
|||
rcCmdMgr.addCommand(new StdViewZoomIn());
|
||||
rcCmdMgr.addCommand(new StdViewZoomOut());
|
||||
rcCmdMgr.addCommand(new StdViewBoxZoom());
|
||||
rcCmdMgr.addCommand(new StdBoxSelection());
|
||||
rcCmdMgr.addCommand(new StdCmdTreeSelection());
|
||||
rcCmdMgr.addCommand(new StdCmdMeasureDistance());
|
||||
rcCmdMgr.addCommand(new StdCmdSceneInspector());
|
||||
|
|
|
@ -495,6 +495,7 @@ int RectangleSelection::mouseButtonEvent( const SoMouseButtonEvent * const e, co
|
|||
{
|
||||
releaseMouseModel();
|
||||
m_bWorking = false;
|
||||
_clPoly.push_back(e->getPosition());
|
||||
ret = Finish;
|
||||
} break;
|
||||
default:
|
||||
|
|
|
@ -88,8 +88,6 @@ protected:
|
|||
int m_iXnew, m_iYnew;
|
||||
SbBool m_bInner;
|
||||
SbBool mustRedraw;
|
||||
|
||||
private:
|
||||
std::vector<SbVec2s> _clPoly;
|
||||
};
|
||||
|
||||
|
|
|
@ -441,7 +441,7 @@ MenuItem* StdWorkbench::setupMenuBar() const
|
|||
edit->setCommand("&Edit");
|
||||
*edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
|
||||
<< "Std_Paste" << "Std_DuplicateSelection" << "Separator"
|
||||
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete"
|
||||
<< "Std_Refresh" << "Std_BoxSelection" << "Std_SelectAll" << "Std_Delete"
|
||||
<< "Std_Placement" << "Std_Alignment"
|
||||
<< "Std_Edit" << "Separator" << "Std_DlgPreferences";
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
edit->setCommand("&Edit");
|
||||
*edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
|
||||
<< "Std_Paste" << "Std_DuplicateSelection" << "Separator"
|
||||
<< "Std_Refresh" << "Std_SelectAll" << "Std_Delete"
|
||||
<< "Std_Refresh" << "Std_BoxSelection" << "Std_SelectAll" << "Std_Delete"
|
||||
<< "Std_Placement" << "Std_Alignment"
|
||||
<< "Separator" << "Std_DlgPreferences";
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user