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