HAL
hal::GraphicsItem Class Reference

Superclass for all graphic items used ins the GraphicsScene. It contains information about the underlying objects that are represented, i.e. the type and the id. More...

#include <graphics_item.h>

Inheritance diagram for hal::GraphicsItem:
Inheritance graph
Collaboration diagram for hal::GraphicsItem:
Collaboration graph

Public Member Functions

 GraphicsItem (const ItemType type, const u32 id)
 
ItemType itemType () const
 
u32 id () const
 
void setHightlight (bool hl)
 
- Public Member Functions inherited from QGraphicsItem
 QGraphicsItem (QGraphicsItem *parent)
 
virtual ~QGraphicsItem ()
 
QGraphicsScenescene () const const
 
QGraphicsItemparentItem () const const
 
QGraphicsItemtopLevelItem () const const
 
QGraphicsObjectparentObject () const const
 
QGraphicsWidgetparentWidget () const const
 
QGraphicsWidgettopLevelWidget () const const
 
QGraphicsWidgetwindow () const const
 
QGraphicsItempanel () const const
 
void setParentItem (QGraphicsItem *newParent)
 
QList< QGraphicsItem * > children () const const
 
QList< QGraphicsItem * > childItems () const const
 
bool isWidget () const const
 
bool isWindow () const const
 
bool isPanel () const const
 
QGraphicsObjecttoGraphicsObject ()
 
const QGraphicsObjecttoGraphicsObject () const const
 
QGraphicsItemGroupgroup () const const
 
void setGroup (QGraphicsItemGroup *group)
 
QGraphicsItem::GraphicsItemFlags flags () const const
 
void setFlag (QGraphicsItem::GraphicsItemFlag flag, bool enabled)
 
void setFlags (QGraphicsItem::GraphicsItemFlags flags)
 
QGraphicsItem::CacheMode cacheMode () const const
 
void setCacheMode (QGraphicsItem::CacheMode mode, const QSize &logicalCacheSize)
 
QGraphicsItem::PanelModality panelModality () const const
 
void setPanelModality (QGraphicsItem::PanelModality panelModality)
 
bool isBlockedByModalPanel (QGraphicsItem **blockingPanel) const const
 
QString toolTip () const const
 
void setToolTip (const QString &toolTip)
 
QCursor cursor () const const
 
void setCursor (const QCursor &cursor)
 
bool hasCursor () const const
 
void unsetCursor ()
 
bool isVisible () const const
 
bool isVisibleTo (const QGraphicsItem *parent) const const
 
void setVisible (bool visible)
 
void hide ()
 
void show ()
 
bool isEnabled () const const
 
void setEnabled (bool enabled)
 
bool isSelected () const const
 
void setSelected (bool selected)
 
bool acceptDrops () const const
 
void setAcceptDrops (bool on)
 
qreal opacity () const const
 
qreal effectiveOpacity () const const
 
void setOpacity (qreal opacity)
 
QGraphicsEffectgraphicsEffect () const const
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
Qt::MouseButtons acceptedMouseButtons () const const
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 
bool acceptsHoverEvents () const const
 
void setAcceptsHoverEvents (bool enabled)
 
bool acceptHoverEvents () const const
 
void setAcceptHoverEvents (bool enabled)
 
bool acceptTouchEvents () const const
 
void setAcceptTouchEvents (bool enabled)
 
bool filtersChildEvents () const const
 
void setFiltersChildEvents (bool enabled)
 
bool handlesChildEvents () const const
 
void setHandlesChildEvents (bool enabled)
 
bool isActive () const const
 
void setActive (bool active)
 
bool hasFocus () const const
 
void setFocus (Qt::FocusReason focusReason)
 
void clearFocus ()
 
QGraphicsItemfocusProxy () const const
 
void setFocusProxy (QGraphicsItem *item)
 
QGraphicsItemfocusItem () const const
 
void grabMouse ()
 
void ungrabMouse ()
 
void grabKeyboard ()
 
void ungrabKeyboard ()
 
QPointF pos () const const
 
qreal x () const const
 
void setX (qreal x)
 
qreal y () const const
 
void setY (qreal y)
 
QPointF scenePos () const const
 
void setPos (const QPointF &pos)
 
void setPos (qreal x, qreal y)
 
void moveBy (qreal dx, qreal dy)
 
void ensureVisible (const QRectF &rect, int xmargin, int ymargin)
 
void ensureVisible (qreal x, qreal y, qreal w, qreal h, int xmargin, int ymargin)
 
QMatrix matrix () const const
 
QMatrix sceneMatrix () const const
 
void setMatrix (const QMatrix &matrix, bool combine)
 
void resetMatrix ()
 
QTransform transform () const const
 
QTransform sceneTransform () const const
 
QTransform deviceTransform (const QTransform &viewportTransform) const const
 
QTransform itemTransform (const QGraphicsItem *other, bool *ok) const const
 
void setTransform (const QTransform &matrix, bool combine)
 
void resetTransform ()
 
void rotate (qreal angle)
 
void scale (qreal sx, qreal sy)
 
void shear (qreal sh, qreal sv)
 
void translate (qreal dx, qreal dy)
 
void setRotation (qreal angle)
 
qreal rotation () const const
 
void setScale (qreal factor)
 
qreal scale () const const
 
QList< QGraphicsTransform * > transformations () const const
 
void setTransformations (const QList< QGraphicsTransform * > &transformations)
 
QPointF transformOriginPoint () const const
 
void setTransformOriginPoint (const QPointF &origin)
 
void setTransformOriginPoint (qreal x, qreal y)
 
virtual void advance (int phase)
 
qreal zValue () const const
 
void setZValue (qreal z)
 
void stackBefore (const QGraphicsItem *sibling)
 
virtual QRectF boundingRect () const const=0
 
QRectF childrenBoundingRect () const const
 
QRectF sceneBoundingRect () const const
 
virtual QPainterPath shape () const const
 
bool isClipped () const const
 
QPainterPath clipPath () const const
 
virtual bool contains (const QPointF &point) const const
 
virtual bool collidesWithItem (const QGraphicsItem *other, Qt::ItemSelectionMode mode) const const
 
virtual bool collidesWithPath (const QPainterPath &path, Qt::ItemSelectionMode mode) const const
 
QList< QGraphicsItem * > collidingItems (Qt::ItemSelectionMode mode) const const
 
bool isObscured (const QRectF &rect) const const
 
bool isObscured (qreal x, qreal y, qreal w, qreal h) const const
 
virtual bool isObscuredBy (const QGraphicsItem *item) const const
 
virtual QPainterPath opaqueArea () const const
 
QRegion boundingRegion (const QTransform &itemToDeviceTransform) const const
 
qreal boundingRegionGranularity () const const
 
void setBoundingRegionGranularity (qreal granularity)
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
 
void update (const QRectF &rect)
 
void update (qreal x, qreal y, qreal width, qreal height)
 
void scroll (qreal dx, qreal dy, const QRectF &rect)
 
QPointF mapToItem (const QGraphicsItem *item, const QPointF &point) const const
 
QPointF mapToParent (const QPointF &point) const const
 
QPointF mapToScene (const QPointF &point) const const
 
QPolygonF mapToItem (const QGraphicsItem *item, const QRectF &rect) const const
 
QPolygonF mapToParent (const QRectF &rect) const const
 
QPolygonF mapToScene (const QRectF &rect) const const
 
QRectF mapRectToItem (const QGraphicsItem *item, const QRectF &rect) const const
 
QRectF mapRectToParent (const QRectF &rect) const const
 
QRectF mapRectToScene (const QRectF &rect) const const
 
QPolygonF mapToItem (const QGraphicsItem *item, const QPolygonF &polygon) const const
 
QPolygonF mapToParent (const QPolygonF &polygon) const const
 
QPolygonF mapToScene (const QPolygonF &polygon) const const
 
QPainterPath mapToItem (const QGraphicsItem *item, const QPainterPath &path) const const
 
QPainterPath mapToParent (const QPainterPath &path) const const
 
QPainterPath mapToScene (const QPainterPath &path) const const
 
QPointF mapFromItem (const QGraphicsItem *item, const QPointF &point) const const
 
QPointF mapFromParent (const QPointF &point) const const
 
QPointF mapFromScene (const QPointF &point) const const
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QRectF &rect) const const
 
QPolygonF mapFromParent (const QRectF &rect) const const
 
QPolygonF mapFromScene (const QRectF &rect) const const
 
QRectF mapRectFromItem (const QGraphicsItem *item, const QRectF &rect) const const
 
QRectF mapRectFromParent (const QRectF &rect) const const
 
QRectF mapRectFromScene (const QRectF &rect) const const
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QPolygonF &polygon) const const
 
QPolygonF mapFromParent (const QPolygonF &polygon) const const
 
QPolygonF mapFromScene (const QPolygonF &polygon) const const
 
QPainterPath mapFromItem (const QGraphicsItem *item, const QPainterPath &path) const const
 
QPainterPath mapFromParent (const QPainterPath &path) const const
 
QPainterPath mapFromScene (const QPainterPath &path) const const
 
QPointF mapToItem (const QGraphicsItem *item, qreal x, qreal y) const const
 
QPointF mapToParent (qreal x, qreal y) const const
 
QPointF mapToScene (qreal x, qreal y) const const
 
QPolygonF mapToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const const
 
QPolygonF mapToParent (qreal x, qreal y, qreal w, qreal h) const const
 
QPolygonF mapToScene (qreal x, qreal y, qreal w, qreal h) const const
 
QRectF mapRectToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const const
 
QRectF mapRectToParent (qreal x, qreal y, qreal w, qreal h) const const
 
QRectF mapRectToScene (qreal x, qreal y, qreal w, qreal h) const const
 
QPointF mapFromItem (const QGraphicsItem *item, qreal x, qreal y) const const
 
QPointF mapFromParent (qreal x, qreal y) const const
 
QPointF mapFromScene (qreal x, qreal y) const const
 
QPolygonF mapFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const const
 
QPolygonF mapFromParent (qreal x, qreal y, qreal w, qreal h) const const
 
QPolygonF mapFromScene (qreal x, qreal y, qreal w, qreal h) const const
 
QRectF mapRectFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const const
 
QRectF mapRectFromParent (qreal x, qreal y, qreal w, qreal h) const const
 
QRectF mapRectFromScene (qreal x, qreal y, qreal w, qreal h) const const
 
bool isAncestorOf (const QGraphicsItem *child) const const
 
QGraphicsItemcommonAncestorItem (const QGraphicsItem *other) const const
 
bool isUnderMouse () const const
 
QVariant data (int key) const const
 
void setData (int key, const QVariant &value)
 
Qt::InputMethodHints inputMethodHints () const const
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
virtual int type () const const
 
void installSceneEventFilter (QGraphicsItem *filterItem)
 
void removeSceneEventFilter (QGraphicsItem *filterItem)
 
qgraphicsitem_cast (QGraphicsItem *item)
 

Static Public Member Functions

static void loadSettings ()
 
static void setLod (const qreal lod)
 

Protected Member Functions

QColor penColor (QStyle::State state, const QColor &colorHint=QColor()) const
 
QColor selectionColor () const
 
QColor groupingColor () const
 
- Protected Member Functions inherited from QGraphicsItem
void updateMicroFocus ()
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 
virtual bool sceneEvent (QEvent *event)
 
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
 
virtual void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void dropEvent (QGraphicsSceneDragDropEvent *event)
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *event)
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const const
 
virtual QVariant itemChange (QGraphicsItem::GraphicsItemChange change, const QVariant &value)
 
void prepareGeometryChange ()
 

Protected Attributes

ItemType mItemType
 
bool mHighlight
 
u32 mId
 
QColor mColor
 

Static Protected Attributes

static qreal sLod
 
static QColor sSelectionColor
 
static QColor sHighlightColor
 

Additional Inherited Members

- Public Types inherited from QGraphicsItem
enum  GraphicsItemFlag
 
enum  GraphicsItemChange
 
enum  CacheMode
 
enum  PanelModality
 
enum  anonymous
 
- Public Attributes inherited from QGraphicsItem
typedef GraphicsItemFlags
 
 ItemIsMovable
 
 ItemIsSelectable
 
 ItemIsFocusable
 
 ItemClipsToShape
 
 ItemClipsChildrenToShape
 
 ItemIgnoresTransformations
 
 ItemIgnoresParentOpacity
 
 ItemDoesntPropagateOpacityToChildren
 
 ItemStacksBehindParent
 
 ItemUsesExtendedStyleOption
 
 ItemHasNoContents
 
 ItemSendsGeometryChanges
 
 ItemAcceptsInputMethod
 
 ItemNegativeZStacksBehindParent
 
 ItemIsPanel
 
 ItemIsFocusScope
 
 ItemSendsScenePositionChanges
 
 ItemStopsClickFocusPropagation
 
 ItemStopsFocusHandling
 
 ItemContainsChildrenInShape
 
 ItemPositionChange
 
 ItemMatrixChange
 
 ItemVisibleChange
 
 ItemEnabledChange
 
 ItemSelectedChange
 
 ItemParentChange
 
 ItemChildAddedChange
 
 ItemChildRemovedChange
 
 ItemTransformChange
 
 ItemPositionHasChanged
 
 ItemTransformHasChanged
 
 ItemSceneChange
 
 ItemVisibleHasChanged
 
 ItemEnabledHasChanged
 
 ItemSelectedHasChanged
 
 ItemParentHasChanged
 
 ItemSceneHasChanged
 
 ItemCursorChange
 
 ItemCursorHasChanged
 
 ItemToolTipChange
 
 ItemToolTipHasChanged
 
 ItemFlagsChange
 
 ItemFlagsHaveChanged
 
 ItemZValueChange
 
 ItemZValueHasChanged
 
 ItemOpacityChange
 
 ItemOpacityHasChanged
 
 ItemScenePositionHasChanged
 
 ItemRotationChange
 
 ItemRotationHasChanged
 
 ItemScaleChange
 
 ItemScaleHasChanged
 
 ItemTransformOriginPointChange
 
 ItemTransformOriginPointHasChanged
 
 NoCache
 
 ItemCoordinateCache
 
 DeviceCoordinateCache
 
 NonModal
 
 PanelModal
 
 SceneModal
 
 Type
 
 UserType
 

Detailed Description

Superclass for all graphic items used ins the GraphicsScene. It contains information about the underlying objects that are represented, i.e. the type and the id.

Definition at line 43 of file graphics_item.h.

Constructor & Destructor Documentation

◆ GraphicsItem()

hal::GraphicsItem::GraphicsItem ( const ItemType  type,
const u32  id 
)

Constructor.

Parameters
type- The ItemType of the GraphicsItem (i.e. Module/Gate/Net)
id- The id of the underlying object (e.g. the module id if ItemType::Module)

Definition at line 23 of file graphics_item.cpp.

References QGraphicsItem::ItemIsSelectable, and QGraphicsItem::setFlags().

Member Function Documentation

◆ groupingColor()

QColor hal::GraphicsItem::groupingColor ( ) const
protected

Gets a pen color based on the grouping the underlying object is in.
If the underlying object is in no grouping, an invalid color is returned.

Returns
the color of the grouping the underlying object is in

Definition at line 55 of file graphics_item.cpp.

References hal::GroupingTableModel::colorForItem(), hal::gContentManager, hal::ContentManager::getGroupingManagerWidget(), hal::GroupingManagerWidget::getModel(), mId, and mItemType.

Referenced by hal::StandardGraphicsGate::paint(), hal::StandardGraphicsModule::paint(), and penColor().

◆ id()

u32 hal::GraphicsItem::id ( ) const

Gets the id of the underlying object that is represented by this GraphicsItem.

Returns
the id of the underlying object in its netlist

Definition at line 37 of file graphics_item.cpp.

References mId.

Referenced by hal::GraphicsScene::addGraphItem(), hal::GraphGraphicsView::mouseDoubleClickEvent(), hal::GraphicsScene::removeGraphItem(), and hal::DragController::set().

◆ itemType()

◆ loadSettings()

void hal::GraphicsItem::loadSettings ( )
static

Loads some settings used by this GraphicsItem.

Definition at line 12 of file graphics_item.cpp.

References sHighlightColor, and sSelectionColor.

Referenced by hal::style::debugUpdate().

◆ penColor()

QColor hal::GraphicsItem::penColor ( QStyle::State  state,
const QColor colorHint = QColor() 
) const
protected

Returns the pen color that should be used based on the current state (i.e. State_Selected or not) and the grouping of the underlying object is in.
If the Item in not selected and not in a grouping, a colorHint can be passed to manually chose a pen color.

Parameters
state- The state of the widget.
colorHint- A color to be chosen if the widget is not selected and no grouping color was found
Returns
the penColor to use

Definition at line 61 of file graphics_item.cpp.

References groupingColor(), QColor::isValid(), mColor, selectionColor(), hal::state, and QStyle::State_Selected.

Referenced by hal::ArrowSeparatedNet::paint(), hal::CircleSeparatedNet::paint(), hal::LabeledSeparatedNet::paint(), hal::StandardGraphicsNet::paint(), hal::StandardGraphicsGate::paint(), and hal::StandardGraphicsModule::paint().

◆ selectionColor()

QColor hal::GraphicsItem::selectionColor ( ) const
protected

Gets the pen color for selected GraphicItems.

Returns
the color for selected GraphicItems

Definition at line 49 of file graphics_item.cpp.

References mHighlight, sHighlightColor, and sSelectionColor.

Referenced by hal::StandardGraphicsGate::paint(), hal::StandardGraphicsModule::paint(), and penColor().

◆ setHightlight()

void hal::GraphicsItem::setHightlight ( bool  hl)

Highlights or normalizes(removes highlight) this GraphicsItem.

Parameters
hl- true to highlight the GraphicsItem. false to normalize the GraphicsItem.

Definition at line 42 of file graphics_item.cpp.

References mHighlight, and QGraphicsItem::update().

Referenced by hal::StandardArrowNet::paint().

◆ setLod()

void hal::GraphicsItem::setLod ( const qreal  lod)
static

Set the level-of-detail this GraphicItem uses to be drawn. It should be set based on the zoom level of the view. If the level-of-detail falls below a certain threshold some details of the GraphicsItem (or the item as a whole) wont be drawn anymore. There thresholds are configured in the graph_widget_constants namespace.

Parameters
lod- The level of detail that should be applied.

Definition at line 18 of file graphics_item.cpp.

References sLod.

Referenced by hal::GraphGraphicsView::paintEvent(), and hal::GatelibraryGraphicsView::showGate().

Member Data Documentation

◆ mColor

◆ mHighlight

bool hal::GraphicsItem::mHighlight
protected

true if the GraphicsItem is highlighted.

Definition at line 139 of file graphics_item.h.

Referenced by hal::StandardArrowNet::paint(), selectionColor(), and setHightlight().

◆ mId

u32 hal::GraphicsItem::mId
protected

The id of the underlying object in its netlist

Definition at line 144 of file graphics_item.h.

Referenced by groupingColor(), id(), hal::StandardGraphicsGate::paint(), and hal::StandardGraphicsModule::paint().

◆ mItemType

ItemType hal::GraphicsItem::mItemType
protected

The ItemType of the GraphicsItem (i.e. Module/Gate/Net)

Definition at line 134 of file graphics_item.h.

Referenced by groupingColor(), and itemType().

◆ sHighlightColor

QColor hal::GraphicsItem::sHighlightColor
staticprotected

The pen color used for highlighted GraphItems

Definition at line 103 of file graphics_item.h.

Referenced by loadSettings(), hal::StandardGraphicsModule::loadSettings(), and selectionColor().

◆ sLod

◆ sSelectionColor

QColor hal::GraphicsItem::sSelectionColor
staticprotected

The pen color used for selected GraphItems

Definition at line 98 of file graphics_item.h.

Referenced by loadSettings(), hal::StandardGraphicsModule::loadSettings(), and selectionColor().


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