Do prepareGeometryChange() on labels on each clock cycle
This fixes an issue where when the size of a signal label is reduced, artifacts from the previous label was still visible on the processor view
MODIFY
src/graphics/connection.cpp
src/graphics/connection.cpp
@@ -22,6 +22,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;
+ m_label.setVisible(false);
}
Connection::Connection(Shape* source, QPointF* sourcePoint, QList<PointPair> dests)
@@ -29,6 +30,11 @@ Connection::Connection(Shape* source, QPointF* sourcePoint, QList<PointPair> des
m_dests = dests;
m_label.m_source = source;
m_label.m_drawPos = sourcePoint;
+ m_label.setVisible(false);
+}
+
+void Connection::updateLabel(){
+ m_label.prepareGeometryChange();
}
QRectF Connection::boundingRect() const {

MODIFY
src/graphics/connection.h
src/graphics/connection.h
@@ -51,6 +51,7 @@ public:
void drawPointAtFirstKink(bool val) { m_pointAtFirstKink = val; }
void finalize();
+ void updateLabel();
QPair<QPointF, QPointF> getPoints() const;
QPair<Shape*, Shape*> getShapes() const { return QPair<Shape*, Shape*>(m_source, m_dests[0].first); }
Shape* getSource() { return m_source; }

MODIFY
src/graphics/pipelinewidget.cpp
src/graphics/pipelinewidget.cpp
@@ -480,10 +480,18 @@ PipelineWidget::PipelineWidget(QWidget* parent) : QGraphicsView(parent) {
setSceneRect(scene->itemsBoundingRect().adjusted(-50, -50, 50, 100));
}
+void PipelineWidget::notifyLabelsGeometryChange(){
+ // Since labels geometry can change from clock cycle to clock cycle,
+ // make connections call prepareGeometryChange on their labels
+ for(const auto& c : m_connections){
+ c->updateLabel();
+ }
+}
+
void PipelineWidget::update() {
if(!m_pipelinePtr->isRunning()){
- QWidget::update();
for (const auto& item : m_animatedItems) {
+ notifyLabelsGeometryChange();
item->update();
}
}
@@ -624,5 +632,4 @@ void PipelineWidget::scaleView(qreal scaleFactor) {
void PipelineWidget::displayAllValues(bool state) {
emit displayAllValuesSig(state);
- scene()->update();
}

MODIFY
src/graphics/pipelinewidget.h
src/graphics/pipelinewidget.h
@@ -38,6 +38,7 @@ signals:
void displayAllValuesSig(bool state);
private:
+ void notifyLabelsGeometryChange();
void scaleView(qreal scaleFactor);
void adjustPositioning();
void setSignal(Graphics::Connection* conn, SignalBase* sig);

Do prepareGeometryChange() on labels on each clock cycle

This fixes an issue where when the size of a signal label is reduced, artifacts from the previous label was still visible on the processor view