From f49b38a595b0b2f8870ae79e59a4269a19a0103f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Jun 2021 15:21:56 +0200 Subject: [PATCH 1/5] Draft: Fix incorrect use of `in` operator Looking at the surrounding code, this should be `==` rather than `in`. The code does work as intended, because a string is always a substring of itself, but better to fix it anyway. Seems this was broken since this code was first introduced in commit 94b0fe1599 (Draft: clean up ViewProviderLabel class) --- src/Mod/Draft/draftviewproviders/view_label.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftviewproviders/view_label.py b/src/Mod/Draft/draftviewproviders/view_label.py index 0238363287..571b40e000 100644 --- a/src/Mod/Draft/draftviewproviders/view_label.py +++ b/src/Mod/Draft/draftviewproviders/view_label.py @@ -394,7 +394,7 @@ class ViewProviderLabel(ViewProviderDraftAnnotation): if s: self.arrowpos.scaleFactor.setValue((s, s, s)) - elif prop in "Justification" and "Justification" in properties: + elif prop == "Justification" and "Justification" in properties: if vobj.Justification == "Left": self.text2d.justification = coin.SoText2.LEFT self.text3d.justification = coin.SoAsciiText.LEFT From fd8475b1c6b8d7f1cbb05776d740e2ba5dda023a Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Jun 2021 15:24:03 +0200 Subject: [PATCH 2/5] Draft: Fix SVG generation for label objects Label objects would produce invalid SVG XML, because the stroke-linecap property was added as if it was a style (with : and ;), but it was inserted in the XML tag directly, rather than inside the style attribute value. The invalid SVG prevented for example a TechDraw draft view from rendering when it contained a label. This was added in commit d8c74c06fd (Draft: Using square endcaps for lines in SVG output). This stroke-linecap is supported both as a presentation attribute inside the style or a XML attribute, so for consistency with the surrounding attributes, it is made a normal attribute, rather than putting it inside the style. See also https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap --- src/Mod/Draft/draftfunctions/svg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftfunctions/svg.py b/src/Mod/Draft/draftfunctions/svg.py index ba34655dfd..5e53d217ab 100644 --- a/src/Mod/Draft/draftfunctions/svg.py +++ b/src/Mod/Draft/draftfunctions/svg.py @@ -615,7 +615,7 @@ def get_svg(obj, svg_path += 'fill="none" ' svg_path += 'stroke="{}" '.format(stroke) svg_path += 'stroke-width="{}" '.format(linewidth) - svg_path += 'stroke-linecap:square;' + svg_path += 'stroke-linecap="square" ' svg_path += 'd="{}"'.format(path_dir_str) svg_path += '/>' svg += svg_path From be69ec5e005b423cbcddfeecd6963f404652bd76 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 29 Jun 2021 15:29:57 +0200 Subject: [PATCH 3/5] Draft: Fix mixup of TextAlignment vs Justification for Labels TextAlignment is the vertical alignment, while Justification is the horizontal alignment. here, get_text was passed the vertical, while it expected the horizontal. This caused the alignment of a Label to be wrong in the resulting SVG (e.g. in a TechDraw draft view). This seems to have been broken since SVG support for Labels was first introduced in commit 3391a5ea4b (Initial work, only text (no lines)). --- src/Mod/Draft/draftfunctions/svg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftfunctions/svg.py b/src/Mod/Draft/draftfunctions/svg.py index 5e53d217ab..dd5238e1fa 100644 --- a/src/Mod/Draft/draftfunctions/svg.py +++ b/src/Mod/Draft/draftfunctions/svg.py @@ -641,7 +641,7 @@ def get_svg(obj, fontname = obj.ViewObject.TextFont position = get_proj(obj.Placement.Base, plane) rotation = obj.Placement.Rotation - justification = obj.ViewObject.TextAlignment + justification = obj.ViewObject.Justification text = obj.Text svg += svgtext.get_text(plane, techdraw, stroke, fontsize, fontname, From 214e716a8fd3cc49703a4815d0028efd62f8596d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 20 Mar 2022 14:54:20 +0100 Subject: [PATCH 4/5] Draft: Simplify using getattr instead of hasattr Using the default argument supported by getattr makes this code a bit simpler and probably (ever so slightly) faster. See https://forum.freecadweb.org/viewtopic.php?f=10&t=58611 for previous discussion. This is not an exhaustive change, these are just a few I encounted while working with the code. --- src/Mod/Draft/draftobjects/shape2dview.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Mod/Draft/draftobjects/shape2dview.py b/src/Mod/Draft/draftobjects/shape2dview.py index 5183da27ce..df08c6ab34 100644 --- a/src/Mod/Draft/draftobjects/shape2dview.py +++ b/src/Mod/Draft/draftobjects/shape2dview.py @@ -184,9 +184,8 @@ class Shape2DView(DraftObject): return nedges def execute(self,obj): - if hasattr(obj,"AutoUpdate"): - if not obj.AutoUpdate: - return True + if not getattr(obj,"AutoUpdate", True): + return True import Part, DraftGeomUtils obj.positionBySupport() pl = obj.Placement @@ -215,7 +214,7 @@ class Shape2DView(DraftObject): if getattr(obj,"VisibleOnly",True): objs = gui_utils.remove_hidden(objs) shapes = [] - if hasattr(obj,"FuseArch") and obj.FuseArch: + if getattr(obj,"FuseArch", False): shtypes = {} for o in objs: if utils.get_type(o) in ["Wall","Structure"]: From 7ff834882e4ac27e4627b54629e83047b6e1c86e Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 23 Mar 2022 10:37:28 +0100 Subject: [PATCH 5/5] Gui: remove all leftovers of iisTaskPanel --- src/Gui/CMakeLists.txt | 4 +- src/Gui/TaskView/TaskView.cpp | 108 +----------------------------- src/Gui/TaskView/TaskView.h | 35 +--------- src/Mod/Mesh/Gui/DlgSmoothing.cpp | 4 -- 4 files changed, 5 insertions(+), 146 deletions(-) diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 89b0a5e297..6ad901f9dd 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -4,7 +4,7 @@ add_subdirectory(PreferencePacks) add_subdirectory(PreferencePackTemplates) if(WIN32) -add_definitions(-DFCGui -DQIIS_MAKEDLL -DQSINT_MAKEDLL -DOVR_OS_WIN32 -DQUARTER_INTERNAL -DQUARTER_MAKE_DLL -DCOIN_DLL) +add_definitions(-DFCGui -DQSINT_MAKEDLL -DOVR_OS_WIN32 -DQUARTER_INTERNAL -DQUARTER_MAKE_DLL -DCOIN_DLL) endif(WIN32) IF(CMAKE_BUILD_TYPE) @@ -1181,7 +1181,6 @@ SET(FreeCADGui_SRCS ${FreeCADGui_SDK_SRCS} ${FreeCADGui_CPP_SRCS} ${FreeCADGui_XML_SRCS} - ${iis_MOC_SRCS} ${qsint_MOC_SRCS} ${Gui_QRC_SRCS} ${Gui_UIC_HDRS} @@ -1196,7 +1195,6 @@ SET(FreeCADGui_SRCS ${Language_SRCS} ${Propertyeditor_SRCS} ${Task_View_SRCS} - ${iisTaskPanel_SRCS} ${qsintActionPanel_SRCS} ${Resource_SRCS} ${Quarter_SRCS} diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index c6cea3eca4..71dee6e116 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -42,11 +42,9 @@ #include "TaskDialog.h" #include "TaskEditControl.h" -#if defined (QSINT_ACTIONPANEL) #include #include #include -#endif using namespace Gui::TaskView; @@ -73,69 +71,6 @@ TaskWidget::~TaskWidget() // TaskGroup //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#if !defined (QSINT_ACTIONPANEL) -TaskGroup::TaskGroup(QWidget *parent) - : iisTaskGroup(parent, false) -{ - setScheme(iisFreeCADTaskPanelScheme::defaultScheme()); -} - -TaskGroup::~TaskGroup() -{ -} - -namespace Gui { namespace TaskView { -class TaskIconLabel : public iisIconLabel { -public: - TaskIconLabel(const QIcon &icon, - const QString &title, - QWidget *parent = 0) - : iisIconLabel(icon, title, parent) { - // do not allow to get the focus because when hiding the task box - // it could cause to activate another MDI view. - setFocusPolicy(Qt::NoFocus); - } - void setTitle(const QString &text) { - myText = text; - update(); - } -}; -} -} - -void TaskGroup::actionEvent (QActionEvent* e) -{ - QAction *action = e->action(); - switch (e->type()) { - case QEvent::ActionAdded: - { - TaskIconLabel *label = new TaskIconLabel( - action->icon(), action->text(), this); - this->addIconLabel(label); - connect(label,SIGNAL(clicked()),action,SIGNAL(triggered()),Qt::QueuedConnection); - break; - } - case QEvent::ActionChanged: - { - // update label when action changes - QBoxLayout* bl = this->groupLayout(); - int index = this->actions().indexOf(action); - if (index < 0) break; - QWidgetItem* item = static_cast(bl->itemAt(index)); - TaskIconLabel* label = static_cast(item->widget()); - label->setTitle(action->text()); - break; - } - case QEvent::ActionRemoved: - { - // cannot change anything - break; - } - default: - break; - } -} -#else TaskGroup::TaskGroup(QWidget *parent) : QSint::ActionBox(parent) { @@ -177,19 +112,12 @@ void TaskGroup::actionEvent (QActionEvent* e) break; } } -#endif + //************************************************************************** //************************************************************************** // TaskBox //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#if !defined (QSINT_ACTIONPANEL) -TaskBox::TaskBox(const QPixmap &icon, const QString &title, bool expandable, QWidget *parent) - : iisTaskBox(icon, title, expandable, parent), wasShown(false) -{ - setScheme(iisFreeCADTaskPanelScheme::defaultScheme()); -} -#else TaskBox::TaskBox(QWidget *parent) : QSint::ActionGroup(parent), wasShown(false) { @@ -228,7 +156,6 @@ QSize TaskBox::minimumSizeHint() const QSize s2 = QWidget::minimumSizeHint(); return QSize(qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())); } -#endif TaskBox::~TaskBox() { @@ -292,28 +219,12 @@ void TaskBox::actionEvent (QActionEvent* e) switch (e->type()) { case QEvent::ActionAdded: { -#if !defined (QSINT_ACTIONPANEL) - TaskIconLabel *label = new TaskIconLabel( - action->icon(), action->text(), this); - this->addIconLabel(label); - connect(label,SIGNAL(clicked()),action,SIGNAL(triggered())); -#else QSint::ActionLabel *label = new QSint::ActionLabel(action, this); this->addActionLabel(label, true, false); -#endif break; } case QEvent::ActionChanged: { -#if !defined (QSINT_ACTIONPANEL) - // update label when action changes - QBoxLayout* bl = myGroup->groupLayout(); - int index = this->actions().indexOf(action); - if (index < 0) break; - QWidgetItem* item = static_cast(bl->itemAt(index)); - TaskIconLabel* label = static_cast(item->widget()); - label->setTitle(action->text()); -#endif break; } case QEvent::ActionRemoved: @@ -331,7 +242,6 @@ void TaskBox::actionEvent (QActionEvent* e) // TaskPanel //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#if defined (QSINT_ACTIONPANEL) TaskPanel::TaskPanel(QWidget *parent) : QSint::ActionPanel(parent) { @@ -355,7 +265,7 @@ QSize TaskPanel::minimumSizeHint() const QSize s2 = QWidget::minimumSizeHint(); return QSize(qMax(s1.width(), s2.width()), qMax(s1.height(), s2.height())); } -#endif + //************************************************************************** //************************************************************************** @@ -368,10 +278,6 @@ TaskView::TaskView(QWidget *parent) //addWidget(new TaskEditControl(this)); //addWidget(new TaskAppearance(this)); //addStretch(); -#if !defined (QSINT_ACTIONPANEL) - taskPanel = new iisTaskPanel(this); - taskPanel->setScheme(iisFreeCADTaskPanelScheme::defaultScheme()); -#else taskPanel = new TaskPanel(this); QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); @@ -379,7 +285,7 @@ TaskView::TaskView(QWidget *parent) sizePolicy.setHeightForWidth(taskPanel->sizePolicy().hasHeightForWidth()); taskPanel->setSizePolicy(sizePolicy); taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); -#endif + this->setWidget(taskPanel); setWidgetResizable(true); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -604,9 +510,7 @@ void TaskView::showDialog(TaskDialog *dlg) taskPanel->addWidget(ActiveCtrl); } -#if defined (QSINT_ACTIONPANEL) taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); -#endif if (!dlg->needsFullSpace()) taskPanel->addStretch(); @@ -726,7 +630,6 @@ void TaskView::addTaskWatcher(void) taskPanel->addStretch(); updateWatcher(); -#if defined (QSINT_ACTIONPANEL) #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) // Workaround to avoid a crash in Qt. See also // https://forum.freecadweb.org/viewtopic.php?f=8&t=39187 @@ -741,7 +644,6 @@ void TaskView::addTaskWatcher(void) #endif taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); -#endif } void TaskView::removeTaskWatcher(void) @@ -819,18 +721,14 @@ void TaskView::clicked (QAbstractButton * button) void TaskView::clearActionStyle() { -#if defined (QSINT_ACTIONPANEL) static_cast(QSint::FreeCADPanelScheme::defaultScheme())->clearActionStyle(); taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); -#endif } void TaskView::restoreActionStyle() { -#if defined (QSINT_ACTIONPANEL) static_cast(QSint::FreeCADPanelScheme::defaultScheme())->restoreActionStyle(); taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme()); -#endif } diff --git a/src/Gui/TaskView/TaskView.h b/src/Gui/TaskView/TaskView.h index 77d3b6058f..e894c1b2dc 100644 --- a/src/Gui/TaskView/TaskView.h +++ b/src/Gui/TaskView/TaskView.h @@ -24,16 +24,10 @@ #ifndef GUI_TASKVIEW_TASKVIEW_H #define GUI_TASKVIEW_TASKVIEW_H -#define QSINT_ACTIONPANEL - #include #include -#if !defined (QSINT_ACTIONPANEL) -#include -#else #include -#endif #include #include "TaskWatcher.h" @@ -62,19 +56,6 @@ public: //~TaskContent(); }; -#if !defined (QSINT_ACTIONPANEL) -class GuiExport TaskGroup : public iisTaskGroup, public TaskContent -{ - Q_OBJECT - -public: - TaskGroup(QWidget *parent = 0); - ~TaskGroup(); - -protected: - void actionEvent (QActionEvent*); -}; -#else class GuiExport TaskGroup : public QSint::ActionBox, public TaskContent { Q_OBJECT @@ -88,21 +69,13 @@ public: protected: void actionEvent (QActionEvent*); }; -#endif /// Father class of content with header and Icon -#if !defined (QSINT_ACTIONPANEL) -class GuiExport TaskBox : public iisTaskBox, public TaskContent -#else class GuiExport TaskBox : public QSint::ActionGroup, public TaskContent -#endif { Q_OBJECT public: -#if !defined (QSINT_ACTIONPANEL) - TaskBox(const QPixmap &icon, const QString &title, bool expandable, QWidget *parent); -#else /** Constructor. Creates TaskBox without header. */ explicit TaskBox(QWidget *parent = 0); @@ -126,7 +99,7 @@ public: bool expandable = true, QWidget *parent = 0); virtual QSize minimumSizeHint() const; -#endif + ~TaskBox(); void hideGroupBox(); bool isGroupVisible() const; @@ -139,7 +112,6 @@ private: bool wasShown; }; -#if defined (QSINT_ACTIONPANEL) class GuiExport TaskPanel : public QSint::ActionPanel { Q_OBJECT @@ -149,7 +121,6 @@ public: virtual ~TaskPanel(); virtual QSize minimumSizeHint() const; }; -#endif /// Father class of content of a Free widget (without header and Icon), shut be an exception! class GuiExport TaskWidget : public QWidget, public TaskContent @@ -213,11 +184,7 @@ protected: std::vector ActiveWatcher; -#if !defined (QSINT_ACTIONPANEL) - iisTaskPanel* taskPanel; -#else QSint::ActionPanel* taskPanel; -#endif TaskDialog *ActiveDialog; TaskEditControl *ActiveCtrl; diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.cpp b/src/Mod/Mesh/Gui/DlgSmoothing.cpp index d491c29cae..1f2fbecdf2 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.cpp +++ b/src/Mod/Mesh/Gui/DlgSmoothing.cpp @@ -150,11 +150,7 @@ TaskSmoothing::TaskSmoothing() selection = new Selection(); selection->setObjects(Gui::Selection().getSelectionEx(nullptr, Mesh::Feature::getClassTypeId())); Gui::Selection().clearSelection(); -#if !defined (QSINT_ACTIONPANEL) - Gui::TaskView::TaskGroup* tasksel = new Gui::TaskView::TaskGroup(); -#else Gui::TaskView::TaskBox* tasksel = new Gui::TaskView::TaskBox(); -#endif tasksel->groupLayout()->addWidget(selection); tasksel->hide(); Content.push_back(tasksel);