Core: Change placement dialog to operate on passed selection objects

This commit is contained in:
wmayer
2024-09-05 17:43:09 +02:00
parent f8648b475a
commit 6f245c0103
3 changed files with 26 additions and 1 deletions

View File

@@ -195,7 +195,21 @@ std::vector<App::DocumentObject*> PlacementHandler::getObjects(Gui::Document* do
std::vector<App::DocumentObject*> PlacementHandler::getSelectedObjects(Gui::Document* document) const
{
return Gui::Selection().getObjectsOfType(App::DocumentObject::getClassTypeId(), document->getDocument()->getName());
App::Document* doc = document->getDocument();
std::vector<App::DocumentObject*> list;
list.reserve(selectionObjects.size());
for (const auto& it : selectionObjects) {
const App::DocumentObject* obj = it.getObject();
if (obj && obj->getDocument() == doc) {
list.push_back(const_cast<App::DocumentObject*>(obj)); // NOLINT
}
}
if (!list.empty()) {
return list;
}
return Gui::Selection().getObjectsOfType(App::DocumentObject::getClassTypeId(), doc->getName());
}
void PlacementHandler::revertTransformationOfViewProviders(Gui::Document* document)
@@ -1073,6 +1087,15 @@ void TaskPlacement::setSelection(const std::vector<Gui::SelectionObject>& select
widget->setSelection(selection);
}
/*!
* \brief TaskPlacement::clearSelection
* Clears the array of selection objects.
*/
void TaskPlacement::clearSelection()
{
widget->setSelection({});
}
/*!
* \brief TaskPlacement::bindObject
* Binds the spin boxes to the placement components of the first object of the selection.