Skip to content

Commit

Permalink
Clean-up code and improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jun 17, 2024
1 parent 84e199a commit 32988ff
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 63 deletions.
2 changes: 2 additions & 0 deletions src/Gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,7 @@ void Application::initApplication()

void Application::initTypes()
{
// clang-format off
// views
Gui::BaseView ::init();
Gui::MDIView ::init();
Expand Down Expand Up @@ -1945,6 +1946,7 @@ void Application::initTypes()
// register transaction type
new App::TransactionProducer<TransactionViewProvider>
(ViewProviderDocumentObject::getClassTypeId());
// clang-format on
}

void Application::initOpenInventor()
Expand Down
2 changes: 0 additions & 2 deletions src/Gui/DlgMaterialPropertiesImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@

#include "PreCompiled.h"

#include <App/Color.h>
#include <App/PropertyStandard.h>

#include "Application.h"
#include "DlgMaterialPropertiesImp.h"
#include "ui_DlgMaterialProperties.h"
#include "ViewProvider.h"
Expand Down
1 change: 0 additions & 1 deletion src/Gui/ViewProviderGeometryObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class GuiExport ViewProviderGeometryObject: public ViewProviderDragger

/// Get the python wrapper for that ViewProvider
PyObject* getPyObject() override;
static App::Material getUserDefinedMaterial();

protected:
/// get called by the container whenever a property has been changed
Expand Down
51 changes: 20 additions & 31 deletions src/Mod/Part/Gui/AppPartGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class Module: public Py::ExtensionModule<Module>
PyObject* initModule()
{
return Base::Interpreter().addModule(new Module);
;
}

} // namespace PartGui
Expand Down Expand Up @@ -140,15 +139,17 @@ 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};
// clang-format off
static struct PyModuleDef pAttachEngineTextsModuleDef = {
PyModuleDef_HEAD_INIT,
"AttachEngineResources",
"AttachEngineResources",
-1,
AttacherGui::AttacherGuiPy::Methods,
nullptr, nullptr, nullptr, nullptr
};
// clang-format on

PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef);

Py_INCREF(pAttachEngineTextsModule);
Expand Down Expand Up @@ -218,46 +219,34 @@ PyMOD_INIT_FUNC(PartGui)
PartGui::Workbench ::init();
auto manip = std::make_shared<PartGui::WorkbenchManipulator>();
Gui::WorkbenchManipulator::installManipulator(manip);
// clang-format on

// instantiating the commands
CreatePartCommands();
CreateSimplePartCommands();
CreateParamPartCommands();
CreatePartSelectCommands();
try {
Py::Object ae =
Base::Interpreter().runStringObject("__import__('AttachmentEditor.Commands').Commands");
const char* cmd = "__import__('AttachmentEditor.Commands').Commands";
Py::Object ae = Base::Interpreter().runStringObject(cmd);
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::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());
// clang-format on

// add resources and reloads the translators
loadPartResource();

// register bitmaps
// Gui::BitmapFactoryInst& rclBmpFactory = Gui::BitmapFactory();
// rclBmpFactory.addXPM("Part_Feature",(const char**) PartFeature_xpm);
// rclBmpFactory.addXPM("Part_FeatureImport",(const char**) PartFeatureImport_xpm);

PyMOD_Return(partGuiModule);
}
50 changes: 23 additions & 27 deletions src/Mod/Part/Gui/DlgProjectionOnSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,38 +720,34 @@ void PartGui::DlgProjectionOnSurface::higlight_object(Part::Feature* iCurrentObj
auto vp = dynamic_cast<PartGui::ViewProviderPartExt*>(
Gui::Application::Instance->getViewProvider(iCurrentObject));
if (vp) {
App::Color aColor;
aColor.setPackedValue(iColor);
std::vector<App::Color> colors;
App::Color defaultColor;
if (currentShapeType == TopAbs_FACE) {
std::vector<App::Material> colors = vp->ShapeAppearance.getValues();
App::Color defaultColor = vp->ShapeAppearance.getDiffuseColor();

if (static_cast<Standard_Integer>(colors.size()) != anIndices.Extent()) {
colors.resize(anIndices.Extent(), vp->ShapeAppearance[0]);
}

if (iHighlight) {
colors.at(index - 1).diffuseColor = aColor;
}
else {
colors.at(index - 1).diffuseColor = defaultColor;
}
vp->ShapeAppearance.setValues(colors);
colors = vp->ShapeAppearance.getDiffuseColors();
defaultColor = colors.front();
}
else if (currentShapeType == TopAbs_EDGE) {
std::vector<App::Color> colors = vp->LineColorArray.getValues();
App::Color defaultColor = vp->LineColor.getValue();
colors = vp->LineColorArray.getValues();
defaultColor = vp->LineColor.getValue();
}

if (static_cast<Standard_Integer>(colors.size()) != anIndices.Extent()) {
colors.resize(anIndices.Extent(), defaultColor);
}
if (static_cast<Standard_Integer>(colors.size()) != anIndices.Extent()) {
colors.resize(anIndices.Extent(), defaultColor);
}

if (iHighlight) {
colors.at(index - 1) = aColor;
}
else {
colors.at(index - 1) = defaultColor;
}
if (iHighlight) {
App::Color aColor;
aColor.setPackedValue(iColor);
colors.at(index - 1) = aColor;
}
else {
colors.at(index - 1) = defaultColor;
}
if (currentShapeType == TopAbs_FACE) {
vp->ShapeAppearance.setDiffuseColors(colors);
}
else if (currentShapeType == TopAbs_EDGE) {
vp->LineColorArray.setValues(colors);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Surface/Gui/TaskSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ void ViewProviderSections::highlightReferences(ShapeType type, const References&
// check again that the index is in range because it's possible that
// the sub-names are invalid
if (idx < materials.size()) {
materials[idx].diffuseColor =
App::Color(1.0, 0.0, 1.0); // magenta
// magenta
materials[idx].diffuseColor = App::Color(1.0, 0.0, 1.0);
}
}

Expand Down

0 comments on commit 32988ff

Please sign in to comment.