HAL
graphics_node.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
29 
30 #include <QString>
31 
32 namespace hal
33 {
40  class GraphicsNode : public GraphicsItem
41  {
42  public:
47  struct Visuals
48  {
49  bool mVisible;
50 
57 
58  // DRAW TYPE ENUM
59  };
60 
68  GraphicsNode(const ItemType type, const u32 id, const QString& name);
69 
76  virtual QRectF boundingRect() const override;
77 
83  virtual QPainterPath shape() const override;
84 
93  virtual QPointF getInputScenePosition(const u32 mNetId, const QString& pin_type) const = 0;
94 
103  virtual QPointF getOutputScenePosition(const u32 mNetId, const QString& pin_type) const = 0;
104 
114  virtual QPointF endpointPositionByIndex(int index, bool isInput) const = 0;
115 
121  virtual float yEndpointDistance() const = 0;
122 
128  virtual float yTopPinDistance() const = 0;
129 
138  int inputByNet(u32 netId) const;
139 
148  int outputByNet(u32 netId) const;
149 
159  QList<u32> inputNets() const;
160 
170  QList<u32> outputNets() const;
171 
172  // virtual std::string get_input_pin_type_at_position(const size_t pos) const = 0;
173  // virtual std::string get_output_pin_type_at_position(const size_t pos) const = 0;
174 
180  virtual void setVisuals(const Visuals& v);
181 
187  qreal width() const;
188 
194  qreal height() const;
195 
201  void set_name(const QString& name);
202 
203  // qreal xOffset() const;
204  // qreal yOffset() const;
205 
206  protected:
212 
216  qreal mWidth;
217 
221  qreal mHeight;
222 
223  // pin by net number
224  // (multiple) pins not assigned to network are stored with id=0
230 
236  };
237 }
Superclass for all graphic items used ins the GraphicsScene. It contains information about the underl...
Definition: graphics_item.h:44
Abstract base class for nodes (e.g. gates, modules)
Definition: graphics_node.h:41
virtual QRectF boundingRect() const override
QMultiHash< u32, int > mInputByNet
QMultiHash< u32, int > mOutputByNet
QList< u32 > inputNets() const
virtual QPainterPath shape() const override
virtual float yEndpointDistance() const =0
QString mNodeText[3]
qreal width() const
virtual float yTopPinDistance() const =0
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
virtual QPointF getInputScenePosition(const u32 mNetId, const QString &pin_type) const =0
virtual QPointF endpointPositionByIndex(int index, bool isInput) const =0
void set_name(const QString &name)
virtual QPointF getOutputScenePosition(const u32 mNetId, const QString &pin_type) const =0
ItemType
The ItemType enum provides the enum type to classify graphic items into Modules, Gates or Nets....
Definition: gui_def.h:45
quint32 u32
std::string name
virtual int type() const const