Fix linux drawing issues
MODIFY
src/graphics/connection.cpp
src/graphics/connection.cpp
@@ -12,7 +12,7 @@ namespace {
inline double pointDistance(QPointF a, QPointF b) {
return sqrt(pow(a.x() - b.x(), 2) + pow(a.y() - b.y(), 2));
}
-}
+} // namespace
using namespace std;
Connection::Connection(Shape* source, QPointF* sourcePoint, Shape* dest, QPointF* destPoint)
@@ -20,6 +20,7 @@ Connection::Connection(Shape* source, QPointF* sourcePoint, Shape* dest, QPointF
m_dests << QPair<Shape*, QPointF*>(dest, destPoint);
m_label.m_source = source;
m_label.m_drawPos = sourcePoint;
+ update();
}
Connection::Connection(Shape* source, QPointF* sourcePoint, QList<PointPair> dests)
@@ -27,11 +28,15 @@ Connection::Connection(Shape* source, QPointF* sourcePoint, QList<PointPair> des
m_dests = dests;
m_label.m_source = source;
m_label.m_drawPos = sourcePoint;
+ update();
}
QRectF Connection::boundingRect() const {
const static double pad = 5; // pad around each edge
- double left, top, bot, right;
+ double left = 0;
+ double top = 0;
+ double bot = 0;
+ double right = 0;
// Iterate through all points in the connection line to find bounding rect
for (const auto& pointVec : m_polyLines) {
for (const auto& point : pointVec) {
@@ -226,6 +231,7 @@ void Connection::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidg
void Connection::addLabelToScene() {
// Must be called after connection has been added to a scene
scene()->addItem(&m_label);
+ update();
}
// --------- label ------------

MODIFY
src/graphics/pipelinewidget.cpp
src/graphics/pipelinewidget.cpp
#include <QCoreApplication>
#include <QWheelEvent>
+qreal PipelineWidget::spaceBetweenStateRegs = 350;
+
PipelineWidget::PipelineWidget(QWidget* parent) : QGraphicsView(parent) {
QGraphicsScene* scene = new QGraphicsScene(this);
// scene->setItemIndexMethod(QGraphicsScene::NoIndex);
@@ -16,7 +18,6 @@ PipelineWidget::PipelineWidget(QWidget* parent) : QGraphicsView(parent) {
setRenderHint(QPainter::Antialiasing);
setRenderHint(QPainter::TextAntialiasing);
setDragMode(QGraphicsView::ScrollHandDrag);
- setCursor(Qt::CrossCursor);
m_pipelinePtr = Pipeline::getPipeline();

MODIFY
src/graphics/pipelinewidget.h
src/graphics/pipelinewidget.h
@@ -25,7 +25,7 @@ public:
PipelineWidget(QWidget* parent = nullptr);
void wheelEvent(QWheelEvent* event);
- void expandToView() { fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); }
+ void expandToView() { fitInView(scene()->itemsBoundingRect(), Qt::KeepAspectRatio); }
void displayAllValues(bool state);
void zoomIn();
void zoomOut();
@@ -55,7 +55,7 @@ private:
constexpr static qreal shapeMargin = 15; // Minimum distance between two shapes
constexpr static qreal stateRegHeight = 500;
- constexpr static qreal spaceBetweenStateRegs = 350;
+ static qreal spaceBetweenStateRegs;
constexpr static qreal minConnectionLen = 30;
QList<Graphics::Connection*> m_connections;

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -37,6 +37,8 @@ ProcessorTab::ProcessorTab(QWidget* parent) : QWidget(parent), m_ui(new Ui::Proc
m_ui->step->setEnabled(false);
m_ui->run->setEnabled(false);
m_ui->start->setEnabled(false);
+
+ // m_ui->pipelineWidget->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
}
void ProcessorTab::toggleTimer(bool state) {

Fix linux drawing issues