From f973f6b3f9913290a3781562b1a9d16654942eff Mon Sep 17 00:00:00 2001 From: Jolbas <39026960+Jolbas@users.noreply.github.com> Date: Sun, 4 Jun 2023 10:34:55 +0200 Subject: [PATCH 1/8] Improved font handling Navigation cube Also adding anisotropy texture mapping for better readability on steep angles. --- src/Gui/DlgSettingsNavigation.cpp | 20 ++++++++++---------- src/Gui/DlgSettingsNavigation.ui | 5 +++++ src/Gui/MainWindow.cpp | 10 ---------- src/Gui/NaviCube.cpp | 11 +++++------ src/Gui/View3DSettings.cpp | 15 +-------------- src/Gui/View3DSettings.h | 1 - 6 files changed, 21 insertions(+), 41 deletions(-) diff --git a/src/Gui/DlgSettingsNavigation.cpp b/src/Gui/DlgSettingsNavigation.cpp index 895d17de7c..2b148cc1ce 100644 --- a/src/Gui/DlgSettingsNavigation.cpp +++ b/src/Gui/DlgSettingsNavigation.cpp @@ -108,10 +108,13 @@ void DlgSettingsNavigation::saveSettings() hCustom->SetFloat("Q2", q2); hCustom->SetFloat("Q3", q3); } - hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/NaviCube"); - hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1()); + if (ui->naviCubeFontName->currentIndex()) { + hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1()); + } else { + hGrp->RemoveASCII("FontString"); + } } void DlgSettingsNavigation::loadSettings() @@ -171,9 +174,6 @@ void DlgSettingsNavigation::loadSettings() this, &DlgSettingsNavigation::onMouseButtonClicked); // fill up font styles - hGrp = App::GetApplication().GetParameterGroupByPath( - "User parameter:BaseApp/Preferences/NaviCube"); - std::string defaultSansserifFont = NaviCubeSettings::getDefaultSansserifFont().toStdString(); // we purposely allow all available fonts on the system #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -182,12 +182,12 @@ void DlgSettingsNavigation::loadSettings() QStringList familyNames = QFontDatabase::families(QFontDatabase::Any); #endif ui->naviCubeFontName->addItems(familyNames); - + + hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/NaviCube"); int indexFamilyNames = familyNames.indexOf( - QString::fromStdString(hGrp->GetASCII("FontString", defaultSansserifFont.c_str()))); - if (indexFamilyNames < 0) - indexFamilyNames = 0; - ui->naviCubeFontName->setCurrentIndex(indexFamilyNames); + QString::fromStdString(hGrp->GetASCII("FontString"))); + ui->naviCubeFontName->setCurrentIndex(indexFamilyNames + 1); } diff --git a/src/Gui/DlgSettingsNavigation.ui b/src/Gui/DlgSettingsNavigation.ui index 90b7607bb6..f884bc8239 100644 --- a/src/Gui/DlgSettingsNavigation.ui +++ b/src/Gui/DlgSettingsNavigation.ui @@ -157,6 +157,11 @@ NaviCube + + + Default + + diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 4ba658eac6..2ad42ab93a 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -446,16 +446,6 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) // accept drops on the window, get handled in dropEvent, dragEnterEvent setAcceptDrops(true); - // setup font substitutions for NaviCube - // Helvetica usually gives good enough results on mac & linux - // in rare cases Helvetica matches a bad font on linux - // Nimbus Sans Narrow and Open Sans Condensed added as fallback - // Bahnschrift is a condensed font available on windows versions since 2017 - // Arial added as fallback for older version - auto substitutions = QStringLiteral("Bahnschrift,Helvetica,Nimbus Sans Narrow,Open Sans Condensed,Arial,Sans"); - auto family = QStringLiteral("FreeCAD NaviCube"); - QFont::insertSubstitutions(family, substitutions.split(QLatin1Char(','))); - statusBar()->showMessage(tr("Ready"), 2001); } diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp index 41f6a2efc2..d39b102b9e 100644 --- a/src/Gui/NaviCube.cpp +++ b/src/Gui/NaviCube.cpp @@ -401,12 +401,10 @@ int imageVerticalBalance(QImage p, int sizeHint) { void NaviCubeImplementation::createCubeFaceTextures() { int texSize = 192; // Works well for the max cube size 1024 - // find font sizes QFont font; - if (!m_TextFont.empty()) { - QString fontString = QString::fromStdString(m_TextFont); - font.fromString(fontString); - } + if (m_TextFont.empty()) font.fromString(QStringLiteral("Arial")); + else font.fromString(QString::fromStdString(m_TextFont)); + font.setStyleHint(QFont::SansSerif); if (m_FontWeight > 0) { font.setWeight(convertWeights(m_FontWeight)); } @@ -454,9 +452,10 @@ void NaviCubeImplementation::createCubeFaceTextures() { delete m_LabelTextures[pickId].texture; } m_LabelTextures[pickId].texture = new QOpenGLTexture(image.mirrored()); - m_LabelTextures[pickId].texture->generateMipMaps(); + m_LabelTextures[pickId].texture->setMaximumAnisotropy(4.0); m_LabelTextures[pickId].texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear); m_LabelTextures[pickId].texture->setMagnificationFilter(QOpenGLTexture::Linear); + m_LabelTextures[pickId].texture->generateMipMaps(); } } diff --git a/src/Gui/View3DSettings.cpp b/src/Gui/View3DSettings.cpp index 3ac95d3f66..05ffeb31f9 100644 --- a/src/Gui/View3DSettings.cpp +++ b/src/Gui/View3DSettings.cpp @@ -442,7 +442,6 @@ NaviCubeSettings::NaviCubeSettings(ParameterGrp::handle hGrp, [this](ParameterGrp*, ParameterGrp::ParamType, const char *Name, const char *) { parameterChanged(Name); }); - } NaviCubeSettings::~NaviCubeSettings() @@ -450,16 +449,6 @@ NaviCubeSettings::~NaviCubeSettings() connectParameterChanged.disconnect(); } -QString NaviCubeSettings::getDefaultSansserifFont() -{ - // "FreeCAD NaviCube" family susbtitutions are set in MainWindow::MainWindow - QFont font(QStringLiteral("FreeCAD NaviCube")); - font.setStyleHint(QFont::SansSerif); - // QFontInfo is required to get the actually matched font family - return QFontInfo(font).family(); - // return QStringLiteral("FreeCAD NaviCube"); -} - void NaviCubeSettings::applySettings() { parameterChanged("BaseColor"); @@ -506,9 +495,7 @@ void NaviCubeSettings::parameterChanged(const char* Name) nc->setFontZoom(hGrp->GetFloat("FontZoom", 0.3)); } else if (strcmp(Name, "FontString") == 0) { - std::string font = - hGrp->GetASCII("FontString", getDefaultSansserifFont().toStdString().c_str()); - nc->setFont(font); + nc->setFont(hGrp->GetASCII("FontString")); } else if (strcmp(Name, "FontWeight") == 0) { nc->setFontWeight(hGrp->GetInt("FontWeight", 0)); diff --git a/src/Gui/View3DSettings.h b/src/Gui/View3DSettings.h index 7c52247405..eddea34ea3 100644 --- a/src/Gui/View3DSettings.h +++ b/src/Gui/View3DSettings.h @@ -60,7 +60,6 @@ public: ~NaviCubeSettings(); void applySettings(); - static QString getDefaultSansserifFont(); private: void parameterChanged(ParameterGrp::MessageType pName); ParameterGrp::handle hGrp; From 2e2eb3e70b1aaafbca646bbab7f589a61757aad5 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Wed, 7 Jun 2023 12:31:34 +0200 Subject: [PATCH 2/8] Core: fix navigation cube BaseColor pref tooltip --- src/Gui/DlgSettingsNavigation.ui | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Gui/DlgSettingsNavigation.ui b/src/Gui/DlgSettingsNavigation.ui index f884bc8239..711cc07975 100644 --- a/src/Gui/DlgSettingsNavigation.ui +++ b/src/Gui/DlgSettingsNavigation.ui @@ -209,8 +209,7 @@ - color for all elements -around the cube + Base color for all elements From 7a68d1b6d3f953e1c3f1cebf410fc72b576789e3 Mon Sep 17 00:00:00 2001 From: grubertechnic Date: Tue, 6 Jun 2023 15:47:05 +0200 Subject: [PATCH 3/8] [TechDraw] let arrow size of a dimension change due property task panel --- src/Mod/TechDraw/App/Preferences.cpp | 6 ++++++ src/Mod/TechDraw/App/Preferences.h | 2 ++ src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp | 3 ++- src/Mod/TechDraw/Gui/PreferencesGui.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderDimension.cpp | 9 +++++++++ src/Mod/TechDraw/Gui/ViewProviderDimension.h | 2 ++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index b88bca9771..7278ee04db 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -42,6 +42,7 @@ using namespace TechDraw; const double Preferences::DefaultFontSizeInMM = 5.0; +const double Preferences::DefaultArrowSize = 3.5; //! Returns the TechDraw preference group Base::Reference Preferences::getPreferenceGroup(const char* Name) @@ -70,6 +71,11 @@ double Preferences::dimFontSizeMM() return getPreferenceGroup("Dimensions")->GetFloat("FontSize", DefaultFontSizeInMM); } +double Preferences::dimArrowSize() +{ + return getPreferenceGroup("Dimensions")->GetFloat("ArrowSize", DefaultArrowSize); +} + App::Color Preferences::normalColor() { App::Color fcColor; diff --git a/src/Mod/TechDraw/App/Preferences.h b/src/Mod/TechDraw/App/Preferences.h index c976a17849..e4757e9348 100644 --- a/src/Mod/TechDraw/App/Preferences.h +++ b/src/Mod/TechDraw/App/Preferences.h @@ -51,6 +51,7 @@ public: static QString labelFontQString(); static double labelFontSizeMM(); static double dimFontSizeMM(); + static double dimArrowSize(); static App::Color normalColor(); static App::Color selectColor(); @@ -74,6 +75,7 @@ public: static std::string lineGroupFile(); static const double DefaultFontSizeInMM; + static const double DefaultArrowSize; static std::string formatSpec(); static int altDecimals(); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp index 6bdf0f0ade..829bca5a97 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp @@ -74,10 +74,11 @@ void DlgPrefsTechDrawDimensionsImp::loadSettings() //Quantity widgets do not use preset value since they are based on //QAbstractSpinBox double fontDefault = Preferences::dimFontSizeMM(); + double arrowDefault = Preferences::dimArrowSize(); ui->plsb_FontSize->setValue(fontDefault); // double arrowDefault = 5.0; // plsb_ArrowSize->setValue(arrowDefault); - ui->plsb_ArrowSize->setValue(fontDefault); + ui->plsb_ArrowSize->setValue(arrowDefault); ui->pcbStandardAndStyle->onRestore(); ui->cbGlobalDecimals->onRestore(); diff --git a/src/Mod/TechDraw/Gui/PreferencesGui.cpp b/src/Mod/TechDraw/Gui/PreferencesGui.cpp index 6628dbbfce..43ead436dc 100644 --- a/src/Mod/TechDraw/Gui/PreferencesGui.cpp +++ b/src/Mod/TechDraw/Gui/PreferencesGui.cpp @@ -145,7 +145,7 @@ int PreferencesGui::dimArrowStyle() double PreferencesGui::dimArrowSize() { - return Preferences::getPreferenceGroup("Dimensions")->GetFloat("ArrowSize", Preferences::dimFontSizeMM()); + return Preferences::getPreferenceGroup("Dimensions")->GetFloat("ArrowSize", Preferences::dimArrowSize()); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp index 8732c238d6..64973da627 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp @@ -70,6 +70,9 @@ ViewProviderDimension::ViewProviderDimension() ADD_PROPERTY_TYPE(Fontsize, (Preferences::dimFontSizeMM()), group, (App::PropertyType)(App::Prop_None), "Dimension text size in units"); + ADD_PROPERTY_TYPE(Arrowsize, (Preferences::dimArrowSize()), + group, (App::PropertyType)(App::Prop_None), + "Arrow size in units"); ADD_PROPERTY_TYPE(LineWidth, (prefWeight()), group, (App::PropertyType)(App::Prop_None), "Dimension line width"); ADD_PROPERTY_TYPE(Color, (prefColor()), group, App::Prop_None, "Color of the dimension"); @@ -195,6 +198,7 @@ void ViewProviderDimension::onChanged(const App::Property* p) { if ((p == &Font) || (p == &Fontsize) || + (p == &Arrowsize) || (p == &LineWidth) || (p == &StandardAndStyle) || (p == &RenderingExtent) || @@ -240,6 +244,11 @@ double ViewProviderDimension::prefFontSize() const return Preferences::dimFontSizeMM(); } +double ViewProviderDimension::prefArrowSize() const +{ + return Preferences::dimArrowSize(); +} + double ViewProviderDimension::prefWeight() const { return TechDraw::LineGroup::getDefaultWidth("Thin"); diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.h b/src/Mod/TechDraw/Gui/ViewProviderDimension.h index 8a72f9abec..9756101fc4 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.h +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.h @@ -45,6 +45,7 @@ public: App::PropertyFont Font; App::PropertyLength Fontsize; + App::PropertyLength Arrowsize; App::PropertyLength LineWidth; App::PropertyColor Color; @@ -81,6 +82,7 @@ public: App::Color prefColor() const; std::string prefFont() const; double prefFontSize() const; + double prefArrowSize() const; double prefWeight() const; int prefStandardAndStyle() const; bool canDelete(App::DocumentObject* obj) const override; From 9ad7a0ea722d525f4366f3e89b238d61074d5cc2 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Wed, 17 May 2023 22:06:52 -0400 Subject: [PATCH 4/8] [TD]use vp Property for arrow size --- src/Mod/TechDraw/Gui/QGIViewDimension.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index 1dd0ca7116..adca99a655 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -1267,7 +1267,9 @@ void QGIViewDimension::drawArrows(int count, const Base::Vector2d positions[], d } arrow->setStyle(QGIArrow::getPrefArrowStyle()); - arrow->setSize(QGIArrow::getPrefArrowSize()); + auto vp = static_cast(getViewProvider(getViewObject())); + auto arrowSize = vp->Arrowsize.getValue(); + arrow->setSize(arrowSize); arrow->setFlipped(flipped); if (QGIArrow::getPrefArrowStyle() != 7) {// if not "None" @@ -2624,7 +2626,13 @@ double QGIViewDimension::getDefaultArrowTailLength() const { // Arrow length shall be equal to font height and both ISO and ASME seem // to have arrow tail twice the arrow length, so let's make it twice arrow size - return QGIArrow::getPrefArrowSize() * 2.0; + auto arrowSize = PreferencesGui::dimArrowSize(); + auto vp = static_cast(getViewProvider(getViewObject())); + if (vp) { + arrowSize = vp->Arrowsize.getValue(); + + } + return arrowSize * 2.0; } double QGIViewDimension::getDefaultIsoDimensionLineSpacing() const From df102ed0059c387010ad4fa8837ecd9eac375d1a Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Mon, 5 Jun 2023 09:43:43 +0200 Subject: [PATCH 5/8] Sketcher: Minor improvements to some GUI texts --- src/Mod/Sketcher/Gui/Command.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index ceb66eab49..7a8d1598b6 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -1115,12 +1115,12 @@ public: void languageChange() { - gridAutoSpacing->setText(tr("Grid Auto Spacing")); + gridAutoSpacing->setText(tr("Grid auto spacing")); gridAutoSpacing->setToolTip(tr("Resize grid automatically depending on zoom.")); gridAutoSpacing->setStatusTip(gridAutoSpacing->toolTip()); sizeLabel->setText(tr("Spacing")); - gridSizeBox->setToolTip(tr("Distance between two subsequent grid lines")); + gridSizeBox->setToolTip(tr("Distance between two subsequent grid lines.")); } protected: @@ -1217,7 +1217,7 @@ CmdSketcherGrid::CmdSketcherGrid() sGroup = "Sketcher"; sMenuText = QT_TR_NOOP("Toggle grid"); sToolTipText = - QT_TR_NOOP("Toggle the grid in the sketch. In the menu you can change grid settings"); + QT_TR_NOOP("Toggle the grid in the sketch. In the menu you can change grid settings."); sWhatsThis = "Sketcher_Grid"; sStatusTip = sToolTipText; eType = 0; @@ -1371,7 +1371,7 @@ public: angleLabel->setText(tr("Snap angle")); snapAngle->setToolTip( tr("Angular step for tools that use 'Snap at Angle' (line for instance). Hold CTRL to " - "enable 'Snap at Angle'. The angle start from the East axis (horizontal right)")); + "enable 'Snap at Angle'. The angle starts from the positive X axis of the sketch.")); } protected: @@ -1474,7 +1474,7 @@ CmdSketcherSnap::CmdSketcherSnap() sMenuText = QT_TR_NOOP("Toggle snap"); sToolTipText = QT_TR_NOOP("Toggle all snap functionality. In the menu you can toggle 'Snap to grid' and " - "'Snap to objects' individually, and change further snap settings"); + "'Snap to objects' individually, and change further snap settings."); sWhatsThis = "Sketcher_Snap"; sStatusTip = sToolTipText; eType = 0; From 3ff1c54f11dd78086d4fc563ac25b93ca88e3827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Insaurralde=20Avalos?= <36372335+adrianinsaval@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:48:57 -0400 Subject: [PATCH 6/8] [Sketcher] Fix incorrect toolbar name uppercase --- src/Mod/Sketcher/Gui/Workbench.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/Workbench.cpp b/src/Mod/Sketcher/Gui/Workbench.cpp index 58e1b6e0c3..389f4eee1f 100644 --- a/src/Mod/Sketcher/Gui/Workbench.cpp +++ b/src/Mod/Sketcher/Gui/Workbench.cpp @@ -159,7 +159,7 @@ namespace { inline const QStringList editModeToolbarNames() { - return QStringList {QString::fromLatin1("Sketcher Edit Mode"), + return QStringList {QString::fromLatin1("Sketcher edit mode"), QString::fromLatin1("Sketcher geometries"), QString::fromLatin1("Sketcher constraints"), QString::fromLatin1("Sketcher tools"), From 1bd8082a7eefd7c58302d876522705b6c72b8dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20B=C3=A4hr?= Date: Wed, 24 May 2023 22:17:43 +0200 Subject: [PATCH 7/8] Fix build of "tests" on macOS Building the C++ unit tests failed for tests/src/App/Metadata.cpp tests/src/Base/Reader.cpp because some XML headers were not found. This was because the XercesC include dir was not in the search list for headers. I cannot say why only macOS seems to be affected, but it's not the first time, see e.g https://github.com/FreeCAD/FreeCAD/commit/05469895f9cb7fbd85810745b6fca8796e3f500e --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d6d828382d..09db35011f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,7 +37,7 @@ endif() add_executable(Tests_run) add_subdirectory(lib) add_subdirectory(src) -target_include_directories(Tests_run PUBLIC ${Python3_INCLUDE_DIRS}) +target_include_directories(Tests_run PUBLIC ${Python3_INCLUDE_DIRS} ${XercesC_INCLUDE_DIRS}) target_link_libraries(Tests_run gtest_main ${Google_Tests_LIBS} FreeCADApp) add_executable(Sketcher_tests_run) From e8e7a64b3921481f7300d3527951db699760162c Mon Sep 17 00:00:00 2001 From: wandererfan Date: Thu, 8 Jun 2023 10:09:53 -0400 Subject: [PATCH 8/8] [TD]fix select vertex behind highlight --- src/Mod/TechDraw/Gui/ZVALUE.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Mod/TechDraw/Gui/ZVALUE.h b/src/Mod/TechDraw/Gui/ZVALUE.h index d004943ffc..9425ba6c63 100644 --- a/src/Mod/TechDraw/Gui/ZVALUE.h +++ b/src/Mod/TechDraw/Gui/ZVALUE.h @@ -7,16 +7,16 @@ namespace ZVALUE { //border/label const int border = 0; const int FACE = 10; const int HATCH = 30; - const int HIDEDGE = 40; - const int SECTIONFACE = 45; - const int SECTIONHATCH = 46; - const int EDGE = 50; - const int VERTEX = 60; + const int SECTIONFACE = 40; + const int SECTIONHATCH = 41; + const int HIGHLIGHT = 50; + const int HIDEDGE = 60; + const int EDGE = 70; + const int VERTEX = 80; + const int SECTIONLINE = 90; + const int MATTING = 100; const int DIMENSION = 110; const int LABEL = 120; - const int SECTIONLINE = 80; //TODO: change to "DECORATION"? section lines, symmetry lines, etc? - const int HIGHLIGHT = 80; - const int MATTING = 100; const int TRACKER = 125; const int LOCK = 200; }