diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index c7656f99f..07e91c519 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -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(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(list)); + m_visSpecialPoints->SetShowRect(showRect); + m_visSpecialPoints->SetRect(CurrentRect()); if (not qApp->getCurrentScene()->items().contains(m_visSpecialPoints)) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 2e8883f99..0303102b9 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -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; diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp index dfae65144..27e361dc8 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp @@ -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(supportColor2, this); + m_rectItem->SetWidth(widthHairLine); } //--------------------------------------------------------------------------------------------------------------------- @@ -51,13 +70,12 @@ void VisPieceSpecialPoints::RefreshGeometry() const QSharedPointer p = Visualization::data->GeometricObject(m_spoints.at(i)); point->RefreshPointGeometry(*p); point->setVisible(true); - } -} -//--------------------------------------------------------------------------------------------------------------------- -void VisPieceSpecialPoints::SetPoints(const QVector &pins) -{ - m_spoints = pins; + if (m_showRect) + { + DrawPath(m_rectItem, RectPath(m_placeLabelRect), supportColor2, Qt::SolidLine, Qt::RoundCap); + } + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.h b/src/libs/vtools/visualization/path/vispiecespecialpoints.h index de54da8c9..859757c66 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.h +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.h @@ -41,17 +41,43 @@ public: virtual ~VisPieceSpecialPoints() Q_DECL_EQ_DEFAULT; virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void SetPoints(const QVector &pins); + + void SetPoints(const QVector &pins); + void SetShowRect(bool show); + void SetRect(const QRectF &rect); + virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Vis::PieceSpecialPoints)}; private: Q_DISABLE_COPY(VisPieceSpecialPoints) QVector m_points; QVector 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 &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 diff --git a/src/libs/vwidgets/vcurvepathitem.cpp b/src/libs/vwidgets/vcurvepathitem.cpp index e87c2ef5e..b6568e31c 100644 --- a/src/libs/vwidgets/vcurvepathitem.cpp +++ b/src/libs/vwidgets/vcurvepathitem.cpp @@ -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 &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); diff --git a/src/libs/vwidgets/vcurvepathitem.h b/src/libs/vwidgets/vcurvepathitem.h index a0d3cd356..7d35ca3d7 100644 --- a/src/libs/vwidgets/vcurvepathitem.h +++ b/src/libs/vwidgets/vcurvepathitem.h @@ -50,6 +50,7 @@ public: void SetDirectionArrows(const QVector> &arrows); void SetPoints(const QVector &points); + void SetWidth(qreal width); protected: virtual void ScalePenWidth(); private: @@ -57,6 +58,7 @@ private: QVector> m_directionArrows; QVector m_points; + qreal m_defaultWidth; }; #endif // VCURVEPATHITEM_H