Show place label rect.
--HG-- branch : feature
This commit is contained in:
parent
7a2297ed6b
commit
f78c122cb0
|
@ -281,6 +281,11 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
|||
NewSpecialPoint(uiTabPlaceLabels->listWidgetPlaceLabels, piece.GetPlaceLabels().at(i));
|
||||
}
|
||||
|
||||
if (piece.GetPlaceLabels().size() > 0)
|
||||
{
|
||||
uiTabPlaceLabels->listWidgetPlaceLabels->setCurrentRow(0);
|
||||
}
|
||||
|
||||
uiTabPaths->comboBoxStartPoint->blockSignals(true);
|
||||
uiTabPaths->comboBoxStartPoint->clear();
|
||||
uiTabPaths->comboBoxStartPoint->blockSignals(false);
|
||||
|
@ -1297,11 +1302,11 @@ QT_WARNING_POP
|
|||
|| (index == TabOrder::Labels &&
|
||||
uiTabLabels->tabWidget->currentIndex() == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels)))
|
||||
{
|
||||
ShowPieceSpecialPoints(uiTabPins->listWidgetPins);
|
||||
ShowPieceSpecialPointsWithRect(uiTabPins->listWidgetPins, false);
|
||||
}
|
||||
else if (index == TabOrder::PlaceLabels)
|
||||
{
|
||||
ShowPieceSpecialPoints(uiTabPlaceLabels->listWidgetPlaceLabels);
|
||||
ShowPieceSpecialPointsWithRect(uiTabPlaceLabels->listWidgetPlaceLabels, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1317,7 +1322,7 @@ void DialogSeamAllowance::TabChanged(int index)
|
|||
{
|
||||
if (index == uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels))
|
||||
{
|
||||
ShowPieceSpecialPoints(uiTabPins->listWidgetPins);
|
||||
ShowPieceSpecialPointsWithRect(uiTabPins->listWidgetPins, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2868,6 +2873,15 @@ void DialogSeamAllowance::InitPassmarksTab()
|
|||
void DialogSeamAllowance::InitPlaceLabelsTab()
|
||||
{
|
||||
uiTabPlaceLabels->listWidgetPlaceLabels->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(uiTabPlaceLabels->listWidgetPlaceLabels, &QListWidget::currentRowChanged, this, [this]()
|
||||
{
|
||||
if (not m_visSpecialPoints.isNull())
|
||||
{
|
||||
m_visSpecialPoints->SetShowRect(true);
|
||||
m_visSpecialPoints->SetRect(CurrentRect());
|
||||
m_visSpecialPoints->RefreshGeometry();
|
||||
}
|
||||
});
|
||||
connect(uiTabPlaceLabels->listWidgetPlaceLabels, &QListWidget::customContextMenuRequested, this,
|
||||
&DialogSeamAllowance::ShowPlaceLabelsContextMenu);
|
||||
}
|
||||
|
@ -3126,7 +3140,20 @@ void DialogSeamAllowance::SetPLAngle(QString angleFormula)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list)
|
||||
QRectF DialogSeamAllowance::CurrentRect() const
|
||||
{
|
||||
QRectF rect;
|
||||
if (QListWidgetItem *item = uiTabPlaceLabels->listWidgetPlaceLabels->currentItem())
|
||||
{
|
||||
VPlaceLabelItem label = CurrentPlaceLabel(qvariant_cast<quint32>(item->data(Qt::UserRole)));
|
||||
rect = QRectF(QPointF(label.x() - label.GetWidth()/2.0, label.y() - label.GetHeight()/2.0),
|
||||
QPointF(label.x() + label.GetWidth()/2.0, label.y() + label.GetHeight()/2.0));
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::ShowPieceSpecialPointsWithRect(const QListWidget *list, bool showRect)
|
||||
{
|
||||
SCASSERT(list != nullptr)
|
||||
if (m_visSpecialPoints.isNull())
|
||||
|
@ -3135,6 +3162,8 @@ void DialogSeamAllowance::ShowPieceSpecialPoints(const QListWidget *list)
|
|||
}
|
||||
|
||||
m_visSpecialPoints->SetPoints(GetListInternals<quint32>(list));
|
||||
m_visSpecialPoints->SetShowRect(showRect);
|
||||
m_visSpecialPoints->SetRect(CurrentRect());
|
||||
|
||||
if (not qApp->getCurrentScene()->items().contains(m_visSpecialPoints))
|
||||
{
|
||||
|
|
|
@ -268,7 +268,8 @@ private:
|
|||
void SetPLHeight(QString heightFormula);
|
||||
void SetPLAngle(QString angleFormula);
|
||||
|
||||
void ShowPieceSpecialPoints(const QListWidget *list);
|
||||
QRectF CurrentRect() const;
|
||||
void ShowPieceSpecialPointsWithRect(const QListWidget *list, bool showRect);
|
||||
|
||||
VPiecePath CurrentPath(quint32 id) const;
|
||||
VPlaceLabelItem CurrentPlaceLabel(quint32 id) const;
|
||||
|
|
|
@ -31,12 +31,31 @@
|
|||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
QPainterPath RectPath(const QRectF &rect)
|
||||
{
|
||||
QPainterPath path;
|
||||
if (not rect.isNull())
|
||||
{
|
||||
path.addRect(rect);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisPieceSpecialPoints::VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent)
|
||||
: VisPath(data, parent),
|
||||
m_points(),
|
||||
m_spoints()
|
||||
m_spoints(),
|
||||
m_showRect(false),
|
||||
m_placeLabelRect(),
|
||||
m_rectItem(nullptr),
|
||||
supportColor2(Qt::darkGreen)
|
||||
{
|
||||
m_rectItem = InitItem<VCurvePathItem>(supportColor2, this);
|
||||
m_rectItem->SetWidth(widthHairLine);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -51,13 +70,12 @@ void VisPieceSpecialPoints::RefreshGeometry()
|
|||
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(m_spoints.at(i));
|
||||
point->RefreshPointGeometry(*p);
|
||||
point->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisPieceSpecialPoints::SetPoints(const QVector<quint32> &pins)
|
||||
{
|
||||
m_spoints = pins;
|
||||
if (m_showRect)
|
||||
{
|
||||
DrawPath(m_rectItem, RectPath(m_placeLabelRect), supportColor2, Qt::SolidLine, Qt::RoundCap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -41,17 +41,43 @@ public:
|
|||
virtual ~VisPieceSpecialPoints() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||
|
||||
void SetPoints(const QVector<quint32> &pins);
|
||||
void SetShowRect(bool show);
|
||||
void SetRect(const QRectF &rect);
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::PieceSpecialPoints)};
|
||||
private:
|
||||
Q_DISABLE_COPY(VisPieceSpecialPoints)
|
||||
QVector<VSimplePoint *> m_points;
|
||||
QVector<quint32> m_spoints;
|
||||
bool m_showRect;
|
||||
QRectF m_placeLabelRect;
|
||||
VCurvePathItem *m_rectItem;
|
||||
QColor supportColor2;
|
||||
|
||||
VSimplePoint *GetPoint(quint32 i, const QColor &color);
|
||||
|
||||
void HideAllItems();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VisPieceSpecialPoints::SetPoints(const QVector<quint32> &pins)
|
||||
{
|
||||
m_spoints = pins;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VisPieceSpecialPoints::SetShowRect(bool show)
|
||||
{
|
||||
m_showRect = show;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VisPieceSpecialPoints::SetRect(const QRectF &rect)
|
||||
{
|
||||
m_placeLabelRect = rect;
|
||||
}
|
||||
|
||||
#endif // VISPIECESPECIALPOINTS_H
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
VCurvePathItem::VCurvePathItem(QGraphicsItem *parent)
|
||||
: QGraphicsPathItem(parent),
|
||||
m_directionArrows(),
|
||||
m_points()
|
||||
m_points(),
|
||||
m_defaultWidth(widthMainLine)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -107,10 +108,16 @@ void VCurvePathItem::SetPoints(const QVector<QPointF> &points)
|
|||
m_points = points;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCurvePathItem::SetWidth(qreal width)
|
||||
{
|
||||
m_defaultWidth = width;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCurvePathItem::ScalePenWidth()
|
||||
{
|
||||
const qreal width = ScaleWidth(widthMainLine, SceneScale(scene()));
|
||||
const qreal width = ScaleWidth(m_defaultWidth, SceneScale(scene()));
|
||||
|
||||
QPen toolPen = pen();
|
||||
toolPen.setWidthF(width);
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
|
||||
void SetDirectionArrows(const QVector<QPair<QLineF, QLineF>> &arrows);
|
||||
void SetPoints(const QVector<QPointF> &points);
|
||||
void SetWidth(qreal width);
|
||||
protected:
|
||||
virtual void ScalePenWidth();
|
||||
private:
|
||||
|
@ -57,6 +58,7 @@ private:
|
|||
|
||||
QVector<QPair<QLineF, QLineF>> m_directionArrows;
|
||||
QVector<QPointF> m_points;
|
||||
qreal m_defaultWidth;
|
||||
};
|
||||
|
||||
#endif // VCURVEPATHITEM_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user