HAL  v4.5.0-283-g3f42a39fa
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::ClockTreeScene Class Reference

#include </home/runner/work/hal/hal/plugins/clock_tree_viewer/include/clock_tree_viewer/clock_tree_scene.h>

Inheritance diagram for hal::ClockTreeScene:
Inheritance graph
Collaboration diagram for hal::ClockTreeScene:
Collaboration graph

Public Member Functions

 ClockTreeScene (QObject *parent=nullptr)
 
void setLayout (const ctv::Layout &layout, const ctv::Style &style, const ClockTreeColors &colors)
 
void setColors (const ClockTreeColors &colors)
 
void setHighlight (const QVector< int > &nodes)
 
void clearLayout ()
 
bool hasLayout () const
 
const ctv::Style & style () const
 
QColor edgeColor () const
 
QColor nodeColor (int index) const
 
const QVector< int > & highlightedNodes () const
 
QRectF highlightedRect () const
 
Result< QImage > renderPicture (const QColor &background)
 
- Public Member Functions inherited from QGraphicsScene
 QGraphicsScene (QObject *parent)
 
 QGraphicsScene (const QRectF &sceneRect, QObject *parent)
 
 QGraphicsScene (qreal x, qreal y, qreal width, qreal height, QObject *parent)
 
virtual ~QGraphicsScene ()
 
QRectF sceneRect () const const
 
qreal width () const const
 
qreal height () const const
 
void setSceneRect (const QRectF &rect)
 
void setSceneRect (qreal x, qreal y, qreal w, qreal h)
 
void render (QPainter *painter, const QRectF &target, const QRectF &source, Qt::AspectRatioMode aspectRatioMode)
 
QGraphicsScene::ItemIndexMethod itemIndexMethod () const const
 
void setItemIndexMethod (QGraphicsScene::ItemIndexMethod method)
 
bool isSortCacheEnabled () const const
 
void setSortCacheEnabled (bool enabled)
 
int bspTreeDepth () const const
 
void setBspTreeDepth (int depth)
 
QRectF itemsBoundingRect () const const
 
QList< QGraphicsItem * > items (Qt::SortOrder order) const const
 
QList< QGraphicsItem * > items (const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const const
 
QList< QGraphicsItem * > items (const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const const
 
QList< QGraphicsItem * > items (const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const const
 
QList< QGraphicsItem * > items (const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const const
 
QList< QGraphicsItem * > collidingItems (const QGraphicsItem *item, Qt::ItemSelectionMode mode) const const
 
QGraphicsItem * itemAt (const QPointF &position) const const
 
QGraphicsItem * itemAt (const QPointF &position, const QTransform &deviceTransform) const const
 
QList< QGraphicsItem * > items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const const
 
QList< QGraphicsItem * > items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const const
 
QGraphicsItem * itemAt (qreal x, qreal y) const const
 
QGraphicsItem * itemAt (qreal x, qreal y, const QTransform &deviceTransform) const const
 
QList< QGraphicsItem * > selectedItems () const const
 
QPainterPath selectionArea () const const
 
void setSelectionArea (const QPainterPath &path, const QTransform &deviceTransform)
 
void setSelectionArea (const QPainterPath &path, Qt::ItemSelectionMode mode, const QTransform &deviceTransform)
 
void setSelectionArea (const QPainterPath &path, Qt::ItemSelectionOperation selectionOperation, Qt::ItemSelectionMode mode, const QTransform &deviceTransform)
 
QGraphicsItemGroup * createItemGroup (const QList< QGraphicsItem * > &items)
 
void destroyItemGroup (QGraphicsItemGroup *group)
 
void addItem (QGraphicsItem *item)
 
QGraphicsEllipseItem * addEllipse (const QRectF &rect, const QPen &pen, const QBrush &brush)
 
QGraphicsLineItem * addLine (const QLineF &line, const QPen &pen)
 
QGraphicsPathItem * addPath (const QPainterPath &path, const QPen &pen, const QBrush &brush)
 
QGraphicsPixmapItem * addPixmap (const QPixmap &pixmap)
 
QGraphicsPolygonItem * addPolygon (const QPolygonF &polygon, const QPen &pen, const QBrush &brush)
 
QGraphicsRectItem * addRect (const QRectF &rect, const QPen &pen, const QBrush &brush)
 
QGraphicsTextItem * addText (const QString &text, const QFont &font)
 
QGraphicsSimpleTextItem * addSimpleText (const QString &text, const QFont &font)
 
QGraphicsProxyWidget * addWidget (QWidget *widget, Qt::WindowFlags wFlags)
 
QGraphicsEllipseItem * addEllipse (qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
 
QGraphicsLineItem * addLine (qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen)
 
QGraphicsRectItem * addRect (qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
 
void removeItem (QGraphicsItem *item)
 
QGraphicsItem * focusItem () const const
 
void setFocusItem (QGraphicsItem *item, Qt::FocusReason focusReason)
 
bool hasFocus () const const
 
void setFocus (Qt::FocusReason focusReason)
 
void clearFocus ()
 
void setStickyFocus (bool enabled)
 
bool stickyFocus () const const
 
QGraphicsItem * mouseGrabberItem () const const
 
QBrush backgroundBrush () const const
 
void setBackgroundBrush (const QBrush &brush)
 
QBrush foregroundBrush () const const
 
void setForegroundBrush (const QBrush &brush)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const const
 
QList< QGraphicsView * > views () const const
 
void update (qreal x, qreal y, qreal w, qreal h)
 
void invalidate (qreal x, qreal y, qreal w, qreal h, QGraphicsScene::SceneLayers layers)
 
QStyle * style () const const
 
void setStyle (QStyle *style)
 
QFont font () const const
 
void setFont (const QFont &font)
 
QPalette palette () const const
 
void setPalette (const QPalette &palette)
 
bool isActive () const const
 
QGraphicsItem * activePanel () const const
 
void setActivePanel (QGraphicsItem *item)
 
QGraphicsWidget * activeWindow () const const
 
void setActiveWindow (QGraphicsWidget *widget)
 
bool sendEvent (QGraphicsItem *item, QEvent *event)
 
qreal minimumRenderSize () const const
 
void setMinimumRenderSize (qreal minSize)
 
bool focusOnTouch () const const
 
void setFocusOnTouch (bool enabled)
 
void update (const QRectF &rect)
 
void invalidate (const QRectF &rect, QGraphicsScene::SceneLayers layers)
 
void advance ()
 
void clearSelection ()
 
void clear ()
 
void changed (const QList< QRectF > &region)
 
void sceneRectChanged (const QRectF &rect)
 
void selectionChanged ()
 
void focusItemChanged (QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason)
 
- Public Member Functions inherited from QObject
virtual const QMetaObject * metaObject () const const
 
 QObject (QObject *parent)
 
virtual ~QObject ()
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThread * thread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
T findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArray > dynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObject * parent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
T qobject_cast (QObject *object)
 
T qobject_cast (const QObject *object)
 
T qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Static Public Member Functions

static QPointF fromChip (double x, double y)
 
static QPointF toChip (const QPointF &scenePosition)
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Additional Inherited Members

- Public Types inherited from QGraphicsScene
enum  ItemIndexMethod
 
enum  SceneLayer
 
- Public Attributes inherited from QGraphicsScene
typedef SceneLayers
 
 BspTreeIndex
 
 NoIndex
 
 ItemLayer
 
 BackgroundLayer
 
 ForegroundLayer
 
 AllLayers
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QGraphicsScene
virtual bool event (QEvent *event) override
 
virtual bool eventFilter (QObject *watched, QEvent *event) override
 
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *contextMenuEvent)
 
virtual void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dropEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void focusInEvent (QFocusEvent *focusEvent)
 
virtual void focusOutEvent (QFocusEvent *focusEvent)
 
virtual void helpEvent (QGraphicsSceneHelpEvent *helpEvent)
 
virtual void keyPressEvent (QKeyEvent *keyEvent)
 
virtual void keyReleaseEvent (QKeyEvent *keyEvent)
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *mouseEvent)
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *wheelEvent)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void drawBackground (QPainter *painter, const QRectF &rect)
 
virtual void drawForeground (QPainter *painter, const QRectF &rect)
 
virtual void drawItems (QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget *widget)
 
bool focusNextPrevChild (bool next)
 
- Protected Member Functions inherited from QObject
QObject * sender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Properties inherited from QGraphicsScene
 backgroundBrush
 
 foregroundBrush
 
 itemIndexMethod
 
 sceneRect
 
 bspTreeDepth
 
 palette
 
 font
 
 sortCacheEnabled
 
 stickyFocus
 
 minimumRenderSize
 
 focusOnTouch
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The scene that holds the drawing of a clock tree: a line for every connection and a dot for every gate.

Gates can be highlighted by a ring around them. The ring has the same size on the screen at every zoom, so a single gate can be found in a drawing of the whole chip, where the dot of a gate is far smaller than a pixel.

The scene paints no background of its own, the view shows its own. Chip coordinates have their origin in the lower left corner, the scene's y axis points down. The scene therefore stores the chip's y coordinate negated, use fromChip and toChip to convert.

Definition at line 69 of file clock_tree_scene.h.

Constructor & Destructor Documentation

◆ ClockTreeScene()

hal::ClockTreeScene::ClockTreeScene ( QObject *  parent = nullptr)
explicit

Construct an empty scene.

Parameters
[in]parent- The parent object. Defaults to a nullptr.

Definition at line 63 of file clock_tree_scene.cpp.

Member Function Documentation

◆ clearLayout()

void hal::ClockTreeScene::clearLayout ( )

Remove the drawing.

Definition at line 254 of file clock_tree_scene.cpp.

References QVector::clear(), QGraphicsScene::clear(), and QGraphicsScene::setSceneRect().

Referenced by setLayout().

◆ edgeColor()

QColor hal::ClockTreeScene::edgeColor ( ) const
inline

Get the color the lines are painted in.

Returns
The color, meaningless without a drawing.

Definition at line 146 of file clock_tree_scene.h.

◆ fromChip()

QPointF hal::ClockTreeScene::fromChip ( double  x,
double  y 
)
static

Get the position in the scene of a position on the chip.

Parameters
[in]x- The x coordinate on the chip.
[in]y- The y coordinate on the chip.
Returns
The position in the scene.

Definition at line 70 of file clock_tree_scene.cpp.

References x, and y.

Referenced by setLayout().

◆ hasLayout()

bool hal::ClockTreeScene::hasLayout ( ) const
inline

Check whether a drawing is shown.

Returns
true if there is a drawing, false otherwise.

Definition at line 129 of file clock_tree_scene.h.

Referenced by hal::ClockTreeGraphicsView::showArea().

◆ highlightedNodes()

const QVector<int>& hal::ClockTreeScene::highlightedNodes ( ) const
inline

Get the gates that are highlighted.

Returns
The indices into ctv::Layout::nodes, sorted.

Definition at line 167 of file clock_tree_scene.h.

◆ highlightedRect()

QRectF hal::ClockTreeScene::highlightedRect ( ) const

Get the area that the highlighted gates are in.

Returns
The smallest rectangle in the scene that holds the centers of all of them. It has no size if there is only one gate, and it is a null rectangle if there is none: check highlightedNodes to tell them apart.

Definition at line 230 of file clock_tree_scene.cpp.

References QVector::first(), QVector::isEmpty(), x, and y.

◆ nodeColor()

QColor hal::ClockTreeScene::nodeColor ( int  index) const
inline

Get the color a dot is painted in.

Parameters
[in]index- The index of the gate in ctv::Layout::nodes.
Returns
The color, an invalid color if there is no such gate.

Definition at line 157 of file clock_tree_scene.h.

References index, and QVector::value().

◆ renderPicture()

Result< QImage > hal::ClockTreeScene::renderPicture ( const QColor &  background)

Render the whole drawing and its margin into a picture, independent of any view and its zoom. Highlights are part of the picture.

A picture that would be larger than ctv::MAX_PICTURE_SIDE_PIXELS on a side gets a lower resolution than the style asks for, unless the user chose that resolution.

Parameters
[in]background- The color of the background, which the scene does not paint.
Returns
The picture on success, an error if there is no drawing or the picture would be too large at a resolution the user chose.

Definition at line 278 of file clock_tree_scene.cpp.

References QRectF::adjusted(), QPainter::Antialiasing, QPainter::end(), ERR, QImage::fill(), QImage::Format_RGB32, QRectF::height(), QGraphicsScene::height(), QImage::isNull(), QColor::isValid(), hal::ctv::MAX_PICTURE_SIDE_PIXELS, OK, hal::ctv::Style::picture_margin, hal::ctv::Style::pixels_per_unit, hal::ctv::Style::pixels_per_unit_is_fixed, QGraphicsScene::render(), QPainter::setRenderHint(), Qt::white, QRectF::width(), and QGraphicsScene::width().

Referenced by hal::ClockTreeViewer::savePicture().

◆ setColors()

void hal::ClockTreeScene::setColors ( const ClockTreeColors &  colors)

Paint the current drawing in other colors. Only what actually changes color is repainted.

Parameters
[in]colors- The new colors, for the gates and connections of the layout that is shown.

Definition at line 134 of file clock_tree_scene.cpp.

References hal::ctv::Style::edge_width, QPen::setCosmetic(), and QVector::size().

◆ setHighlight()

void hal::ClockTreeScene::setHighlight ( const QVector< int > &  nodes)

Highlight gates by a ring around each of them, instead of the ones that were highlighted before.

Parameters
[in]nodes- The gates, as indices into ctv::Layout::nodes. Indices that are out of range are ignored.

Definition at line 181 of file clock_tree_scene.cpp.

References QGraphicsScene::addItem(), QVector::begin(), QVector::clear(), QVector::end(), QVector::erase(), QGraphicsItem::ItemIgnoresTransformations, Qt::NoBrush, QVector::push_back(), QVector::reserve(), QPen::setCosmetic(), and QVector::size().

◆ setLayout()

void hal::ClockTreeScene::setLayout ( const ctv::Layout &  layout,
const ctv::Style &  style,
const ClockTreeColors &  colors 
)

Replace the drawing. The scene is as large as the tree plus the picture margin on every side.

Parameters
[in]layout- The gates and connections to draw.
[in]style- The sizes to draw them with.
[in]colors- The colors to draw them with.

Definition at line 86 of file clock_tree_scene.cpp.

References QGraphicsScene::addEllipse(), QGraphicsScene::addLine(), QRectF::adjusted(), clearLayout(), hal::ctv::Style::edge_width, hal::ctv::Layout::edges, hal::ctv::Edge::from, fromChip(), QGraphicsScene::itemsBoundingRect(), hal::ctv::Style::node_radius, hal::ctv::Layout::nodes, hal::ctv::Style::picture_margin, QVector::push_back(), QVector::reserve(), QGraphicsScene::setSceneRect(), style(), hal::core_strings::to(), hal::ctv::Edge::to, hal::ctv::Node::x, and hal::ctv::Node::y.

◆ style()

const ctv::Style & hal::ClockTreeScene::style ( ) const

Get the sizes the current drawing was made with.

Returns
The sizes, meaningless without a drawing.

Definition at line 273 of file clock_tree_scene.cpp.

Referenced by setLayout(), and hal::ClockTreeGraphicsView::showArea().

◆ toChip()

QPointF hal::ClockTreeScene::toChip ( const QPointF &  scenePosition)
static

Get the position on the chip of a position in the scene.

Parameters
[in]scenePosition- The position in the scene.
Returns
The position on the chip.

Definition at line 75 of file clock_tree_scene.cpp.

References QPointF::x(), and QPointF::y().

Referenced by hal::ClockTreeGraphicsView::mouseMoveEvent().


The documentation for this class was generated from the following files: