Skip to content

Commit

Permalink
add command to select visible objects
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 21, 2016
1 parent 5abb99b commit 9b33f41
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/Gui/CommandView.cpp
Expand Up @@ -906,6 +906,47 @@ bool StdCmdHideSelection::isActive(void)
return (Gui::Selection().size() != 0);
}

//===========================================================================
// Std_SelectVisibleObjects
//===========================================================================
DEF_STD_CMD_A(StdCmdSelectVisibleObjects)

StdCmdSelectVisibleObjects::StdCmdSelectVisibleObjects()
: Command("Std_SelectVisibleObjects")
{
sGroup = QT_TR_NOOP("Standard-View");
sMenuText = QT_TR_NOOP("Select visible objects");
sToolTipText = QT_TR_NOOP("Select visible objects in the active document");
sStatusTip = QT_TR_NOOP("Select visible objects in the active document");
sWhatsThis = "Std_SelectVisibleObjects";
eType = Alter3DView;
}

void StdCmdSelectVisibleObjects::activated(int iMsg)
{
Q_UNUSED(iMsg);
// go through active document
Gui::Document* doc = Application::Instance->activeDocument();
App::Document* app = doc->getDocument();
const std::vector<App::DocumentObject*> obj = app->getObjectsOfType
(App::DocumentObject::getClassTypeId());

std::vector<App::DocumentObject*> visible;
visible.reserve(obj.size());
for (std::vector<App::DocumentObject*>::const_iterator it=obj.begin();it!=obj.end();++it) {
if (doc->isShow((*it)->getNameInDocument()))
visible.push_back(*it);
}

SelectionSingleton& rSel = Selection();
rSel.setSelection(app->getName(), visible);
}

bool StdCmdSelectVisibleObjects::isActive(void)
{
return App::GetApplication().getActiveDocument();
}

//===========================================================================
// Std_ToggleObjects
//===========================================================================
Expand Down Expand Up @@ -2649,6 +2690,7 @@ void CreateViewStdCommands(void)
rcCmdMgr.addCommand(new StdCmdToggleSelectability());
rcCmdMgr.addCommand(new StdCmdShowSelection());
rcCmdMgr.addCommand(new StdCmdHideSelection());
rcCmdMgr.addCommand(new StdCmdSelectVisibleObjects());
rcCmdMgr.addCommand(new StdCmdToggleObjects());
rcCmdMgr.addCommand(new StdCmdShowObjects());
rcCmdMgr.addCommand(new StdCmdHideObjects());
Expand Down
1 change: 1 addition & 0 deletions src/Gui/Workbench.cpp
Expand Up @@ -531,6 +531,7 @@ MenuItem* StdWorkbench::setupMenuBar() const
MenuItem* visu = new MenuItem;
visu->setCommand("Visibility");
*visu << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
<< "Std_SelectVisibleObjects"
<< "Separator" << "Std_ToggleObjects" << "Std_ShowObjects" << "Std_HideObjects"
<< "Separator" << "Std_ToggleSelectability"
<< "Separator" << "View_Measure_Toggle_All" << "View_Measure_Clear_All";
Expand Down

0 comments on commit 9b33f41

Please sign in to comment.