LibrePCB Developers Documentation
PolygonGraphicsItem Class Referencefinal

The PolygonGraphicsItem class. More...

#include <polygongraphicsitem.h>

+ Inheritance diagram for PolygonGraphicsItem:
+ Collaboration diagram for PolygonGraphicsItem:

Classes

struct  VertexHandle
 

Public Member Functions

 PolygonGraphicsItem ()=delete
 
 PolygonGraphicsItem (const PolygonGraphicsItem &other)=delete
 
 PolygonGraphicsItem (Polygon &polygon, const IF_GraphicsLayerProvider &lp, QGraphicsItem *parent=nullptr) noexcept
 
virtual ~PolygonGraphicsItem () noexcept
 
PolygongetObj () noexcept
 
int getLineIndexAtPosition (const Point &pos) const noexcept
 
QVector< int > getVertexIndicesAtPosition (const Point &pos) const noexcept
 
void setEditable (bool editable) noexcept
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value) noexcept override
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
 
PolygonGraphicsItemoperator= (const PolygonGraphicsItem &rhs)=delete
 
- Public Member Functions inherited from PrimitivePathGraphicsItem
 PrimitivePathGraphicsItem (const PrimitivePathGraphicsItem &other)=delete
 
 PrimitivePathGraphicsItem (QGraphicsItem *parent=nullptr) noexcept
 
virtual ~PrimitivePathGraphicsItem () noexcept
 
void setPosition (const Point &pos) noexcept
 
void setRotation (const Angle &rot) noexcept
 
void setMirrored (bool mirrored) noexcept
 
void setPath (const QPainterPath &path) noexcept
 
void setLineWidth (const UnsignedLength &width) noexcept
 
void setLineLayer (const std::shared_ptr< GraphicsLayer > &layer) noexcept
 
void setFillLayer (const std::shared_ptr< GraphicsLayer > &layer) noexcept
 
void setLighterColors (bool lighter) noexcept
 
void setShapeMode (ShapeMode mode) noexcept
 
QRectF boundingRect () const noexcept override
 
QPainterPath shape () const noexcept override
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0) noexcept override
 
PrimitivePathGraphicsItemoperator= (const PrimitivePathGraphicsItem &rhs)=delete
 

Private Member Functions

void polygonEdited (const Polygon &polygon, Polygon::Event event) noexcept
 
void updateFillLayer () noexcept
 
void updatePath () noexcept
 
void updateZValue () noexcept
 
void updateBoundingRectMargin () noexcept
 

Private Attributes

PolygonmPolygon
 
const IF_GraphicsLayerProvidermLayerProvider
 
bool mEditable
 
qreal mVertexHandleRadiusPx
 
QVector< VertexHandlemVertexHandles
 
Polygon::OnEditedSlot mOnEditedSlot
 

Additional Inherited Members

- Public Types inherited from PrimitivePathGraphicsItem
enum class  ShapeMode
 
- Protected Attributes inherited from PrimitivePathGraphicsItem
bool mMirror
 
std::shared_ptr< GraphicsLayermLineLayer
 
std::shared_ptr< GraphicsLayermFillLayer
 
bool mLighterColors
 
ShapeMode mShapeMode
 
QPen mPen
 
QPen mPenHighlighted
 
QBrush mBrush
 
QBrush mBrushHighlighted
 
QPainterPath mPainterPath
 
QRectF mBoundingRect
 
qreal mBoundingRectMarginPx
 
QPainterPath mShape
 
GraphicsLayer::OnEditedSlot mOnLayerEditedSlot
 

Detailed Description

Constructor & Destructor Documentation

◆ PolygonGraphicsItem() [1/3]

PolygonGraphicsItem ( )
delete

◆ PolygonGraphicsItem() [2/3]

PolygonGraphicsItem ( const PolygonGraphicsItem other)
delete

◆ PolygonGraphicsItem() [3/3]

PolygonGraphicsItem ( Polygon polygon,
const IF_GraphicsLayerProvider lp,
QGraphicsItem *  parent = nullptr 
)
noexcept

◆ ~PolygonGraphicsItem()

~PolygonGraphicsItem ( )
virtualnoexcept

Member Function Documentation

◆ getObj()

Polygon & getObj ( )
inlinenoexcept

◆ getLineIndexAtPosition()

int getLineIndexAtPosition ( const Point pos) const
noexcept

Get the line segment at a specific position

Parameters
posThe position to check for lines.
Returns
The index of the vertex after the line under the cursor. So for the first line segment, index 1 is returned. If no line is located under the specified position, -1 is returned.
+ Here is the call graph for this function:

◆ getVertexIndicesAtPosition()

QVector< int > getVertexIndicesAtPosition ( const Point pos) const
noexcept

Get the vertices at a specific position

Parameters
posThe position to check for vertices.
Returns
All indices of the vertices at the specified position.
+ Here is the call graph for this function:

◆ setEditable()

void setEditable ( bool  editable)
noexcept

Enable/disable editing mode when selected

If the item is editable and selected, vertex handles will be shown to indicate that they can be moved. If not editable, handles will not be shown.

Parameters
editableWhether the polygon is (visually) editable or not.

◆ itemChange()

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

◆ paint()

void paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = 0 
)
overridenoexcept
+ Here is the call graph for this function:

◆ operator=()

PolygonGraphicsItem & operator= ( const PolygonGraphicsItem rhs)
delete

◆ polygonEdited()

void polygonEdited ( const Polygon polygon,
Polygon::Event  event 
)
privatenoexcept

◆ updateFillLayer()

void updateFillLayer ( )
privatenoexcept
+ Here is the call graph for this function:

◆ updatePath()

void updatePath ( )
privatenoexcept
+ Here is the call graph for this function:

◆ updateZValue()

void updateZValue ( )
privatenoexcept
+ Here is the call graph for this function:

◆ updateBoundingRectMargin()

void updateBoundingRectMargin ( )
privatenoexcept
+ Here is the caller graph for this function:

Member Data Documentation

◆ mPolygon

Polygon& mPolygon
private

◆ mLayerProvider

const IF_GraphicsLayerProvider& mLayerProvider
private

◆ mEditable

bool mEditable
private

◆ mVertexHandleRadiusPx

qreal mVertexHandleRadiusPx
private

◆ mVertexHandles

QVector<VertexHandle> mVertexHandles
private

◆ mOnEditedSlot

Polygon::OnEditedSlot mOnEditedSlot
private

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