PartDesign: Add transparent previews

This commit is contained in:
Kacper Donat
2024-10-13 13:33:18 +02:00
parent 38db306a84
commit 7f87d87f61
58 changed files with 1438 additions and 1021 deletions

View File

@@ -46,71 +46,15 @@ ViewProviderPrimitive::ViewProviderPrimitive() = default;
ViewProviderPrimitive::~ViewProviderPrimitive() = default;
void ViewProviderPrimitive::attach(App::DocumentObject* obj) {
ViewProviderAddSub::attach(obj);
}
void ViewProviderPrimitive::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
addDefaultAction(menu, QObject::tr("Edit Primitive"));
PartDesignGui::ViewProvider::setupContextMenu(menu, receiver, member);
}
bool ViewProviderPrimitive::setEdit(int ModNum)
TaskDlgFeatureParameters* ViewProviderPrimitive::getEditDialog()
{
if (ModNum == ViewProvider::Default ) {
// When double-clicking on the item for this fillet the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskPrimitiveParameters *primitiveDlg = qobject_cast<TaskPrimitiveParameters *>(dlg);
if (dlg && !primitiveDlg) {
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
Gui::Control().closeDialog();
else
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
// always change to PartDesign WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
// start the edit dialog
// another pad left open its task panel
if (primitiveDlg)
Gui::Control().showDialog(primitiveDlg);
else
Gui::Control().showDialog(new TaskPrimitiveParameters(this));
setPreviewDisplayMode(true);
return true;
}
else {
return ViewProviderAddSub::setEdit(ModNum);
}
}
void ViewProviderPrimitive::unsetEdit(int ModNum)
{
setPreviewDisplayMode(false);
// Rely on parent class to:
// restitute old workbench (set setEdit above) and close the dialog if exiting editing
PartDesignGui::ViewProvider::unsetEdit(ModNum);
}
void ViewProviderPrimitive::updateData(const App::Property* p) {
PartDesignGui::ViewProviderAddSub::updateData(p);
return new TaskDlgPrimitiveParameters(this);
}
QIcon ViewProviderPrimitive::getIcon() const {