Refactor class VPlaceLabelItem.
Store more info about a placelabel. --HG-- branch : develop
This commit is contained in:
parent
7dc420ad47
commit
bd611bf333
|
@ -31,6 +31,9 @@
|
|||
|
||||
#include <QVector>
|
||||
#include <QPolygonF>
|
||||
#include <QTransform>
|
||||
|
||||
#include "../ifc/ifcdef.h"
|
||||
|
||||
enum class GOType : char
|
||||
{
|
||||
|
@ -74,6 +77,8 @@ struct VLayoutPlaceLabel
|
|||
QPointF center;
|
||||
PlaceLabelType type;
|
||||
PlaceLabelImg shape;
|
||||
QTransform rotationMatrix{};
|
||||
QRectF box{};
|
||||
};
|
||||
|
||||
#endif // VGEOMETRYDEF_H
|
||||
|
|
|
@ -197,6 +197,22 @@ void VPlaceLabelItem::SetLabelType(PlaceLabelType type)
|
|||
d->type = type;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QTransform VPlaceLabelItem::RotationMatrix() const
|
||||
{
|
||||
QTransform t;
|
||||
t.translate(x(), y());
|
||||
t.rotate(-d->aValue-d->correctionAngle);
|
||||
t.translate(-x(), -y());
|
||||
return t;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VPlaceLabelItem::Box() const
|
||||
{
|
||||
return QRectF(0, 0, d->wValue, d->hValue);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPlaceLabelItem &VPlaceLabelItem::operator=(const VPlaceLabelItem &item)
|
||||
{
|
||||
|
@ -212,10 +228,7 @@ VPlaceLabelItem &VPlaceLabelItem::operator=(const VPlaceLabelItem &item)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
PlaceLabelImg VPlaceLabelItem::LabelShape() const
|
||||
{
|
||||
QTransform t;
|
||||
t.translate(x(), y());
|
||||
t.rotate(-d->aValue-d->correctionAngle);
|
||||
t.translate(-x(), -y());
|
||||
QTransform t = RotationMatrix();
|
||||
|
||||
auto SegmentShape = [t, this]()
|
||||
{
|
||||
|
|
|
@ -83,6 +83,9 @@ public:
|
|||
PlaceLabelType GetLabelType() const;
|
||||
void SetLabelType(PlaceLabelType type);
|
||||
|
||||
QTransform RotationMatrix() const;
|
||||
QRectF Box() const;
|
||||
|
||||
PlaceLabelImg LabelShape() const;
|
||||
QPainterPath LabelShapePath() const;
|
||||
|
||||
|
|
|
@ -218,6 +218,8 @@ QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContai
|
|||
{
|
||||
VLayoutPlaceLabel layoutLabel;
|
||||
layoutLabel.shape = label->LabelShape();
|
||||
layoutLabel.rotationMatrix = label->RotationMatrix();
|
||||
layoutLabel.box = label->Box();
|
||||
layoutLabel.center = label->toQPointF();
|
||||
layoutLabel.type = label->GetLabelType();
|
||||
labels.append(layoutLabel);
|
||||
|
|
Loading…
Reference in New Issue
Block a user