Hotfix for drawing issues related to Windows scaling
Various parts of the pipeline widget is based on numbers generated by QFontMetrics. These return values, however, change upon the scaling settings of windows.
This commit specifies fonts to be in pixels (fixed over all scalings) instead of a point size.
MODIFY
src/graphics/pipelinewidget.cpp
src/graphics/pipelinewidget.cpp
@@ -370,10 +370,10 @@ PipelineWidget::PipelineWidget(QWidget* parent) : QGraphicsView(parent) {
// items position relative to these
// Position state registers
- ifid->moveBy(-spaceBetweenStateRegs * 0.2, 0);
+ ifid->moveBy(-spaceBetweenStateRegs * 0.22, 0);
idex->moveBy(spaceBetweenStateRegs * 1, 0);
- exmem->moveBy(spaceBetweenStateRegs * 2, 0);
- memwb->moveBy(spaceBetweenStateRegs * 3, 0);
+ exmem->moveBy(spaceBetweenStateRegs * 2.05, 0);
+ memwb->moveBy(spaceBetweenStateRegs * 3.05, 0);
// position IF stage
moveToIO(instr_mem, ifid, instr_mem->getOutputPoint(0), ifid->getInputPoint(2));
@@ -404,7 +404,7 @@ PipelineWidget::PipelineWidget(QWidget* parent) : QGraphicsView(parent) {
moveToIO(mux_forwardB_EX, mux_ALUSrc2, mux_forwardB_EX->getOutputPoint(0), mux_ALUSrc2->getInputPoint(0), 30);
// position MEM stage
- data_mem->moveBy(spaceBetweenStateRegs * 2.5, 0);
+ data_mem->moveBy(spaceBetweenStateRegs * 2.63, 0);
mux_alures_PC4_MEM->moveBy(spaceBetweenStateRegs * 2.4, 130);
// position WB stage
@@ -475,7 +475,7 @@ PipelineWidget::PipelineWidget(QWidget* parent) : QGraphicsView(parent) {
// For some reason, the boundingrect of the leftmost connections are not forcing the scene rect to change
// We manually adjust it a bit
- setSceneRect(scene->itemsBoundingRect().adjusted(-40, 0, 0, 0));
+ setSceneRect(scene->itemsBoundingRect().adjusted(-50, -50, 50, 100));
}
void PipelineWidget::update() {

MODIFY
src/graphics/shape.cpp
src/graphics/shape.cpp
#include <QPainter>
+#include <QGuiApplication>
+#include <QScreen>
+
namespace Graphics {
Shape::Shape(ShapeType type, Stage stage, int verticalPad, int horizontalPad)
: m_verticalPad(verticalPad), m_horizontalPad(horizontalPad), m_type(type), m_stage(stage) {
setCacheMode(DeviceCoordinateCache);
- m_nameFont.setPointSize(nameFontSize);
+ setPointSize();
+}
+
+void Shape::setPointSize() {
+ m_nameFont.setPixelSize(nameFontSize);
m_nameFont.setBold(true);
- m_ioFont.setPointSize(ioFontSize);
+ m_ioFont.setPixelSize(ioFontSize);
}
QRectF Shape::boundingRect() const {

MODIFY
src/graphics/shape.h
src/graphics/shape.h
@@ -62,6 +62,8 @@ public:
int type() const { return connectionType(); }
private:
+ void setPointSize();
+
QRectF m_rect;
bool m_hasChanged = true; // Flag is set whenever the item has changed (ie.
// when new descriptors have been added)
@@ -105,8 +107,8 @@ private:
// drawing constants
qreal nodeHeight = 20;
- qreal nameFontSize = 10;
- qreal ioFontSize = 8;
+ qreal nameFontSize = 14;
+ qreal ioFontSize = 11;
qreal nodePadding = 5; // padding between each text descriptor for a node
qreal sidePadding = 7; // padding between an IO description and the side of the shape
int m_fixedHeight;

Hotfix for drawing issues related to Windows scaling

Various parts of the pipeline widget is based on numbers generated by QFontMetrics. These return values, however, change upon the scaling settings of windows.

This commit specifies fonts to be in pixels (fixed over all scalings) instead of a point size.