From e540c6292c257f7f0824007428af75fc698d5be1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 22 May 2023 17:27:15 +0300 Subject: [PATCH] Refactoring. Fix code style. --- src/app/puzzle/scene/vpgraphicspiece.cpp | 84 +- src/app/puzzle/xml/vplayoutfilereader.cpp | 67 +- .../configpages/preferencespatternpage.cpp | 45 +- .../configpages/preferencespatternpage.h | 6 +- src/app/valentina/xml/vpattern.cpp | 727 +++++++++--------- src/libs/vlayout/vlayoutpiece.cpp | 295 ++++--- src/libs/vlayout/vtextmanager.cpp | 10 +- src/libs/vmisc/vcommonsettings.h | 6 +- .../floatItemData/vpatternlabeldata_p.h | 40 +- .../tools/piece/dialogseamallowance.cpp | 461 +++++------ .../dialogs/tools/piece/dialogseamallowance.h | 29 +- src/libs/vtools/tools/vtoolseamallowance.h | 97 +-- src/libs/vwidgets/vgraphicssimpletextitem.cpp | 2 +- src/libs/vwidgets/vtextgraphicsitem.cpp | 390 +++++----- src/libs/vwidgets/vtextgraphicsitem.h | 52 +- 15 files changed, 1132 insertions(+), 1179 deletions(-) diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index e57271997..088bbf0be 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -28,32 +28,32 @@ #include "vpgraphicspiece.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "../layout/vppiece.h" #include "../layout/vplayout.h" +#include "../layout/vppiece.h" #include "../layout/vpsheet.h" -#include "../vlayout/vtextmanager.h" #include "../vlayout/vgraphicsfillitem.h" +#include "../vlayout/vtextmanager.h" #include "../vpapplication.h" -#include "compatibility.h" #include "../vlayout/vlayoutpiecepath.h" +#include "compatibility.h" #include "../vgeometry/vlayoutplacelabel.h" -#include "undocommands/vpundopiecemove.h" #include "undocommands/vpundomovepieceonsheet.h" +#include "undocommands/vpundopiecemove.h" #include "vpiecegrainline.h" #include @@ -69,7 +69,7 @@ QT_WARNING_POP namespace { Q_GLOBAL_STATIC_WITH_ARGS(QColor, mainColor, (Qt::black)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(QColor, errorColor, (Qt::red)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(QColor, errorColor, (Qt::red)) // NOLINT //--------------------------------------------------------------------------------------------------------------------- inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal angle, const QPointF &linePos, @@ -101,7 +101,7 @@ inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal an } //--------------------------------------------------------------------------------------------------------------------- -inline auto LineFont(const TextLine& tl, const QFont &base) -> QFont +inline auto LineFont(const TextLine &tl, const QFont &base) -> QFont { QFont fnt = base; fnt.setPixelSize(base.pixelSize() + tl.m_iFontSize); @@ -110,9 +110,8 @@ inline auto LineFont(const TextLine& tl, const QFont &base) -> QFont return fnt; } - //--------------------------------------------------------------------------------------------------------------------- -inline auto LineText(const TextLine& tl, const QFontMetrics &fm, qreal width) -> QString +inline auto LineText(const TextLine &tl, const QFontMetrics &fm, qreal width) -> QString { QString qsText = tl.m_qsText; if (TextWidth(fm, qsText) > width) @@ -124,7 +123,7 @@ inline auto LineText(const TextLine& tl, const QFontMetrics &fm, qreal width) -> } //--------------------------------------------------------------------------------------------------------------------- -inline auto LineAlign(const TextLine& tl, const QString &text, const QFontMetrics &fm, qreal width) -> qreal +inline auto LineAlign(const TextLine &tl, const QString &text, const QFontMetrics &fm, qreal width) -> qreal { const int lineWidth = TextWidth(fm, text); @@ -135,7 +134,7 @@ inline auto LineAlign(const TextLine& tl, const QString &text, const QFontMetric } else if ((tl.m_eAlign & Qt::AlignHCenter) > 0) { - dX = (width - lineWidth)/2; + dX = (width - lineWidth) / 2; } else if ((tl.m_eAlign & Qt::AlignRight) > 0) { @@ -150,11 +149,11 @@ inline auto SelectionBrush() -> QBrush { return {QColor(255, 160, 160, 60)}; } -} // namespace +} // namespace //--------------------------------------------------------------------------------------------------------------------- -VPGraphicsPiece::VPGraphicsPiece(const VPPiecePtr &piece, QGraphicsItem *parent) : - QGraphicsObject(parent), +VPGraphicsPiece::VPGraphicsPiece(const VPPiecePtr &piece, QGraphicsItem *parent) + : QGraphicsObject(parent), m_piece(piece) { // set some infos @@ -190,7 +189,7 @@ auto VPGraphicsPiece::boundingRect() const -> QRectF shape.addPath(m_stickyPath); VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); - const qreal halfPenWidth = settings->GetLayoutLineWidth()/2.; + const qreal halfPenWidth = settings->GetLayoutLineWidth() / 2.; return shape.boundingRect().adjusted(-halfPenWidth, -halfPenWidth, halfPenWidth, halfPenWidth); } @@ -198,7 +197,7 @@ auto VPGraphicsPiece::boundingRect() const -> QRectF //--------------------------------------------------------------------------------------------------------------------- auto VPGraphicsPiece::shape() const -> QPainterPath { - if(!m_cuttingLine.isEmpty()) + if (!m_cuttingLine.isEmpty()) { return m_cuttingLine; } @@ -222,11 +221,11 @@ void VPGraphicsPiece::paint(QPainter *painter, const QStyleOptionGraphicsItem *o //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsPiece::mousePressEvent(QGraphicsSceneMouseEvent *event) { - //perform the default behaviour + // perform the default behaviour QGraphicsObject::mousePressEvent(event); // change the cursor when clicking the left button - if(event->button() == Qt::LeftButton) + if (event->button() == Qt::LeftButton) { setCursor(Qt::ClosedHandCursor); @@ -250,7 +249,7 @@ void VPGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - //perform the default behaviour + // perform the default behaviour QGraphicsItem::mouseReleaseEvent(event); // change the cursor when clicking left button @@ -267,8 +266,8 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (layout->LayoutSettings().GetStickyEdges() && m_hasStickyPosition) { - auto *command = new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, - m_allowChangeMerge); + auto *command = + new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge); layout->UndoStack()->push(command); SetStickyPoints(QVector()); @@ -314,7 +313,7 @@ void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QList sheets = layout->GetSheets(); sheets.removeAll(piece->Sheet()); - QVector moveToActions; + QVector moveToActions; if (not sheets.isEmpty()) { @@ -324,7 +323,7 @@ void VPGraphicsPiece::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { if (not sheet.isNull()) { - QAction* moveToSheet = moveMenu->addAction(sheet->GetName()); + QAction *moveToSheet = moveMenu->addAction(sheet->GetName()); moveToSheet->setData(QVariant::fromValue(sheet)); moveToActions.append(moveToSheet); } @@ -399,7 +398,7 @@ void VPGraphicsPiece::InitPieceLabel(const QVector &labelShape, const V const qreal dW = QLineF(labelShape.at(0), labelShape.at(1)).length(); const qreal dH = QLineF(labelShape.at(1), labelShape.at(2)).length(); - const qreal angle = - QLineF(labelShape.at(0), labelShape.at(1)).angle(); + const qreal angle = -QLineF(labelShape.at(0), labelShape.at(1)).angle(); const QColor color = PieceColor(); const int maxLineWidth = tm.MaxLineWidth(static_cast(dW)); @@ -429,9 +428,9 @@ void VPGraphicsPiece::InitPieceLabel(const QVector &labelShape, const V if (m_textAsPaths) { QPainterPath path; - path.addText(0, - static_cast(fm.ascent())/6., fnt, qsText); + path.addText(0, -static_cast(fm.ascent()) / 6., fnt, qsText); - auto* item = new QGraphicsPathItem(this); + auto *item = new QGraphicsPathItem(this); item->setPath(path); item->setBrush(QBrush(color)); item->setTransform(lineMatrix); @@ -441,7 +440,7 @@ void VPGraphicsPiece::InitPieceLabel(const QVector &labelShape, const V } else { - auto* item = new QGraphicsSimpleTextItem(this); + auto *item = new QGraphicsSimpleTextItem(this); item->setFont(fnt); item->setText(qsText); item->setBrush(QBrush(color)); @@ -464,7 +463,7 @@ void VPGraphicsPiece::InitGrainlineItem() return; } - if(piece->IsGrainlineEnabled()) + if (piece->IsGrainlineEnabled()) { m_grainlineItem = new VGraphicsFillItem(this); m_grainlineItem->setPath(VLayoutPiece::GrainlinePath(piece->GetMappedGrainlineShape())); @@ -516,7 +515,7 @@ void VPGraphicsPiece::PaintSeamLine(QPainter *painter, const VPPiecePtr &piece) if (not piece->IsHideMainPath() || not piece->IsSeamAllowance()) { QVector seamLinePoints = piece->GetMappedContourPoints(); - if(!seamLinePoints.isEmpty()) + if (!seamLinePoints.isEmpty()) { m_seamLine.moveTo(ConstFirst(seamLinePoints)); for (int i = 1; i < seamLinePoints.size(); i++) @@ -541,7 +540,7 @@ void VPGraphicsPiece::PaintCuttingLine(QPainter *painter, const VPPiecePtr &piec if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn()) { QVector cuttingLinepoints = piece->GetMappedSeamAllowancePoints(); - if(!cuttingLinepoints.isEmpty()) + if (!cuttingLinepoints.isEmpty()) { m_cuttingLine.moveTo(ConstFirst(cuttingLinepoints)); for (int i = 1; i < cuttingLinepoints.size(); i++) @@ -564,7 +563,7 @@ void VPGraphicsPiece::PaintCuttingLine(QPainter *painter, const VPPiecePtr &piec void VPGraphicsPiece::PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece) { QVector internalPaths = piece->GetInternalPaths(); - for (const auto& piecePath : internalPaths) + for (const auto &piecePath : internalPaths) { QPainterPath path = piece->GetMatrix().map(piecePath.GetPainterPath()); @@ -585,7 +584,7 @@ void VPGraphicsPiece::PaintInternalPaths(QPainter *painter, const VPPiecePtr &pi void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece) { QVector passmarks = piece->GetMappedPassmarks(); - for(auto &passmark : passmarks) + for (auto &passmark : passmarks) { QPainterPath passmarkPath; for (auto &line : passmark.lines) @@ -610,7 +609,7 @@ void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece) void VPGraphicsPiece::PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece) { QVector placeLabels = piece->GetPlaceLabels(); - for(auto &placeLabel : placeLabels) + for (auto &placeLabel : placeLabels) { QPainterPath path = VAbstractPiece::LabelShapePath(piece->MapPlaceLabelShape(VAbstractPiece::PlaceLabelShape(placeLabel))); @@ -807,7 +806,7 @@ auto VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &valu { if (scene() != nullptr) { - if(change == ItemSelectedHasChanged) + if (change == ItemSelectedHasChanged) { VPPiecePtr piece = m_piece.toStrongRef(); if (not piece.isNull()) @@ -825,4 +824,3 @@ auto VPGraphicsPiece::itemChange(GraphicsItemChange change, const QVariant &valu return QGraphicsObject::itemChange(change, value); } - diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index e84776665..58f96fa90 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -26,23 +26,24 @@ ** ** *************************************************************************/ -#include -#include -#include -#include -#include "vpiecegrainline.h" #include "vplayoutfilereader.h" -#include "vplayoutliterals.h" -#include "../layout/vpsheet.h" -#include "../vlayout/vlayoutpiecepath.h" -#include "../vlayout/vtextmanager.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionconversionerror.h" -#include "../vpatterndb/floatItemData/floatitemdef.h" -#include "../vgeometry/vgeometrydef.h" -#include "../vgeometry/vlayoutplacelabel.h" #include "../layout/vplayout.h" #include "../layout/vppiece.h" +#include "../layout/vpsheet.h" +#include "../vgeometry/vgeometrydef.h" +#include "../vgeometry/vlayoutplacelabel.h" +#include "../vlayout/vlayoutpiecepath.h" +#include "../vlayout/vtextmanager.h" +#include "../vmisc/vcommonsettings.h" +#include "../vpatterndb/floatItemData/floatitemdef.h" +#include "vpiecegrainline.h" +#include "vplayoutliterals.h" +#include +#include +#include +#include QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") @@ -99,7 +100,7 @@ auto StringToPath(const QString &path) -> QVector QStringList points = path.split(ML::pointsSep); p.reserve(points.size()); - for (const auto& point : points) + for (const auto &point : points) { p.append(StringToPoint(point)); } @@ -188,7 +189,7 @@ auto StringToLines(const QString &string) -> QVector QVector path; path.reserve(lines.size()); - for (const auto& line : lines) + for (const auto &line : lines) { QLineF l = StringToLine(line); if (not l.isNull()) @@ -211,7 +212,7 @@ auto StringToRect(const QString &string) -> QRectF return {}; } -} // namespace +} // namespace //--------------------------------------------------------------------------------------------------------------------- auto VPLayoutFileReader::ReadFile(const VPLayoutPtr &layout, QFile *file) -> bool @@ -225,7 +226,7 @@ auto VPLayoutFileReader::ReadFile(const VPLayoutPtr &layout, QFile *file) -> boo ReadLayout(layout); } } - catch(const VException &e) + catch (const VException &e) { raiseError(e.ErrorMessage()); } @@ -238,8 +239,7 @@ void VPLayoutFileReader::ReadLayout(const VPLayoutPtr &layout) { AssertRootTag(ML::TagLayout); - const QStringList tags - { + const QStringList tags{ ML::TagProperties, // 0 ML::TagUnplacedPieces, // 1 ML::TagSheets // 2 @@ -271,8 +271,7 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout) { AssertRootTag(ML::TagProperties); - const QStringList tags - { + const QStringList tags{ ML::TagUnit, // 0 ML::TagTitle, // 1 ML::TagDescription, // 2 @@ -288,15 +287,15 @@ void VPLayoutFileReader::ReadProperties(const VPLayoutPtr &layout) switch (tags.indexOf(name().toString())) { - case 0:// unit + case 0: // unit qDebug("read unit"); layout->LayoutSettings().SetUnit(StrToUnits(readElementText())); break; - case 1:// title + case 1: // title qDebug("read title"); layout->LayoutSettings().SetTitle(readElementText()); break; - case 2:// description + case 2: // description qDebug("read description"); layout->LayoutSettings().SetDescription(readElementText()); break; @@ -331,7 +330,7 @@ void VPLayoutFileReader::ReadControl(const VPLayoutPtr &layout) QXmlStreamAttributes attribs = attributes(); layout->LayoutSettings().SetWarningSuperpositionOfPieces( - ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr)); + ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr)); layout->LayoutSettings().SetWarningPiecesOutOfBound(ReadAttributeBool(attribs, ML::AttrWarningOutOfBound, trueStr)); layout->LayoutSettings().SetStickyEdges(ReadAttributeBool(attribs, ML::AttrStickyEdges, trueStr)); layout->LayoutSettings().SetPiecesGap(qMax(ReadAttributeDouble(attribs, ML::AttrPiecesGap, QChar('0')), 0.0)); @@ -357,10 +356,9 @@ void VPLayoutFileReader::ReadTiles(const VPLayoutPtr &layout) layout->LayoutSettings().SetShowTiles(ReadAttributeBool(attribs, ML::AttrVisible, falseStr)); layout->LayoutSettings().SetPrintTilesScheme(ReadAttributeBool(attribs, ML::AttrPrintScheme, falseStr)); layout->LayoutSettings().SetShowTileNumber(ReadAttributeBool(attribs, ML::AttrTileNumber, falseStr)); -// attribs.value(ML::AttrMatchingMarks); // TODO + // attribs.value(ML::AttrMatchingMarks); // TODO - const QStringList tags - { + const QStringList tags{ ML::TagSize, // 0 ML::TagMargin // 1 }; @@ -426,8 +424,7 @@ void VPLayoutFileReader::ReadSheet(const VPLayoutPtr &layout) QXmlStreamAttributes attribs = attributes(); sheet->SetGrainlineType(StrToGrainlineType(ReadAttributeEmptyString(attribs, ML::AttrGrainlineType))); - const QStringList tags - { + const QStringList tags{ ML::TagName, // 0 ML::TagSize, // 1 ML::TagMargin, // 2 @@ -462,7 +459,6 @@ void VPLayoutFileReader::ReadSheet(const VPLayoutPtr &layout) layout->AddSheet(sheet); } - //--------------------------------------------------------------------------------------------------------------------- void VPLayoutFileReader::ReadPieces(const VPLayoutPtr &layout, const VPSheetPtr &sheet) { @@ -513,8 +509,7 @@ void VPLayoutFileReader::ReadPiece(const VPPiecePtr &piece) piece->SetSewLineOnDrawing(ReadAttributeBool(attribs, ML::AttrSewLineOnDrawing, falseStr)); piece->SetMatrix(StringToTransfrom(ReadAttributeEmptyString(attribs, ML::AttrTransform))); - const QStringList tags - { + const QStringList tags{ ML::TagSeamLine, // 0 ML::TagSeamAllowance, // 1 ML::TagGrainline, // 2 @@ -976,7 +971,7 @@ auto VPLayoutFileReader::ReadSize() -> QSizeF //--------------------------------------------------------------------------------------------------------------------- void VPLayoutFileReader::AssertRootTag(const QString &tag) const { - if (not (isStartElement() && name() == tag)) + if (not(isStartElement() && name() == tag)) { throw VException(tr("Unexpected tag %1 in line %2").arg(name().toString()).arg(lineNumber())); } @@ -984,7 +979,7 @@ void VPLayoutFileReader::AssertRootTag(const QString &tag) const //--------------------------------------------------------------------------------------------------------------------- auto VPLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name, - const QString &defValue) -> QString + const QString &defValue) -> QString { const QString parameter = attribs.value(name).toString(); if (parameter.isEmpty()) @@ -1016,7 +1011,7 @@ auto VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, { parametr = ReadAttributeString(attribs, name, defValue); - const QStringList bools {trueStr, falseStr, QChar('1'), QChar('0')}; + const QStringList bools{trueStr, falseStr, QChar('1'), QChar('0')}; switch (bools.indexOf(parametr)) { case 0: // true @@ -1027,7 +1022,7 @@ auto VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, case 3: // 0 val = false; break; - default:// others + default: // others throw VExceptionConversionError(message, name); } } diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 2c4e0768e..a0d1ef5c0 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -27,19 +27,19 @@ *************************************************************************/ #include "preferencespatternpage.h" -#include "ui_preferencespatternpage.h" #include "../dialogdatetimeformats.h" #include "../dialogknownmaterials.h" -#include "../vmisc/vvalentinasettings.h" #include "../vmisc/vabstractvalapplication.h" +#include "../vmisc/vvalentinasettings.h" +#include "ui_preferencespatternpage.h" #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vwidgets/vmaingraphicsview.h" #include "../ifc/xml/vabstractpattern.h" +#include "../vwidgets/vmaingraphicsview.h" -#include #include +#include #include namespace @@ -57,12 +57,12 @@ auto ComboBoxAllStrings(QComboBox *combo) -> QStringList return itemsInComboBox; } -} // namespace +} // namespace //--------------------------------------------------------------------------------------------------------------------- PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) - : QWidget(parent), - ui(new Ui::PreferencesPatternPage) + : QWidget(parent), + ui(new Ui::PreferencesPatternPage) { ui->setupUi(this); RetranslateUi(); @@ -85,18 +85,19 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) ui->comboBoxLineWidthUnit->setCurrentIndex(indexUnit); } - connect(ui->comboBoxLineWidthUnit, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() - { - const Unit lineUnit = static_cast(ui->comboBoxLineWidthUnit->currentData().toInt()); - const qreal value = UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, lineUnit); - ui->doubleSpinBoxLineWidth->setDecimals(lineUnit == Unit::Mm ? 1 : 6); - ui->doubleSpinBoxLineWidth->setMinimum(UnitConvertor(ui->doubleSpinBoxLineWidth->minimum(), m_oldLineUnit, - lineUnit)); - ui->doubleSpinBoxLineWidth->setMaximum(UnitConvertor(ui->doubleSpinBoxLineWidth->maximum(), m_oldLineUnit, - lineUnit)); - ui->doubleSpinBoxLineWidth->setValue(value); - m_oldLineUnit = lineUnit; - }); + connect(ui->comboBoxLineWidthUnit, QOverload::of(&QComboBox::currentIndexChanged), this, + [this]() + { + const Unit lineUnit = static_cast(ui->comboBoxLineWidthUnit->currentData().toInt()); + const qreal value = UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, lineUnit); + ui->doubleSpinBoxLineWidth->setDecimals(lineUnit == Unit::Mm ? 1 : 6); + ui->doubleSpinBoxLineWidth->setMinimum( + UnitConvertor(ui->doubleSpinBoxLineWidth->minimum(), m_oldLineUnit, lineUnit)); + ui->doubleSpinBoxLineWidth->setMaximum( + UnitConvertor(ui->doubleSpinBoxLineWidth->maximum(), m_oldLineUnit, lineUnit)); + ui->doubleSpinBoxLineWidth->setValue(value); + m_oldLineUnit = lineUnit; + }); m_oldLineUnit = static_cast(ui->comboBoxLineWidthUnit->currentData().toInt()); ui->doubleSpinBoxLineWidth->setDecimals(m_oldLineUnit == Unit::Mm ? 1 : 6); @@ -192,7 +193,7 @@ void PreferencesPatternPage::InitDefaultSeamAllowance() { ui->defaultSeamAllowance->setValue(VAbstractValApplication::VApp()->ValentinaSettings()->GetDefaultSeamAllowance()); ui->defaultSeamAllowance->setSuffix( - UnitsToStr(StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()), true)); + UnitsToStr(StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()), true)); } //--------------------------------------------------------------------------------------------------------------------- @@ -217,12 +218,12 @@ void PreferencesPatternPage::EditDateTimeFormats() if (button == ui->pushButtonEditDateFormats) { CallDateTimeFormatEditor(QDate::currentDate(), VCommonSettings::PredefinedDateFormats(), - settings->GetUserDefinedDateFormats(), ui->comboBoxDateFormats); + settings->GetUserDefinedDateFormats(), ui->comboBoxDateFormats); } else if (button == ui->pushButtonEditTimeFormats) { CallDateTimeFormatEditor(QTime::currentTime(), VCommonSettings::PredefinedTimeFormats(), - settings->GetUserDefinedTimeFormats(), ui->comboBoxTimeFormats); + settings->GetUserDefinedTimeFormats(), ui->comboBoxTimeFormats); } } diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.h b/src/app/valentina/dialogs/configpages/preferencespatternpage.h index 1b443994e..457b15d4b 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.h +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.h @@ -29,12 +29,12 @@ #ifndef PREFERENCESPATTERNPAGE_H #define PREFERENCESPATTERNPAGE_H -#include #include "../vmisc/def.h" +#include namespace Ui { - class PreferencesPatternPage; +class PreferencesPatternPage; } class QComboBox; @@ -51,7 +51,7 @@ public: void InitDefaultSeamAllowance(); protected: - void changeEvent(QEvent* event) override; + void changeEvent(QEvent *event) override; private slots: void EditDateTimeFormats(); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 0f5481f46..6d10987c8 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -27,72 +27,72 @@ *************************************************************************/ #include "vpattern.h" -#include "../vwidgets/vabstractmainwindow.h" -#include "../vtools/tools/vdatatool.h" -#include "../vtools/tools/vtoolseamallowance.h" -#include "../vtools/tools/vtooluniondetails.h" -#include "../ifc/exception/vexceptionobjecterror.h" -#include "../ifc/exception/vexceptionwrongid.h" +#include "../core/vapplication.h" #include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionemptyparameter.h" +#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionundo.h" +#include "../ifc/exception/vexceptionwrongid.h" #include "../ifc/xml/vpatternconverter.h" -#include "../vmisc/customevents.h" -#include "../vmisc/vvalentinasettings.h" -#include "../vmisc/projectversion.h" -#include "../vmisc/compatibility.h" -#include "../vmisc/vsysexits.h" #include "../qmuparser/qmuparsererror.h" #include "../qmuparser/qmutokenparser.h" #include "../vgeometry/varc.h" -#include "../vgeometry/vellipticalarc.h" -#include "../vgeometry/vsplinepath.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" -#include "../core/vapplication.h" -#include "../vpatterndb/vpiecenode.h" +#include "../vgeometry/vellipticalarc.h" +#include "../vgeometry/vsplinepath.h" +#include "../vmisc/compatibility.h" +#include "../vmisc/customevents.h" +#include "../vmisc/projectversion.h" +#include "../vmisc/vsysexits.h" +#include "../vmisc/vvalentinasettings.h" #include "../vpatterndb/calculator.h" -#include "../vpatterndb/floatItemData/vpiecelabeldata.h" -#include "../vpatterndb/floatItemData/vpatternlabeldata.h" #include "../vpatterndb/floatItemData/vgrainlinedata.h" -#include "../vpatterndb/vpiecepath.h" -#include "../vpatterndb/vnodedetail.h" +#include "../vpatterndb/floatItemData/vpatternlabeldata.h" +#include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include "../vpatterndb/variables/vincrement.h" +#include "../vpatterndb/vnodedetail.h" +#include "../vpatterndb/vpiecenode.h" +#include "../vpatterndb/vpiecepath.h" +#include "../vtools/tools/vdatatool.h" +#include "../vtools/tools/vtoolseamallowance.h" +#include "../vtools/tools/vtooluniondetails.h" +#include "../vwidgets/vabstractmainwindow.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" +#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/operation/vtoolrotation.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarc.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h" -#include "../vtools/tools/drawTools/vtoolline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" +#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" -#include "../vtools/tools/drawTools/operation/vtoolrotation.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" -#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/vtoolline.h" #include "../vtools/tools/nodeDetails/vnodearc.h" #include "../vtools/tools/nodeDetails/vnodeellipticalarc.h" @@ -109,17 +109,17 @@ #include #endif -#include -#include -#include #include #include -#include #include -#include +#include #include -#include +#include +#include +#include +#include #include +#include #if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) // DO NOT WORK WITH GCC 4.8 @@ -140,8 +140,7 @@ namespace //--------------------------------------------------------------------------------------------------------------------- auto FileComment() -> QString { - return QStringLiteral("Pattern created with Valentina v%1 (https://smart-pattern.com.ua/).") - .arg(APP_VERSION_STR); + return QStringLiteral("Pattern created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR); } //--------------------------------------------------------------------------------------------------------------------- @@ -164,7 +163,10 @@ auto DefLabelLanguage() -> QString //--------------------------------------------------------------------------------------------------------------------- VPattern::VPattern(VContainer *data, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, QObject *parent) - : VAbstractPattern(parent), data(data), sceneDraw(sceneDraw), sceneDetail(sceneDetail) + : VAbstractPattern(parent), + data(data), + sceneDraw(sceneDraw), + sceneDetail(sceneDetail) { SCASSERT(sceneDraw != nullptr) SCASSERT(sceneDetail != nullptr) @@ -182,8 +184,8 @@ void VPattern::CreateEmptyFile() patternElement.appendChild(createComment(FileComment())); patternElement.appendChild(CreateElementWithText(TagVersion, VPatternConverter::PatternMaxVerStr)); - patternElement.appendChild(CreateElementWithText(TagUnit, - UnitsToStr(VAbstractValApplication::VApp()->patternUnits()))); + patternElement.appendChild( + CreateElementWithText(TagUnit, UnitsToStr(VAbstractValApplication::VApp()->patternUnits()))); patternElement.appendChild(createElement(TagDescription)); patternElement.appendChild(createElement(TagNotes)); @@ -193,9 +195,9 @@ void VPattern::CreateEmptyFile() patternElement.appendChild(createElement(TagPreviewCalculations)); this->appendChild(patternElement); - insertBefore(createProcessingInstruction(QStringLiteral("xml"), - QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), - this->firstChild()); + insertBefore( + createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), + this->firstChild()); // Cache values m_units = VAbstractValApplication::VApp()->patternUnits(); @@ -352,7 +354,7 @@ auto VPattern::GetCompleteData() const -> VContainer const VDataTool *vTool = tools.value(id); SCASSERT(vTool != nullptr) VContainer lastData = vTool->getData(); - //Delete special variables if exist + // Delete special variables if exist lastData.RemoveVariable(currentLength); lastData.RemoveVariable(currentSeamAllowance); return lastData; @@ -387,7 +389,7 @@ auto VPattern::GetCompletePPData(const QString &name) const -> VContainer const VDataTool *vTool = tools.value(id); SCASSERT(vTool != nullptr) VContainer lastData = vTool->getData(); - //Delete special variables if exist + // Delete special variables if exist lastData.RemoveVariable(currentLength); lastData.RemoveVariable(currentSeamAllowance); return lastData; @@ -432,7 +434,7 @@ auto VPattern::GetActivePPPieces() const -> QVector if (not details.isNull()) { QDomElement detail = details.firstChildElement(TagDetail); - while(not detail.isNull()) + while (not detail.isNull()) { bool united = GetParametrBool(detail, VToolSeamAllowance::AttrUnited, falseStr); if (not united) @@ -455,8 +457,8 @@ auto VPattern::SaveDocument(const QString &fileName, QString &error) -> bool } catch (const VExceptionWrongId &e) { - qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error not unique id.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error not unique id.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); return false; } @@ -541,15 +543,15 @@ void VPattern::LiteParseIncrements() } catch (const VExceptionWrongId &e) { - qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); emit SetEnabledGUI(false); return; } catch (VException &e) { - qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); emit SetEnabledGUI(false); return; } @@ -566,10 +568,8 @@ auto VPattern::ElementsToParse() const -> int { QVector tags{TagCalculation, TagDetails, TagModeling, TagIncrements}; - std::function TagsCount = [this](const QString &tagName) - { - return elementsByTagName(tagName).length(); - }; + std::function TagsCount = [this](const QString &tagName) + { return elementsByTagName(tagName).length(); }; return QtConcurrent::blockingMappedReduced(tags, TagsCount, GatherCount); } @@ -645,8 +645,8 @@ void VPattern::LiteParseTree(const Document &parse) } catch (const VExceptionWrongId &e) { - qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { @@ -656,8 +656,8 @@ void VPattern::LiteParseTree(const Document &parse) } catch (VException &e) { - qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { @@ -946,32 +946,31 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse initData.detail.SetUUID(GetParametrEmptyString(domElement, AttrUUID)); initData.detail.SetShortName(GetParametrEmptyString(domElement, AttrShortName).left(25)); initData.detail.SetGradationLabel(GetParametrEmptyString(domElement, AttrGradationLabel)); - initData.detail.SetMx(VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("0.0")))); - initData.detail.SetMy(VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("0.0")))); + initData.detail.SetMx( + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("0.0")))); + initData.detail.SetMy( + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("0.0")))); initData.detail.SetSeamAllowance(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowance, falseStr)); - initData.detail.SetHideMainPath(GetParametrBool(domElement, VToolSeamAllowance::AttrHideMainPath, - QString().setNum(VAbstractValApplication::VApp() - ->ValentinaSettings()->IsHideMainPath()))); - initData.detail.SetSeamAllowanceBuiltIn(GetParametrBool(domElement, - VToolSeamAllowance::AttrSeamAllowanceBuiltIn, - falseStr)); - initData.detail.SetForbidFlipping(GetParametrBool(domElement, AttrForbidFlipping, - QString().setNum(VAbstractValApplication::VApp() - ->ValentinaSettings()->GetForbidWorkpieceFlipping()))); - initData.detail.SetForceFlipping(GetParametrBool(domElement, AttrForceFlipping, - QString().setNum(VAbstractValApplication::VApp() - ->ValentinaSettings()->GetForceWorkpieceFlipping()))); - initData.detail.SetSewLineOnDrawing(GetParametrBool(domElement, AttrSewLineOnDrawing, - QString().setNum(VAbstractValApplication::VApp() - ->ValentinaSettings()->GetSewLineOnDrawing()))); + initData.detail.SetHideMainPath( + GetParametrBool(domElement, VToolSeamAllowance::AttrHideMainPath, + QString().setNum(VAbstractValApplication::VApp()->ValentinaSettings()->IsHideMainPath()))); + initData.detail.SetSeamAllowanceBuiltIn( + GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowanceBuiltIn, falseStr)); + initData.detail.SetForbidFlipping(GetParametrBool( + domElement, AttrForbidFlipping, + QString().setNum(VAbstractValApplication::VApp()->ValentinaSettings()->GetForbidWorkpieceFlipping()))); + initData.detail.SetForceFlipping(GetParametrBool( + domElement, AttrForceFlipping, + QString().setNum(VAbstractValApplication::VApp()->ValentinaSettings()->GetForceWorkpieceFlipping()))); + initData.detail.SetSewLineOnDrawing(GetParametrBool( + domElement, AttrSewLineOnDrawing, + QString().setNum(VAbstractValApplication::VApp()->ValentinaSettings()->GetSewLineOnDrawing()))); initData.detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); initData.detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr)); initData.detail.SetPriority(GetParametrUInt(domElement, VToolSeamAllowance::AttrPiecePriority, QChar('0'))); initData.width = GetParametrString(domElement, AttrWidth, QStringLiteral("0.0")); - const QString w = initData.width;//need for saving fixed formula; + const QString w = initData.width; // need for saving fixed formula; ParseDetailInternals(domElement, initData.detail); @@ -986,7 +985,7 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse { updatePieces.append(piece->getId()); } - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (w != initData.width) { SetAttribute(domElement, AttrWidth, initData.width); @@ -1007,14 +1006,9 @@ void VPattern::ParseDetailInternals(const QDomElement &domElement, VPiece &detai { const uint version = GetParametrUInt(domElement, AttrVersion, QChar('1')); - const QStringList tags = QStringList() << TagNodes - << TagData - << TagPatternInfo - << TagGrainline - << VToolSeamAllowance::TagCSA - << VToolSeamAllowance::TagIPaths - << VToolSeamAllowance::TagPins - << VToolSeamAllowance::TagPlaceLabels; + const QStringList tags = QStringList() << TagNodes << TagData << TagPatternInfo << TagGrainline + << VToolSeamAllowance::TagCSA << VToolSeamAllowance::TagIPaths + << VToolSeamAllowance::TagPins << VToolSeamAllowance::TagPlaceLabels; QFuture> futurePathV1; QFuture futurePathV2; @@ -1034,52 +1028,49 @@ void VPattern::ParseDetailInternals(const QDomElement &domElement, VPiece &detai { switch (tags.indexOf(element.tagName())) { - case 0:// TagNodes + case 0: // TagNodes if (version == 1) { // TODO. Delete if minimal supported version is 0.4.0 Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code."); - futurePathV1 = QtConcurrent::run([this, domElement, element]() - { - const bool closed = GetParametrUInt(domElement, AttrClosed, QChar('1')); - const qreal width = GetParametrDouble(domElement, AttrWidth, QStringLiteral("0.0")); - return ParseDetailNodes(element, width, closed); - }); + futurePathV1 = QtConcurrent::run( + [this, domElement, element]() + { + const bool closed = GetParametrUInt(domElement, AttrClosed, QChar('1')); + const qreal width = GetParametrDouble(domElement, AttrWidth, QStringLiteral("0.0")); + return ParseDetailNodes(element, width, closed); + }); } else { futurePathV2 = QtConcurrent::run(&VPattern::ParsePieceNodes, element); } break; - case 1:// TagData - futurePPData = QtConcurrent::run([this, element, detail]() - { - return ParsePieceDataTag(element, detail.GetPieceLabelData()); - }); + case 1: // TagData + futurePPData = QtConcurrent::run( + [this, element, detail]() { return ParsePieceDataTag(element, detail.GetPieceLabelData()); }); break; - case 2:// TagPatternInfo - futurePatternInfo = QtConcurrent::run([this, element, detail]() - { - return ParsePiecePatternInfo(element, detail.GetPatternLabelData()); - }); + case 2: // TagPatternInfo + futurePatternInfo = + QtConcurrent::run([this, element, detail]() + { return ParsePiecePatternInfo(element, detail.GetPatternLabelData()); }); break; - case 3:// TagGrainline - futureGGeometry = QtConcurrent::run([this, element, detail]() - { - return ParsePieceGrainline(element, detail.GetGrainlineGeometry()); - }); + case 3: // TagGrainline + futureGGeometry = + QtConcurrent::run([this, element, detail]() + { return ParsePieceGrainline(element, detail.GetGrainlineGeometry()); }); break; - case 4:// VToolSeamAllowance::TagCSA + case 4: // VToolSeamAllowance::TagCSA futureRecords = QtConcurrent::run(&VPattern::ParsePieceCSARecords, element); break; - case 5:// VToolSeamAllowance::TagIPaths + case 5: // VToolSeamAllowance::TagIPaths futureIPaths = QtConcurrent::run(&VPattern::ParsePieceInternalPaths, element); break; - case 6:// VToolSeamAllowance::TagPins + case 6: // VToolSeamAllowance::TagPins futurePins = QtConcurrent::run(&VPattern::ParsePiecePointRecords, element); break; - case 7:// VToolSeamAllowance::TagPlaceLabels + case 7: // VToolSeamAllowance::TagPlaceLabels futurePlaceLabels = QtConcurrent::run(&VPattern::ParsePiecePointRecords, element); break; default: @@ -1141,8 +1132,8 @@ auto VPattern::ParseDetailNodes(const QDomElement &domElement, qreal width, bool for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement element = nodeList.at(i).toElement(); - if (not element.isNull() - && element.tagName() == VAbstractPattern::TagNode) // Old detail version need this check! + if (not element.isNull() && + element.tagName() == VAbstractPattern::TagNode) // Old detail version need this check! { oldNodes.append(ParseDetailNode(element)); } @@ -1163,8 +1154,8 @@ auto VPattern::ParsePieceDataTag(const QDomElement &domElement, VPieceLabelData ppData.SetFoldPosition(GetParametrEmptyString(domElement, AttrFoldPosition)); ppData.SetQuantity(static_cast(GetParametrUInt(domElement, AttrQuantity, QChar('1')))); ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr)); - ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), - GetParametrDouble(domElement, AttrMy, QChar('0')))); + ppData.SetPos( + QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), GetParametrDouble(domElement, AttrMy, QChar('0')))); ppData.SetFontSize(static_cast(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, QChar('0')))); ppData.SetRotation(GetParametrString(domElement, AttrRotation, QChar('0'))); @@ -1197,8 +1188,8 @@ auto VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPatternLabe -> VPatternLabelData { patternInfo.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr)); - patternInfo.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), - GetParametrDouble(domElement, AttrMy, QChar('0')))); + patternInfo.SetPos( + QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), GetParametrDouble(domElement, AttrMy, QChar('0')))); patternInfo.SetFontSize(static_cast(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, QChar('0')))); patternInfo.SetRotation(GetParametrString(domElement, AttrRotation, QChar('0'))); @@ -1229,8 +1220,8 @@ auto VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPatternLabe auto VPattern::ParsePieceGrainline(const QDomElement &domElement, VGrainlineData gGeometry) const -> VGrainlineData { gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, falseStr)); - gGeometry.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), - GetParametrDouble(domElement, AttrMy, QChar('0')))); + gGeometry.SetPos( + QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')), GetParametrDouble(domElement, AttrMy, QChar('0')))); gGeometry.SetArrowType(static_cast(GetParametrUInt(domElement, AttrArrows, QChar('0')))); const quint32 topPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR); @@ -1365,79 +1356,79 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem VToolPlaceLabel::ToolType}); /*24*/ switch (points.indexOf(type)) { - case 0: //VToolBasePoint::ToolType + case 0: // VToolBasePoint::ToolType ParseToolBasePoint(scene, domElement, parse); break; - case 1: //VToolEndLine::ToolType + case 1: // VToolEndLine::ToolType ParseToolEndLine(scene, domElement, parse); break; - case 2: //VToolAlongLine::ToolType + case 2: // VToolAlongLine::ToolType ParseToolAlongLine(scene, domElement, parse); break; - case 3: //VToolShoulderPoint::ToolType + case 3: // VToolShoulderPoint::ToolType ParseToolShoulderPoint(scene, domElement, parse); break; - case 4: //VToolNormal::ToolType + case 4: // VToolNormal::ToolType ParseToolNormal(scene, domElement, parse); break; - case 5: //VToolBisector::ToolType + case 5: // VToolBisector::ToolType ParseToolBisector(scene, domElement, parse); break; - case 6: //VToolLineIntersect::ToolType + case 6: // VToolLineIntersect::ToolType ParseToolLineIntersect(scene, domElement, parse); break; - case 7: //VToolPointOfContact::ToolType + case 7: // VToolPointOfContact::ToolType ParseToolPointOfContact(scene, domElement, parse); break; - case 8: //VNodePoint::ToolType + case 8: // VNodePoint::ToolType ParseNodePoint(domElement, parse); break; - case 9: //VToolHeight::ToolType + case 9: // VToolHeight::ToolType ParseToolHeight(scene, domElement, parse); break; - case 10: //VToolTriangle::ToolType + case 10: // VToolTriangle::ToolType ParseToolTriangle(scene, domElement, parse); break; - case 11: //VToolPointOfIntersection::ToolType + case 11: // VToolPointOfIntersection::ToolType ParseToolPointOfIntersection(scene, domElement, parse); break; - case 12: //VToolCutSpline::ToolType + case 12: // VToolCutSpline::ToolType ParseToolCutSpline(scene, domElement, parse); break; - case 13: //VToolCutSplinePath::ToolType + case 13: // VToolCutSplinePath::ToolType ParseToolCutSplinePath(scene, domElement, parse); break; - case 14: //VToolCutArc::ToolType + case 14: // VToolCutArc::ToolType ParseToolCutArc(scene, domElement, parse); break; - case 15: //VToolLineIntersectAxis::ToolType + case 15: // VToolLineIntersectAxis::ToolType ParseToolLineIntersectAxis(scene, domElement, parse); break; - case 16: //VToolCurveIntersectAxis::ToolType + case 16: // VToolCurveIntersectAxis::ToolType ParseToolCurveIntersectAxis(scene, domElement, parse); break; - case 17: //VToolPointOfIntersectionArcs::ToolType + case 17: // VToolPointOfIntersectionArcs::ToolType ParseToolPointOfIntersectionArcs(scene, domElement, parse); break; - case 18: //VToolPointOfIntersectionCircles::ToolType + case 18: // VToolPointOfIntersectionCircles::ToolType ParseToolPointOfIntersectionCircles(scene, domElement, parse); break; - case 19: //VToolPointFromCircleAndTangent::ToolType + case 19: // VToolPointFromCircleAndTangent::ToolType ParseToolPointFromCircleAndTangent(scene, domElement, parse); break; - case 20: //VToolPointFromArcAndTangent::ToolType + case 20: // VToolPointFromArcAndTangent::ToolType ParseToolPointFromArcAndTangent(scene, domElement, parse); break; - case 21: //VToolTrueDarts::ToolType + case 21: // VToolTrueDarts::ToolType ParseToolTrueDarts(scene, domElement, parse); break; - case 22: //VToolPointOfIntersectionCurves::ToolType + case 22: // VToolPointOfIntersectionCurves::ToolType ParseToolPointOfIntersectionCurves(scene, domElement, parse); break; - case 23: //VToolPin::ToolType + case 23: // VToolPin::ToolType ParsePinPoint(domElement, parse); break; - case 24: //VToolPlaceLabel::ToolType + case 24: // VToolPlaceLabel::ToolType ParsePlaceLabel(domElement, parse); break; default: @@ -1453,8 +1444,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem * @param domElement tag in xml tree. * @param parse parser file mode. */ -void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document &parse) +void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse) { SCASSERT(scene != nullptr) Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); @@ -1551,7 +1541,7 @@ auto VPattern::GetLabelBase(quint32 index) const -> QString alphabet = al.split(QChar(',')); break; } - case 1: // en + case 1: // en default: // en { const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); @@ -1561,7 +1551,7 @@ auto VPattern::GetLabelBase(quint32 index) const -> QString } QString base; - const int count = qFloor(index/static_cast(alphabet.size())); + const int count = qFloor(index / static_cast(alphabet.size())); const int number = static_cast(index) - static_cast(alphabet.size()) * count; int i = 0; do @@ -1589,10 +1579,10 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement & initData.typeCreation = Source::FromFile; PointsCommonAttributes(domElement, initData); - initData.x = VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrX, QStringLiteral("10.0"))); - initData.y = VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrY, QStringLiteral("10.0"))); + initData.x = + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrX, QStringLiteral("10.0"))); + initData.y = + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrY, QStringLiteral("10.0"))); spoint = VToolBasePoint::Create(initData); } @@ -1624,7 +1614,7 @@ void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domEleme PointsWithLineCommonAttributes(domElement, initData); initData.formulaLength = GetParametrString(domElement, AttrLength, QStringLiteral("100.0")); - const QString f = initData.formulaLength;//need for saving fixed formula; + const QString f = initData.formulaLength; // need for saving fixed formula; initData.basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); @@ -1632,7 +1622,7 @@ void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domEleme const QString angleFix = initData.formulaAngle; VToolEndLine::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formulaLength || angleFix != initData.formulaAngle) { SetAttribute(domElement, AttrLength, initData.formulaLength); @@ -1650,7 +1640,7 @@ void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domEleme catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -1678,12 +1668,12 @@ void VPattern::ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domEle PointsWithLineCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QStringLiteral("100.0")); - const QString f = initData.formula;//need for saving fixed formula; + const QString f = initData.formula; // need for saving fixed formula; initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); VToolAlongLine::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formula) { SetAttribute(domElement, AttrLength, initData.formula); @@ -1700,7 +1690,7 @@ void VPattern::ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domEle catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -1722,13 +1712,13 @@ void VPattern::ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &do PointsWithLineCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QStringLiteral("100.0")); - const QString f = initData.formula;//need for saving fixed formula; + const QString f = initData.formula; // need for saving fixed formula; initData.p1Line = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); initData.p2Line = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); initData.pShoulder = GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR); VToolShoulderPoint::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formula) { SetAttribute(domElement, AttrLength, initData.formula); @@ -1745,7 +1735,7 @@ void VPattern::ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -1767,13 +1757,13 @@ void VPattern::ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElemen PointsWithLineCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QStringLiteral("100.0")); - const QString f = initData.formula;//need for saving fixed formula; + const QString f = initData.formula; // need for saving fixed formula; initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); initData.angle = GetParametrDouble(domElement, AttrAngle, QStringLiteral("0.0")); VToolNormal::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formula) { SetAttribute(domElement, AttrLength, initData.formula); @@ -1790,7 +1780,7 @@ void VPattern::ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -1812,13 +1802,13 @@ void VPattern::ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElem PointsWithLineCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QStringLiteral("100.0")); - const QString f = initData.formula;//need for saving fixed formula; + const QString f = initData.formula; // need for saving fixed formula; initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); initData.thirdPointId = GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR); VToolBisector::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formula) { SetAttribute(domElement, AttrLength, initData.formula); @@ -1835,7 +1825,7 @@ void VPattern::ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -1888,13 +1878,13 @@ void VPattern::ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &d PointsCommonAttributes(domElement, initData); initData.radius = GetParametrString(domElement, AttrRadius, QChar('0')); - const QString f = initData.radius;//need for saving fixed formula; + const QString f = initData.radius; // need for saving fixed formula; initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); VToolPointOfContact::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.radius) { SetAttribute(domElement, AttrRadius, initData.radius); @@ -1911,7 +1901,7 @@ void VPattern::ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &d catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -1945,7 +1935,7 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par { // Possible case. Parent was deleted, but the node object is still here. qDebug() << "Broken relation. Parent was deleted, but the node object is still here. Node point id =" << initData.id << "."; - return;// Just ignore + return; // Just ignore } QSharedPointer p(new VPointF(*point)); @@ -1987,8 +1977,9 @@ void VPattern::ParsePinPoint(const QDomElement &domElement, const Document &pars catch (const VExceptionBadId &) { // Possible case. Parent was deleted, but the node object is still here. qDebug() << "Broken relation. Parent was deleted, but the place label object is still here. Place label " - "id =" << initData.id << "."; - return;// Just ignore + "id =" + << initData.id << "."; + return; // Just ignore } initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); @@ -2025,32 +2016,33 @@ void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse) catch (const VExceptionBadId &) { // Possible case. Parent was deleted, but the node object is still here. qDebug() << "Broken relation. Parent was deleted, but the place label object is still here. Place label " - "id =" << initData.id << "."; - return;// Just ignore + "id =" + << initData.id << "."; + return; // Just ignore } initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR); initData.width = GetParametrString(domElement, AttrWidth, QStringLiteral("1.0")); - const QString w = initData.width;//need for saving fixed formula; + const QString w = initData.width; // need for saving fixed formula; initData.height = GetParametrString(domElement, AttrHeight, QStringLiteral("1.0")); - const QString h = initData.height;//need for saving fixed formula; + const QString h = initData.height; // need for saving fixed formula; initData.angle = GetParametrString(domElement, AttrAngle, QStringLiteral("0.0")); - const QString angle = initData.angle;//need for saving fixed formula; + const QString angle = initData.angle; // need for saving fixed formula; - initData.visibilityTrigger = GetParametrString(domElement, VAbstractPattern::AttrVisible, - QStringLiteral("1.0")); - const QString visibility = initData.visibilityTrigger;//need for saving fixed formula; + initData.visibilityTrigger = + GetParametrString(domElement, VAbstractPattern::AttrVisible, QStringLiteral("1.0")); + const QString visibility = initData.visibilityTrigger; // need for saving fixed formula; initData.type = static_cast(GetParametrUInt(domElement, AttrPlaceLabelType, QChar('0'))); VToolPlaceLabel::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. - if (w != initData.width || h != initData.height || angle != initData.angle - || visibility != initData.visibilityTrigger) + // Rewrite attribute formula. Need for situation when we have wrong formula. + if (w != initData.width || h != initData.height || angle != initData.angle || + visibility != initData.visibilityTrigger) { SetAttribute(domElement, AttrWidth, initData.width); SetAttribute(domElement, AttrHeight, initData.height); @@ -2069,7 +2061,7 @@ void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse) catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating place label"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -2182,13 +2174,13 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle PointsCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QChar('0')); - const QString f = initData.formula;//need for saving fixed formula; + const QString f = initData.formula; // need for saving fixed formula; initData.baseCurveId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR); initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1); initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2); VToolCutSpline::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formula) { SetAttribute(domElement, AttrLength, initData.formula); @@ -2205,7 +2197,7 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -2227,13 +2219,13 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do PointsCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QChar('0')); - const QString f = initData.formula;//need for saving fixed formula; + const QString f = initData.formula; // need for saving fixed formula; initData.baseCurveId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR); initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1); initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2); VToolCutSplinePath::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formula) { SetAttribute(domElement, AttrLength, initData.formula); @@ -2250,7 +2242,7 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -2272,13 +2264,13 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen PointsCommonAttributes(domElement, initData); initData.formula = GetParametrString(domElement, AttrLength, QChar('0')); - const QString f = initData.formula;//need for saving fixed formula; + const QString f = initData.formula; // need for saving fixed formula; initData.baseCurveId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR); initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1); initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2); VToolCutArc::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (f != initData.formula) { SetAttribute(domElement, AttrLength, initData.formula); @@ -2295,14 +2287,13 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, - const Document &parse) +void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse) { SCASSERT(scene != nullptr) Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); @@ -2326,7 +2317,7 @@ void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement const QString angleFix = initData.formulaAngle; VToolLineIntersectAxis::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (angleFix != initData.formulaAngle) { SetAttribute(domElement, AttrAngle, initData.formulaAngle); @@ -2336,23 +2327,20 @@ void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement } catch (const VExceptionBadId &e) { - VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"), - domElement); + VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"), domElement); excep.AddMoreInformation(e.ErrorMessage()); throw excep; } catch (qmu::QmuParserError &e) { - VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"), - domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, - const Document &parse) +void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse) { SCASSERT(scene != nullptr) Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); @@ -2382,7 +2370,7 @@ void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElemen initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2); VToolCurveIntersectAxis::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (angleFix != initData.formulaAngle) { SetAttribute(domElement, AttrAngle, initData.formulaAngle); @@ -2392,16 +2380,14 @@ void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElemen } catch (const VExceptionBadId &e) { - VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"), - domElement); + VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"), domElement); excep.AddMoreInformation(e.ErrorMessage()); throw excep; } catch (qmu::QmuParserError &e) { - VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"), - domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"), domElement); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -2463,7 +2449,7 @@ void VPattern::ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QD initData.crossPoint = static_cast(GetParametrUInt(domElement, AttrCrossPoint, QChar('1'))); VToolPointOfIntersectionCircles::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (c1R != initData.firstCircleRadius || c2R != initData.secondCircleRadius) { SetAttribute(domElement, AttrC1Center, initData.firstCircleRadius); @@ -2546,7 +2532,7 @@ void VPattern::ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDo initData.crossPoint = static_cast(GetParametrUInt(domElement, AttrCrossPoint, QChar('1'))); VToolPointFromCircleAndTangent::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (cR != initData.circleRadius) { SetAttribute(domElement, AttrCCenter, initData.circleRadius); @@ -2620,17 +2606,17 @@ void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement & initData.dartP3Id = GetParametrUInt(domElement, AttrDartP3, NULL_ID_STR); initData.name1 = GetParametrString(domElement, AttrName1, QChar('A')); - initData.mx1 = VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrMx1, QString::number(labelMX))); - initData.my1 = VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrMy1, QString::number(labelMY))); + initData.mx1 = + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMx1, QString::number(labelMX))); + initData.my1 = + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMy1, QString::number(labelMY))); initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr); initData.name2 = GetParametrString(domElement, AttrName2, QChar('A')); - initData.mx2 = VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrMx2, QString::number(labelMX))); - initData.my2 = VAbstractValApplication::VApp() - ->toPixel(GetParametrDouble(domElement, AttrMy2, QString::number(labelMY))); + initData.mx2 = + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMx2, QString::number(labelMX))); + initData.my2 = + VAbstractValApplication::VApp()->toPixel(GetParametrDouble(domElement, AttrMy2, QString::number(labelMY))); initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr); VToolTrueDarts::Create(initData); @@ -2673,7 +2659,7 @@ void VPattern::ParseOldToolSpline(VMainGraphicsScene *scene, QDomElement &domEle const auto p1 = data->GeometricObject(point1); const auto p4 = data->GeometricObject(point4); - auto* spline = new VSpline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve); + auto *spline = new VSpline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve); if (duplicate > 0) { spline->SetDuplicate(duplicate); @@ -2713,16 +2699,16 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen initData.point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR); initData.a1 = GetParametrString(domElement, AttrAngle1, QChar('0')); - const QString angle1 = initData.a1;//need for saving fixed formula; + const QString angle1 = initData.a1; // need for saving fixed formula; initData.a2 = GetParametrString(domElement, AttrAngle2, QChar('0')); - const QString angle2 = initData.a2;//need for saving fixed formula; + const QString angle2 = initData.a2; // need for saving fixed formula; initData.l1 = GetParametrString(domElement, AttrLength1, QChar('0')); - const QString length1 = initData.l1;//need for saving fixed formula; + const QString length1 = initData.l1; // need for saving fixed formula; initData.l2 = GetParametrString(domElement, AttrLength2, QChar('0')); - const QString length2 = initData.l2;//need for saving fixed formula; + const QString length2 = initData.l2; // need for saving fixed formula; initData.color = GetParametrString(domElement, AttrColor, ColorBlack); initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine); @@ -2735,12 +2721,12 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen if (spl != nullptr) { VAbstractMainWindow *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(spl, &VToolSpline::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (angle1 != initData.a1 || angle2 != initData.a2 || length1 != initData.l1 || length2 != initData.l2) { SetAttribute(domElement, AttrAngle1, initData.a1); @@ -2760,7 +2746,7 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple interactive spline"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -2858,7 +2844,7 @@ void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, QDomElement &do const VPointF p = *data->GeometricObject(pSpline); QLineF line(0, 0, 100, 0); - line.setAngle(angle+180); + line.setAngle(angle + 180); VFSplinePoint splPoint(p, kAsm1, line.angle(), kAsm2, angle); points.append(splPoint); @@ -2870,7 +2856,7 @@ void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, QDomElement &do } } - auto* path = new VSplinePath(points, kCurve); + auto *path = new VSplinePath(points, kCurve); if (duplicate > 0) { path->SetDuplicate(duplicate); @@ -2934,7 +2920,7 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement } } - //need for saving fixed formula; + // need for saving fixed formula; const QVector angle1 = initData.a1; const QVector angle2 = initData.a2; const QVector length1 = initData.l1; @@ -2945,12 +2931,12 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement if (spl != nullptr) { VAbstractMainWindow *window = - qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); + qobject_cast(VAbstractValApplication::VApp()->getMainWindow()); SCASSERT(window != nullptr) connect(spl, &VToolSplinePath::ToolTip, window, &VAbstractMainWindow::ShowToolTip); } - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. int count = 0; for (qint32 i = 0; i < num; ++i) { @@ -2980,7 +2966,7 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating interactive spline path"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -3084,7 +3070,7 @@ void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &pa catch (const VExceptionBadId &e) { // Possible case. Parent was deleted, but the node object is still here. Q_UNUSED(e) - return;// Just ignore + return; // Just ignore } VNodeSpline::Create(initData); @@ -3124,7 +3110,7 @@ void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document else { VCubicBezierPath *spl = - new VCubicBezierPath(*initData.data->GeometricObject(initData.idObject)); + new VCubicBezierPath(*initData.data->GeometricObject(initData.idObject)); spl->setIdObject(initData.idObject); spl->setMode(Draw::Modeling); initData.data->UpdateGObject(initData.id, spl); @@ -3133,7 +3119,7 @@ void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document catch (const VExceptionBadId &e) { // Possible case. Parent was deleted, but the node object is still here. Q_UNUSED(e) - return;// Just ignore + return; // Just ignore } VNodeSplinePath::Create(initData); } @@ -3163,18 +3149,18 @@ void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, DrawToolsCommonAttributes(domElement, initData.id, initData.notes); initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); initData.radius = GetParametrString(domElement, AttrRadius, QStringLiteral("10")); - const QString r = initData.radius;//need for saving fixed formula; + const QString r = initData.radius; // need for saving fixed formula; initData.f1 = GetParametrString(domElement, AttrAngle1, QStringLiteral("180")); - const QString f1Fix = initData.f1;//need for saving fixed formula; + const QString f1Fix = initData.f1; // need for saving fixed formula; initData.f2 = GetParametrString(domElement, AttrAngle2, QStringLiteral("270")); - const QString f2Fix = initData.f2;//need for saving fixed formula; + const QString f2Fix = initData.f2; // need for saving fixed formula; initData.color = GetParametrString(domElement, AttrColor, ColorBlack); initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine); initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0')); initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias); VToolArc::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (r != initData.radius || f1Fix != initData.f1 || f2Fix != initData.f2) { SetAttribute(domElement, AttrRadius, initData.radius); @@ -3193,7 +3179,7 @@ void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -3217,23 +3203,23 @@ void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &do initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); initData.radius1 = GetParametrString(domElement, AttrRadius1, QStringLiteral("10")); initData.radius2 = GetParametrString(domElement, AttrRadius2, QStringLiteral("10")); - const QString r1 = initData.radius1;//need for saving fixed formula; - const QString r2 = initData.radius2;//need for saving fixed formula; + const QString r1 = initData.radius1; // need for saving fixed formula; + const QString r2 = initData.radius2; // need for saving fixed formula; initData.f1 = GetParametrString(domElement, AttrAngle1, QStringLiteral("180")); - const QString f1Fix = initData.f1;//need for saving fixed formula; + const QString f1Fix = initData.f1; // need for saving fixed formula; initData.f2 = GetParametrString(domElement, AttrAngle2, QStringLiteral("270")); - const QString f2Fix = initData.f2;//need for saving fixed formula; + const QString f2Fix = initData.f2; // need for saving fixed formula; initData.rotationAngle = GetParametrString(domElement, AttrRotationAngle, QChar('0')); - const QString frotationFix = initData.rotationAngle;//need for saving fixed formula; + const QString frotationFix = initData.rotationAngle; // need for saving fixed formula; initData.color = GetParametrString(domElement, AttrColor, ColorBlack); initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine); initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0')); initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias); VToolEllipticalArc::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. - if (r1 != initData.radius1 || r2 != initData.radius2 || f1Fix != initData.f1 || f2Fix != initData.f2 - || frotationFix != initData.rotationAngle) + // Rewrite attribute formula. Need for situation when we have wrong formula. + if (r1 != initData.radius1 || r2 != initData.radius2 || f1Fix != initData.f1 || f2Fix != initData.f2 || + frotationFix != initData.rotationAngle) { SetAttribute(domElement, AttrRadius1, initData.radius1); SetAttribute(domElement, AttrRadius2, initData.radius2); @@ -3253,7 +3239,7 @@ void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -3282,7 +3268,7 @@ void VPattern::ParseNodeEllipticalArc(const QDomElement &domElement, const Docum catch (const VExceptionBadId &e) { // Possible case. Parent was deleted, but the node object is still here. Q_UNUSED(e) - return;// Just ignore + return; // Just ignore } arc->setIdObject(initData.idObject); arc->setMode(Draw::Modeling); @@ -3321,7 +3307,7 @@ void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse catch (const VExceptionBadId &e) { // Possible case. Parent was deleted, but the node object is still here. Q_UNUSED(e) - return;// Just ignore + return; // Just ignore } arc->setIdObject(initData.idObject); arc->setMode(Draw::Modeling); @@ -3354,18 +3340,18 @@ void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &do DrawToolsCommonAttributes(domElement, initData.id, initData.notes); initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); initData.radius = GetParametrString(domElement, AttrRadius, QStringLiteral("10")); - const QString r = initData.radius;//need for saving fixed formula; + const QString r = initData.radius; // need for saving fixed formula; initData.f1 = GetParametrString(domElement, AttrAngle1, QStringLiteral("180")); - const QString f1Fix = initData.f1;//need for saving fixed formula; + const QString f1Fix = initData.f1; // need for saving fixed formula; initData.length = GetParametrString(domElement, AttrLength, QStringLiteral("10")); - const QString lengthFix = initData.length;//need for saving fixed length; + const QString lengthFix = initData.length; // need for saving fixed length; initData.color = GetParametrString(domElement, AttrColor, ColorBlack); initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine); initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0')); initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias); VToolArcWithLength::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (r != initData.radius || f1Fix != initData.f1 || lengthFix != initData.length) { SetAttribute(domElement, AttrRadius, initData.radius); @@ -3384,7 +3370,7 @@ void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -3407,13 +3393,13 @@ void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElem DrawToolsCommonAttributes(domElement, initData.id, initData.notes); initData.origin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); initData.angle = GetParametrString(domElement, AttrAngle, QStringLiteral("10")); - const QString a = initData.angle;//need for saving fixed formula; + const QString a = initData.angle; // need for saving fixed formula; initData.suffix = GetParametrString(domElement, AttrSuffix, QString()); VAbstractOperation::ExtractData(domElement, initData); VToolRotation::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (a != initData.angle) { SetAttribute(domElement, AttrAngle, initData.angle); @@ -3430,7 +3416,7 @@ void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -3516,18 +3502,18 @@ void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, DrawToolsCommonAttributes(domElement, initData.id, initData.notes); initData.formulaAngle = GetParametrString(domElement, AttrAngle, QChar('0')); - const QString a = initData.formulaAngle;//need for saving fixed formula; + const QString a = initData.formulaAngle; // need for saving fixed formula; initData.formulaRotationAngle = GetParametrString(domElement, AttrRotationAngle, QChar('0')); - const QString r = initData.formulaRotationAngle;//need for saving fixed formula; + const QString r = initData.formulaRotationAngle; // need for saving fixed formula; initData.formulaLength = GetParametrString(domElement, AttrLength, QChar('0')); - const QString len = initData.formulaLength;//need for saving fixed formula; + const QString len = initData.formulaLength; // need for saving fixed formula; initData.suffix = GetParametrString(domElement, AttrSuffix, QString()); initData.rotationOrigin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); VAbstractOperation::ExtractData(domElement, initData); VToolMove::Create(initData); - //Rewrite attribute formula. Need for situation when we have wrong formula. + // Rewrite attribute formula. Need for situation when we have wrong formula. if (a != initData.formulaAngle || r != initData.formulaRotationAngle || len != initData.formulaLength) { SetAttribute(domElement, AttrAngle, initData.formulaAngle); @@ -3546,7 +3532,7 @@ void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); throw excep; } } @@ -3595,7 +3581,7 @@ auto VPattern::FindIncrement(const QString &name) const -> QDomElement { QDomNodeList list = elementsByTagName(TagIncrement); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { const QDomElement domElement = list.at(i).toElement(); if (not domElement.isNull()) @@ -3617,7 +3603,7 @@ void VPattern::GarbageCollector(bool commit) bool cleared = false; QDomNodeList modelingList = elementsByTagName(TagModeling); - for (int i=0; i < modelingList.size(); ++i) + for (int i = 0; i < modelingList.size(); ++i) { QDomElement modElement = modelingList.at(i).toElement(); if (not modElement.isNull()) @@ -3646,14 +3632,15 @@ void VPattern::GarbageCollector(bool commit) try { vidtype id = GetParametrId(modNode); - auto record = std::find_if(history.begin(), history.end(), - [id](const VToolRecord &record) { return record.getId() == id; }); + auto record = + std::find_if(history.begin(), history.end(), + [id](const VToolRecord &record) { return record.getId() == id; }); if (record != history.end()) { history.erase(record); } } - catch(const VExceptionWrongId &) + catch (const VExceptionWrongId &) { // do nothing } @@ -3764,7 +3751,7 @@ auto VPattern::LastDrawName() const -> QString return QString(); } - const QDomElement &elem = elements.at(elements.size()-1).toElement(); + const QDomElement &elem = elements.at(elements.size() - 1).toElement(); if (not elem.isNull()) { return GetParametrString(elem, AttrName); @@ -3796,18 +3783,19 @@ auto VPattern::PPLastToolId(const QString &name) const -> quint32 //--------------------------------------------------------------------------------------------------------------------- void VPattern::RefreshPieceGeometry() { - auto CleanRefreshList = qScopeGuard([this]() - { - updatePieces.clear(); - VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView()); - }); + auto CleanRefreshList = qScopeGuard( + [this]() + { + updatePieces.clear(); + VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView()); + }); if (VApplication::IsGUIMode() && m_parsing) { return; } - for(auto pieceId : qAsConst(updatePieces)) + for (auto pieceId : qAsConst(updatePieces)) { if (VApplication::IsGUIMode() && m_parsing) { @@ -3821,7 +3809,7 @@ void VPattern::RefreshPieceGeometry() piece->RefreshGeometry(); } } - catch(const VExceptionBadId &) + catch (const VExceptionBadId &) { // do nothing } @@ -3845,52 +3833,52 @@ void VPattern::RefreshPieceGeometry() * @param parse parser file mode. * @param type type of spline. */ -void VPattern::ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement, - const Document &parse, const QString &type) +void VPattern::ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, + const QString &type) { SCASSERT(scene != nullptr) Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - static const QStringList splines({VToolSpline::OldToolType, /*0*/ - VToolSpline::ToolType, /*1*/ - VToolSplinePath::OldToolType, /*2*/ - VToolSplinePath::ToolType, /*3*/ - VNodeSpline::ToolType, /*4*/ - VNodeSplinePath::ToolType, /*5*/ - VToolCubicBezier::ToolType, /*6*/ - VToolCubicBezierPath::ToolType});/*7*/ + static const QStringList splines({VToolSpline::OldToolType, /*0*/ + VToolSpline::ToolType, /*1*/ + VToolSplinePath::OldToolType, /*2*/ + VToolSplinePath::ToolType, /*3*/ + VNodeSpline::ToolType, /*4*/ + VNodeSplinePath::ToolType, /*5*/ + VToolCubicBezier::ToolType, /*6*/ + VToolCubicBezierPath::ToolType}); /*7*/ switch (splines.indexOf(type)) { - case 0: //VToolSpline::OldToolType + case 0: // VToolSpline::OldToolType qCDebug(vXML, "VOldToolSpline."); - ParseOldToolSpline(scene, domElement, parse);// TODO. Delete if minimal supported version is 0.2.7 + ParseOldToolSpline(scene, domElement, parse); // TODO. Delete if minimal supported version is 0.2.7 break; - case 1: //VToolSpline::ToolType + case 1: // VToolSpline::ToolType qCDebug(vXML, "VToolSpline."); ParseToolSpline(scene, domElement, parse); break; - case 2: //VToolSplinePath::OldToolType + case 2: // VToolSplinePath::OldToolType qCDebug(vXML, "VOldToolSplinePath."); - ParseOldToolSplinePath(scene, domElement, parse);// TODO. Delete if minimal supported version is 0.2.7 + ParseOldToolSplinePath(scene, domElement, parse); // TODO. Delete if minimal supported version is 0.2.7 break; - case 3: //VToolSplinePath::ToolType + case 3: // VToolSplinePath::ToolType qCDebug(vXML, "VToolSplinePath."); ParseToolSplinePath(scene, domElement, parse); break; - case 4: //VNodeSpline::ToolType + case 4: // VNodeSpline::ToolType qCDebug(vXML, "VNodeSpline."); ParseNodeSpline(domElement, parse); break; - case 5: //VNodeSplinePath::ToolType + case 5: // VNodeSplinePath::ToolType qCDebug(vXML, "VNodeSplinePath."); ParseNodeSplinePath(domElement, parse); break; - case 6: //VToolCubicBezier::ToolType + case 6: // VToolCubicBezier::ToolType qCDebug(vXML, "VToolCubicBezier."); ParseToolCubicBezier(scene, domElement, parse); break; - case 7: //VToolCubicBezierPath::ToolType + case 7: // VToolCubicBezierPath::ToolType qCDebug(vXML, "VToolCubicBezierPath."); ParseToolCubicBezierPath(scene, domElement, parse); break; @@ -3921,13 +3909,13 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen switch (arcs.indexOf(type)) { - case 0: //VToolArc::ToolType + case 0: // VToolArc::ToolType ParseToolArc(scene, domElement, parse); break; - case 1: //VNodeArc::ToolType + case 1: // VNodeArc::ToolType ParseNodeArc(domElement, parse); break; - case 2: //VToolArcWithLength::ToolType + case 2: // VToolArcWithLength::ToolType ParseToolArcWithLength(scene, domElement, parse); break; default: @@ -3945,7 +3933,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen * @param type type of spline. */ void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, - const QString &type) + const QString &type) { SCASSERT(scene != nullptr) Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); @@ -3956,10 +3944,10 @@ void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement switch (arcs.indexOf(type)) { - case 0: //VToolArc::ToolType + case 0: // VToolArc::ToolType ParseToolEllipticalArc(scene, domElement, parse); break; - case 1: //VNodeEllipticalArc::ToolType + case 1: // VNodeEllipticalArc::ToolType ParseNodeEllipticalArc(domElement, parse); break; default: @@ -3976,8 +3964,8 @@ void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement * @param parse parser file mode. * @param type type of spline. */ -void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document &parse, const QString &type) +void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse, + const QString &type) { SCASSERT(scene != nullptr) Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); @@ -3986,7 +3974,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d const QStringList tools = QStringList() << VToolUnionDetails::ToolType; switch (tools.indexOf(type)) { - case 0: //VToolUnionDetails::ToolType + case 0: // VToolUnionDetails::ToolType try { VToolUnionDetailsInitData initData; @@ -4024,23 +4012,23 @@ void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &dom Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of operation is empty"); - const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/ - << VToolFlippingByLine::ToolType /*1*/ - << VToolFlippingByAxis::ToolType /*2*/ - << VToolMove::ToolType; /*3*/ + const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/ + << VToolFlippingByLine::ToolType /*1*/ + << VToolFlippingByAxis::ToolType /*2*/ + << VToolMove::ToolType; /*3*/ switch (opers.indexOf(type)) { - case 0: //VToolRotation::ToolType + case 0: // VToolRotation::ToolType ParseToolRotation(scene, domElement, parse); break; - case 1: //VToolFlippingByLine::ToolType + case 1: // VToolFlippingByLine::ToolType ParseToolFlippingByLine(scene, domElement, parse); break; - case 2: //VToolFlippingByAxis::ToolType + case 2: // VToolFlippingByAxis::ToolType ParseToolFlippingByAxis(scene, domElement, parse); break; - case 3: //VToolMove::ToolType + case 3: // VToolMove::ToolType ParseToolMove(scene, domElement, parse); break; default: @@ -4081,8 +4069,9 @@ void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domEleme catch (const VExceptionBadId &) { // Possible case. Parent was deleted, but the node object is still here. qDebug() << "Broken relation. Parent was deleted, but the piece path object is still here. Piece " - "path id =" << initData.id << "."; - return;// Just ignore + "path id =" + << initData.id << "."; + return; // Just ignore } } else @@ -4136,10 +4125,11 @@ void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &pars { const QString name = GetParametrString(domElement, AttrName, QString()).simplified(); const QString desc = GetParametrEmptyString(domElement, AttrDescription); - const IncrementType type = StringToIncrementType(GetParametrString(domElement, AttrType, - strTypeIncrement)); - const QString formula = (type == IncrementType::Separator) ? - QChar('0') : GetParametrString(domElement, AttrFormula, QChar('0')); + const IncrementType type = + StringToIncrementType(GetParametrString(domElement, AttrType, strTypeIncrement)); + const QString formula = (type == IncrementType::Separator) + ? QChar('0') + : GetParametrString(domElement, AttrFormula, QChar('0')); const bool specialUnits = GetParametrBool(domElement, AttrSpecialUnits, falseStr); bool ok = false; @@ -4260,7 +4250,8 @@ void VPattern::SetIncrementSpecialUnits(const QString &name, bool special) QDomElement node = FindIncrement(name); if (not node.isNull()) { - SetAttributeOrRemoveIf(node, AttrSpecialUnits, special, [](bool special) noexcept {return not special;}); + SetAttributeOrRemoveIf(node, AttrSpecialUnits, special, + [](bool special) noexcept { return not special; }); emit patternChanged(false); } else @@ -4274,7 +4265,7 @@ void VPattern::ReplaceNameInFormula(QVector &expressions, const Q { const auto bias = name.length() - newName.length(); - for(int i = 0; i < expressions.size(); ++i) + for (int i = 0; i < expressions.size(); ++i) { if (expressions.at(i).expression.indexOf(name) != -1) { @@ -4283,14 +4274,13 @@ void VPattern::ReplaceNameInFormula(QVector &expressions, const Q // Eval formula try { - QScopedPointer cal(new qmu::QmuTokenParser(expressions.at(i).expression, false, - false)); - tokens = cal->GetTokens();// Tokens (variables, measurements) - + QScopedPointer cal( + new qmu::QmuTokenParser(expressions.at(i).expression, false, false)); + tokens = cal->GetTokens(); // Tokens (variables, measurements) } catch (const qmu::QmuParserError &) { - continue;// Because we not sure if used. A formula is broken. + continue; // Because we not sure if used. A formula is broken. } QList tValues = tokens.values(); @@ -4299,7 +4289,7 @@ void VPattern::ReplaceNameInFormula(QVector &expressions, const Q continue; } - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys(); // Take all tokens positions QString newFormula = expressions.at(i).expression; for (int i = 0; i < tKeys.size(); ++i) @@ -4312,7 +4302,7 @@ void VPattern::ReplaceNameInFormula(QVector &expressions, const Q newFormula.replace(tKeys.at(i), name.length(), newName); if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. + { // Translated token has different length than original. Position next tokens need to be corrected. VTranslateVars::BiasTokens(tKeys.at(i), bias, tokens); tKeys = tokens.keys(); tValues = tokens.values(); @@ -4389,14 +4379,14 @@ auto VPattern::GenerateSuffix() const -> QString { suffix = QStringLiteral("%1%2").arg(suffixBase).arg(num); - for (int i=0; i < uniqueNames.size(); ++i) + for (int i = 0; i < uniqueNames.size(); ++i) { if (not data->IsUnique(uniqueNames.at(i) + suffix)) { break; } - if (i == uniqueNames.size()-1) + if (i == uniqueNames.size() - 1) { qCDebug(vXML, "Suffix is: %s", qUtf8Printable(suffix)); return suffix; @@ -4432,7 +4422,7 @@ void VPattern::SetReadOnly(bool rOnly) if (not pattern.isNull()) { - SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, [](bool rOnly) noexcept {return not rOnly;}); + SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, [](bool rOnly) noexcept { return not rOnly; }); modified = true; } } @@ -4481,7 +4471,7 @@ void VPattern::PrepareForParse(const Document &parse) nameActivPP.clear(); patternPieces.clear(); - qDeleteAll(toolsOnRemove);//Remove all invisible on a scene objects. + qDeleteAll(toolsOnRemove); // Remove all invisible on a scene objects. toolsOnRemove.clear(); tools.clear(); @@ -4491,14 +4481,9 @@ void VPattern::PrepareForParse(const Document &parse) else if (parse == Document::LiteParse || parse == Document::FullLiteParse) { Q_STATIC_ASSERT_X(static_cast(VarType::Unknown) == 12, "Check that you used all types"); - QVector types{VarType::LineAngle, - VarType::LineLength, - VarType::CurveLength, - VarType::CurveCLength, - VarType::ArcRadius, - VarType::CurveAngle, - VarType::PieceExternalArea, - VarType::PieceSeamLineArea}; + QVector types{VarType::LineAngle, VarType::LineLength, VarType::CurveLength, + VarType::CurveCLength, VarType::ArcRadius, VarType::CurveAngle, + VarType::PieceExternalArea, VarType::PieceSeamLineArea}; if (parse == Document::FullLiteParse) { types.append(VarType::Increment); @@ -4534,12 +4519,12 @@ auto VPattern::ActiveDrawBoundingRect() const -> QRectF QRectF rec; - for (qint32 i = 0; i< history.size(); ++i) + for (qint32 i = 0; i < history.size(); ++i) { const VToolRecord tool = history.at(i); if (tool.getNameDraw() == nameActivPP) { - switch ( tool.getTypeTool() ) + switch (tool.getTypeTool()) { case Tool::Arrow: case Tool::SinglePoint: @@ -4547,12 +4532,12 @@ auto VPattern::ActiveDrawBoundingRect() const -> QRectF case Tool::LinePoint: case Tool::AbstractSpline: case Tool::Cut: - case Tool::Midpoint:// Same as Tool::AlongLine, but tool will never has such type - case Tool::ArcIntersectAxis:// Same as Tool::CurveIntersectAxis, but tool will never has such type - case Tool::BackgroundImage:// Not part of active draw - case Tool::BackgroundImageControls:// Not part of active draw - case Tool::BackgroundPixmapImage:// Not part of active draw - case Tool::BackgroundSVGImage:// Not part of active draw + case Tool::Midpoint: // Same as Tool::AlongLine, but tool will never has such type + case Tool::ArcIntersectAxis: // Same as Tool::CurveIntersectAxis, but tool will never has such type + case Tool::BackgroundImage: // Not part of active draw + case Tool::BackgroundImageControls: // Not part of active draw + case Tool::BackgroundPixmapImage: // Not part of active draw + case Tool::BackgroundSVGImage: // Not part of active draw case Tool::LAST_ONE_DO_NOT_USE: Q_UNREACHABLE(); break; @@ -4602,7 +4587,7 @@ auto VPattern::ActiveDrawBoundingRect() const -> QRectF case Tool::Move: rec = ToolBoundingRect(rec, tool.getId()); break; - //These tools are not accesseble in Draw mode, but still 'history' contains them. + // These tools are not accesseble in Draw mode, but still 'history' contains them. case Tool::Piece: case Tool::UnionDetails: case Tool::NodeArc: @@ -4636,7 +4621,7 @@ template auto VPattern::ToolBoundingRect(const QRectF &rec, quint32 SCASSERT(vTool != nullptr) QRectF childrenRect = vTool->childrenBoundingRect(); - //map to scene coordinate. + // map to scene coordinate. childrenRect.translate(vTool->scenePos()); recTool = recTool.united(vTool->sceneBoundingRect()); @@ -4644,7 +4629,7 @@ template auto VPattern::ToolBoundingRect(const QRectF &rec, quint32 } else { - qDebug()<<"Can't find tool with id="<DataVariables(), labelData.GetRotation()); } - catch(qmu::QmuParserError &e) + catch (qmu::QmuParserError &e) { Q_UNUSED(e); return false; @@ -122,8 +122,8 @@ auto FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat const auto topLeftPinPoint = pattern->GeometricObject(topLeftPin); const auto bottomRightPinPoint = pattern->GeometricObject(bottomRightPin); - const QRectF labelRect = QRectF(static_cast(*topLeftPinPoint), - static_cast(*bottomRightPinPoint)); + const QRectF labelRect = + QRectF(static_cast(*topLeftPinPoint), static_cast(*bottomRightPinPoint)); labelWidth = qAbs(labelRect.width()); labelHeight = qAbs(labelRect.height()); @@ -131,7 +131,7 @@ auto FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat return true; } - catch(const VExceptionBadId &) + catch (const VExceptionBadId &) { // do nothing. } @@ -147,7 +147,7 @@ auto FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat labelHeight = cal2.EvalFormula(pattern->DataVariables(), labelData.GetLabelHeight()); labelHeight = ToPixel(labelHeight, *pattern->GetPatternUnit()); } - catch(qmu::QmuParserError &e) + catch (qmu::QmuParserError &e) { Q_UNUSED(e); return false; @@ -161,7 +161,7 @@ auto FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat const auto centerPinPoint = pattern->GeometricObject(centerPin); pos = static_cast(*centerPinPoint) - QRectF(0, 0, labelWidth, labelHeight).center(); } - catch(const VExceptionBadId &) + catch (const VExceptionBadId &) { pos = labelData.GetPos(); } @@ -182,12 +182,12 @@ auto FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat * @param dAng angle of rotation * @return position of point pt after rotating it around the center for dAng radians */ -auto RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) -> QPointF +auto RotatePoint(const QPointF &ptCenter, const QPointF &pt, qreal dAng) -> QPointF { QPointF ptDest; QPointF ptRel = pt - ptCenter; - ptDest.setX(cos(dAng)*ptRel.x() - sin(dAng)*ptRel.y()); - ptDest.setY(sin(dAng)*ptRel.x() + cos(dAng)*ptRel.y()); + ptDest.setX(cos(dAng) * ptRel.x() - sin(dAng) * ptRel.y()); + ptDest.setY(sin(dAng) * ptRel.x() + cos(dAng) * ptRel.y()); return ptDest + ptCenter; } @@ -214,7 +214,7 @@ auto ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) -> QVect QVector labels; const auto placeLabels = piece.GetPlaceLabels(); labels.reserve(placeLabels.size()); - for(const auto &placeLabel : placeLabels) + for (const auto &placeLabel : placeLabels) { const auto label = pattern->GeometricObject(placeLabel); if (label->IsVisible()) @@ -232,8 +232,8 @@ auto ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) -> QVect } //--------------------------------------------------------------------------------------------------------------------- -auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPassmark &passmark, - PassmarkSide side, bool &ok) -> VLayoutPassmark +auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPassmark &passmark, PassmarkSide side, + bool &ok) -> VLayoutPassmark { QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wnoexcept") @@ -249,10 +249,10 @@ auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPa if (nodeIndex == -1) { const QString errorMsg = - QObject::tr("Passmark '%1' is not part of piece '%2'.") - .arg(pData.nodeName, piece.GetName()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + QObject::tr("Passmark '%1' is not part of piece '%2'.").arg(pData.nodeName, piece.GetName()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ok = false; return {}; } @@ -263,8 +263,9 @@ auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPa const QString errorMsg = QObject::tr("Cannot prepare passmark '%1' for piece '%2'. Passmark base line is empty.") .arg(pData.nodeName, piece.GetName()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ok = false; return {}; } @@ -281,11 +282,11 @@ auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPa const QVector lines = passmark.SAPassmark(piece, pattern, side); if (lines.isEmpty()) { - const QString errorMsg = - QObject::tr("Cannot prepare passmark '%1' for piece '%2'. Passmark is empty.") - .arg(pData.nodeName, piece.GetName()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + const QString errorMsg = QObject::tr("Cannot prepare passmark '%1' for piece '%2'. Passmark is empty.") + .arg(pData.nodeName, piece.GetName()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ok = false; return {}; } @@ -300,8 +301,8 @@ auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPa } //--------------------------------------------------------------------------------------------------------------------- -auto PreapreBuiltInSAPassmark(const VPiece &piece, const VContainer *pattern, const VPassmark &passmark, - bool &ok) -> VLayoutPassmark +auto PreapreBuiltInSAPassmark(const VPiece &piece, const VContainer *pattern, const VPassmark &passmark, bool &ok) + -> VLayoutPassmark { QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wnoexcept") @@ -317,10 +318,10 @@ auto PreapreBuiltInSAPassmark(const VPiece &piece, const VContainer *pattern, co if (nodeIndex == -1) { const QString errorMsg = - QObject::tr("Passmark '%1' is not part of piece '%2'.") - .arg(pData.nodeName, piece.GetName()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + QObject::tr("Passmark '%1' is not part of piece '%2'.").arg(pData.nodeName, piece.GetName()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ok = false; return {}; } @@ -328,11 +329,11 @@ auto PreapreBuiltInSAPassmark(const VPiece &piece, const VContainer *pattern, co const QVector lines = passmark.BuiltInSAPassmark(piece, pattern); if (lines.isEmpty()) { - const QString errorMsg = - QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty.") - .arg(pData.nodeName, piece.GetName()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + const QString errorMsg = QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty.") + .arg(pData.nodeName, piece.GetName()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ok = false; return {}; } @@ -346,13 +347,14 @@ auto PreapreBuiltInSAPassmark(const VPiece &piece, const VContainer *pattern, co QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is " "empty.") .arg(pData.nodeName, piece.GetName()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ok = false; return {}; } - layoutPassmark.baseLine = ConstFirst (baseLines); + layoutPassmark.baseLine = ConstFirst(baseLines); layoutPassmark.type = pData.passmarkLineType; layoutPassmark.isBuiltIn = true; layoutPassmark.isClockwiseOpening = pData.passmarkSAPoint.IsPassmarkClockwiseOpening(); @@ -368,7 +370,7 @@ auto ConvertPassmarks(const VPiece &piece, const VContainer *pattern) -> QVector QVector layoutPassmarks; layoutPassmarks.reserve(passmarks.size()); - for(const auto &passmark : passmarks) + for (const auto &passmark : passmarks) { if (passmark.IsNull()) { @@ -403,7 +405,7 @@ auto ConvertPassmarks(const VPiece &piece, const VContainer *pattern) -> QVector VPiecePassmarkData pData = passmark.Data(); - switch(pData.passmarkAngleType) + switch (pData.passmarkAngleType) { case PassmarkAngleType::Straightforward: case PassmarkAngleType::Bisector: @@ -426,17 +428,14 @@ auto ConvertPassmarks(const VPiece &piece, const VContainer *pattern) -> QVector break; } - if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() - && (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || - not piece.IsHideMainPath()) - && pData.isMainPathNode - && pData.passmarkAngleType != PassmarkAngleType::Intersection - && pData.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft - && pData.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight - && pData.passmarkAngleType != PassmarkAngleType::Intersection2 - && pData.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft - && pData.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight - && pData.isShowSecondPassmark) + if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() && + (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) && + pData.isMainPathNode && pData.passmarkAngleType != PassmarkAngleType::Intersection && + pData.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft && + pData.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight && + pData.passmarkAngleType != PassmarkAngleType::Intersection2 && + pData.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft && + pData.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight && pData.isShowSecondPassmark) { AddBuiltInPassmark(); } @@ -487,7 +486,7 @@ auto PrepareGradationPlaceholders(const VContainer *data) -> QMap > measurements = data->DataMeasurements(); + const QMap> measurements = data->DataMeasurements(); auto i = measurements.constBegin(); while (i != measurements.constEnd()) { @@ -506,11 +505,11 @@ auto ReplacePlaceholders(const QMap &placeholders, QString lin auto TestDimension = [per, placeholders, line](const QString &placeholder, const QString &errorMsg) { - if (line.contains(per+placeholder+per) && placeholders.value(placeholder) == QChar('0')) + if (line.contains(per + placeholder + per) && placeholders.value(placeholder) == QChar('0')) { VAbstractApplication::VApp()->IsPedantic() - ? throw VException(errorMsg) - : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } }; @@ -527,7 +526,7 @@ auto ReplacePlaceholders(const QMap &placeholders, QString lin auto i = placeholders.constBegin(); while (i != placeholders.constEnd()) { - line.replace(per+i.key()+per, i.value()); + line.replace(per + i.key() + per, i.value()); ++i; } return line; @@ -539,7 +538,7 @@ auto PrepareGradationId(const QString &label, const VContainer *pattern) -> QStr const QMap placeholders = PrepareGradationPlaceholders(pattern); return ReplacePlaceholders(placeholders, label); } -} // namespace +} // namespace // Friend functions //--------------------------------------------------------------------------------------------------------------------- @@ -586,18 +585,21 @@ auto operator>>(QDataStream &dataStream, VLayoutPiece &piece) -> QDataStream & //--------------------------------------------------------------------------------------------------------------------- VLayoutPiece::VLayoutPiece() - :d(new VLayoutPieceData) -{} + : d(new VLayoutPieceData) +{ +} //--------------------------------------------------------------------------------------------------------------------- VLayoutPiece::VLayoutPiece(const VLayoutPiece &detail) // NOLINT(modernize-use-equals-default) - :VAbstractPiece(detail), d(detail.d) -{} + : VAbstractPiece(detail), + d(detail.d) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece & { - if ( &detail == this ) + if (&detail == this) { return *this; } @@ -608,12 +610,13 @@ auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece & #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW - :VAbstractPiece(std::move(detail)), d(std::move(detail.d)) -{} +VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW : VAbstractPiece(std::move(detail)), + d(std::move(detail.d)) +{ +} //--------------------------------------------------------------------------------------------------------------------- -auto VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW -> VLayoutPiece & +auto VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW->VLayoutPiece & { VAbstractPiece::operator=(detail); std::swap(d, detail.d); @@ -622,21 +625,22 @@ auto VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW -> VLayoutPie #endif //--------------------------------------------------------------------------------------------------------------------- -VLayoutPiece::~VLayoutPiece() //NOLINT(modernize-use-equals-default) -{} +VLayoutPiece::~VLayoutPiece() // NOLINT(modernize-use-equals-default) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece { - QFuture > futureSeamAllowance = - QtConcurrent::run([piece, pattern](){return piece.SeamAllowancePoints(pattern);}); + QFuture> futureSeamAllowance = + QtConcurrent::run([piece, pattern]() { return piece.SeamAllowancePoints(pattern); }); QFuture futureSeamAllowanceValid = - QtConcurrent::run([piece, pattern](){return piece.IsSeamAllowanceValid(pattern);}); - QFuture > futureMainPath = - QtConcurrent::run([piece, pattern](){return piece.MainPathPoints(pattern);}); - QFuture > futureInternalPaths = QtConcurrent::run(ConvertInternalPaths, piece, pattern); - QFuture > futurePassmarks = QtConcurrent::run(ConvertPassmarks, piece, pattern); - QFuture > futurePlaceLabels = QtConcurrent::run(ConvertPlaceLabels, piece, pattern); + QtConcurrent::run([piece, pattern]() { return piece.IsSeamAllowanceValid(pattern); }); + QFuture> futureMainPath = + QtConcurrent::run([piece, pattern]() { return piece.MainPathPoints(pattern); }); + QFuture> futureInternalPaths = QtConcurrent::run(ConvertInternalPaths, piece, pattern); + QFuture> futurePassmarks = QtConcurrent::run(ConvertPassmarks, piece, pattern); + QFuture> futurePlaceLabels = QtConcurrent::run(ConvertPlaceLabels, piece, pattern); VLayoutPiece det; @@ -655,15 +659,15 @@ auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pat if (not futureSeamAllowanceValid.result()) { - const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.") - .arg(piece.GetName()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + const QString errorMsg = QObject::tr("Piece '%1'. Seam allowance is not valid.").arg(piece.GetName()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } - det.SetContourPoints(futureMainPath.result(), - VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() ? false - : piece.IsHideMainPath()); + det.SetContourPoints(futureMainPath.result(), VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() + ? false + : piece.IsHideMainPath()); det.SetSeamAllowancePoints(futureSeamAllowance.result(), piece.IsSeamAllowance(), piece.IsSeamAllowanceBuiltIn()); det.SetInternalPaths(futureInternalPaths.result()); det.SetPassmarks(futurePassmarks.result()); @@ -673,24 +677,24 @@ auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pat // Very important to set main path first! if (det.MappedContourPath().isEmpty()) { - throw VException (tr("Piece %1 doesn't have shape.").arg(piece.GetName())); + throw VException(tr("Piece %1 doesn't have shape.").arg(piece.GetName())); } - const VPieceLabelData& data = piece.GetPieceLabelData(); + const VPieceLabelData &data = piece.GetPieceLabelData(); det.SetQuantity(data.GetQuantity()); if (data.IsVisible()) { det.SetPieceText(piece.GetName(), data, VAbstractApplication::VApp()->Settings()->GetLabelFont(), pattern); } - const VPatternLabelData& geom = piece.GetPatternLabelData(); + const VPatternLabelData &geom = piece.GetPatternLabelData(); if (geom.IsVisible()) { - VAbstractPattern* pDoc = VAbstractValApplication::VApp()->getCurrentDocument(); + VAbstractPattern *pDoc = VAbstractValApplication::VApp()->getCurrentDocument(); det.SetPatternInfo(pDoc, geom, VAbstractApplication::VApp()->Settings()->GetLabelFont(), pattern); } - const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry(); + const VGrainlineData &grainlineGeom = piece.GetGrainlineGeometry(); if (grainlineGeom.IsVisible()) { det.SetGrainline(grainlineGeom, pattern); @@ -713,8 +717,7 @@ auto VLayoutPiece::GetUniqueID() const -> QString } //--------------------------------------------------------------------------------------------------------------------- -template -auto VLayoutPiece::Map(QVector points) const -> QVector +template auto VLayoutPiece::Map(QVector points) const -> QVector { std::transform(points.begin(), points.end(), points.begin(), [this](const T &point) { return d->m_matrix.map(point); }); @@ -729,7 +732,7 @@ auto VLayoutPiece::Map(QVector points) const -> QVector template <> // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) auto VLayoutPiece::Map(QVector passmarks) const -> QVector { - for (auto & passmark : passmarks) + for (auto &passmark : passmarks) { passmark.lines = Map(passmark.lines); passmark.baseLine = d->m_matrix.map(passmark.baseLine); @@ -739,17 +742,17 @@ auto VLayoutPiece::Map(QVector passmarks) cons } //--------------------------------------------------------------------------------------------------------------------- -template <> -auto VLayoutPiece::Map(QVector points) const -> QVector +template <> auto VLayoutPiece::Map(QVector points) const -> QVector { - std::transform(points.begin(), points.end(), points.begin(), [this](VLayoutPoint point) - { - auto p = static_cast(point); // NOLINT(cppcoreguidelines-slicing) - p = d->m_matrix.map(p); - point.rx() = p.x(); - point.ry() = p.y(); - return point; - }); + std::transform(points.begin(), points.end(), points.begin(), + [this](VLayoutPoint point) + { + auto p = static_cast(point); // NOLINT(cppcoreguidelines-slicing) + p = d->m_matrix.map(p); + point.rx() = p.x(); + point.ry() = p.y(); + return point; + }); if (d->m_mirror) { std::reverse(points.begin(), points.end()); @@ -818,7 +821,7 @@ void VLayoutPiece::SetSeamAllowancePoints(const QVector &points, b } else if (not IsSeamAllowanceBuiltIn()) { - qWarning()<<"Seam allowance is empty."; + qWarning() << "Seam allowance is empty."; SetSeamAllowance(false); } } @@ -854,7 +857,7 @@ auto VLayoutPiece::GetPieceText() const -> QStringList } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutPiece::SetPieceText(const QString& qsName, const VPieceLabelData& data, const QFont &font, +void VLayoutPiece::SetPieceText(const QString &qsName, const VPieceLabelData &data, const QFont &font, const VContainer *pattern) { QPointF ptPos; @@ -866,14 +869,12 @@ void VLayoutPiece::SetPieceText(const QString& qsName, const VPieceLabelData& da return; } - QVector v; - v << ptPos - << QPointF(ptPos.x() + labelWidth, ptPos.y()) - << QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight) - << QPointF(ptPos.x(), ptPos.y() + labelHeight); + QVector v{ptPos, QPointF(ptPos.x() + labelWidth, ptPos.y()), + QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight), + QPointF(ptPos.x(), ptPos.y() + labelHeight)}; const qreal dAng = qDegreesToRadians(-labelAngle); - const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2); + const QPointF ptCenter(ptPos.x() + labelWidth / 2, ptPos.y() + labelHeight / 2); for (int i = 0; i < v.count(); ++i) { @@ -934,7 +935,7 @@ auto VLayoutPiece::GetPatternText() const -> QStringList } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutPiece::SetPatternInfo(VAbstractPattern* pDoc, const VPatternLabelData& geom, const QFont &font, +void VLayoutPiece::SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData &geom, const QFont &font, const VContainer *pattern) { QPointF ptPos; @@ -946,14 +947,12 @@ void VLayoutPiece::SetPatternInfo(VAbstractPattern* pDoc, const VPatternLabelDat return; } - QVector v; - v << ptPos - << QPointF(ptPos.x() + labelWidth, ptPos.y()) - << QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight) - << QPointF(ptPos.x(), ptPos.y() + labelHeight); + QVector v{ptPos, QPointF(ptPos.x() + labelWidth, ptPos.y()), + QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight), + QPointF(ptPos.x(), ptPos.y() + labelHeight)}; const qreal dAng = qDegreesToRadians(-labelAngle); - const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2); + const QPointF ptCenter(ptPos.x() + labelWidth / 2, ptPos.y() + labelHeight / 2); for (int i = 0; i < v.count(); ++i) { v[i] = RotatePoint(ptCenter, v.at(i), dAng); @@ -1003,7 +1002,7 @@ void VLayoutPiece::SetGrainline(const VPieceGrainline &grainline) } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutPiece::SetGrainline(const VGrainlineData& geom, const VContainer* pattern) +void VLayoutPiece::SetGrainline(const VGrainlineData &geom, const VContainer *pattern) { QScopedPointer item(GetMainPathItem()); @@ -1154,13 +1153,13 @@ void VLayoutPiece::Mirror(const QLineF &edge) m.reset(); m.translate(p2.x(), p2.y()); - m.scale(m.m11(), m.m22()*-1); + m.scale(m.m11(), m.m22() * -1); m.translate(-p2.x(), -p2.y()); d->m_matrix *= m; m.reset(); m.translate(p2.x(), p2.y()); - m.rotate(-(360-angle)); + m.rotate(-(360 - angle)); m.translate(-p2.x(), -p2.y()); d->m_matrix *= m; @@ -1235,7 +1234,7 @@ auto VLayoutPiece::isNull() const -> bool { if (not d->m_contour.isEmpty() && d->m_layoutWidth > 0) { - return not (IsSeamAllowance() && not IsSeamAllowanceBuiltIn() && not d->m_seamAllowance.isEmpty()); + return not(IsSeamAllowance() && not IsSeamAllowanceBuiltIn() && not d->m_seamAllowance.isEmpty()); } return true; } @@ -1264,7 +1263,7 @@ void VLayoutPiece::SetLayoutAllowancePoints() QVector points; CastTo(GetSeamAllowancePoints(), points); - d->m_square = qFloor(qAbs(SumTrapezoids(points)/2.0)); + d->m_square = qFloor(qAbs(SumTrapezoids(points) / 2.0)); } } else @@ -1278,7 +1277,7 @@ void VLayoutPiece::SetLayoutAllowancePoints() QVector points; CastTo(GetContourPoints(), points); - d->m_square = qFloor(qAbs(SumTrapezoids(points)/2.0)); + d->m_square = qFloor(qAbs(SumTrapezoids(points) / 2.0)); } } } @@ -1291,15 +1290,14 @@ void VLayoutPiece::SetLayoutAllowancePoints() //--------------------------------------------------------------------------------------------------------------------- auto VLayoutPiece::GetMappedExternalContourPoints() const -> QVector { - return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? GetMappedSeamAllowancePoints() : - GetMappedContourPoints(); + return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? GetMappedSeamAllowancePoints() + : GetMappedContourPoints(); } //--------------------------------------------------------------------------------------------------------------------- auto VLayoutPiece::GetExternalContourPoints() const -> QVector { - return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? GetSeamAllowancePoints() : - GetContourPoints(); + return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? GetSeamAllowancePoints() : GetContourPoints(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1336,9 +1334,9 @@ void VLayoutPiece::SetPlaceLabels(const QVector &labels) } //--------------------------------------------------------------------------------------------------------------------- -auto VLayoutPiece::MappedInternalPathsForCut(bool cut) const -> QVector > +auto VLayoutPiece::MappedInternalPathsForCut(bool cut) const -> QVector> { - QVector > paths; + QVector> paths; paths.reserve(d->m_internalPaths.size()); for (const auto &path : d->m_internalPaths) @@ -1391,7 +1389,7 @@ auto VLayoutPiece::ContourPath() const -> QPainterPath if (ConstLast(points).toPoint() != ConstFirst(points).toPoint()) { - points.append(points.at(0));// Should be always closed + points.append(points.at(0)); // Should be always closed } QPainterPath ekv; @@ -1407,7 +1405,7 @@ auto VLayoutPiece::ContourPath() const -> QPainterPath // Draw passmarks QPainterPath passmaksPath; const QVector passmarks = GetPassmarks(); - for(const auto &passmark : passmarks) + for (const auto &passmark : passmarks) { for (const auto &line : passmark.lines) { @@ -1462,7 +1460,7 @@ auto VLayoutPiece::GetItem(bool textAsPaths) const -> QGraphicsItem * for (const auto &path : d->m_internalPaths) { - auto* pathItem = new QGraphicsPathItem(item); + auto *pathItem = new QGraphicsPathItem(item); pathItem->setPath(d->m_matrix.map(path.GetPainterPath())); QPen pen = pathItem->pen(); @@ -1473,7 +1471,7 @@ auto VLayoutPiece::GetItem(bool textAsPaths) const -> QGraphicsItem * for (const auto &label : d->m_placeLabels) { - auto* pathItem = new QGraphicsPathItem(item); + auto *pathItem = new QGraphicsPathItem(item); QPen pen = pathItem->pen(); pen.setWidthF(VAbstractApplication::VApp()->Settings()->WidthHairLine()); pathItem->setPen(pen); @@ -1490,8 +1488,8 @@ auto VLayoutPiece::GetItem(bool textAsPaths) const -> QGraphicsItem * //--------------------------------------------------------------------------------------------------------------------- auto VLayoutPiece::IsLayoutAllowanceValid() const -> bool { - QVector base = (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) ? - d->m_seamAllowance : d->m_contour; + QVector base = + (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) ? d->m_seamAllowance : d->m_contour; QVector points; CastTo(base, points); return VAbstractPiece::IsAllowanceValid(points, d->m_layoutAllowance); @@ -1519,11 +1517,10 @@ auto VLayoutPiece::BiggestEdge() const -> qreal return edge; } - //--------------------------------------------------------------------------------------------------------------------- auto VLayoutPiece::MapPlaceLabelShape(PlaceLabelImg shape) const -> PlaceLabelImg { - for (auto & i : shape) + for (auto &i : shape) { i = Map(i); } @@ -1556,8 +1553,8 @@ auto VLayoutPiece::GrainlinePath(const GrainlineShape &shape) -> QPainterPath } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector &labelShape, - const VTextManager &tm, bool textAsPaths) const +void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector &labelShape, const VTextManager &tm, + bool textAsPaths) const { SCASSERT(parent != nullptr) @@ -1568,12 +1565,12 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector 0) { - dX = (dW - TextWidth(fm, qsText))/2; + dX = (dW - TextWidth(fm, qsText)) / 2; } else if ((tl.m_eAlign & Qt::AlignRight) > 0) { @@ -1632,9 +1629,9 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector(fm.ascent())/6., fnt, qsText); + path.addText(0, -static_cast(fm.ascent()) / 6., fnt, qsText); - auto* item = new QGraphicsPathItem(parent); + auto *item = new QGraphicsPathItem(parent); item->setPath(path); item->setBrush(QBrush(Qt::black)); item->setTransform(labelMatrix); @@ -1643,7 +1640,7 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVectorsetFont(fnt); item->setText(qsText); item->setTransform(labelMatrix); @@ -1772,12 +1769,12 @@ auto VLayoutPiece::Edge(const QVector &path, int i) const -> QLineF vsizetype i1, i2; if (i < path.count()) { - i1 = i-1; + i1 = i - 1; i2 = i; } else { - i1 = path.count()-1; + i1 = path.count() - 1; i2 = 0; } @@ -1799,7 +1796,7 @@ auto VLayoutPiece::EdgeByPoint(const QVector &path, const QPointF &p1) const QVector points = Map(path); auto posIter = std::find_if(points.cbegin(), points.cend(), - [&p1](const QPointF &point){ return VFuzzyComparePoints(point, p1); }); + [&p1](const QPointF &point) { return VFuzzyComparePoints(point, p1); }); if (posIter != points.cend()) { return static_cast(posIter - points.cbegin() + 1); diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 83b9537fd..e7aac10f3 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -117,7 +117,7 @@ const quint16 VTextManager::classVersion = 1; namespace { -Q_GLOBAL_STATIC(QVector, m_patternLabelLines) // NOLINT +Q_GLOBAL_STATIC(QVector, m_patternLabelLinesCache) // NOLINT } // Friend functions @@ -644,10 +644,10 @@ void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern) { m_liLines.clear(); - if (m_patternLabelLines->isEmpty() || pDoc->GetPatternWasChanged()) + if (m_patternLabelLinesCache->isEmpty() || pDoc->GetPatternWasChanged()) { QVector lines = pDoc->GetPatternLabelTemplate(); - if (lines.isEmpty() && m_patternLabelLines->isEmpty()) + if (lines.isEmpty() && m_patternLabelLinesCache->isEmpty()) { return; // Nothing to parse } @@ -660,8 +660,8 @@ void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern) } pDoc->SetPatternWasChanged(false); - *m_patternLabelLines = PrepareLines(lines); + *m_patternLabelLinesCache = PrepareLines(lines); } - m_liLines = *m_patternLabelLines; + m_liLines = *m_patternLabelLinesCache; } diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index 83274f5bb..41d06320a 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -46,8 +46,10 @@ class QMarginsF; class VCommonSettings : public QSettings { Q_OBJECT // NOLINT - public : VCommonSettings(Format format, Scope scope, const QString &organization, - const QString &application = QString(), QObject *parent = nullptr); + +public: + VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), + QObject *parent = nullptr); VCommonSettings(const QString &fileName, Format format, QObject *parent = nullptr); ~VCommonSettings() override = default; diff --git a/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h b/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h index 1be55312d..4804a5ca1 100644 --- a/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h +++ b/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h @@ -33,8 +33,8 @@ #include #include -#include "../vmisc/typedef.h" #include "../vmisc/defglobal.h" +#include "../vmisc/typedef.h" #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #include "../vmisc/diagnostic.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) @@ -46,43 +46,24 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") class VPatternLabelDataPrivate : public QSharedData { public: - VPatternLabelDataPrivate() - : m_dLabelWidth(), - m_dLabelHeight(), - m_dLabelAngle(), - m_iFontSize(0), - m_centerPin(NULL_ID), - m_topLeftPin(NULL_ID), - m_bottomRightPin(NULL_ID) - {} - - VPatternLabelDataPrivate(const VPatternLabelDataPrivate &data) - : QSharedData(data), - m_dLabelWidth(data.m_dLabelWidth), - m_dLabelHeight(data.m_dLabelHeight), - m_dLabelAngle(data.m_dLabelAngle), - m_iFontSize(data.m_iFontSize), - m_centerPin(data.m_centerPin), - m_topLeftPin(data.m_topLeftPin), - m_bottomRightPin(data.m_bottomRightPin) - {} - + VPatternLabelDataPrivate() = default; + VPatternLabelDataPrivate(const VPatternLabelDataPrivate &data) = default; ~VPatternLabelDataPrivate() = default; /** @brief m_dLabelWidth formula to calculate the width of label */ - QString m_dLabelWidth; + QString m_dLabelWidth{}; // NOLINT(misc-non-private-member-variables-in-classes) /** @brief m_dLabelHeight formula to calculate the height of label */ - QString m_dLabelHeight; + QString m_dLabelHeight{}; // NOLINT(misc-non-private-member-variables-in-classes) /** @brief m_dLabelAngle formula to calculate the rotation angle of label */ - QString m_dLabelAngle; + QString m_dLabelAngle{}; // NOLINT(misc-non-private-member-variables-in-classes) /** @brief m_iFontSize label text base font size */ - int m_iFontSize; + int m_iFontSize{0}; // NOLINT(misc-non-private-member-variables-in-classes) /** @brief m_centerPin center pin id */ - quint32 m_centerPin; + quint32 m_centerPin{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes) /** @brief m_topLeftPin top left corner pin id */ - quint32 m_topLeftPin; + quint32 m_topLeftPin{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes) /** @brief m_bottomRightPin bottom right corner pin id */ - quint32 m_bottomRightPin; + quint32 m_bottomRightPin{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes) private: Q_DISABLE_ASSIGN_MOVE(VPatternLabelDataPrivate) // NOLINT @@ -91,4 +72,3 @@ private: QT_WARNING_POP #endif // VPATTERNLABELDATA_P_H - diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index c02e2035c..13d6d1c34 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -76,7 +76,16 @@ #include #include -enum TabOrder {Paths=0, Pins=1, Labels=2, Grainline=3, Passmarks=4, PlaceLabels=5, Count=6}; +enum TabOrder +{ + Paths = 0, + Pins = 1, + Labels = 2, + Grainline = 3, + Passmarks = 4, + PlaceLabels = 5, + Count = 6 +}; namespace { @@ -120,9 +129,8 @@ void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString } // namespace //--------------------------------------------------------------------------------------------------------------------- -DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, VAbstractPattern *doc, quint32 toolId, - QWidget *parent) - : DialogSeamAllowance(data, toolId, parent) +DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, VAbstractPattern *doc, quint32 toolId, QWidget *parent) + : DialogSeamAllowance(data, toolId, parent) { SCASSERT(doc != nullptr) m_doc = doc; @@ -177,7 +185,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId, ChangeColor(uiTabPaths->labelEditName, OkColor(this)); flagMainPathIsValid = MainPathIsValid(); - m_ftb->SetCurrentIndex(TabOrder::Paths);// Show always first tab active on start. + m_ftb->SetCurrentIndex(TabOrder::Paths); // Show always first tab active on start. } //--------------------------------------------------------------------------------------------------------------------- @@ -256,7 +264,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) item->setFont(NodeFont(item->font())); item->setData(Qt::UserRole, QVariant::fromValue(record)); uiTabPaths->listWidgetCustomSA->addItem(item); - uiTabPaths->listWidgetCustomSA->setCurrentRow(uiTabPaths->listWidgetCustomSA->count()-1); + uiTabPaths->listWidgetCustomSA->setCurrentRow(uiTabPaths->listWidgetCustomSA->count() - 1); } } uiTabPaths->listWidgetCustomSA->blockSignals(false); @@ -273,7 +281,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) item->setFont(NodeFont(item->font())); item->setData(Qt::UserRole, QVariant::fromValue(path)); uiTabPaths->listWidgetInternalPaths->addItem(item); - uiTabPaths->listWidgetInternalPaths->setCurrentRow(uiTabPaths->listWidgetInternalPaths->count()-1); + uiTabPaths->listWidgetInternalPaths->setCurrentRow(uiTabPaths->listWidgetInternalPaths->count() - 1); } } @@ -289,7 +297,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) item->setFont(NodeFont(item->font())); item->setData(Qt::UserRole, QVariant::fromValue(point)); listWidget->addItem(item); - listWidget->setCurrentRow(uiTabPins->listWidgetPins->count()-1); + listWidget->setCurrentRow(uiTabPins->listWidgetPins->count() - 1); } catch (const VExceptionBadId &e) { @@ -340,9 +348,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->lineEditGradationLabel->setText(piece.GetGradationLabel()); uiTabPaths->spinBoxPriority->setValue(static_cast(piece.GetPriority())); - uiTabPaths->plainTextEditFormulaWidth->setPlainText( - VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(piece.GetFormulaSAWidth(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + uiTabPaths->plainTextEditFormulaWidth->setPlainText(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + piece.GetFormulaSAWidth(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); m_saWidth = piece.GetSAWidth(); const VPieceLabelData &ppData = piece.GetPieceLabelData(); @@ -525,7 +532,7 @@ void DialogSeamAllowance::CheckState() SCASSERT(bOk != nullptr); bOk->setEnabled(IsValid()); // In case dialog hasn't apply button - if ( bApply != nullptr && applyAllowed) + if (bApply != nullptr && applyAllowed) { bApply->setEnabled(bOk->isEnabled()); } @@ -557,8 +564,8 @@ void DialogSeamAllowance::CheckState() if (not applyAllowed) { tooltip = tooltip + QStringLiteral(" ") + - tr("To open all detail's features complete creating the main path. Please, press OK.") - + QStringLiteral(""); + tr("To open all detail's features complete creating the main path. Please, press OK.") + + QStringLiteral(""); } uiTabPaths->helpLabel->setText(tooltip); uiTabPaths->tabWidget->setTabIcon(uiTabPaths->tabWidget->indexOf(uiTabPaths->tabMainPath), QIcon()); @@ -664,7 +671,7 @@ void DialogSeamAllowance::showEvent(QShowEvent *event) resize(sz); } - isInitialized = true;//first show windows are held + isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -878,8 +885,8 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos) void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos) { const int row = uiTabPaths->listWidgetInternalPaths->currentRow(); - if (uiTabPaths->listWidgetInternalPaths->count() == 0 || row == -1 - || row >= uiTabPaths->listWidgetInternalPaths->count()) + if (uiTabPaths->listWidgetInternalPaths->count() == 0 || row == -1 || + row >= uiTabPaths->listWidgetInternalPaths->count()) { return; } @@ -935,9 +942,8 @@ void DialogSeamAllowance::ShowPinsContextMenu(const QPoint &pos) void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) { const int row = uiTabPlaceLabels->listWidgetPlaceLabels->currentRow(); - if (uiTabPlaceLabels->listWidgetPlaceLabels->count() == 0 - || row == -1 - || row >= uiTabPlaceLabels->listWidgetPlaceLabels->count()) + if (uiTabPlaceLabels->listWidgetPlaceLabels->count() == 0 || row == -1 || + row >= uiTabPlaceLabels->listWidgetPlaceLabels->count()) { return; } @@ -963,10 +969,9 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) newLabel.SetLabelType(type); m_newPlaceLabels.insert(labelId, newLabel); - QPointer saveCommand = - new SavePlaceLabelOptions(toolId, currentLabel, newLabel, - VAbstractValApplication::VApp()->getCurrentDocument(), - const_cast(data), labelId); + QPointer saveCommand = new SavePlaceLabelOptions( + toolId, currentLabel, newLabel, VAbstractValApplication::VApp()->getCurrentDocument(), + const_cast(data), labelId); m_undoStack.append(saveCommand); UpdateCurrentPlaceLabelRecords(); }; @@ -1096,9 +1101,9 @@ void DialogSeamAllowance::NodeChanged(int index) QString w1Formula = node.GetFormulaSABefore(); EnableDefButton(uiTabPaths->pushButtonDefBefore, w1Formula); - w1Formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(w1Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - if (w1Formula.length() > 80)// increase height if needed. + w1Formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + w1Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + if (w1Formula.length() > 80) // increase height if needed. { this->DeployWidthBeforeFormulaTextEdit(); } @@ -1111,9 +1116,9 @@ void DialogSeamAllowance::NodeChanged(int index) QString w2Formula = node.GetFormulaSAAfter(); EnableDefButton(uiTabPaths->pushButtonDefAfter, w2Formula); - w2Formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(w2Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - if (w2Formula.length() > 80)// increase height if needed. + w2Formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + w2Formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + if (w2Formula.length() > 80) // increase height if needed. { this->DeployWidthAfterFormulaTextEdit(); } @@ -1288,8 +1293,8 @@ void DialogSeamAllowance::NodeAngleChanged(int index) //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ReturnDefBefore() { - const QString def = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString def = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); uiTabPaths->plainTextEditFormulaWidthBefore->setPlainText(def); if (auto *button = qobject_cast(sender())) { @@ -1300,8 +1305,8 @@ void DialogSeamAllowance::ReturnDefBefore() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ReturnDefAfter() { - const QString def = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString def = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + currentSeamAllowance, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); uiTabPaths->plainTextEditFormulaWidthAfter->setPlainText(def); if (auto *button = qobject_cast(sender())) { @@ -1328,7 +1333,7 @@ void DialogSeamAllowance::CustomSAChanged(int row) return; } - const QListWidgetItem *item = uiTabPaths->listWidgetCustomSA->item( row ); + const QListWidgetItem *item = uiTabPaths->listWidgetCustomSA->item(row); SCASSERT(item != nullptr); const auto record = qvariant_cast(item->data(Qt::UserRole)); @@ -1380,10 +1385,9 @@ void DialogSeamAllowance::PathDialogClosed(int result) VPiecePath newPath = dialogTool->GetPiecePath(); m_newPaths.insert(dialogTool->GetToolId(), newPath); - QPointer saveCommand = - new SavePiecePathOptions(toolId, currentPath, newPath, - VAbstractValApplication::VApp()->getCurrentDocument(), - const_cast(data), dialogTool->GetToolId()); + QPointer saveCommand = new SavePiecePathOptions( + toolId, currentPath, newPath, VAbstractValApplication::VApp()->getCurrentDocument(), + const_cast(data), dialogTool->GetToolId()); m_undoStack.append(saveCommand); UpdateCurrentCustomSARecord(); UpdateCurrentInternalPathRecord(); @@ -1391,7 +1395,7 @@ void DialogSeamAllowance::PathDialogClosed(int result) catch (const VExceptionBadId &e) { qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Error. Can't save piece path.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); } } delete m_dialog; @@ -1409,7 +1413,7 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result) { VPlaceLabelItem currentLabel = CurrentPlaceLabel(dialogTool->GetToolId()); - const QHash > *vars = data->DataVariables(); + const QHash> *vars = data->DataVariables(); const qreal w = qAbs(Visualization::FindLengthFromUser(dialogTool->GetWidth(), vars, false)); const qreal h = qAbs(Visualization::FindLengthFromUser(dialogTool->GetHeight(), vars, false)); @@ -1417,7 +1421,7 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result) const qreal v = Visualization::FindValFromUser(dialogTool->GetFormulaVisible(), vars, false); qDebug() << w << h << a << v; - VPlaceLabelItem newLabel = VPlaceLabelItem(); + VPlaceLabelItem newLabel = VPlaceLabelItem(); newLabel.setName(currentLabel.name()); newLabel.setX(currentLabel.x()); newLabel.setY(currentLabel.y()); @@ -1433,17 +1437,16 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result) m_newPlaceLabels.insert(dialogTool->GetToolId(), newLabel); - QPointer saveCommand = - new SavePlaceLabelOptions(toolId, currentLabel, newLabel, - VAbstractValApplication::VApp()->getCurrentDocument(), - const_cast(data), dialogTool->GetToolId()); + QPointer saveCommand = new SavePlaceLabelOptions( + toolId, currentLabel, newLabel, VAbstractValApplication::VApp()->getCurrentDocument(), + const_cast(data), dialogTool->GetToolId()); m_undoStack.append(saveCommand); UpdateCurrentPlaceLabelRecords(); } catch (const VExceptionBadId &e) { qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Error. Can't save piece path.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); } } delete m_dialog; @@ -1466,7 +1469,7 @@ void DialogSeamAllowance::FancyTabChanged(int index) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") - switch(index) + switch (index) { case TabOrder::Paths: m_tabPaths->show(); @@ -1683,8 +1686,8 @@ void DialogSeamAllowance::UpdateGrainlineValues() for (std::size_t i = 0; i < 2; ++i) { - QLabel* plbVal; - QLabel* plbText; + QLabel *plbVal; + QLabel *plbText; QString qsUnit; if (i == 0) { @@ -1705,8 +1708,8 @@ void DialogSeamAllowance::UpdateGrainlineValues() QString qsVal; try { - qsFormula = VAbstractApplication::VApp()->TrVars() - ->FormulaFromUser(qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + qsFormula = VAbstractApplication::VApp()->TrVars()->FormulaFromUser( + qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); Calculator cal; qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula); if (qIsInf(dVal) || qIsNaN(dVal)) @@ -1757,8 +1760,8 @@ void DialogSeamAllowance::UpdateDetailLabelValues() for (std::size_t i = 0; i < 3; ++i) { - QLabel* plbVal; - QLabel* plbText; + QLabel *plbVal; + QLabel *plbText; QString qsUnit; if (i == 0) { @@ -1786,8 +1789,8 @@ void DialogSeamAllowance::UpdateDetailLabelValues() try { - qsFormula = VAbstractApplication::VApp()->TrVars() - ->FormulaFromUser(qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + qsFormula = VAbstractApplication::VApp()->TrVars()->FormulaFromUser( + qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); Calculator cal; qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula); if (qIsInf(dVal) || qIsNaN(dVal)) @@ -1819,7 +1822,7 @@ void DialogSeamAllowance::UpdateDetailLabelValues() flagDLAngle = bFormulasOK[2]; flagDLFormulas = bFormulasOK[0] && bFormulasOK[1]; - if (not flagDLAngle || not (flagDLFormulas || flagDPin) || not flagPLAngle || not (flagPLFormulas || flagPPin)) + if (not flagDLAngle || not(flagDLFormulas || flagDPin) || not flagPLAngle || not(flagPLFormulas || flagPPin)) { m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning"), @@ -1842,8 +1845,8 @@ void DialogSeamAllowance::UpdatePatternLabelValues() for (std::size_t i = 0; i < 3; ++i) { - QLabel* plbVal; - QLabel* plbText; + QLabel *plbVal; + QLabel *plbText; QString qsUnit; if (i == 0) { @@ -1870,8 +1873,8 @@ void DialogSeamAllowance::UpdatePatternLabelValues() QString qsVal; try { - qsFormula = VAbstractApplication::VApp()->TrVars() - ->FormulaFromUser(qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + qsFormula = VAbstractApplication::VApp()->TrVars()->FormulaFromUser( + qsFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); Calculator cal; qreal dVal = cal.EvalFormula(data->DataVariables(), qsFormula); if (qIsInf(dVal) || qIsNaN(dVal)) @@ -1903,7 +1906,7 @@ void DialogSeamAllowance::UpdatePatternLabelValues() flagPLAngle = bFormulasOK[2]; flagPLFormulas = bFormulasOK[0] && bFormulasOK[1]; - if (not flagDLAngle || not (flagDLFormulas || flagDPin) || not flagPLAngle || not (flagPLFormulas || flagPPin)) + if (not flagDLAngle || not(flagDLFormulas || flagDPin) || not flagPLAngle || not(flagPLFormulas || flagPPin)) { m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning"), @@ -2041,7 +2044,7 @@ void DialogSeamAllowance::EnabledManualPassmarkAngle() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::EditGrainlineFormula() { - QPlainTextEdit* pleFormula; + QPlainTextEdit *pleFormula; bool bCheckZero; QString title; @@ -2092,7 +2095,7 @@ void DialogSeamAllowance::EditGrainlineFormula() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::EditDLFormula() { - QPlainTextEdit* pleFormula; + QPlainTextEdit *pleFormula; bool bCheckZero; QString title; @@ -2152,7 +2155,7 @@ void DialogSeamAllowance::EditDLFormula() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::EditPLFormula() { - QPlainTextEdit* pleFormula; + QPlainTextEdit *pleFormula; bool bCheckZero; QString title; @@ -2218,7 +2221,7 @@ void DialogSeamAllowance::DeployGrainlineRotation() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::DeployGrainlineLength() { - DeployFormula(this,uiTabGrainline->lineEditLenFormula, uiTabGrainline->pushButtonShowLen, m_iLenBaseHeight); + DeployFormula(this, uiTabGrainline->lineEditLenFormula, uiTabGrainline->pushButtonShowLen, m_iLenBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- @@ -2594,7 +2597,7 @@ void DialogSeamAllowance::GrainlinePinPointChanged() else { flagGPin = false; - topPinId == NULL_ID && bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; + topPinId == NULL_ID &&bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; if (not flagGFormulas && not flagGPin) { @@ -2628,7 +2631,7 @@ void DialogSeamAllowance::DetailPinPointChanged() else { flagDPin = false; - topPinId == NULL_ID && bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; + topPinId == NULL_ID &&bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning"), @@ -2662,7 +2665,7 @@ void DialogSeamAllowance::PatternPinPointChanged() else { flagPPin = false; - topPinId == NULL_ID && bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; + topPinId == NULL_ID &&bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning"), @@ -2762,7 +2765,7 @@ auto DialogSeamAllowance::CreatePiece() const -> VPiece piece.GetGrainlineGeometry().SetVisible(uiTabGrainline->groupBoxGrainline->isChecked()); piece.GetGrainlineGeometry().SetArrowType( - static_cast(uiTabGrainline->comboBoxArrow->currentData().toInt())); + static_cast(uiTabGrainline->comboBoxArrow->currentData().toInt())); if (not flagGPin) { @@ -2811,13 +2814,13 @@ auto DialogSeamAllowance::GetPathName(quint32 path, bool reverse) const -> QStri //--------------------------------------------------------------------------------------------------------------------- auto DialogSeamAllowance::MainPathIsValid() const -> bool { - if(CreatePiece().MainPathPoints(data).count() < 3) + if (CreatePiece().MainPathPoints(data).count() < 3) { uiTabPaths->helpLabel->setText(DialogWarningIcon() + tr("You need more points!")); return false; } - if(not MainPathIsClockwise()) + if (not MainPathIsClockwise()) { uiTabPaths->helpLabel->setText(DialogWarningIcon() + tr("You have to choose points in a clockwise direction!")); return false; @@ -2877,7 +2880,7 @@ auto DialogSeamAllowance::MainPathIsClockwise() const -> bool QVector points; CastTo(CreatePiece().MainPathPoints(data), points); - if(points.count() < 3) + if (points.count() < 3) { return false; } @@ -2911,7 +2914,7 @@ void DialogSeamAllowance::InitNodesList() if (index != -1) { uiTabPaths->comboBoxNodes->setCurrentIndex(index); - NodeChanged(index);// Need in case combox index was not changed + NodeChanged(index); // Need in case combox index was not changed } else { @@ -2944,7 +2947,7 @@ void DialogSeamAllowance::InitPassmarksList() if (index != -1) { uiTabPassmarks->comboBoxPassmarks->setCurrentIndex(index); - PassmarkChanged(index);// Need in case combox index was not changed + PassmarkChanged(index); // Need in case combox index was not changed } else { @@ -2974,7 +2977,7 @@ auto DialogSeamAllowance::GetLastId() const -> quint32 const int count = uiTabPaths->listWidgetMainPath->count(); if (count > 0) { - QListWidgetItem *item = uiTabPaths->listWidgetMainPath->item(count-1); + QListWidgetItem *item = uiTabPaths->listWidgetMainPath->item(count - 1); const auto node = qvariant_cast(item->data(Qt::UserRole)); return node.GetId(); } @@ -3131,31 +3134,33 @@ void DialogSeamAllowance::InitMainPathTab() connect(uiTabPaths->listWidgetMainPath, &QListWidget::itemSelectionChanged, this, &DialogSeamAllowance::SetMoveControls); - connect(uiTabPaths->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, [this]() - { - ValidObjects(MainPathIsValid()); - }); + connect(uiTabPaths->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, + [this]() { ValidObjects(MainPathIsValid()); }); - connect(uiTabPaths->toolButtonTop, &QToolButton::clicked, this, [this]() - { - MoveListRowTop(uiTabPaths->listWidgetMainPath); - ValidObjects(MainPathIsValid()); - }); - connect(uiTabPaths->toolButtonUp, &QToolButton::clicked, this, [this]() - { - MoveListRowUp(uiTabPaths->listWidgetMainPath); - ValidObjects(MainPathIsValid()); - }); - connect(uiTabPaths->toolButtonDown, &QToolButton::clicked, this, [this]() - { - MoveListRowDown(uiTabPaths->listWidgetMainPath); - ValidObjects(MainPathIsValid()); - }); - connect(uiTabPaths->toolButtonBottom, &QToolButton::clicked, this, [this]() - { - MoveListRowBottom(uiTabPaths->listWidgetMainPath); - ValidObjects(MainPathIsValid()); - }); + connect(uiTabPaths->toolButtonTop, &QToolButton::clicked, this, + [this]() + { + MoveListRowTop(uiTabPaths->listWidgetMainPath); + ValidObjects(MainPathIsValid()); + }); + connect(uiTabPaths->toolButtonUp, &QToolButton::clicked, this, + [this]() + { + MoveListRowUp(uiTabPaths->listWidgetMainPath); + ValidObjects(MainPathIsValid()); + }); + connect(uiTabPaths->toolButtonDown, &QToolButton::clicked, this, + [this]() + { + MoveListRowDown(uiTabPaths->listWidgetMainPath); + ValidObjects(MainPathIsValid()); + }); + connect(uiTabPaths->toolButtonBottom, &QToolButton::clicked, this, + [this]() + { + MoveListRowBottom(uiTabPaths->listWidgetMainPath); + ValidObjects(MainPathIsValid()); + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -3169,21 +3174,23 @@ void DialogSeamAllowance::InitPieceTab() uiTabPaths->lineEditName->setClearButtonEnabled(true); uiTabPaths->lineEditName->setText(GetDefaultPieceName()); - connect(uiTabPaths->checkBoxForbidFlipping, &QCheckBox::stateChanged, this, [this](int state) - { - if (state == Qt::Checked) - { - uiTabPaths->checkBoxForceFlipping->setChecked(false); - } - }); + connect(uiTabPaths->checkBoxForbidFlipping, &QCheckBox::stateChanged, this, + [this](int state) + { + if (state == Qt::Checked) + { + uiTabPaths->checkBoxForceFlipping->setChecked(false); + } + }); - connect(uiTabPaths->checkBoxForceFlipping, &QCheckBox::stateChanged, this, [this](int state) - { - if (state == Qt::Checked) - { - uiTabPaths->checkBoxForbidFlipping->setChecked(false); - } - }); + connect(uiTabPaths->checkBoxForceFlipping, &QCheckBox::stateChanged, this, + [this](int state) + { + if (state == Qt::Checked) + { + uiTabPaths->checkBoxForbidFlipping->setChecked(false); + } + }); VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); uiTabPaths->checkBoxForbidFlipping->setChecked(settings->GetForbidWorkpieceFlipping()); @@ -3219,31 +3226,33 @@ void DialogSeamAllowance::InitSeamAllowanceTab() m_timerWidthAfter->setSingleShot(true); connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthAfter); - connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, [this](bool enable) - { - uiTabPaths->checkBoxBuiltIn->setEnabled(enable); + connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, + [this](bool enable) + { + uiTabPaths->checkBoxBuiltIn->setEnabled(enable); - if (not enable) - { - uiTabPaths->groupBoxAutomatic->setEnabled(enable); - uiTabPaths->groupBoxCustom->setEnabled(enable); - } - else - { - emit uiTabPaths->checkBoxBuiltIn->toggled(uiTabPaths->checkBoxBuiltIn->isChecked()); - } - }); + if (not enable) + { + uiTabPaths->groupBoxAutomatic->setEnabled(enable); + uiTabPaths->groupBoxCustom->setEnabled(enable); + } + else + { + emit uiTabPaths->checkBoxBuiltIn->toggled(uiTabPaths->checkBoxBuiltIn->isChecked()); + } + }); - connect(uiTabPaths->checkBoxBuiltIn, &QCheckBox::toggled, this, [this](bool enable) - { - uiTabPaths->groupBoxAutomatic->setEnabled(not enable); - uiTabPaths->groupBoxCustom->setEnabled(not enable); + connect(uiTabPaths->checkBoxBuiltIn, &QCheckBox::toggled, this, + [this](bool enable) + { + uiTabPaths->groupBoxAutomatic->setEnabled(not enable); + uiTabPaths->groupBoxCustom->setEnabled(not enable); - if (not enable) - { - InitNodesList(); - } - }); + if (not enable) + { + InitNodesList(); + } + }); // init the default seam allowance, convert the value if app unit is different than pattern unit m_saWidth = UnitConvertor(VAbstractApplication::VApp()->Settings()->GetDefaultSeamAllowance(), @@ -3268,36 +3277,30 @@ void DialogSeamAllowance::InitSeamAllowanceTab() &DialogSeamAllowance::ShowCustomSAContextMenu); connect(uiTabPaths->listWidgetCustomSA, &QListWidget::currentRowChanged, this, &DialogSeamAllowance::CustomSAChanged); - connect(uiTabPaths->comboBoxStartPoint, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogSeamAllowance::CSAStartPointChanged); + connect(uiTabPaths->comboBoxStartPoint, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogSeamAllowance::CSAStartPointChanged); connect(uiTabPaths->comboBoxEndPoint, QOverload::of(&QComboBox::currentIndexChanged), this, &DialogSeamAllowance::CSAEndPointChanged); - connect(uiTabPaths->comboBoxIncludeType, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogSeamAllowance::CSAIncludeTypeChanged); + connect(uiTabPaths->comboBoxIncludeType, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogSeamAllowance::CSAIncludeTypeChanged); connect(uiTabPaths->toolButtonExprWidth, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidth); connect(uiTabPaths->toolButtonExprBefore, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthBefore); connect(uiTabPaths->toolButtonExprAfter, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthAfter); - connect(uiTabPaths->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, [this]() - { - m_timerWidth->start(formulaTimerTimeout); - }); + connect(uiTabPaths->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, + [this]() { m_timerWidth->start(formulaTimerTimeout); }); - connect(uiTabPaths->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this, [this]() - { - m_timerWidthBefore->start(formulaTimerTimeout); - }); + connect(uiTabPaths->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this, + [this]() { m_timerWidthBefore->start(formulaTimerTimeout); }); - connect(uiTabPaths->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this, [this]() - { - m_timerWidthAfter->start(formulaTimerTimeout); - }); + connect(uiTabPaths->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this, + [this]() { m_timerWidthAfter->start(formulaTimerTimeout); }); connect(uiTabPaths->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogSeamAllowance::DeployWidthFormulaTextEdit); - connect(uiTabPaths->pushButtonGrowWidthBefore, &QPushButton::clicked, - this, &DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit); + connect(uiTabPaths->pushButtonGrowWidthBefore, &QPushButton::clicked, this, + &DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit); connect(uiTabPaths->pushButtonGrowWidthAfter, &QPushButton::clicked, this, &DialogSeamAllowance::DeployWidthAfterFormulaTextEdit); } @@ -3398,10 +3401,10 @@ void DialogSeamAllowance::InitLabelsTab() InitPinPoint(uiTabLabels->comboBoxDLTopLeftPin); InitPinPoint(uiTabLabels->comboBoxDLBottomRightPin); - connect(uiTabLabels->comboBoxDLTopLeftPin, &QComboBox::currentTextChanged, - this, &DialogSeamAllowance::DetailPinPointChanged); - connect(uiTabLabels->comboBoxDLBottomRightPin, &QComboBox::currentTextChanged, - this, &DialogSeamAllowance::DetailPinPointChanged); + connect(uiTabLabels->comboBoxDLTopLeftPin, &QComboBox::currentTextChanged, this, + &DialogSeamAllowance::DetailPinPointChanged); + connect(uiTabLabels->comboBoxDLBottomRightPin, &QComboBox::currentTextChanged, this, + &DialogSeamAllowance::DetailPinPointChanged); connect(uiTabLabels->pushButtonDLWidth, &QPushButton::clicked, this, &DialogSeamAllowance::EditDLFormula); connect(uiTabLabels->pushButtonDLHeight, &QPushButton::clicked, this, &DialogSeamAllowance::EditDLFormula); @@ -3429,10 +3432,10 @@ void DialogSeamAllowance::InitLabelsTab() InitPinPoint(uiTabLabels->comboBoxPLTopLeftPin); InitPinPoint(uiTabLabels->comboBoxPLBottomRightPin); - connect(uiTabLabels->comboBoxPLTopLeftPin, &QComboBox::currentTextChanged, - this, &DialogSeamAllowance::PatternPinPointChanged); - connect(uiTabLabels->comboBoxPLBottomRightPin, &QComboBox::currentTextChanged, - this, &DialogSeamAllowance::PatternPinPointChanged); + connect(uiTabLabels->comboBoxPLTopLeftPin, &QComboBox::currentTextChanged, this, + &DialogSeamAllowance::PatternPinPointChanged); + connect(uiTabLabels->comboBoxPLBottomRightPin, &QComboBox::currentTextChanged, this, + &DialogSeamAllowance::PatternPinPointChanged); connect(uiTabLabels->pushButtonPLWidth, &QPushButton::clicked, this, &DialogSeamAllowance::EditPLFormula); connect(uiTabLabels->pushButtonPLHeight, &QPushButton::clicked, this, &DialogSeamAllowance::EditPLFormula); @@ -3488,10 +3491,10 @@ void DialogSeamAllowance::InitLabelsTab() connect(uiTabLabels->pushButtonPatternMaterials, &QPushButton::clicked, this, &DialogSeamAllowance::ManagePatternMaterials); - connect(uiTabLabels->comboBoxDateFormat, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogSeamAllowance::PatternLabelDataChanged); - connect(uiTabLabels->comboBoxTimeFormat, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->comboBoxDateFormat, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogSeamAllowance::PatternLabelDataChanged); + connect(uiTabLabels->comboBoxTimeFormat, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogSeamAllowance::PatternLabelDataChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -3547,10 +3550,10 @@ void DialogSeamAllowance::InitGrainlineTab() InitPinPoint(uiTabGrainline->comboBoxGrainlineTopPin); InitPinPoint(uiTabGrainline->comboBoxGrainlineBottomPin); - connect(uiTabGrainline->comboBoxGrainlineTopPin, &QComboBox::currentTextChanged, - this, &DialogSeamAllowance::GrainlinePinPointChanged); - connect(uiTabGrainline->comboBoxGrainlineBottomPin, &QComboBox::currentTextChanged, - this, &DialogSeamAllowance::GrainlinePinPointChanged); + connect(uiTabGrainline->comboBoxGrainlineTopPin, &QComboBox::currentTextChanged, this, + &DialogSeamAllowance::GrainlinePinPointChanged); + connect(uiTabGrainline->comboBoxGrainlineBottomPin, &QComboBox::currentTextChanged, this, + &DialogSeamAllowance::GrainlinePinPointChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -3608,19 +3611,19 @@ void DialogSeamAllowance::InitPassmarksTab() // notch list InitPassmarksList(); - connect(uiTabPassmarks->comboBoxPassmarks, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogSeamAllowance::PassmarkChanged); + connect(uiTabPassmarks->comboBoxPassmarks, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogSeamAllowance::PassmarkChanged); #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - connect(uiTabPassmarks->buttonGroupLineType, QOverload::of(&QButtonGroup::buttonClicked), - this, &DialogSeamAllowance::PassmarkLineTypeChanged); - connect(uiTabPassmarks->buttonGroupAngleType, QOverload::of(&QButtonGroup::buttonClicked), - this, &DialogSeamAllowance::PassmarkAngleTypeChanged); + connect(uiTabPassmarks->buttonGroupLineType, QOverload::of(&QButtonGroup::buttonClicked), this, + &DialogSeamAllowance::PassmarkLineTypeChanged); + connect(uiTabPassmarks->buttonGroupAngleType, QOverload::of(&QButtonGroup::buttonClicked), this, + &DialogSeamAllowance::PassmarkAngleTypeChanged); #else - connect(uiTabPassmarks->buttonGroupLineType, &QButtonGroup::idClicked, - this, &DialogSeamAllowance::PassmarkLineTypeChanged); - connect(uiTabPassmarks->buttonGroupAngleType, &QButtonGroup::idClicked, - this, &DialogSeamAllowance::PassmarkAngleTypeChanged); + connect(uiTabPassmarks->buttonGroupLineType, &QButtonGroup::idClicked, this, + &DialogSeamAllowance::PassmarkLineTypeChanged); + connect(uiTabPassmarks->buttonGroupAngleType, &QButtonGroup::idClicked, this, + &DialogSeamAllowance::PassmarkAngleTypeChanged); #endif connect(uiTabPassmarks->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this, &DialogSeamAllowance::PassmarkShowSecondChanged); @@ -3632,15 +3635,16 @@ 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::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); } @@ -3677,8 +3681,8 @@ auto DialogSeamAllowance::UndoStack() -> QVector> & //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula) { - const QString width = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString width = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (width.length() > 80) { @@ -3700,8 +3704,8 @@ void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula) //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetFormulaPassmarkLength(const QString &formula) { - const QString width = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString width = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (width.length() > 80) { @@ -3795,8 +3799,8 @@ void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula) angleFormula = '0'; } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3815,8 +3819,8 @@ void DialogSeamAllowance::SetGrainlineLength(QString lengthFormula) lengthFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(lengthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + lengthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3836,8 +3840,8 @@ void DialogSeamAllowance::SetDLWidth(QString widthFormula) widthFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(widthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + widthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3857,8 +3861,8 @@ void DialogSeamAllowance::SetDLHeight(QString heightFormula) heightFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(heightFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + heightFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3878,8 +3882,8 @@ void DialogSeamAllowance::SetDLAngle(QString angleFormula) angleFormula = '0'; } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3899,8 +3903,8 @@ void DialogSeamAllowance::SetPLWidth(QString widthFormula) widthFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(widthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + widthFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3920,8 +3924,8 @@ void DialogSeamAllowance::SetPLHeight(QString heightFormula) heightFormula = QString().setNum(UnitConvertor(10, Unit::Cm, *data->GetPatternUnit())); } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(heightFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + heightFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3941,8 +3945,8 @@ void DialogSeamAllowance::SetPLAngle(QString angleFormula) angleFormula = '0'; } - const QString formula = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + angleFormula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. if (formula.length() > 80) { @@ -3961,8 +3965,8 @@ auto DialogSeamAllowance::CurrentRect() const -> QRectF 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)); + 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; } @@ -4021,7 +4025,7 @@ auto DialogSeamAllowance::GetDefaultPieceName() const -> QString QString name = defName; int i = 0; - while(names.contains(name)) + while (names.contains(name)) { name = defName + QStringLiteral("_%1").arg(++i); } @@ -4149,39 +4153,39 @@ void DialogSeamAllowance::InitGradationPlaceholders() { QString label = VAbstractValApplication::VApp()->GetDimensionHeightLabel(); - m_gradationPlaceholders.insert(pl_heightLabel, qMakePair(tr("Height label", "dimension"), - not label.isEmpty() ? label : heightValue)); + m_gradationPlaceholders.insert( + pl_heightLabel, qMakePair(tr("Height label", "dimension"), not label.isEmpty() ? label : heightValue)); m_gradationPlaceholders.insert(pl_dimensionXLabel, qMakePair(tr("Dimension X label", "dimension"), not label.isEmpty() ? label : heightValue)); label = VAbstractValApplication::VApp()->GetDimensionSizeLabel(); - m_gradationPlaceholders.insert(pl_sizeLabel, qMakePair(tr("Size label", "dimension"), - not label.isEmpty() ? label : sizeValue)); + m_gradationPlaceholders.insert( + pl_sizeLabel, qMakePair(tr("Size label", "dimension"), not label.isEmpty() ? label : sizeValue)); m_gradationPlaceholders.insert(pl_dimensionYLabel, qMakePair(tr("Dimension Y label", "dimension"), not label.isEmpty() ? label : sizeValue)); label = VAbstractValApplication::VApp()->GetDimensionHipLabel(); - m_gradationPlaceholders.insert(pl_hipLabel, qMakePair(tr("Hip label", "dimension"), - not label.isEmpty() ? label : hipValue)); + m_gradationPlaceholders.insert(pl_hipLabel, + qMakePair(tr("Hip label", "dimension"), not label.isEmpty() ? label : hipValue)); m_gradationPlaceholders.insert(pl_dimensionZLabel, qMakePair(tr("Dimension Z label", "dimension"), not label.isEmpty() ? label : hipValue)); label = VAbstractValApplication::VApp()->GetDimensionWaistLabel(); - m_gradationPlaceholders.insert(pl_waistLabel, qMakePair(tr("Waist label", "dimension"), - not label.isEmpty() ? label : waistValue)); + m_gradationPlaceholders.insert( + pl_waistLabel, qMakePair(tr("Waist label", "dimension"), not label.isEmpty() ? label : waistValue)); m_gradationPlaceholders.insert(pl_dimensionWLabel, qMakePair(tr("Dimension W label", "dimension"), not label.isEmpty() ? label : waistValue)); } { - const QMap > measurements = data->DataMeasurements(); + const QMap> measurements = data->DataMeasurements(); auto i = measurements.constBegin(); while (i != measurements.constEnd()) { QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText(); - m_gradationPlaceholders.insert(pl_measurement + i.key(), - qMakePair(tr("Measurement: %1").arg(description), - QString::number(*i.value()->GetValue()))); + m_gradationPlaceholders.insert( + pl_measurement + i.key(), + qMakePair(tr("Measurement: %1").arg(description), QString::number(*i.value()->GetValue()))); ++i; } } @@ -4421,7 +4425,7 @@ void DialogSeamAllowance::SetMoveControls() uiTabPaths->toolButtonDown->setEnabled(true); uiTabPaths->toolButtonBottom->setEnabled(true); } - else if (uiTabPaths->listWidgetMainPath->currentRow() == uiTabPaths->listWidgetMainPath->count()-1) + else if (uiTabPaths->listWidgetMainPath->currentRow() == uiTabPaths->listWidgetMainPath->count() - 1) { uiTabPaths->toolButtonTop->setEnabled(true); uiTabPaths->toolButtonUp->setEnabled(true); @@ -4448,9 +4452,10 @@ void DialogSeamAllowance::EditPatternLabel() { if (m_patternLabelDataChanged && m_askSavePatternLabelData) { - QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Save label data."), - tr("Label data were changed. Do you want to save them before editing label template?"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); + QMessageBox::StandardButton answer = QMessageBox::question( + this, tr("Save label data."), + tr("Label data were changed. Do you want to save them before editing label template?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (answer == QMessageBox::Yes) { diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index c9da229fa..784f89b7c 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -36,14 +36,14 @@ namespace Ui { - class DialogSeamAllowance; - class TabPaths; - class TabLabels; - class TabGrainline; - class TabPins; - class TabPassmarks; - class TabPlaceLabels; -} +class DialogSeamAllowance; +class TabPaths; +class TabLabels; +class TabGrainline; +class TabPins; +class TabPassmarks; +class TabPlaceLabels; +} // namespace Ui class VisPieceSpecialPoints; class FancyTabBar; @@ -54,8 +54,7 @@ class DialogSeamAllowance : public DialogTool Q_OBJECT // NOLINT public: - DialogSeamAllowance(const VContainer *data, VAbstractPattern *doc, quint32 toolId, - QWidget *parent = nullptr); + DialogSeamAllowance(const VContainer *data, VAbstractPattern *doc, quint32 toolId, QWidget *parent = nullptr); DialogSeamAllowance(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); ~DialogSeamAllowance() override; @@ -177,11 +176,11 @@ private: Q_DISABLE_COPY_MOVE(DialogSeamAllowance) // NOLINT Ui::DialogSeamAllowance *ui; - Ui::TabPaths *uiTabPaths; - Ui::TabLabels *uiTabLabels; - Ui::TabGrainline *uiTabGrainline; - Ui::TabPins *uiTabPins; - Ui::TabPassmarks *uiTabPassmarks; + Ui::TabPaths *uiTabPaths; + Ui::TabLabels *uiTabLabels; + Ui::TabGrainline *uiTabGrainline; + Ui::TabPins *uiTabPins; + Ui::TabPassmarks *uiTabPassmarks; Ui::TabPlaceLabels *uiTabPlaceLabels; QWidget *m_tabPaths{nullptr}; diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 939f5846f..80fb36787 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -57,14 +57,11 @@ class VToolSeamAllowance : public VInteractiveTool, public QGraphicsPathItem public: ~VToolSeamAllowance() override = default; - static auto Create(const QPointer &dialog, - VMainGraphicsScene *scene, - VAbstractPattern *doc, + static auto Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) -> VToolSeamAllowance *; static auto Create(VToolSeamAllowanceInitData &initData) -> VToolSeamAllowance *; - static auto Duplicate(const QPointer &dialog, - VMainGraphicsScene *scene, - VAbstractPattern *doc) -> VToolSeamAllowance *; + static auto Duplicate(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc) + -> VToolSeamAllowance *; static auto Duplicate(VToolSeamAllowanceInitData &initData) -> VToolSeamAllowance *; static const quint8 pieceVersion; @@ -89,32 +86,16 @@ public: void RemoveWithConfirm(bool ask); - static void InsertNodes(const QVector &nodes, - quint32 pieceId, - VMainGraphicsScene *scene, - VContainer *data, - VAbstractPattern *doc); + static void InsertNodes(const QVector &nodes, quint32 pieceId, VMainGraphicsScene *scene, + VContainer *data, VAbstractPattern *doc); - static void AddAttributes(VAbstractPattern *doc, - QDomElement &domElement, - quint32 id, - const VPiece &piece); + static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiece &piece); static void AddCSARecord(VAbstractPattern *doc, QDomElement &domElement, CustomSARecord record); - static void AddCSARecords(VAbstractPattern *doc, - QDomElement &domElement, - const QVector &records); - static void AddInternalPaths(VAbstractPattern *doc, - QDomElement &domElement, - const QVector &paths); - static void AddPins(VAbstractPattern *doc, - QDomElement &domElement, - const QVector &pins); - static void AddPlaceLabels(VAbstractPattern *doc, - QDomElement &domElement, - const QVector &placeLabels); - static void AddPatternPieceData(VAbstractPattern *doc, - QDomElement &domElement, - const VPiece &piece); + static void AddCSARecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records); + static void AddInternalPaths(VAbstractPattern *doc, QDomElement &domElement, const QVector &paths); + static void AddPins(VAbstractPattern *doc, QDomElement &domElement, const QVector &pins); + static void AddPlaceLabels(VAbstractPattern *doc, QDomElement &domElement, const QVector &placeLabels); + static void AddPatternPieceData(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); static void AddPatternInfo(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); static void AddGrainline(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); @@ -126,7 +107,10 @@ public: void RefreshGeometry(bool updateChildren = true); auto type() const -> int override { return Type; } - enum { Type = UserType + static_cast(Tool::Piece) }; + enum + { + Type = UserType + static_cast(Tool::Piece) + }; auto getTagName() const -> QString override; void ShowVisualization(bool show) override; @@ -211,66 +195,45 @@ private: /** @brief m_geometryIsReady is true when a piece's geometry is ready and checks for validity can be enabled. */ bool m_geometryIsReady{false}; - explicit VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, - QGraphicsItem *parent = nullptr); + explicit VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem *parent = nullptr); void UpdateExcludeState(); void UpdateInternalPaths(); - auto FindLabelGeometry(const VPatternLabelData &labelData, - const QVector &pins, - qreal &rotationAngle, - qreal &labelWidth, - qreal &labelHeight, - QPointF &pos) -> VPieceItem::MoveTypes; - auto FindGrainlineGeometry(const VGrainlineData &geom, - const QVector &pins, - qreal &length, - qreal &rotationAngle, - QPointF &pos) -> VPieceItem::MoveTypes; + auto FindLabelGeometry(const VPatternLabelData &labelData, const QVector &pins, qreal &rotationAngle, + qreal &labelWidth, qreal &labelHeight, QPointF &pos) -> VPieceItem::MoveTypes; + auto FindGrainlineGeometry(const VGrainlineData &geom, const QVector &pins, qreal &length, + qreal &rotationAngle, QPointF &pos) -> VPieceItem::MoveTypes; void InitNodes(const VPiece &detail, VMainGraphicsScene *scene); - static void InitNode(const VPieceNode &node, - VMainGraphicsScene *scene, - VToolSeamAllowance *parent); + static void InitNode(const VPieceNode &node, VMainGraphicsScene *scene, VToolSeamAllowance *parent); void InitCSAPaths(const VPiece &detail) const; void InitInternalPaths(const VPiece &detail); void InitSpecialPoints(const QVector &points) const; - auto PrepareLabelData(const VPatternLabelData &labelData, - const QVector &pins, - VTextGraphicsItem *labelItem, - QPointF &pos, - qreal &labelAngle) -> bool; + auto PrepareLabelData(const VPatternLabelData &labelData, const QVector &pins, + VTextGraphicsItem *labelItem, QPointF &pos, qreal &labelAngle) -> bool; auto SelectedTools() const -> QList; auto IsGrainlinePositionValid() const -> bool; - static void AddPointRecords(VAbstractPattern *doc, - QDomElement &domElement, - const QVector &records, + static void AddPointRecords(VAbstractPattern *doc, QDomElement &domElement, const QVector &records, const QString &tag); - static auto DuplicateNodes(const VPiecePath &path, - const VToolSeamAllowanceInitData &initData, + static auto DuplicateNodes(const VPiecePath &path, const VToolSeamAllowanceInitData &initData, QMap &replacements) -> QVector; - static auto DuplicateNode(const VPieceNode &node, const VToolSeamAllowanceInitData &initData) - -> quint32; + static auto DuplicateNode(const VPieceNode &node, const VToolSeamAllowanceInitData &initData) -> quint32; - static auto DuplicatePiecePath(quint32 id, const VToolSeamAllowanceInitData &initData) - -> quint32; + static auto DuplicatePiecePath(quint32 id, const VToolSeamAllowanceInitData &initData) -> quint32; static auto DuplicateCustomSARecords(const QVector &records, const VToolSeamAllowanceInitData &initData, - const QMap &replacements) - -> QVector; + const QMap &replacements) -> QVector; - static auto DuplicateInternalPaths(const QVector &iPaths, - const VToolSeamAllowanceInitData &initData) + static auto DuplicateInternalPaths(const QVector &iPaths, const VToolSeamAllowanceInitData &initData) -> QVector; - static auto DuplicatePlaceLabels(const QVector &placeLabels, - const VToolSeamAllowanceInitData &initData) + static auto DuplicatePlaceLabels(const QVector &placeLabels, const VToolSeamAllowanceInitData &initData) -> QVector; }; diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index fa1598716..d6ce3932b 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -85,7 +85,7 @@ void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic { auto UpdateLine = [this]() { - if (VScenePoint *parent = dynamic_cast(parentItem())) + if (auto *parent = dynamic_cast(parentItem())) { parent->RefreshLine(); } diff --git a/src/libs/vwidgets/vtextgraphicsitem.cpp b/src/libs/vwidgets/vtextgraphicsitem.cpp index 2cfdb8aad..9304ef06d 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.cpp +++ b/src/libs/vwidgets/vtextgraphicsitem.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include +#include #include #include #include @@ -37,24 +38,22 @@ #include #include #include -#include -#include "../vmisc/def.h" -#include "../vmisc/vmath.h" -#include "../vmisc/literals.h" #include "../vmisc/compatibility.h" +#include "../vmisc/def.h" +#include "../vmisc/literals.h" #include "vtextgraphicsitem.h" -const qreal resizeSquare = MmToPixel(3.); -const qreal rotateCircle = MmToPixel(2.); -#define ROTATE_RECT 60 -#define ROTATE_ARC 50 -const qreal minW = MmToPixel(4.) + resizeSquare; -const qreal minH = MmToPixel(4.) + resizeSquare; -#define ACTIVE_Z 10 - namespace { +constexpr qreal resizeSquare = MmToPixel(3.); +constexpr qreal rotateCircle = MmToPixel(2.); +constexpr int rotateRect = 60; +constexpr int rotateArc = 50; +constexpr qreal minW = MmToPixel(4.) + resizeSquare; +constexpr qreal minH = MmToPixel(4.) + resizeSquare; +constexpr int activeZ = 10; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief GetBoundingRect calculates the bounding box around rectBB rectangle, rotated around its center by dRot degrees @@ -64,7 +63,7 @@ namespace */ auto GetBoundingRect(const QRectF &rectBB, qreal dRot) -> QRectF { - QPointF apt[4] = { rectBB.topLeft(), rectBB.topRight(), rectBB.bottomLeft(), rectBB.bottomRight() }; + std::array apt = {rectBB.topLeft(), rectBB.topRight(), rectBB.bottomLeft(), rectBB.bottomRight()}; QPointF ptCenter = rectBB.center(); qreal dX1 = 0; @@ -73,11 +72,11 @@ auto GetBoundingRect(const QRectF &rectBB, qreal dRot) -> QRectF qreal dY2 = 0; double dAng = qDegreesToRadians(dRot); - for (int i = 0; i < 4; ++i) + for (std::size_t i = 0; i < 4; ++i) { - QPointF pt = apt[i] - ptCenter; - qreal dX = pt.x()*cos(dAng) + pt.y()*sin(dAng); - qreal dY = -pt.x()*sin(dAng) + pt.y()*cos(dAng); + QPointF pt = apt.at(i) - ptCenter; + qreal dX = pt.x() * cos(dAng) + pt.y() * sin(dAng); + qreal dY = -pt.x() * sin(dAng) + pt.y() * cos(dAng); if (i == 0) { @@ -110,22 +109,15 @@ auto GetBoundingRect(const QRectF &rectBB, qreal dRot) -> QRectF rect.setHeight(dY2 - dY1); return rect; } -}//static functions +} // namespace //--------------------------------------------------------------------------------------------------------------------- /** * @brief VTextGraphicsItem::VTextGraphicsItem constructor * @param pParent pointer to the parent item */ -VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent) - : VPieceItem(pParent), - m_ptStartPos(), - m_ptStart(), - m_szStart(), - m_dRotation(0), - m_dAngle(0), - m_rectResize(), - m_tm() +VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem *pParent) + : VPieceItem(pParent) { m_inactiveZ = 2; SetSize(minW, minH); @@ -137,7 +129,7 @@ VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent) * @brief VTextGraphicsItem::SetFont sets the item font * @param fnt font to be used in item */ -void VTextGraphicsItem::SetFont(const QFont& fnt) +void VTextGraphicsItem::SetFont(const QFont &fnt) { m_tm.SetFont(fnt); } @@ -163,7 +155,7 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem int iY = 0; for (int i = 0; i < m_tm.GetSourceLinesCount(); ++i) { - const TextLine& tl = m_tm.GetSourceLine(i); + const TextLine &tl = m_tm.GetSourceLine(i); fnt.setPixelSize(m_tm.GetFont().pixelSize() + tl.m_iFontSize); fnt.setBold(tl.m_bold); @@ -205,8 +197,8 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem if (m_eMode == mResize) { // draw the resize diagonal lines - painter->drawLine(1, 1, qFloor(m_rectBoundingBox.width())-1, qFloor(m_rectBoundingBox.height())-1); - painter->drawLine(1, qFloor(m_rectBoundingBox.height())-1, qFloor(m_rectBoundingBox.width())-1, 1); + painter->drawLine(1, 1, qFloor(m_rectBoundingBox.width()) - 1, qFloor(m_rectBoundingBox.height()) - 1); + painter->drawLine(1, qFloor(m_rectBoundingBox.height()) - 1, qFloor(m_rectBoundingBox.width()) - 1, 1); } } else @@ -214,24 +206,21 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem // in rotate mode, draw the circle in the middle painter->setPen(Qt::black); painter->setBrush(Qt::black); - painter->drawEllipse( - QPointF(m_rectBoundingBox.width()/2, m_rectBoundingBox.height()/2), - rotateCircle, - rotateCircle - ); - if (m_rectBoundingBox.width() > minW*3 && m_rectBoundingBox.height() > minH*3) + painter->drawEllipse(QPointF(m_rectBoundingBox.width() / 2, m_rectBoundingBox.height() / 2), rotateCircle, + rotateCircle); + if (m_rectBoundingBox.width() > minW * 3 && m_rectBoundingBox.height() > minH * 3) { painter->setPen(QPen(Qt::black, 3)); painter->setBrush(Qt::NoBrush); // and then draw the arc in each of the corners - int iTop = ROTATE_RECT - ROTATE_ARC; - int iLeft = ROTATE_RECT - ROTATE_ARC; - int iRight = qRound(m_rectBoundingBox.width()) - ROTATE_RECT; - int iBottom = qRound(m_rectBoundingBox.height()) - ROTATE_RECT; - painter->drawArc(iLeft, iTop, ROTATE_ARC, ROTATE_ARC, 180*16, -90*16); - painter->drawArc(iRight, iTop, ROTATE_ARC, ROTATE_ARC, 90*16, -90*16); - painter->drawArc(iLeft, iBottom, ROTATE_ARC, ROTATE_ARC, 270*16, -90*16); - painter->drawArc(iRight, iBottom, ROTATE_ARC, ROTATE_ARC, 0*16, -90*16); + int iTop = rotateRect - rotateArc; + int iLeft = rotateRect - rotateArc; + int iRight = qRound(m_rectBoundingBox.width()) - rotateRect; + int iBottom = qRound(m_rectBoundingBox.height()) - rotateRect; + painter->drawArc(iLeft, iTop, rotateArc, rotateArc, 180 * 16, -90 * 16); + painter->drawArc(iRight, iTop, rotateArc, rotateArc, 90 * 16, -90 * 16); + painter->drawArc(iLeft, iBottom, rotateArc, rotateArc, 270 * 16, -90 * 16); + painter->drawArc(iRight, iBottom, rotateArc, rotateArc, 0 * 16, -90 * 16); } } } @@ -284,7 +273,7 @@ auto VTextGraphicsItem::IsContained(QRectF rectBB, qreal dRot, qreal &dX, qreal dX = 0; dY = 0; - if (rectParent.contains(rectBB) == false) + if (not rectParent.contains(rectBB)) { if (rectParent.left() - rectBB.left() > fabs(dX)) { @@ -325,7 +314,7 @@ void VTextGraphicsItem::UpdateData(const QString &qsName, const VPieceLabelData * @brief VTextGraphicsItem::UpdateData Updates the pattern label * @param pDoc pointer to the pattern object */ -void VTextGraphicsItem::UpdateData(VAbstractPattern* pDoc, const VContainer *pattern) +void VTextGraphicsItem::UpdateData(VAbstractPattern *pDoc, const VContainer *pattern) { m_tm.Update(pDoc, pattern); } @@ -357,8 +346,8 @@ auto VTextGraphicsItem::GetFontSize() const -> int */ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) { - if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick - && (flags() & QGraphicsItem::ItemIsMovable)) + if (pME->button() == Qt::LeftButton && pME->type() != QEvent::GraphicsSceneMouseDoubleClick && + (flags() & QGraphicsItem::ItemIsMovable)) { if (m_moveType == NotMovable) { @@ -378,10 +367,10 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) // in rotation mode, do not do any changes here, because user might want to // rotate the label more. - if ((m_moveType & AllModifications ) == AllModifications) + if ((m_moveType & AllModifications) == AllModifications) { AllUserModifications(pME->pos()); - setZValue(ACTIVE_Z); + setZValue(activeZ); Update(); } else if (m_moveType & IsRotatable) @@ -399,7 +388,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) m_eMode = mRotate; SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); } - setZValue(ACTIVE_Z); + setZValue(activeZ); Update(); } else if (m_moveType & IsResizable) @@ -412,7 +401,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) { UserMoveAndResize(pME->pos()); } - setZValue(ACTIVE_Z); + setZValue(activeZ); Update(); } else if (m_moveType & IsMovable) @@ -431,7 +420,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); } - setZValue(ACTIVE_Z); + setZValue(activeZ); Update(); } else @@ -450,102 +439,19 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) * @brief VTextGraphicsItem::mouseMoveEvent handles mouse move events * @param pME pointer to QGraphicsSceneMouseEvent object */ -void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME) +void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *pME) { - qreal dX; - qreal dY; - QRectF rectBB; if (m_eMode == mMove && m_moveType & IsMovable) { - const QPointF ptDiff = pME->scenePos() - m_ptStart; - // in move mode move the label along the mouse move from the origin - QPointF pt = m_ptStartPos + ptDiff; - rectBB.setTopLeft(pt); - rectBB.setWidth(m_rectBoundingBox.width()); - rectBB.setHeight(m_rectBoundingBox.height()); - // before moving label to a new position, check if it will still be inside the parent item - if (IsContained(rectBB, rotation(), dX, dY) == false) - { - pt.setX(pt.x() + dX); - pt.setY(pt.y() + dY); - } - setPos(pt); - UpdateBox(); + MoveLabel(pME); } else if (m_eMode == mResize && m_moveType & IsResizable) { - QLineF vectorDiff(m_ptStart, pME->scenePos()); - vectorDiff.setAngle(vectorDiff.angle() + m_dRotation); - const QPointF ptDiff = vectorDiff.p2() - m_ptStart; - - // in resize mode, resize the label along the mouse move from the origin - QPointF pt; - QSizeF sz; - - if (m_moveType & IsMovable) - { - const qreal newWidth = m_szStart.width() + ptDiff.x(); - const qreal newHeight = m_szStart.height() + ptDiff.y(); - if (newWidth <= minW || newHeight <= minH) - { - return; - } - - pt = m_ptStartPos; - sz = QSizeF(newWidth, newHeight); - } - else - { - const qreal newWidth = m_szStart.width() + ptDiff.x()*2.0; - const qreal newHeight = m_szStart.height() + ptDiff.y()*2.0; - if (newWidth <= minW || newHeight <= minH) - { - return; - } - - pt = QPointF(m_ptRotCenter.x() - newWidth/2.0, m_ptRotCenter.y() - newHeight/2.0); - sz = QSizeF(m_szStart.width() + ptDiff.x()*2.0, m_szStart.height() + ptDiff.y()*2.0); - } - - rectBB.setTopLeft(pt); - rectBB.setSize(sz); - // before resizing the label to a new size, check if it will still be inside the parent item - if (IsContained(rectBB, rotation(), dX, dY)) - { - if (not (m_moveType & IsMovable)) - { - setPos(pt); - } - } - else - { - return; - } - - SetSize(sz.width(), sz.height()); - Update(); - emit SignalShrink(); + ResizeLabel(pME); } else if (m_eMode == mRotate && m_moveType & IsRotatable) { - // if the angle from the original position is small (0.5 degrees), just remeber the new angle - // new angle will be the starting angle for rotation - if (fabs(m_dAngle) < 0.01) - { - m_dAngle = GetAngle(mapToParent(pME->pos())); - return; - } - // calculate the angle difference from the starting angle - double dAng = qRadiansToDegrees(GetAngle(mapToParent(pME->pos())) - m_dAngle); - rectBB.setTopLeft(m_ptStartPos); - rectBB.setWidth(m_rectBoundingBox.width()); - rectBB.setHeight(m_rectBoundingBox.height()); - // check if the rotated label will be inside the parent item and then rotate it - if (IsContained(rectBB, m_dRotation + dAng, dX, dY) == true) - { - setRotation(m_dRotation + dAng); - Update(); - } + RotateLabel(pME); } } @@ -554,56 +460,60 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME) * @brief VTextGraphicsItem::mouseReleaseEvent handles left button mouse release events * @param pME pointer to QGraphicsSceneMouseEvent object */ -void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) +void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *pME) { - if (pME->button() == Qt::LeftButton) + if (pME->button() != Qt::LeftButton) { - // restore the cursor - if ((m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize) && (flags() & QGraphicsItem::ItemIsMovable)) - { - SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); - } - double dDist = fabs(pME->scenePos().x() - m_ptStart.x()) + fabs(pME->scenePos().y() - m_ptStart.y()); - // determine if this was just press/release (bShort == true) or user did some operation between press and release - bool bShort = (dDist < 2); + return; + } - if (m_eMode == mMove || m_eMode == mResize) - { // if user just pressed and released the button, we must switch the mode to rotate - // but if user did some operation (move/resize), emit the proper signal and update the label - if (bShort == true) + // restore the cursor + if ((m_eMode == mMove || m_eMode == mRotate || m_eMode == mResize) && (flags() & QGraphicsItem::ItemIsMovable)) + { + SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); + } + + double dDist = fabs(pME->scenePos().x() - m_ptStart.x()) + fabs(pME->scenePos().y() - m_ptStart.y()); + // determine if this was just press/release (bShort == true) or user did some operation between press and + // release + bool bShort = (dDist < 2); + + if (m_eMode == mMove || m_eMode == mResize) + { // if user just pressed and released the button, we must switch the mode to rotate + // but if user did some operation (move/resize), emit the proper signal and update the label + if (bShort) + { + if (m_bReleased && m_moveType & IsRotatable) { - if (m_bReleased == true && m_moveType & IsRotatable) - { - m_eMode = mRotate; - UpdateBox(); - } - } - else if (m_eMode == mMove && m_moveType & IsMovable) - { - emit SignalMoved(pos()); + m_eMode = mRotate; UpdateBox(); } - else if (m_moveType & IsResizable) - { - emit SignalResized(m_rectBoundingBox.width(), m_tm.GetFont().pixelSize()); - Update(); - } } - else - { // in rotate mode, if user did just press/release, switch to move mode - if (bShort == true && (m_moveType & IsMovable || m_moveType & IsResizable)) - { - m_eMode = mMove; - } - else if (m_moveType & IsRotatable) - { - // if user rotated the item, emit proper signal and update the label - emit SignalRotated(rotation()); - } + else if (m_eMode == mMove && m_moveType & IsMovable) + { + emit SignalMoved(pos()); UpdateBox(); } - m_bReleased = true; + else if (m_moveType & IsResizable) + { + emit SignalResized(m_rectBoundingBox.width(), m_tm.GetFont().pixelSize()); + Update(); + } } + else + { // in rotate mode, if user did just press/release, switch to move mode + if (bShort && (m_moveType & IsMovable || m_moveType & IsResizable)) + { + m_eMode = mMove; + } + else if (m_moveType & IsRotatable) + { + // if user rotated the item, emit proper signal and update the label + emit SignalRotated(rotation()); + } + UpdateBox(); + } + m_bReleased = true; } //--------------------------------------------------------------------------------------------------------------------- @@ -611,11 +521,11 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) * @brief VTextGraphicsItem::hoverMoveEvent checks if cursor has to be changed * @param pHE pointer to the scene hover event */ -void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) +void VTextGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *pHE) { if (m_eMode == mResize && m_moveType & IsResizable) { - if (m_rectResize.contains(pHE->pos()) == true) + if (m_rectResize.contains(pHE->pos())) { setCursor(Qt::SizeFDiagCursor); } @@ -658,7 +568,7 @@ void VTextGraphicsItem::CorrectLabel() QRectF rectBB; rectBB.setTopLeft(pos()); rectBB.setSize(m_rectBoundingBox.size()); - if (IsContained(rectBB, rotation(), dX, dY) == false) + if (not IsContained(rectBB, rotation(), dX, dY)) { // put the label inside the pattern setPos(pos().x() + dX, pos().y() + dY); @@ -693,7 +603,7 @@ void VTextGraphicsItem::UserRotateAndMove() //--------------------------------------------------------------------------------------------------------------------- void VTextGraphicsItem::UserMoveAndResize(const QPointF &pos) { - if (m_rectResize.contains(pos) == true) + if (m_rectResize.contains(pos)) { m_eMode = mResize; setCursor(Qt::SizeFDiagCursor); @@ -704,3 +614,113 @@ void VTextGraphicsItem::UserMoveAndResize(const QPointF &pos) SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1); } } + +//--------------------------------------------------------------------------------------------------------------------- +void VTextGraphicsItem::MoveLabel(QGraphicsSceneMouseEvent *pME) +{ + const QPointF ptDiff = pME->scenePos() - m_ptStart; + // in move mode move the label along the mouse move from the origin + QPointF pt = m_ptStartPos + ptDiff; + QRectF rectBB; + rectBB.setTopLeft(pt); + rectBB.setWidth(m_rectBoundingBox.width()); + rectBB.setHeight(m_rectBoundingBox.height()); + // before moving label to a new position, check if it will still be inside the parent item + qreal dX; + qreal dY; + if (not IsContained(rectBB, rotation(), dX, dY)) + { + pt.setX(pt.x() + dX); + pt.setY(pt.y() + dY); + } + setPos(pt); + UpdateBox(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VTextGraphicsItem::ResizeLabel(QGraphicsSceneMouseEvent *pME) +{ + QLineF vectorDiff(m_ptStart, pME->scenePos()); + vectorDiff.setAngle(vectorDiff.angle() + m_dRotation); + const QPointF ptDiff = vectorDiff.p2() - m_ptStart; + + // in resize mode, resize the label along the mouse move from the origin + QPointF pt; + QSizeF sz; + + if (m_moveType & IsMovable) + { + const qreal newWidth = m_szStart.width() + ptDiff.x(); + const qreal newHeight = m_szStart.height() + ptDiff.y(); + if (newWidth <= minW || newHeight <= minH) + { + return; + } + + pt = m_ptStartPos; + sz = QSizeF(newWidth, newHeight); + } + else + { + const qreal newWidth = m_szStart.width() + ptDiff.x() * 2.0; + const qreal newHeight = m_szStart.height() + ptDiff.y() * 2.0; + if (newWidth <= minW || newHeight <= minH) + { + return; + } + + pt = QPointF(m_ptRotCenter.x() - newWidth / 2.0, m_ptRotCenter.y() - newHeight / 2.0); + sz = QSizeF(m_szStart.width() + ptDiff.x() * 2.0, m_szStart.height() + ptDiff.y() * 2.0); + } + + QRectF rectBB; + rectBB.setTopLeft(pt); + rectBB.setSize(sz); + // before resizing the label to a new size, check if it will still be inside the parent item + qreal dX; + qreal dY; + if (IsContained(rectBB, rotation(), dX, dY)) + { + if (not(m_moveType & IsMovable)) + { + setPos(pt); + } + } + else + { + return; + } + + SetSize(sz.width(), sz.height()); + Update(); + emit SignalShrink(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VTextGraphicsItem::RotateLabel(QGraphicsSceneMouseEvent *pME) +{ + // if the angle from the original position is small (0.5 degrees), just remeber the new angle + // new angle will be the starting angle for rotation + if (fabs(m_dAngle) < 0.01) + { + m_dAngle = GetAngle(mapToParent(pME->pos())); + return; + } + + QRectF rectBB; + rectBB.setTopLeft(m_ptStartPos); + rectBB.setWidth(m_rectBoundingBox.width()); + rectBB.setHeight(m_rectBoundingBox.height()); + + // calculate the angle difference from the starting angle + double dAng = qRadiansToDegrees(GetAngle(mapToParent(pME->pos())) - m_dAngle); + + // check if the rotated label will be inside the parent item and then rotate it + qreal dX; + qreal dY; + if (IsContained(rectBB, m_dRotation + dAng, dX, dY)) + { + setRotation(m_dRotation + dAng); + Update(); + } +} diff --git a/src/libs/vwidgets/vtextgraphicsitem.h b/src/libs/vwidgets/vtextgraphicsitem.h index b9d638b46..a7490d7b6 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.h +++ b/src/libs/vwidgets/vtextgraphicsitem.h @@ -40,8 +40,8 @@ #include #include -#include "vpieceitem.h" #include "../vlayout/vtextmanager.h" +#include "vpieceitem.h" /** * @brief The VTextGraphicsItem class. This class implements text graphics item, @@ -51,30 +51,34 @@ class VTextGraphicsItem final : public VPieceItem { Q_OBJECT // NOLINT + public: - explicit VTextGraphicsItem(QGraphicsItem* pParent = nullptr); - virtual ~VTextGraphicsItem() = default; + explicit VTextGraphicsItem(QGraphicsItem *pParent = nullptr); + ~VTextGraphicsItem() override = default; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; - virtual void Update() override; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; + void Update() override; - virtual auto type() const -> int override { return Type; } - enum { Type = UserType + static_cast(Vis::TextGraphicsItem)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Vis::TextGraphicsItem) + }; - void SetFont(const QFont& fnt); + void SetFont(const QFont &fnt); auto GetFontSize() const -> int; void SetSize(qreal fW, qreal fH); auto IsContained(QRectF rectBB, qreal dRot, qreal &dX, qreal &dY) const -> bool; - void UpdateData(const QString& qsName, const VPieceLabelData& data, const VContainer *pattern); - void UpdateData(VAbstractPattern* pDoc, const VContainer *pattern); + void UpdateData(const QString &qsName, const VPieceLabelData &data, const VContainer *pattern); + void UpdateData(VAbstractPattern *pDoc, const VContainer *pattern); auto GetTextLines() const -> vsizetype; protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent* pME) override; - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* pME) override; - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) override; - virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *pME) override; - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) override; + void mousePressEvent(QGraphicsSceneMouseEvent *pME) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent *pME) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *pME) override; + void hoverEnterEvent(QGraphicsSceneHoverEvent *pME) override; + void hoverMoveEvent(QGraphicsSceneHoverEvent *pHE) override; void UpdateBox(); void CorrectLabel(); @@ -86,17 +90,21 @@ signals: private: Q_DISABLE_COPY_MOVE(VTextGraphicsItem) // NOLINT - QPointF m_ptStartPos; - QPointF m_ptStart; - QSizeF m_szStart; - double m_dRotation; - double m_dAngle; - QRectF m_rectResize; - VTextManager m_tm; + QPointF m_ptStartPos{}; + QPointF m_ptStart{}; + QSizeF m_szStart{}; + double m_dRotation{0}; + double m_dAngle{0}; + QRectF m_rectResize{}; + VTextManager m_tm{}; void AllUserModifications(const QPointF &pos); void UserRotateAndMove(); void UserMoveAndResize(const QPointF &pos); + + void MoveLabel(QGraphicsSceneMouseEvent *pME); + void ResizeLabel(QGraphicsSceneMouseEvent *pME); + void RotateLabel(QGraphicsSceneMouseEvent *pME); }; #endif // VTEXTGRAPHICSITEM_H