HAL  v4.5.0-283-g3f42a39fa
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
clock_tree_scene.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 // Copyright (c) 2025-2026 Sascha Tommasone. All rights reserved.
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included in all
17 // copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 // SOFTWARE.
26 
27 #pragma once
28 
31 
32 #include <QColor>
33 #include <QGraphicsScene>
34 #include <QImage>
35 #include <QPointF>
36 #include <QRectF>
37 #include <QVector>
38 
40 class QGraphicsLineItem;
41 
42 namespace hal
43 {
48  {
51 
54 
57  };
58 
70  {
71  public:
77  explicit ClockTreeScene( QObject *parent = nullptr );
78 
86  static QPointF fromChip( double x, double y );
87 
94  static QPointF toChip( const QPointF &scenePosition );
95 
103  void setLayout( const ctv::Layout &layout, const ctv::Style &style, const ClockTreeColors &colors );
104 
110  void setColors( const ClockTreeColors &colors );
111 
117  void setHighlight( const QVector<int> &nodes );
118 
122  void clearLayout();
123 
129  [[nodiscard]] bool hasLayout() const
130  {
131  return mHasLayout;
132  }
133 
139  [[nodiscard]] const ctv::Style &style() const;
140 
146  [[nodiscard]] QColor edgeColor() const
147  {
148  return mEdgeColor;
149  }
150 
157  [[nodiscard]] QColor nodeColor( int index ) const
158  {
159  return mNodeColors.value( index );
160  }
161 
167  [[nodiscard]] const QVector<int> &highlightedNodes() const
168  {
169  return mHighlighted;
170  }
171 
178  [[nodiscard]] QRectF highlightedRect() const;
179 
191  Result<QImage> renderPicture( const QColor &background );
192 
193  private:
197  [[nodiscard]] static QColor colorOfNode( const ClockTreeColors &colors, int index );
198 
199  ctv::Style mStyle;
200 
201  bool mHasLayout;
202 
203  QColor mEdgeColor;
204 
205  QVector<QGraphicsLineItem *> mEdgeItems;
206 
208 
209  QVector<QColor> mNodeColors;
210 
211  QVector<QPointF> mNodeCenters;
212 
214  QRectF mContentRect;
215 
216  QColor mHighlightColor;
217 
219 
220  QVector<int> mHighlighted;
221  };
222 } // namespace hal
const ctv::Style & style() const
Result< QImage > renderPicture(const QColor &background)
const QVector< int > & highlightedNodes() const
static QPointF fromChip(double x, double y)
void setHighlight(const QVector< int > &nodes)
ClockTreeScene(QObject *parent=nullptr)
void setLayout(const ctv::Layout &layout, const ctv::Style &style, const ClockTreeColors &colors)
static QPointF toChip(const QPointF &scenePosition)
QColor nodeColor(int index) const
QRectF highlightedRect() const
void setColors(const ClockTreeColors &colors)
QColor edgeColor() const
Definition: defines.h:45
QObject * parent() const const
T value(int i) const const
QVector< QColor > nodes