diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 2002008728..e512a96e1a 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -87,16 +87,17 @@ #include #include "DrawGuiUtil.h" -#include "PreferencesGui.h" #include "MDIViewPage.h" +#include "PreferencesGui.h" +#include "QGIViewPart.h" +#include "Rez.h" #include "TaskProjGroup.h" #include "TaskSectionView.h" #include "TaskActiveView.h" #include "TaskDetail.h" #include "ViewProviderPage.h" #include "ViewProviderViewPart.h" -#include "QGIViewPart.h" -#include "Rez.h" + class Vertex; using namespace TechDrawGui; @@ -807,7 +808,15 @@ bool _checkDrawViewPartBalloon(Gui::Command* cmd) { bool _checkDirectPlacement(const QGIViewPart *viewPart, const std::vector &subNames, QPointF &placement) { + // Let's see, if we can help speed up the placement of the balloon: + // As of now we support: + // Single selected vertex: place the ballon tip end here + // Single selected edge: place the ballon tip at its midpoint (suggested placement for e.g. chamfer dimensions) + // + // Single selected faces are currently not supported, but maybe we could in this case use the center of mass? + if (subNames.size() != 1) { + // If nothing or more than one subjects are selected, let the user decide, where to place the balloon return false; } diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index 81654e5d04..a977ae0589 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -489,14 +489,11 @@ void QGVPage::createBalloon(QPointF origin, DrawViewPart *parent) std::string featName = getDrawPage()->getDocument()->getUniqueObjectName("Balloon"); std::string pageName = getDrawPage()->getNameInDocument(); - Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Balloon")); - TechDraw::DrawViewBalloon *balloon = 0; - Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Balloon")); Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawViewBalloon','%s')", featName.c_str()); Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", pageName.c_str(), featName.c_str()); - balloon = dynamic_cast(getDrawPage()->getDocument()->getObject(featName.c_str())); + TechDraw::DrawViewBalloon *balloon = dynamic_cast(getDrawPage()->getDocument()->getObject(featName.c_str())); if (!balloon) { throw Base::TypeError("CmdTechDrawNewBalloon - balloon not found\n"); } @@ -506,8 +503,8 @@ void QGVPage::createBalloon(QPointF origin, DrawViewPart *parent) Gui::Command::commitCommand(); - balloon->recomputeFeature(); parent->touch(true); + Gui::Command::updateActive(); } QGIView * QGVPage::addViewDimension(TechDraw::DrawViewDimension *dim) @@ -1264,21 +1261,24 @@ double QGVPage::getDevicePixelRatio() const { } QPixmap QGVPage::prepareCursorPixmap(const char *iconName, QPoint &hotspot) { - double cursorSize = 64.0; + double pixelRatio = getDevicePixelRatio(); - if (pixelRatio != 1.0) { - cursorSize = 32.0*pixelRatio; - } - + // Due to impossibility to query cursor size via Qt API, we stick to (32x32)*device_pixel_ratio + // as FreeCAD Wiki suggests - see https://wiki.freecadweb.org/HiDPI_support#Custom_cursor_size + double cursorSize = 32.0*pixelRatio; + QPixmap pixmap = Gui::BitmapFactory().pixmapFromSvg(iconName, QSizeF(cursorSize, cursorSize)); - if (pixelRatio == 1.0) { - pixmap = pixmap.scaled(32, 32); - hotspot /= 2; - } pixmap.setDevicePixelRatio(pixelRatio); + // The default (and here expected) SVG cursor graphics size is 64x64 pixels, thus we must adjust + // the 64x64 based hotspot position for our 32x32 based cursor pixmaps accordingly + hotspot /= 2; + #if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) + // On XCB platform, the pixmap device pixel ratio is not taken into account for cursor hot spot, + // therefore we must take care of the transformation ourselves... + // Refer to QTBUG-68571 - https://bugreports.qt.io/browse/QTBUG-68571 if (qGuiApp->platformName() == QLatin1String("xcb")) { hotspot *= pixelRatio; }