From 1776c0d1735a3f37e7744cb6f6e0013db0dcb446 Mon Sep 17 00:00:00 2001 From: joern274 Date: Fri, 17 Nov 2023 13:49:08 +0100 Subject: [PATCH] bugfix: close gaps for 'trivial' junctions --- .../layouters/net_layout_junction.h | 11 ++++++ .../graph_widget/layouters/graph_layouter.cpp | 37 ++++++++++--------- .../layouters/net_layout_junction.cpp | 17 +++++++++ 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/plugins/gui/include/gui/graph_widget/layouters/net_layout_junction.h b/plugins/gui/include/gui/graph_widget/layouters/net_layout_junction.h index 4cb5d01d650..0f661275663 100644 --- a/plugins/gui/include/gui/graph_widget/layouters/net_layout_junction.h +++ b/plugins/gui/include/gui/graph_widget/layouters/net_layout_junction.h @@ -285,6 +285,17 @@ namespace hal { void dumpToFile(const QPoint& pnt) const; static QString gridPointName(const QPoint& p); + + /** + * Returns whether a junction is trivial and can be omitted + * @return true if only one direction and inputs identical to outputs, false otherwise + */ + bool isTrivial() const; + + /** + * Reset dump junction file, initialize file with timestamp + */ + static void resetFile(); }; /** diff --git a/plugins/gui/src/graph_widget/layouters/graph_layouter.cpp b/plugins/gui/src/graph_widget/layouters/graph_layouter.cpp index 095acd758cc..e6d8c4ef79b 100644 --- a/plugins/gui/src/graph_widget/layouters/graph_layouter.cpp +++ b/plugins/gui/src/graph_widget/layouters/graph_layouter.cpp @@ -42,7 +42,7 @@ namespace hal const static qreal sMinimumHChannelHeight = 20; GraphLayouter::GraphLayouter(GraphContext* context, QObject* parent) - : QObject(parent), mScene(new GraphicsScene(this)), mParentContext(context), mDone(false), mRollbackStatus(0), mDumpJunctions(true) + : QObject(parent), mScene(new GraphicsScene(this)), mParentContext(context), mDone(false), mRollbackStatus(0), mDumpJunctions(false) { SelectionDetailsWidget* details = gContentManager->getSelectionDetailsWidget(); if (details) @@ -213,6 +213,8 @@ namespace hal void GraphLayouter::layout() { + if (mDumpJunctions) + NetLayoutJunctionEntries::resetFile(); QElapsedTimer timer; timer.start(); mParentContext->layoutProgress(0); @@ -587,12 +589,15 @@ namespace hal { if (it != mJunctionEntries.constEnd() && mJunctionThreads.size() < QThread::idealThreadCount()) { - if (mDumpJunctions) - it.value().dumpToFile(it.key()); - JunctionThread* jt = new JunctionThread(it.key(), it.value()); - connect(jt,&QThread::finished,this,&GraphLayouter::handleJunctionThreadFinished); - mJunctionThreads.append(jt); - jt->start(); + if (!it.value().isTrivial()) + { + if (mDumpJunctions) + it.value().dumpToFile(it.key()); + JunctionThread* jt = new JunctionThread(it.key(), it.value()); + connect(jt,&QThread::finished,this,&GraphLayouter::handleJunctionThreadFinished); + mJunctionThreads.append(jt); + jt->start(); + } ++it; } qApp->processEvents(); @@ -1342,8 +1347,8 @@ namespace hal if (it.key().isHorizontal()) { - float x0 = j0 ? mLayouter->mCoordArrayX->lanePosition(ix0,j0->rect().right()) : mLayouter->mCoordX[ix0].junctionExit(); - float x1 = j1 ? mLayouter->mCoordArrayX->lanePosition(ix1,j1->rect().left()) : mLayouter->mCoordX[ix1].junctionEntry(); + float x0 = mLayouter->mCoordArrayX->lanePosition(ix0,j0? j0->rect().right() : 0); + float x1 = mLayouter->mCoordArrayX->lanePosition(ix1,j1? j1->rect().left() : 0); float yy = mLayouter->mCoordArrayY->lanePosition(iy0,ilane); mLines.appendHLine(x0, x1, yy); } @@ -1355,19 +1360,17 @@ namespace hal { // netjunction -> endpoint auto itEpc = mLayouter->mEndpointHash.find(wToPoint); - y0 = j0 ? mLayouter->mCoordArrayY->lanePosition(iy0,j0->rect().bottom()) : mLayouter->mCoordY[iy0].junctionExit(); - y1 = itEpc != mLayouter->mEndpointHash.constEnd() ? itEpc.value().lanePosition(j1->rect().top(), true) : mLayouter->mCoordY[iy1].junctionEntry(); - // if (itEpc==mEndpointHash.constEnd()) - // qDebug() << "xxx to endp" << wToPoint.x() << wToPoint.y() << y0 << y1; + y0 = mLayouter->mCoordArrayY->lanePosition(iy0, j0? j0->rect().bottom() : 0); + y1 = itEpc != mLayouter->mEndpointHash.constEnd() ? itEpc.value().lanePosition(j1->rect().top(), true) + : mLayouter->mCoordArrayY->lanePosition(iy1,0); } else { // endpoint -> netjunction auto itEpc = mLayouter->mEndpointHash.find(wFromPoint); - y0 = itEpc != mLayouter->mEndpointHash.constEnd() ? itEpc.value().lanePosition(j0->rect().bottom(), true) : mLayouter->mCoordY[iy0].junctionExit(); - y1 = j1 ? mLayouter->mCoordArrayY->lanePosition(iy1,j1->rect().top()) : mLayouter->mCoordY[iy1].junctionEntry(); - // if (itEpc==mEndpointHash.constEnd()) - // qDebug() << "xxx fr endp" << wFromPoint.x() << wFromPoint.y() << y0 << y1; + y0 = itEpc != mLayouter->mEndpointHash.constEnd() ? itEpc.value().lanePosition(j0->rect().bottom(), true) + : mLayouter->mCoordArrayY->lanePosition(iy0,0); + y1 = mLayouter->mCoordArrayY->lanePosition(iy1, j1? j1->rect().top() : 0); } if (y1 > y0) mLines.appendVLine(xx, y0, y1); diff --git a/plugins/gui/src/graph_widget/layouters/net_layout_junction.cpp b/plugins/gui/src/graph_widget/layouters/net_layout_junction.cpp index d48f9815cf9..06ce0f423ce 100644 --- a/plugins/gui/src/graph_widget/layouters/net_layout_junction.cpp +++ b/plugins/gui/src/graph_widget/layouters/net_layout_junction.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "hal_core/netlist/project_manager.h" #ifdef JUNCTION_DEBUG @@ -908,6 +909,15 @@ namespace hal { return mRange.isEntry(0) || mRange.isEntry(1); } + bool NetLayoutJunctionEntries::isTrivial() const + { + if (mEntries[NetLayoutDirection::Left].isEmpty() && mEntries[NetLayoutDirection::Right].isEmpty()) + return mEntries[NetLayoutDirection::Up] == mEntries[NetLayoutDirection::Down]; + if (mEntries[NetLayoutDirection::Up].isEmpty() && mEntries[NetLayoutDirection::Down].isEmpty()) + return mEntries[NetLayoutDirection::Left] == mEntries[NetLayoutDirection::Right]; + return false; + } + void NetLayoutJunctionEntries::dumpToFile(const QPoint &pnt) const { QFile ff(QString::fromStdString(ProjectManager::instance()->get_project_directory().get_filename("junction_data.txt").string())); @@ -923,6 +933,13 @@ namespace hal { xout.flush(); } + void NetLayoutJunctionEntries::resetFile() + { + QFile ff(QString::fromStdString(ProjectManager::instance()->get_project_directory().get_filename("junction_data.txt").string())); + if (!ff.open(QIODevice::WriteOnly)) return; + ff.write(QDateTime::currentDateTime().toLocalTime().toString("--- dd.MM.yyyy hh:mm:ss ---\n").toUtf8()); + } + QString NetLayoutJunctionEntries::toString() const { QString retval;