Material: Appearance Updates 2

Improves the use of the ShapeAppearance property for the Part workbench.

    removes DiffuseColor property
        adds Python compatibility using custom attributes
        transitions DiffuseColor to ShapeAppearance on open
    Improved UI elements for setting object appearance, and appearance per face
    Lays the foundation for future texture support
This commit is contained in:
David Carter
2024-06-01 18:26:38 -04:00
committed by Chris Hennes
parent c4d0f3ed97
commit 5feb963f9d
55 changed files with 1540 additions and 714 deletions

View File

@@ -1,25 +1,25 @@
/***************************************************************************
* Copyright (c) 2002 Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* FreeCAD is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* *
***************************************************************************/
* Copyright (c) 2002 Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* FreeCAD is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with FreeCAD; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
* *
***************************************************************************/
#include "PreCompiled.h"
@@ -92,13 +92,15 @@ void loadPartResource()
Gui::Translator::instance()->refresh();
}
namespace PartGui {
class Module : public Py::ExtensionModule<Module>
namespace PartGui
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("PartGui")
Module()
: Py::ExtensionModule<Module>("PartGui")
{
initialize("This module is the PartGui module."); // register with Python
initialize("This module is the PartGui module."); // register with Python
}
private:
@@ -106,10 +108,11 @@ private:
PyObject* initModule()
{
return Base::Interpreter().addModule(new Module);;
return Base::Interpreter().addModule(new Module);
;
}
} // namespace PartGui
} // namespace PartGui
PyMOD_INIT_FUNC(PartGui)
{
@@ -123,7 +126,7 @@ PyMOD_INIT_FUNC(PartGui)
Base::Interpreter().runString("import Part");
Base::Interpreter().runString("import MatGui");
}
catch(const Base::Exception& e) {
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(nullptr);
}
@@ -137,13 +140,15 @@ PyMOD_INIT_FUNC(PartGui)
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/parametric"));
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools"));
static struct PyModuleDef pAttachEngineTextsModuleDef = {
PyModuleDef_HEAD_INIT,
"AttachEngineResources",
"AttachEngineResources", -1,
AttacherGui::AttacherGuiPy::Methods,
nullptr, nullptr, nullptr, nullptr
};
static struct PyModuleDef pAttachEngineTextsModuleDef = {PyModuleDef_HEAD_INIT,
"AttachEngineResources",
"AttachEngineResources",
-1,
AttacherGui::AttacherGuiPy::Methods,
nullptr,
nullptr,
nullptr,
nullptr};
PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef);
Py_INCREF(pAttachEngineTextsModule);
@@ -220,23 +225,31 @@ PyMOD_INIT_FUNC(PartGui)
CreateSimplePartCommands();
CreateParamPartCommands();
CreatePartSelectCommands();
try{
Py::Object ae = Base::Interpreter().runStringObject("__import__('AttachmentEditor.Commands').Commands");
Py::Module(partGuiModule).setAttr(std::string("AttachmentEditor"),ae);
} catch (Base::PyException &err){
try {
Py::Object ae =
Base::Interpreter().runStringObject("__import__('AttachmentEditor.Commands').Commands");
Py::Module(partGuiModule).setAttr(std::string("AttachmentEditor"), ae);
}
catch (Base::PyException& err) {
err.ReportException();
}
// register preferences pages
Gui::Dialog::DlgPreferencesImp::setGroupData("Part/Part Design", "Part design", QObject::tr("Part and Part Design workbench"));
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsGeneral>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
(void)new Gui::PrefPageProducer<PartGui::DlgSettings3DViewPart>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsObjectColor>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportIges>(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportStep>(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
Gui::ViewProviderBuilder::add(
Part::PropertyPartShape::getClassTypeId(),
PartGui::ViewProviderPart::getClassTypeId());
Gui::Dialog::DlgPreferencesImp::setGroupData("Part/Part Design",
"Part design",
QObject::tr("Part and Part Design workbench"));
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsGeneral>(
QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
(void)new Gui::PrefPageProducer<PartGui::DlgSettings3DViewPart>(
QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsObjectColor>(
QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportIges>(
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportStep>(
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
Gui::ViewProviderBuilder::add(Part::PropertyPartShape::getClassTypeId(),
PartGui::ViewProviderPart::getClassTypeId());
// add resources and reloads the translators
loadPartResource();