Refactor class VPlaceLabelItem.

Store more info about a placelabel.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-05-27 14:54:44 +03:00
parent 7dc420ad47
commit bd611bf333
4 changed files with 27 additions and 4 deletions

View File

@ -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

View File

@ -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]()
{

View File

@ -83,6 +83,9 @@ public:
PlaceLabelType GetLabelType() const;
void SetLabelType(PlaceLabelType type);
QTransform RotationMatrix() const;
QRectF Box() const;
PlaceLabelImg LabelShape() const;
QPainterPath LabelShapePath() const;

View File

@ -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);