Merge pull request #22340 from maxwxyz/3d-nav-cursors

Gui: Change navigation cursors to SVG
This commit is contained in:
Chris Hennes
2025-09-07 19:11:14 -05:00
committed by GitHub
8 changed files with 96 additions and 169 deletions
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333333"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<g
id="layer1">
<path
id="path70"
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
d="M 2.1171834,0.01188558 1.083138,1.083138 0.01188558,2.1171834 1.083138,3.1496785 2.1171834,4.2224812 3.1496785,3.1496785 4.2224812,2.1171834 3.1496785,1.083138 Z M 1.2908773,1.2908773 h 0.4299479 v 0.2697509 0.160197 H 1.5606282 1.2908773 Z m 1.2226643,0 H 2.9414225 V 1.7208252 H 2.6737386 2.5135416 V 1.5606282 Z M 1.2908773,2.5135416 h 0.2697509 0.160197 v 0.160197 0.2676839 H 1.2908773 Z m 1.2226643,0 h 0.160197 0.2676839 V 2.9414225 H 2.5135416 V 2.6737386 Z" />
<path
id="path71"
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;fill:#ffffff;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
d="M 2.1171875,0.25390625 1.28125,1.1230469 h 0.6074219 v 0.4375 0.328125 h -0.328125 -0.4375 V 1.2792969 L 0.25390625,2.1171875 1.1230469,2.953125 V 2.3457031 h 0.4375 0.328125 V 2.6738281 3.109375 H 1.2792969 L 2.1171875,3.9804688 2.9550781,3.109375 H 2.3457031 V 2.6738281 2.3457031 h 0.328125 0.4355469 v 0.609375 L 3.9804688,2.1171875 3.109375,1.2792969 v 0.609375 H 2.6738281 2.3457031 v -0.328125 -0.4375 h 0.609375 z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333333"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<g
id="layer1">
<path
id="path103"
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:1.9;enable-background:accumulate;stop-color:#000000"
d="M 1.9084106 0.13280843 C 1.4044505 0.12489516 0.87462437 0.31132929 0.44751789 0.69349771 L 0.15037842 0.95911456 L 0.67954507 1.5508097 L 0.97668455 1.2851928 C 1.5383167 0.78265296 2.2838501 0.85615471 2.5957071 1.2402344 L 2.7652058 1.4490071 L 2.1151163 1.9766235 L 3.8788329 2.1931477 L 4.0312784 0.42167968 L 3.3806721 0.94981281 L 3.2111734 0.7400065 C 2.8895484 0.34389668 2.4123707 0.1407217 1.9084106 0.13280843 z M 0.35346679 2.041219 L 0.20308837 3.8126871 L 0.85214435 3.2850707 L 1.021643 3.4943603 C 1.664893 4.2865799 2.9331526 4.3036555 3.7873656 3.5393188 L 4.0819213 3.2731852 L 3.5527547 2.6835571 L 3.2576822 2.9471069 C 2.69605 3.4496469 1.9505166 3.3761449 1.6386596 2.9920654 L 1.4691609 2.7843261 L 2.1171834 2.2577433 L 0.35346679 2.041219 z " />
<path
id="path104"
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;fill:#ffffff;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:1.9;enable-background:accumulate;stop-color:#000000"
d="M 1.90625,0.30078125 C 1.4457174,0.29354989 0.95627644,0.46426654 0.56054687,0.81835938 L 0.38867188,0.97265625 0.69335937,1.3125 0.86328125,1.1601562 C 1.4810321,0.60740228 2.3416726,0.66073938 2.7265625,1.1347656 L 3.0039063,1.4746094 2.53125,1.8574219 3.7265625,2.0039063 3.8300781,0.80078125 3.3554688,1.1855469 3.0800781,0.84765625 C 2.7920433,0.49291582 2.3664937,0.30800808 1.90625,0.30078125 Z M 0.50585937,2.2304688 0.40429688,3.4296875 0.87695313,3.046875 1.1523437,3.3867188 c 0.5756557,0.708971 1.7300501,0.7355065 2.5214844,0.027344 L 3.84375,3.2617188 3.5390625,2.921875 3.3710938,3.0722656 C 2.7533916,3.6249762 1.8927024,3.5716822 1.5078125,3.0976563 L 1.2304687,2.7617188 1.703125,2.3769531 Z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="16"
height="16"
viewBox="0 0 4.2333332 4.2333333"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<g
id="layer1">
<path
id="path79"
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
d="M 2.1177001,0.27595214 0.88315018,1.0257772 H 1.7213419 V 1.2955281 2.4086385 2.6763224 H 0.35398352 L 2.1177001,3.9573811 3.8793497,2.6763224 H 2.5140583 V 2.4086385 1.2955281 1.0257772 H 3.350183 Z" />
<path
id="path80"
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;fill:#ffffff;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
d="M 2.1171875,0.73828125 1.484375,1.1230469 h 0.4042969 v 0.4375 1.1132812 0.4355469 H 0.87304688 L 2.1171875,4.0136719 3.359375,3.109375 H 2.3457031 v -0.4355469 -1.1132812 -0.4375 h 0.4023438 z"
transform="translate(5.1673e-4,-0.2651001)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+3
View File
@@ -38,7 +38,10 @@
<file>clear-selection.svg</file>
<file>colors.svg</file>
<file>critical-info.svg</file>
<file>cursor-pan.svg</file>
<file>cursor-through.svg</file>
<file>cursor-rotate.svg</file>
<file>cursor-zoom.svg</file>
<file>dagViewFail.svg</file>
<file>dagViewPass.svg</file>
<file>dagViewPending.svg</file>
+9 -108
View File
@@ -103,6 +103,7 @@
#include <Base/Tools2D.h>
#include <Quarter/devices/InputDevice.h>
#include <Quarter/eventhandlers/EventFilter.h>
#include <Gui/BitmapFactory.h>
#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()
+1 -1
View File
@@ -510,7 +510,7 @@ private:
static void drawSingleBackground(const QColor&);
void setCursorRepresentation(int mode);
void aboutToDestroyGLContext();
void createStandardCursors(double);
void createStandardCursors();
private:
NaviCube* naviCube;
+6 -59
View File
@@ -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 <Mod/TechDraw/Gui/moc_QGVPage.cpp>
+1 -1
View File
@@ -162,7 +162,7 @@ protected:
void initNavigationStyle();
void setNavigationStyle(std::string navParm);
void createStandardCursors(double dpr);
void createStandardCursors();
private:
RendererType m_renderer;