HAL
graphics_node.cpp
Go to the documentation of this file.
2 
4 
5 #include <QApplication>
6 
7 namespace hal
8 {
10  : GraphicsItem(type, id)
11  {
12  mNodeText[0] = name;
14  //setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsGeometryChanges | ItemIsFocusable);
15  //setAcceptHoverEvents(true);
16  }
17 
19  {
20  return QRectF(0, 0, mWidth, mHeight);
21  }
22 
24  {
25  QPainterPath path;
26  path.addRect(QRectF(0, 0, mWidth, mHeight));
27  return path;
28  }
29 
31  {
33 
34  mColor = v.mMainColor;
35  }
36 
37  qreal GraphicsNode::width() const
38  {
39  return mWidth;
40  }
41 
42  qreal GraphicsNode::height() const
43  {
44  return mHeight;
45  }
46 
48  {
49  if (mInputByNet.isEmpty()) return QList<u32>();
50  int n = mInputByNet.size();
51  QVector<u32> retval(n);
52  for (auto it=mInputByNet.constBegin(); it!=mInputByNet.constEnd(); ++it)
53  {
54  Q_ASSERT(it.value() < n);
55  retval[it.value()] = it.key();
56  }
57  return retval.toList();
58  }
59 
61  {
62  if (mOutputByNet.isEmpty()) return QList<u32>();
63  int n = mOutputByNet.size();
64  QVector<u32> retval(n);
65  for (auto it=mOutputByNet.constBegin(); it!=mOutputByNet.constEnd(); ++it)
66  {
67  Q_ASSERT(it.value() < n);
68  retval[it.value()] = it.key();
69  }
70  return retval.toList();
71  }
72 
73  int GraphicsNode::inputByNet(u32 netId) const
74  {
75  return mInputByNet.value(netId,-1);
76  }
77 
78  int GraphicsNode::outputByNet(u32 netId) const
79  {
80  return mOutputByNet.value(netId,-1);
81  }
82 
84  {
85  mNodeText[0] = name;
86  }
87 }
Superclass for all graphic items used ins the GraphicsScene. It contains information about the underl...
Definition: graphics_item.h:44
virtual QRectF boundingRect() const override
QMultiHash< u32, int > mInputByNet
QMultiHash< u32, int > mOutputByNet
QList< u32 > inputNets() const
virtual QPainterPath shape() const override
QString mNodeText[3]
qreal width() const
GraphicsNode(const ItemType type, const u32 id, const QString &name)
QList< u32 > outputNets() const
int outputByNet(u32 netId) const
qreal height() const
virtual void setVisuals(const Visuals &v)
int inputByNet(u32 netId) const
void set_name(const QString &name)
ItemType
The ItemType enum provides the enum type to classify graphic items into Modules, Gates or Nets....
Definition: gui_def.h:45
n
Definition: test.py:6
quint32 u32
PinType type
std::string name
i32 id
void setFlags(QGraphicsItem::GraphicsItemFlags flags)
void setVisible(bool visible)
void addRect(const QRectF &rectangle)
QList< T > toList() const const