Core: Change placement dialog to operate on passed selection objects

This commit is contained in:
wmayer
2024-09-09 11:25:30 -05:00
committed by Chris Hennes
parent bb3c7afe95
commit d07ae89f72
3 changed files with 26 additions and 1 deletions
+1
View File
@@ -1562,6 +1562,7 @@ void StdCmdPlacement::activated(int iMsg)
plm->setPropertyName(QLatin1String("Placement"));
plm->setSelection(selection);
plm->bindObject();
plm->clearSelection();
}
}
Gui::Control().showDialog(plm);
+24 -1
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.
+1
View File
@@ -187,6 +187,7 @@ public:
void setPropertyName(const QString&);
void setPlacement(const Base::Placement&);
void setSelection(const std::vector<SelectionObject>&);
void clearSelection();
void bindObject();
bool accept() override;
bool reject() override;