digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
Loading...
Searching...
No Matches
Digikam::DImgChildItem Class Reference
Inheritance diagram for Digikam::DImgChildItem:

Signals

void geometryChanged ()
void geometryOnImageChanged ()
void positionChanged ()
 These signals are emitted in any case when the geometry changed: Either after changing the geometry relative to the original image, or when the size of the parent GraphicsDImgItem changed (zooming).
void positionOnImageChanged ()
 These signals are emitted when the geometry, relative to the original image, of this item has changed.
void sizeChanged ()
void sizeOnImageChanged ()

Public Member Functions

 DImgChildItem (QGraphicsItem *const parent=nullptr)
 This is a base class for items that are positioned on top of a GraphicsDImgItem, positioned in relative coordinates, i.e.
QRectF boundingRect () const override
 Reimplemented.
void moveBy (qreal dx, qreal dy)
QPoint originalPos () const
QRect originalRect () const
QSize originalSize () const
GraphicsDImgItem * parentDImgItem () const
 If the parent item is a GraphicsDImgItem, return it, if the parent item is null or of a different class, returns nullptr.
QRectF rect () const
QPointF relativePos () const
QRectF relativeRect () const
QSizeF relativeSize () const
void setOriginalPos (const QPointF &posInOriginal)
 Sets the position and size of this item, in coordinates of the original image.
void setOriginalPos (qreal x, qreal y)
void setOriginalRect (const QRectF &rect)
void setOriginalRect (qreal x, qreal y, qreal width, qreal height)
void setOriginalSize (const QSizeF &sizeInOriginal)
void setOriginalSize (qreal width, qreal height)
void setPos (const QPointF &zoomedPos)
 Sets the position and size of this item, in coordinates of the parent DImg item.
void setPos (qreal x, qreal y)
void setRect (const QRectF &rect)
void setRect (qreal x, qreal y, qreal width, qreal height)
void setRectInSceneCoordinates (const QRectF &rect)
 Equivalent to mapping the scene coordinates to the parent item, and calling setRect().
void setRelativePos (const QPointF &relativePosition)
 Sets the position and size of this item, relative to the DImg displayed in the parent item.
void setRelativePos (qreal x, qreal y)
void setRelativeRect (const QRectF &rect)
void setRelativeRect (qreal x, qreal y, qreal width, qreal height)
void setRelativeSize (const QSizeF &relativeSize)
void setRelativeSize (qreal width, qreal height)
void setSize (const QSizeF &zoomedSize)
void setSize (qreal width, qreal height)
QSizeF size () const

Protected Slots

void imageSizeChanged (const QSizeF &)

Protected Member Functions

QVariant itemChange (GraphicsItemChange change, const QVariant &value) override

Constructor & Destructor Documentation

◆ DImgChildItem()

Digikam::DImgChildItem::DImgChildItem ( QGraphicsItem *const parent = nullptr)
explicit

[0;1], on the image. From the set relative size, the boundingRect() is calculated.

This is a simple example. Just create new SimpleRectChildItem(item); where item is a GrahpicsDImgItem, and at the center of the image, a rectangle of 1% the size of the image will be drawn.

class SimpleRectChildItem : public DImgChildItem { public:

SimpleRectChildItem(QGraphicsItem* const parent)
    : DImgChildItem(parent)
{
    setRelativePos(0.5, 0.5);
    setRelativeSize(0.01, 0.01);
}

void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
{
    painter->setPen(Qt::red);
    painter->drawRect(boundingRect());
}

};

Member Function Documentation

◆ boundingRect()

QRectF Digikam::DImgChildItem::boundingRect ( ) const
override
Returns
a rectangle starting at (0,0) (pos() in parent coordinates) and has a size determined by the relative size.

◆ originalRect()

QRect Digikam::DImgChildItem::originalRect ( ) const
Returns
the position and size in coordinates of the original image.
Note
the return value is integer based. At high zoom rates, different values of relativeRect() or zoomedRect() may result in the same originalRect(), when one pixel in the original is represented by more than one pixel on screen.

◆ positionChanged

void Digikam::DImgChildItem::positionChanged ( )
signal

positionChanged() is equivalent to listening to xChanged() and yChanged().

◆ positionOnImageChanged

void Digikam::DImgChildItem::positionOnImageChanged ( )
signal

This happens by calling any of the methods above.

◆ rect()

QRectF Digikam::DImgChildItem::rect ( ) const
Returns
position and size of this item, in coordinates of the parent DImg with the current zoom. This is the same result as QRectF(pos(), boundingRect()), boundingRect is virtual and may be overridden by base classes.

◆ relativeRect()

QRectF Digikam::DImgChildItem::relativeRect ( ) const
Returns
the position and size relative to the DImg displayed in the parent item. All four values are in the interval [0-1].

◆ setOriginalPos()

void Digikam::DImgChildItem::setOriginalPos ( const QPointF & posInOriginal)

Requires a valid parent item.

◆ setPos()

void Digikam::DImgChildItem::setPos ( const QPointF & zoomedPos)

This is accepting unscaled parent coordinates, just like the "normal" setPos() does. Requires a valid parent item.

◆ setRelativePos()

void Digikam::DImgChildItem::setRelativePos ( const QPointF & relativePosition)

The values of

Parameters
relativePositionmust be in the interval [0-1].