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