diff --git a/src/Gui/Icons/cursor-pan.svg b/src/Gui/Icons/cursor-pan.svg new file mode 100644 index 0000000000..d0a05836cd --- /dev/null +++ b/src/Gui/Icons/cursor-pan.svg @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/src/Gui/Icons/cursor-rotate.svg b/src/Gui/Icons/cursor-rotate.svg new file mode 100644 index 0000000000..afb333c3cc --- /dev/null +++ b/src/Gui/Icons/cursor-rotate.svg @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/src/Gui/Icons/cursor-zoom.svg b/src/Gui/Icons/cursor-zoom.svg new file mode 100644 index 0000000000..68193dc9f6 --- /dev/null +++ b/src/Gui/Icons/cursor-zoom.svg @@ -0,0 +1,26 @@ + + + + + + + + + + diff --git a/src/Gui/Icons/resource.qrc b/src/Gui/Icons/resource.qrc index 7ba58795d6..e49d60caf8 100644 --- a/src/Gui/Icons/resource.qrc +++ b/src/Gui/Icons/resource.qrc @@ -38,7 +38,10 @@ clear-selection.svg colors.svg critical-info.svg + cursor-pan.svg cursor-through.svg + cursor-rotate.svg + cursor-zoom.svg dagViewFail.svg dagViewPass.svg dagViewPending.svg diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 1d9bcbbe61..b23c6388be 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -103,6 +103,7 @@ #include #include #include +#include #include "View3DInventorViewer.h" #include "Application.h" @@ -149,81 +150,6 @@ FC_LOG_LEVEL_INIT("3DViewer", true, true) using namespace Gui; -// NOLINTBEGIN -// clang-format off -/*** zoom-style cursor ******/ - -#define ZOOM_WIDTH 16 -#define ZOOM_HEIGHT 16 -#define ZOOM_BYTES ((ZOOM_WIDTH + 7) / 8) * ZOOM_HEIGHT -#define ZOOM_HOT_X 5 -#define ZOOM_HOT_Y 7 - -static unsigned char zoom_bitmap[ZOOM_BYTES] = -{ - 0x00, 0x0f, 0x80, 0x1c, 0x40, 0x38, 0x20, 0x70, - 0x90, 0xe4, 0xc0, 0xcc, 0xf0, 0xfc, 0x00, 0x0c, - 0x00, 0x0c, 0xf0, 0xfc, 0xc0, 0xcc, 0x90, 0xe4, - 0x20, 0x70, 0x40, 0x38, 0x80, 0x1c, 0x00, 0x0f -}; - -static unsigned char zoom_mask_bitmap[ZOOM_BYTES] = -{ - 0x00, 0x0f, 0x80, 0x1f, 0xc0, 0x3f, 0xe0, 0x7f, - 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0x00, 0x0f, - 0x00, 0x0f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, - 0xe0, 0x7f, 0xc0, 0x3f, 0x80, 0x1f, 0x00, 0x0f -}; - -/*** pan-style cursor *******/ - -#define PAN_WIDTH 16 -#define PAN_HEIGHT 16 -#define PAN_BYTES ((PAN_WIDTH + 7) / 8) * PAN_HEIGHT -#define PAN_HOT_X 7 -#define PAN_HOT_Y 7 - -static unsigned char pan_bitmap[PAN_BYTES] = -{ - 0xc0, 0x03, 0x60, 0x02, 0x20, 0x04, 0x10, 0x08, - 0x68, 0x16, 0x54, 0x2a, 0x73, 0xce, 0x01, 0x80, - 0x01, 0x80, 0x73, 0xce, 0x54, 0x2a, 0x68, 0x16, - 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0xc0, 0x03 -}; - -static unsigned char pan_mask_bitmap[PAN_BYTES] = -{ - 0xc0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, - 0xe8, 0x17, 0xdc, 0x3b, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xdc, 0x3b, 0xe8, 0x17, - 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x03 -}; - -/*** rotate-style cursor ****/ - -#define ROTATE_WIDTH 16 -#define ROTATE_HEIGHT 16 -#define ROTATE_BYTES ((ROTATE_WIDTH + 7) / 8) * ROTATE_HEIGHT -#define ROTATE_HOT_X 6 -#define ROTATE_HOT_Y 8 - -static unsigned char rotate_bitmap[ROTATE_BYTES] = { - 0xf0, 0xef, 0x18, 0xb8, 0x0c, 0x90, 0xe4, 0x83, - 0x34, 0x86, 0x1c, 0x83, 0x00, 0x81, 0x00, 0xff, - 0xff, 0x00, 0x81, 0x00, 0xc1, 0x38, 0x61, 0x2c, - 0xc1, 0x27, 0x09, 0x30, 0x1d, 0x18, 0xf7, 0x0f -}; - -static unsigned char rotate_mask_bitmap[ROTATE_BYTES] = { - 0xf0, 0xef, 0xf8, 0xff, 0xfc, 0xff, 0xfc, 0xff, - 0x3c, 0xfe, 0x1c, 0xff, 0x00, 0xff, 0x00, 0xff, - 0xff, 0x00, 0xff, 0x00, 0xff, 0x38, 0x7f, 0x3c, - 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x1f, 0xf7, 0x0f -}; -// clang-format on -// NOLINTEND - - /*! As ProgressBar has no chance to control the incoming Qt events of Quarter so we need to stop the event handling to prevent the scenegraph from being selected or deselected @@ -681,7 +607,7 @@ void View3DInventorViewer::init() } //create the cursors - createStandardCursors(devicePixelRatio()); + createStandardCursors(); connect(this, &View3DInventorViewer::devicePixelRatioChanged, this, &View3DInventorViewer::createStandardCursors); @@ -766,40 +692,15 @@ View3DInventorViewer::~View3DInventorViewer() delete glAction; } -static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY, double dpr) +void View3DInventorViewer::createStandardCursors() { -#if defined(Q_OS_WIN32) - bitmap.setDevicePixelRatio(dpr); - mask.setDevicePixelRatio(dpr); -#else - Q_UNUSED(dpr) -#endif -#ifdef HAS_QTBUG_95434 - if (qGuiApp->platformName() == QLatin1String("wayland")) { - QImage img = bitmap.toImage(); - img.convertTo(QImage::Format_ARGB32); - QPixmap pixmap = QPixmap::fromImage(img); - pixmap.setMask(mask); - return QCursor(pixmap, hotX, hotY); - } -#endif + QPixmap panPixmap = BitmapFactory().pixmapFromSvg("cursor-pan", QSize(16,16)); + QPixmap spinPixmap = BitmapFactory().pixmapFromSvg("cursor-rotate", QSize(16,16)); + QPixmap zoomPixmap = BitmapFactory().pixmapFromSvg("cursor-zoom", QSize(16,16)); - return QCursor(bitmap, mask, hotX, hotY); -} - -void View3DInventorViewer::createStandardCursors(double dpr) -{ - QBitmap cursor = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_bitmap); - QBitmap mask = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_mask_bitmap); - spinCursor = createCursor(cursor, mask, ROTATE_HOT_X, ROTATE_HOT_Y, dpr); - - cursor = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_bitmap); - mask = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_mask_bitmap); - zoomCursor = createCursor(cursor, mask, ZOOM_HOT_X, ZOOM_HOT_Y, dpr); - - cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap); - mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap); - panCursor = createCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y, dpr); + this->panCursor = QCursor(panPixmap, 8, 8); + this->spinCursor = QCursor(spinPixmap, 8, 8); + this->zoomCursor = QCursor(zoomPixmap, 8, 8); } void View3DInventorViewer::aboutToDestroyGLContext() diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 242d80bef3..7d510620d4 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -510,7 +510,7 @@ private: static void drawSingleBackground(const QColor&); void setCursorRepresentation(int mode); void aboutToDestroyGLContext(); - void createStandardCursors(double); + void createStandardCursors(); private: NaviCube* naviCube; diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index 8bd105dfd3..da2c817edc 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -76,36 +76,6 @@ #define INKSCAPE_NS_URI "http://www.inkscape.org/namespaces/inkscape" #define SODIPODI_NS_URI "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" -/*** pan-style cursor *******/ - -#define PAN_WIDTH 16 -#define PAN_HEIGHT 16 -#define PAN_BYTES ((PAN_WIDTH + 7) / 8) * PAN_HEIGHT -#define PAN_HOT_X 7 -#define PAN_HOT_Y 7 - -static unsigned char pan_bitmap[PAN_BYTES] = { - 0xc0, 0x03, 0x60, 0x02, 0x20, 0x04, 0x10, 0x08, 0x68, 0x16, 0x54, 0x2a, 0x73, 0xce, 0x01, 0x80, - 0x01, 0x80, 0x73, 0xce, 0x54, 0x2a, 0x68, 0x16, 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0xc0, 0x03}; - -static unsigned char pan_mask_bitmap[PAN_BYTES] = { - 0xc0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xe8, 0x17, 0xdc, 0x3b, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xdc, 0x3b, 0xe8, 0x17, 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x03}; -/*** zoom-style cursor ******/ - -#define ZOOM_WIDTH 16 -#define ZOOM_HEIGHT 16 -#define ZOOM_BYTES ((ZOOM_WIDTH + 7) / 8) * ZOOM_HEIGHT -#define ZOOM_HOT_X 5 -#define ZOOM_HOT_Y 7 - -static unsigned char zoom_bitmap[ZOOM_BYTES] = { - 0x00, 0x0f, 0x80, 0x1c, 0x40, 0x38, 0x20, 0x70, 0x90, 0xe4, 0xc0, 0xcc, 0xf0, 0xfc, 0x00, 0x0c, - 0x00, 0x0c, 0xf0, 0xfc, 0xc0, 0xcc, 0x90, 0xe4, 0x20, 0x70, 0x40, 0x38, 0x80, 0x1c, 0x00, 0x0f}; - -static unsigned char zoom_mask_bitmap[ZOOM_BYTES] = { - 0x00, 0x0f, 0x80, 0x1f, 0xc0, 0x3f, 0xe0, 0x7f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0x00, 0x0f, - 0x00, 0x0f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0xe0, 0x7f, 0xc0, 0x3f, 0x80, 0x1f, 0x00, 0x0f}; using namespace Gui; using namespace TechDraw; using namespace TechDrawGui; @@ -213,7 +183,7 @@ QGVPage::QGVPage(ViewProviderPage* vpPage, QGSPage* scenePage, QWidget* parent) initNavigationStyle(); - createStandardCursors(devicePixelRatio()); + createStandardCursors(); } QGVPage::~QGVPage() @@ -667,36 +637,13 @@ Base::Type QGVPage::getStyleType(std::string model) return type; } -static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY, double dpr) +void QGVPage::createStandardCursors() { -#if defined(Q_OS_WIN32) - bitmap.setDevicePixelRatio(dpr); - mask.setDevicePixelRatio(dpr); -#else - Q_UNUSED(dpr) -#endif -#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0) - if (qGuiApp->platformName() == QLatin1String("wayland")) { - QImage img = bitmap.toImage(); - img.convertTo(QImage::Format_ARGB32); - QPixmap pixmap = QPixmap::fromImage(img); - pixmap.setMask(mask); - return QCursor(pixmap, hotX, hotY); - } -#endif + QPixmap panPixmap = BitmapFactory().pixmapFromSvg("cursor-pan", QSize(16,16)); + QPixmap zoomPixmap = BitmapFactory().pixmapFromSvg("cursor-zoom", QSize(16,16)); - return QCursor(bitmap, mask, hotX, hotY); -} - -void QGVPage::createStandardCursors(double dpr) -{ - QBitmap cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap); - QBitmap mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap); - panCursor = createCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y, dpr); - - cursor = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_bitmap); - mask = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_mask_bitmap); - zoomCursor = createCursor(cursor, mask, ZOOM_HOT_X, ZOOM_HOT_Y, dpr); + this->panCursor = QCursor(panPixmap, 8, 8); + this->zoomCursor = QCursor(zoomPixmap, 8, 8); } #include diff --git a/src/Mod/TechDraw/Gui/QGVPage.h b/src/Mod/TechDraw/Gui/QGVPage.h index 332576871a..aaa9d14984 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.h +++ b/src/Mod/TechDraw/Gui/QGVPage.h @@ -162,7 +162,7 @@ protected: void initNavigationStyle(); void setNavigationStyle(std::string navParm); - void createStandardCursors(double dpr); + void createStandardCursors(); private: RendererType m_renderer;