Skip to content

Commit d9aceda

Browse files
committed
Added connectors to allow pins to be moved away from grid points
1 parent d875ffd commit d9aceda

15 files changed

Lines changed: 157 additions & 54 deletions

plugins/gui/include/gui/graph_widget/items/nets/separated_graphics_net.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,19 @@ namespace hal
8585
*/
8686
virtual void finalize();
8787

88+
/**
89+
* Add extra lines to connect wire to pin in iconic representation
90+
*/
91+
void setInputConnector(const QList<QLineF>& con);
92+
void setOutputConnector(const QList<QLineF>& con);
93+
8894
protected:
8995
static qreal sAlpha;
9096

9197
QVector<QPointF> mInputPositions;
9298
QVector<QPointF> mOutputPositions;
99+
100+
QList<QLineF> mInputConnector;
101+
QList<QLineF> mOutputConnector;
93102
};
94103
}

plugins/gui/include/gui/graph_widget/items/nets/standard_arrow_net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace hal {
4646
* @param n - The underlying net
4747
* @param l - The lines this GraphicsNet consists of
4848
*/
49-
StandardArrowNet(Net* n, const Lines& l, const QList<QPointF>& knots = QList<QPointF>());
49+
StandardArrowNet(Net* n, const Lines& l, const QList<QPointF>& knots, const QList<QLineF>& connectors);
5050
/**
5151
* Adds an input position.
5252
*

plugins/gui/include/gui/graph_widget/items/nets/standard_graphics_net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace hal
124124
* @param n - The undelying net of the StandardGraphicsNet
125125
* @param l - The lines this GraphicsNet consists of
126126
*/
127-
StandardGraphicsNet(Net* n, const Lines& l, const QList<QPointF>& knots = QList<QPointF>());
127+
StandardGraphicsNet(Net* n, const Lines& l, const QList<QPointF>& knots, const QList<QLineF>& connectors);
128128

129129
/**
130130
* Draws the StandardGraphicsNet in the scene.

plugins/gui/include/gui/graph_widget/items/nodes/gates/graphics_gate.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
#pragma once
2727

2828
#include "gui/graph_widget/items/nodes/graphics_node.h"
29-
#include "hal_core/netlist/gate_library/enums/gate_type_property.h"
3029

31-
#include <memory>
3230
#include <QPainterPath>
3331

3432
namespace hal
@@ -55,6 +53,8 @@ namespace hal
5553
*/
5654
GraphicsGate(Gate* g);
5755

56+
virtual QList<QLineF> connectors(u32 netId, bool isInput) const;
57+
5858
protected:
5959

6060
struct GraphicsGatePin
@@ -66,6 +66,7 @@ namespace hal
6666
bool isInput;
6767
float x;
6868
float y;
69+
QList<QLineF> connectors;
6970
};
7071

7172
enum ShapeType { StandardShape, InverterShape, AndShape, OrShape };

plugins/gui/include/gui/graph_widget/items/nodes/graphics_node.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <QString>
3131
#include <QFont>
32+
#include <QLineF>
3233

3334
namespace hal
3435
{
@@ -190,7 +191,10 @@ namespace hal
190191
*/
191192
static QColor sTextColor;
192193

193-
194+
/**
195+
* Return shape connectors between external net and pin, empty list if no connector available (default)
196+
*/
197+
virtual QList<QLineF> connectors(u32 netId, bool isInput) const;
194198
// qreal xOffset() const;
195199
// qreal yOffset() const;
196200

plugins/gui/include/gui/graph_widget/layouters/graph_layouter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ namespace hal
390390
bool mDone;
391391
int mRollbackStatus;
392392

393-
QRect mNodeBoundingBox;
393+
QRect mSceneBoundingBox;
394394
NetLayoutConnectionMetric mConnectionMetric;
395395
QHash<NetLayoutWire, QList<u32>> mWireHash;
396396
QHash<NetLayoutPoint, NetLayoutJunctionEntries> mJunctionEntries;
@@ -427,6 +427,7 @@ namespace hal
427427
public:
428428
StandardGraphicsNet::Lines mLines;
429429
QList<QPointF> mKnots;
430+
QList<QLineF> mConnectorLines;
430431
DrawNetThread(u32 id, GraphLayouter* parent) : QThread(parent), mId(id), mLayouter(parent) {;}
431432
u32 id() const { return mId; }
432433
void run() override;

plugins/gui/include/gui/graph_widget/layouters/net_layout_point.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ namespace hal {
8080
QGraphicsEllipseItem* graphicsFactory(float r) const;
8181
int distanceTo(const NetLayoutPoint& other) const;
8282
int yGrid() const;
83-
QPoint gridPoint() const { return QPoint(x(),yGrid()); }
83+
QPoint rightGridPoint() const { return QPoint(x(),yGrid()); }
84+
QPoint leftGridPoint() const { return QPoint(x()-1,yGrid()); }
8485
bool isEndpoint() const;
8586
bool isUndefined() const { return x()==INT_MIN || y()==INT_MIN; }
8687
NetLayoutPoint nextPoint(const NetLayoutDirection& dir, bool omitEndpoint=false) const;

plugins/gui/src/graph_widget/items/nets/arrow_separated_net.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ namespace hal
9292
{
9393
QPointF to(position.x() - sWireLength, position.y());
9494
painter->drawLine(position, to);
95+
for (const QLineF& con : mInputConnector)
96+
{
97+
painter->drawLine(con.translated(position));
98+
}
9599
painter->save();
96100
painter->setRenderHint(QPainter::Antialiasing, true);
97101
sPen.setStyle(Qt::PenStyle::SolidLine);
@@ -106,6 +110,10 @@ namespace hal
106110
{
107111
QPointF to(position.x() + sWireLength, position.y());
108112
painter->drawLine(position, to);
113+
for (const QLineF& con : mOutputConnector)
114+
{
115+
painter->drawLine(con.translated(position));
116+
}
109117
painter->save();
110118
painter->setRenderHint(QPainter::Antialiasing, true);
111119
sPen.setStyle(Qt::PenStyle::SolidLine);

plugins/gui/src/graph_widget/items/nets/separated_graphics_net.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,14 @@ namespace hal
2626
mRect = mShape.boundingRect();
2727
mRect.adjust(-sLineWidth, -sLineWidth, sLineWidth, sLineWidth);
2828
}
29+
30+
void SeparatedGraphicsNet::setInputConnector(const QList<QLineF>& con)
31+
{
32+
mInputConnector = con;
33+
}
34+
35+
void SeparatedGraphicsNet::setOutputConnector(const QList<QLineF>& con)
36+
{
37+
mOutputConnector = con;
38+
}
2939
}

plugins/gui/src/graph_widget/items/nets/standard_arrow_net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace hal
44
{
5-
StandardArrowNet::StandardArrowNet(Net* n, const Lines &l, const QList<QPointF>& knots)
6-
: StandardGraphicsNet(n,l,knots), mArrowNet(n)
5+
StandardArrowNet::StandardArrowNet(Net* n, const Lines &l, const QList<QPointF>& knots, const QList<QLineF>& connectors)
6+
: StandardGraphicsNet(n,l,knots,connectors), mArrowNet(n)
77
{;}
88

99
void StandardArrowNet::setInputPosition(const QPointF& pos)

0 commit comments

Comments
 (0)