diff --git a/ChangeLog.txt b/ChangeLog.txt index f9e4d6705..544c9fd27 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,4 @@ -# Version 0.7.47 (unreleased) +# Version 0.7.47 May 13, 2021 - [smart-pattern/valentina#118] Incorrect seam allowance. - [smart-pattern/valentina#119] Improve tool Point of intersection curves. - [smart-pattern/valentina#120] Incorrect seam allowance. @@ -9,6 +9,10 @@ - [smart-pattern/valentina#123] Error inside Save layout dialog. - Improve error handling for the dxf export. - Fix correct handle a final measurement formula error when exporting a pattern recipe. +- Fix regression. Incorrect data caching. +- Improve tool tooltip. Show segment names and aliases. +- Alias support for tools Point of intersection curve and axis and Point of intersection curves. +- [smart-pattern/valentina#124] Standard passmarks length for all pieces. # Version 0.7.46 Mar 31, 2021 - Fix incorrect calculation of value for multisize measurements in Valentina. diff --git a/common.pri b/common.pri index 6662944ef..88e7738b8 100644 --- a/common.pri +++ b/common.pri @@ -279,12 +279,6 @@ defineReplace(FindBuildRevision){ return(\\\"unknown\\\") }else{ # Release mode - macx{ - GIT = /usr/local/bin/git # Can't defeat PATH variable on Mac OS. - }else { - GIT = git # All other platforms are OK. - } - DVCS_HESH=$$system("git rev-parse --short HEAD") isEmpty(DVCS_HESH){ DVCS_HESH = \\\"unknown\\\" # if we can't find build revision left unknown. @@ -301,12 +295,6 @@ defineReplace(FindLatestTagDistance){ return(0) }else{ # Release mode - #get latest git tag and it's distance from HEAD - macx{ - GIT = /usr/local/bin/git # Can't defeat PATH variable on Mac OS. - }else { - GIT = GIT # All other platforms all OK. - } # tag is formatted as TAG-N-gSHA: # 1. latest stable version is TAG, or vX.Y.Z diff --git a/dist/AppImage/appimage.yml b/dist/AppImage/appimage.yml index cf85540af..59ae86247 100644 --- a/dist/AppImage/appimage.yml +++ b/dist/AppImage/appimage.yml @@ -40,7 +40,7 @@ build: # - .... # files: - - "https://gitlab.com/smart-pattern/valentina/repository/archive.tar.gz?ref=develop" + - "https://gitlab.com/smart-pattern/valentina/-/archive/develop/valentina-develop.tar.gz" # OPTIONAL: ingredient packages are packages which become part of the AppImage. # you may want to remove parts of their content in script section. @@ -53,9 +53,8 @@ script: # - $BUILD_SOURCE_DIR point to the source directory # - $BUILD_APPDIR point to the AppDir. This directory will become the content of the AppImage - cd $BUILD_SOURCE_DIR - - mv -v "archive.tar.gz?ref=develop" valentina-develop.tar.gz - tar zxvf $BUILD_SOURCE_DIR/valentina-develop.tar.gz - - mv -v valentina-develop-* valentina + - mv -v valentina-develop valentina - cd $BUILD_SOURCE_DIR/valentina - qmake-qt5 PREFIX=/usr PREFIX_LIB=/usr/lib LRELEASE=lrelease-qt5 Valentina.pro -r DEFINES+=APPIMAGE "CONFIG += noTests noRunPath no_ccache noDebugSymbols" - make -j$(nproc) diff --git a/dist/OBS_debian/debian.changelog b/dist/OBS_debian/debian.changelog index 1d3a4d70b..f1be558f7 100644 --- a/dist/OBS_debian/debian.changelog +++ b/dist/OBS_debian/debian.changelog @@ -1,5 +1,5 @@ -valentina (0.7.46) trusty; urgency=low +valentina (0.7.47) trusty; urgency=low * Auto build. - -- dismine Wed, 31 Mar 2021 17:20:00 +0300 + -- dismine Fri, 13 May 2021 14:17:00 +0300 diff --git a/dist/OBS_debian/debian.rules b/dist/OBS_debian/debian.rules index e36187ef7..ec0176f9b 100755 --- a/dist/OBS_debian/debian.rules +++ b/dist/OBS_debian/debian.rules @@ -18,7 +18,7 @@ mkdir -p builddir builddir/Makefile: builddir - cd builddir && qmake PREFIX=/usr PREFIX_LIB=$(PREFIX_LIB) "CONFIG += noTests noRunPath no_ccache noDebugSymbols" ../$(APPNAME).pro -r + cd builddir && QT_SELECT=qt5 qmake PREFIX=/usr PREFIX_LIB=$(PREFIX_LIB) "CONFIG += noTests noRunPath no_ccache noDebugSymbols" ../$(APPNAME).pro -r build: build-stamp build-stamp: builddir/Makefile dh_testdir diff --git a/dist/OBS_debian/valentina.dsc b/dist/OBS_debian/valentina.dsc index f670d1e42..7d0229a70 100644 --- a/dist/OBS_debian/valentina.dsc +++ b/dist/OBS_debian/valentina.dsc @@ -2,25 +2,20 @@ Format: 3.0 (native) Source: valentina Binary: valentina Architecture: i386 amd64 -Version: 0.6.0 +Version: 0.7.47 Maintainer: Roman Telezhynskyi -Homepage: https://valentinaproject.bitbucket.io/ +Homepage: https://valentinaproject.bitbucket.io Standards-Version: 3.9.5 -Vcs-Browser: https://bitbucket.org/dismine/valentina +Vcs-Browser: https://gitlab.com/smart-pattern/valentina Build-Depends: debhelper (>= 8.0.0), - qtbase5-dev (>= 5.2.0), - libqt5svg5-dev (>= 5.2.0), - g++ (>= 4.7.0), - qt5-default (>= 5.2.0), - qttools5-dev-tools (>= 5.2.0), - libqt5xmlpatterns5-dev (>= 5.2.0), - libqt5opengl5-dev (>= 5.2.0) + qtbase5-dev (>= 5.4.0), + libqt5svg5-dev (>= 5.4.0), + g++ (>= 4.8.0), + qttools5-dev-tools (>= 5.4.0), + libqt5xmlpatterns5-dev (>= 5.4.0), + libqt5opengl5-dev (>= 5.4.0) +Debtransform-Tar: valentina-0.7.47.v0.7.47.tar.gz Package-List: valentina deb graphics optional Files: - d09673bcc475067139b88cf875e5dc0c 20954240 valentina_0.6.0.orig.tar.gz - 2fecf324a32123b08cefc0f047bca5ee 63176 valentina_0.6.0.diff.tar.gz - -DEBTRANSFORM-TAR: valentina_0.6.0.orig.tar.gz -DEBTRANSFORM-FILES-TAR: debian.tar.gz -DEBTRANSFORM-RELEASE: 1 + 00000000000000000000000000000000 0 valentina-0.7.47.v0.7.47.tar.gz diff --git a/dist/debian/changelog b/dist/debian/changelog index 1d3a4d70b..f1be558f7 100644 --- a/dist/debian/changelog +++ b/dist/debian/changelog @@ -1,5 +1,5 @@ -valentina (0.7.46) trusty; urgency=low +valentina (0.7.47) trusty; urgency=low * Auto build. - -- dismine Wed, 31 Mar 2021 17:20:00 +0300 + -- dismine Fri, 13 May 2021 14:17:00 +0300 diff --git a/dist/debian/rules b/dist/debian/rules index e36187ef7..ec0176f9b 100755 --- a/dist/debian/rules +++ b/dist/debian/rules @@ -18,7 +18,7 @@ mkdir -p builddir builddir/Makefile: builddir - cd builddir && qmake PREFIX=/usr PREFIX_LIB=$(PREFIX_LIB) "CONFIG += noTests noRunPath no_ccache noDebugSymbols" ../$(APPNAME).pro -r + cd builddir && QT_SELECT=qt5 qmake PREFIX=/usr PREFIX_LIB=$(PREFIX_LIB) "CONFIG += noTests noRunPath no_ccache noDebugSymbols" ../$(APPNAME).pro -r build: build-stamp build-stamp: builddir/Makefile dh_testdir diff --git a/dist/macx/tape/Info.plist b/dist/macx/tape/Info.plist index 412745612..31a1037a9 100755 --- a/dist/macx/tape/Info.plist +++ b/dist/macx/tape/Info.plist @@ -19,9 +19,9 @@ CFBundleIdentifier io.bitbucket.valentinaproject.@EXECUTABLE@ CFBundleShortVersionString - 0.7.46 + 0.7.47 CFBundleVersion - 0.7.46.0 + 0.7.47.0 CFBundleInfoDictionaryVersion 6.0 CFBundleDocumentTypes diff --git a/dist/macx/valentina/Info.plist b/dist/macx/valentina/Info.plist index 29516c1e8..a5401e0ff 100755 --- a/dist/macx/valentina/Info.plist +++ b/dist/macx/valentina/Info.plist @@ -19,9 +19,9 @@ CFBundleIdentifier io.bitbucket.valentinaproject.@EXECUTABLE@ CFBundleShortVersionString - 0.7.46 + 0.7.47 CFBundleVersion - 0.7.46.0 + 0.7.47.0 CFBundleInfoDictionaryVersion 6.0 CFBundleDocumentTypes diff --git a/dist/rpm/_service b/dist/rpm/_service index c11edecb4..e5fbaf6db 100644 --- a/dist/rpm/_service +++ b/dist/rpm/_service @@ -1,11 +1,11 @@ git://github.com/dismine/Valentina_git.git - 0.7.46 + 0.7.47 valentina git .git - %at + @PARENT_TAG@ master diff --git a/dist/rpm/valentina.spec b/dist/rpm/valentina.spec index 08263cbc9..328c78c10 100644 --- a/dist/rpm/valentina.spec +++ b/dist/rpm/valentina.spec @@ -95,7 +95,7 @@ Requires: poppler-tools Requires: poppler-utils %endif -Version: 0.7.46 +Version: 0.7.47 Release: 0 URL: https://gitlab.com/smart-pattern/valentina License: GPL-3.0+ diff --git a/dist/valentina.dsc b/dist/valentina.dsc index 33a6e09c2..2946f516b 100644 --- a/dist/valentina.dsc +++ b/dist/valentina.dsc @@ -2,7 +2,7 @@ Format: 3.0 (native) Source: valentina Binary: valentina Architecture: i386 amd64 -Version: 0.7.46 +Version: 0.7.47 Maintainer: Roman Telezhynskyi Homepage: https://valentinaproject.bitbucket.io Standards-Version: 3.9.5 @@ -10,16 +10,13 @@ Vcs-Browser: https://gitlab.com/smart-pattern/valentina Build-Depends: debhelper (>= 8.0.0), qtbase5-dev (>= 5.4.0), libqt5svg5-dev (>= 5.4.0), - g++ (>= 4.8.0), - qt5-default (>= 5.4.0), + g++ (>= 4.8.0), qttools5-dev-tools (>= 5.4.0), libqt5xmlpatterns5-dev (>= 5.4.0), libqt5opengl5-dev (>= 5.4.0) +Debtransform-Tar: valentina-0.7.47.v0.7.47.tar.gz Package-List: valentina deb graphics optional -Checksums-Sha1: - 581eb1bf36b4ab7126b5983d809130f15396859e 24838101 valentina_0.7.46.tar -Checksums-Sha256: - 9b156c7120a69b90373efb8ca9998c3e0563a60ad337210166cfd41b00b0f13c 24838101 valentina_0.7.46.tar Files: - 95677e29d3a59cf5b064f7be236a4b78 24838101 valentina_0.7.46.tar + 00000000000000000000000000000000 0 valentina-0.7.47.v0.7.47.tar.gz + diff --git a/scripts/obs_debian.sh b/scripts/obs_debian.sh index afaff0c97..8e8781f85 100755 --- a/scripts/obs_debian.sh +++ b/scripts/obs_debian.sh @@ -17,3 +17,5 @@ do basename=${file##*/} # remove the path from a path-string cp -v -f $file $OBSDEBIAN/debian.${basename} done + +cp -v -f ../dist/valentina.dsc $OBSDEBIAN/valentina.dsc diff --git a/scripts/travis-deploy.sh b/scripts/travis-deploy.sh index 39e297c0e..347aa94ff 100644 --- a/scripts/travis-deploy.sh +++ b/scripts/travis-deploy.sh @@ -24,9 +24,9 @@ if [[ "$DEPLOY" == "true" ]]; then check_failure "Unable to patch the app bundle."; if [[ "$LEGACY" = false ]]; then - legacy_suffix = "" + legacy_suffix="" else - legacy_suffix = "-legacy" + legacy_suffix="-legacy" fi print_info "Start compressing."; diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 53c89fddd..e93e86962 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -332,7 +332,7 @@ bool TMainWindow::LoadFile(const QString &path) throw VException(tr("File contains invalid known measurement(s).")); } - mUnit = m->MUnit(); + mUnit = m->Units(); pUnit = mUnit; currentDimensionA = m->DimensionABase(); @@ -2672,7 +2672,7 @@ void TMainWindow::InitMenu() void TMainWindow::InitDimensionsBaseValue() { const QList dimensions = m->Dimensions().values(); - const QString unit = UnitsToStr(m->MUnit(), true); + const QString unit = UnitsToStr(m->Units(), true); const bool fc = m->IsFullCircumference(); auto DimensionsBaseValue = [this, dimensions, unit, fc](int index, QLabel *name, QLabel *base) @@ -2726,7 +2726,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p SCASSERT(control != nullptr) const bool fc = m->IsFullCircumference(); - const QString unit = UnitsToStr(m->MUnit(), true); + const QString unit = UnitsToStr(m->Units(), true); qreal current = -1; if (control->currentIndex() != -1) @@ -2811,7 +2811,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p void TMainWindow::InitDimensionControls() { const QList dimensions = m->Dimensions().values(); - const QString unit = UnitsToStr(m->MUnit(), true); + const QString unit = UnitsToStr(m->Units(), true); auto InitControl = [this, dimensions, unit](int index, QLabel *&name, QComboBox *&control) { @@ -3574,7 +3574,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path) throw VException(tr("File contains invalid known measurement(s).")); } - mUnit = m->MUnit(); + mUnit = m->Units(); pUnit = mUnit; currentDimensionA = m->DimensionABase(); @@ -4358,7 +4358,7 @@ void TMainWindow::InitMeasurementUnits() } QString units; - switch (m->MUnit()) + switch (m->Units()) { case Unit::Mm: units = tr("Millimeters"); diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 54a55b945..dfff88fdc 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "../xml/vpattern.h" #include "../vpatterndb/vcontainer.h" @@ -42,22 +43,14 @@ #include "../vtools/dialogs/support/dialogeditlabel.h" #include "dialogknownmaterials.h" #include "../vmisc/vvalentinasettings.h" +#include "../qmuparser/qmudef.h" //--------------------------------------------------------------------------------------------------------------------- DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) : QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), - pattern(pattern), - data(QMap()), - descriptionChanged(false), - gradationChanged(false), - defaultChanged(false), - securityChanged(false), - deleteAction(nullptr), - changeImageAction(nullptr), - saveImageAction(nullptr), - showImageAction(nullptr) + pattern(pattern) { ui->setupUi(this); @@ -137,8 +130,27 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat ui->checkBoxPatternReadOnly->setDisabled(true); } + //----------------------- Passmark length + m_variables = pattern->DataMeasurements().keys() + pattern->DataIncrements().keys(); + m_completer = new QCompleter(m_variables, this); + m_completer->setCompletionMode(QCompleter::PopupCompletion); + m_completer->setModelSorting(QCompleter::UnsortedModel); + m_completer->setFilterMode(Qt::MatchContains); + m_completer->setCaseSensitivity(Qt::CaseSensitive); + + ui->lineEditPassmarkLength->setCompleter(m_completer); + connect(ui->lineEditPassmarkLength, &QLineEdit::textEdited, this, [this]() + { + ValidatePassmarkLength(); + DescEdited(); + }); + + ui->lineEditPassmarkLength->installEventFilter(this); + m_oldPassmarkLength = doc->GetPassmarkLengthVariable(); + ui->lineEditPassmarkLength->setText(m_oldPassmarkLength); + ValidatePassmarkLength(); + //Initialization change value. Set to default value after initialization - gradationChanged = false; defaultChanged = false; securityChanged = false; } @@ -149,6 +161,27 @@ DialogPatternProperties::~DialogPatternProperties() delete ui; } +//--------------------------------------------------------------------------------------------------------------------- +auto DialogPatternProperties::eventFilter(QObject *object, QEvent *event) -> bool +{ + if (ui->lineEditPassmarkLength == qobject_cast(object)) + { + if (event->type() == QEvent::KeyPress) + { + auto *keyEvent = static_cast(event); + if ((keyEvent->key() == Qt::Key_Space) && ((keyEvent->modifiers() & Qt::ControlModifier) != 0U)) + { + m_completer->complete(); + return true; + } + } + + return false; + } + + return QDialog::eventFilter(object, event); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::Apply() { @@ -188,8 +221,16 @@ void DialogPatternProperties::SaveDescription() doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); doc->SetLabelPrefix(qvariant_cast(ui->comboBoxLabelLanguage->currentData())); + doc->SetPassmarkLengthVariable(ui->lineEditPassmarkLength->text()); + + if (m_oldPassmarkLength != ui->lineEditPassmarkLength->text()) + { + emit UpddatePieces(); + m_oldPassmarkLength = ui->lineEditPassmarkLength->text(); + } descriptionChanged = false; + emit doc->patternChanged(false); } } @@ -219,6 +260,27 @@ QImage DialogPatternProperties::GetImage() return image; } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::ValidatePassmarkLength() const +{ + const QString text = ui->lineEditPassmarkLength->text(); + QPalette palette = ui->lineEditPassmarkLength->palette(); + const QPalette::ColorRole foregroundRole = ui->lineEditPassmarkLength->foregroundRole(); + + QRegularExpression rx(NameRegExp()); + if (not text.isEmpty()) + { + palette.setColor(foregroundRole, + rx.match(text).hasMatch() && m_variables.contains(text) ? Qt::black : Qt::red); + } + else + { + palette.setColor(foregroundRole, Qt::black); + } + + ui->lineEditPassmarkLength->setPalette(palette); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::InitImage() { diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 188d3008d..ac756ef16 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -38,6 +38,7 @@ class VPattern; class VContainer; class QCheckBox; +class QCompleter; namespace Ui { @@ -50,6 +51,10 @@ class DialogPatternProperties : public QDialog public: explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr); virtual ~DialogPatternProperties() override; +signals: + void UpddatePieces(); +protected: + virtual bool eventFilter(QObject *object, QEvent *event) override; private slots: void Apply(); void Ok(); @@ -61,21 +66,25 @@ private: Ui::DialogPatternProperties *ui; VPattern *doc; VContainer *pattern; - QMap data; - bool descriptionChanged; - bool gradationChanged; - bool defaultChanged; - bool securityChanged; - QAction *deleteAction; - QAction *changeImageAction; - QAction *saveImageAction; - QAction *showImageAction; + QMap data{}; + bool descriptionChanged{false}; + bool defaultChanged{false}; + bool securityChanged{false}; + QAction *deleteAction{nullptr}; + QAction *changeImageAction{nullptr}; + QAction *saveImageAction{nullptr}; + QAction *showImageAction{nullptr}; + QCompleter *m_completer{nullptr}; + QStringList m_variables{}; + QString m_oldPassmarkLength{}; void SaveDescription(); void SaveReadOnlyState(); void InitImage(); QImage GetImage(); + + void ValidatePassmarkLength() const; }; #endif // DIALOGPATTERNPROPERTIES_H diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index d28f9a1aa..e282095e7 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -6,8 +6,8 @@ 0 0 - 571 - 491 + 493 + 582 @@ -81,8 +81,11 @@ - - + + + QFormLayout::ExpandingFieldsGrow + + @@ -95,7 +98,7 @@ - + @@ -105,18 +108,19 @@ - - - - Qt::Horizontal + + + + Passmark length: - - - 40 - 20 - + + + + + + true - + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 1c790fa11..1cb786c75 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2065,7 +2065,7 @@ void MainWindow::CleanWaterkmarkEditors() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::StoreMultisizeMDimensions() { - VAbstractValApplication::VApp()->SetMeasurementsUnits(m->MUnit()); + VAbstractValApplication::VApp()->SetMeasurementsUnits(m->Units()); QList dimensions = m->Dimensions().values(); @@ -2091,7 +2091,7 @@ void MainWindow::StoreMultisizeMDimensions() labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); const bool circumference = dimension->IsCircumference(); VAbstractValApplication::VApp() - ->SetDimensionSizeUnits(circumference ? m->MUnit() : Unit::LAST_UNIT_DO_NOT_USE); + ->SetDimensionSizeUnits(circumference ? m->Units() : Unit::LAST_UNIT_DO_NOT_USE); break; } case MeasurementDimension::W: @@ -5078,6 +5078,8 @@ void MainWindow::CreateActions() connect(ui->actionPattern_properties, &QAction::triggered, this, [this]() { DialogPatternProperties proper(doc, pattern, this); + connect(&proper, &DialogPatternProperties::UpddatePieces, sceneDetails, + &VMainGraphicsScene::UpdatePiecePassmarks); proper.exec(); }); @@ -5352,7 +5354,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) { doc->SetMPath(RelativeMPath(fileName, customMeasureFile)); } - VAbstractValApplication::VApp()->SetPatternUnits(doc->MUnit()); + VAbstractValApplication::VApp()->SetPatternUnits(doc->Units()); QString path = AbsoluteMPath(fileName, doc->MPath()); QString fixedMPath; @@ -5439,7 +5441,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) { doc->SetMPath(RelativeMPath(fileName, fixedMPath)); } - VAbstractValApplication::VApp()->SetPatternUnits(doc->MUnit()); + VAbstractValApplication::VApp()->SetPatternUnits(doc->Units()); } } catch (VException &e) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 2cc23e5bc..005d42216 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -141,6 +141,9 @@ void VPattern::CreateEmptyFile() insertBefore(createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild()); + + // Cache values + m_units = VAbstractValApplication::VApp()->patternUnits(); } //--------------------------------------------------------------------------------------------------------------------- @@ -2280,6 +2283,8 @@ void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElemen initData.curveId = GetParametrUInt(domElement, AttrCurve, NULL_ID_STR); initData.formulaAngle = GetParametrString(domElement, AttrAngle, QStringLiteral("0.0")); const QString angleFix = initData.formulaAngle; + initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1); + initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2); VToolCurveIntersectAxis::Create(initData); //Rewrite attribute formula. Need for situation when we have wrong formula. @@ -2401,6 +2406,10 @@ void VPattern::ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDo initData.secondCurveId = GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR); initData.vCrossPoint = static_cast(GetParametrUInt(domElement, AttrVCrossPoint, QChar('1'))); initData.hCrossPoint = static_cast(GetParametrUInt(domElement, AttrHCrossPoint, QChar('1'))); + initData.curve1AliasSuffix1 = GetParametrEmptyString(domElement, AttrCurve1Alias1); + initData.curve1AliasSuffix2 = GetParametrEmptyString(domElement, AttrCurve1Alias2); + initData.curve2AliasSuffix1 = GetParametrEmptyString(domElement, AttrCurve2Alias1); + initData.curve2AliasSuffix2 = GetParametrEmptyString(domElement, AttrCurve2Alias2); VToolPointOfIntersectionCurves::Create(initData); } @@ -3692,21 +3701,21 @@ void VPattern::RefreshPieceGeometry() VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView()); }); - if (VApplication::VApp()->IsGUIMode() && m_parsing) + if (VApplication::IsGUIMode() && m_parsing) { return; } for(auto pieceId : qAsConst(updatePieces)) { - if (VApplication::VApp()->IsGUIMode() && m_parsing) + if (VApplication::IsGUIMode() && m_parsing) { return; } try { - if (VToolSeamAllowance *piece = qobject_cast(VAbstractPattern::getTool(pieceId))) + if (auto *piece = qobject_cast(VAbstractPattern::getTool(pieceId))) { piece->RefreshGeometry(); } @@ -3718,7 +3727,7 @@ void VPattern::RefreshPieceGeometry() QApplication::processEvents(); - if (VApplication::VApp()->IsGUIMode() && m_parsing) + if (VApplication::IsGUIMode() && m_parsing) { return; } diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 97c182852..c99c393f0 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -119,12 +119,11 @@ signals: public slots: virtual void LiteParseTree(const Document &parse) override; + void RefreshPieceGeometry(); + protected: virtual void customEvent(QEvent * event) override; -private slots: - void RefreshPieceGeometry(); - private: Q_DISABLE_COPY(VPattern) diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index cc4db241b..dc62134c4 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -138,6 +138,10 @@ const QString AttrNotes = QStringLiteral("notes"); const QString AttrAlias = QStringLiteral("alias"); const QString AttrAlias1 = QStringLiteral("alias1"); const QString AttrAlias2 = QStringLiteral("alias2"); +const QString AttrCurve1Alias1 = QStringLiteral("curve1Alias1"); +const QString AttrCurve1Alias2 = QStringLiteral("curve1Alias2"); +const QString AttrCurve2Alias1 = QStringLiteral("curve2Alias1"); +const QString AttrCurve2Alias2 = QStringLiteral("curve2Alias2"); const QString TypeLineDefault = QStringLiteral("default"); const QString TypeLineNone = QStringLiteral("none"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 40835040b..66b3351e7 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -156,6 +156,10 @@ extern const QString AttrNotes; extern const QString AttrAlias; extern const QString AttrAlias1; extern const QString AttrAlias2; +extern const QString AttrCurve1Alias1; +extern const QString AttrCurve1Alias2; +extern const QString AttrCurve2Alias1; +extern const QString AttrCurve2Alias2; extern const QString TypeLineDefault; extern const QString TypeLineNone; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 614fd2433..77690e539 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -62,6 +62,7 @@ schema/pattern/v0.8.8.xsd schema/pattern/v0.8.9.xsd schema/pattern/v0.8.10.xsd + schema/pattern/v0.8.11.xsd schema/multisize_measurements/v0.3.0.xsd schema/multisize_measurements/v0.4.0.xsd schema/multisize_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.8.11.xsd b/src/libs/ifc/schema/pattern/v0.8.11.xsd new file mode 100644 index 000000000..ea5ac8902 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.8.11.xsd @@ -0,0 +1,1127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vabstractmconverter.cpp b/src/libs/ifc/xml/vabstractmconverter.cpp index 2ec8fdc23..1cfb68bc2 100644 --- a/src/libs/ifc/xml/vabstractmconverter.cpp +++ b/src/libs/ifc/xml/vabstractmconverter.cpp @@ -41,6 +41,19 @@ VAbstractMConverter::VAbstractMConverter(const QString &fileName) { } +//--------------------------------------------------------------------------------------------------------------------- +auto VAbstractMConverter::Units() const -> Unit +{ + Unit units = StrToUnits(UniqueTagText(TagUnit, unitCM)); + + if (units == Unit::Px) + { + units = Unit::Cm; + } + + return units; +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractMConverter::AddRootComment() { diff --git a/src/libs/ifc/xml/vabstractmconverter.h b/src/libs/ifc/xml/vabstractmconverter.h index 77e3d226c..a45f343de 100644 --- a/src/libs/ifc/xml/vabstractmconverter.h +++ b/src/libs/ifc/xml/vabstractmconverter.h @@ -43,6 +43,8 @@ public: explicit VAbstractMConverter(const QString &fileName); virtual ~VAbstractMConverter() Q_DECL_EQ_DEFAULT; + auto Units() const -> Unit; + protected: void AddRootComment(); static QMultiMap OldNamesToNewNames_InV0_3_0(); diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index a9fc274db..68688fffb 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -155,14 +155,6 @@ bool VAbstractPattern::patternLabelWasChanged = false; namespace { -// Need to be reinited in setXMLContent as well -Q_GLOBAL_STATIC_WITH_ARGS(QString, patternNumberCached, (unknownCharacter)) -Q_GLOBAL_STATIC_WITH_ARGS(QString, labelDateFormatCached, (unknownCharacter)) -Q_GLOBAL_STATIC_WITH_ARGS(QString, patternNameCached, (unknownCharacter)) -Q_GLOBAL_STATIC_WITH_ARGS(QString, MPathCached, (unknownCharacter)) -Q_GLOBAL_STATIC_WITH_ARGS(QString, WatermarkPathCached, (unknownCharacter)) -Q_GLOBAL_STATIC_WITH_ARGS(QString, companyNameCached, (unknownCharacter)) - void ReadExpressionAttribute(QVector &expressions, const QDomElement &element, const QString &attribute) { VFormulaField formula; @@ -592,17 +584,26 @@ void VAbstractPattern::setXMLContent(const QString &fileName) { Clear(); VDomDocument::setXMLContent(fileName); + m_patternNumber = ReadPatternNumber(); + m_labelDateFormat = ReadLabelDateFormat(); + m_patternName = ReadPatternName(); + m_MPath = ReadMPath(); + m_watermarkPath = ReadWatermarkPath(); + m_companyName = ReadCompanyName(); + m_units = ReadUnits(); } //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::Clear() { clear(); - *patternNumberCached = unknownCharacter; - *labelDateFormatCached = unknownCharacter; - *patternNameCached = unknownCharacter; - *MPathCached = unknownCharacter; - *companyNameCached = unknownCharacter; + m_patternNumber.clear(); + m_labelDateFormat.clear(); + m_patternName.clear(); + m_MPath.clear(); + m_watermarkPath.clear(); + m_companyName.clear(); + m_units = Unit::LAST_UNIT_DO_NOT_USE; } //--------------------------------------------------------------------------------------------------------------------- @@ -820,11 +821,7 @@ QVector VAbstractPattern::getLocalHistory() const //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::MPath() const { - if (*MPathCached == unknownCharacter) - { - *MPathCached = UniqueTagText(TagMeasurements); - } - return *MPathCached; + return m_MPath; } //--------------------------------------------------------------------------------------------------------------------- @@ -832,9 +829,10 @@ void VAbstractPattern::SetMPath(const QString &path) { if (setTagText(TagMeasurements, path)) { - emit patternChanged(false); + m_MPath = path; patternLabelWasChanged = true; - *MPathCached = path; + modified = true; + emit patternChanged(false); } else { @@ -932,19 +930,15 @@ void VAbstractPattern::SetNotes(const QString &text) //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetPatternName() const { - if (*patternNameCached == unknownCharacter) - { - *patternNameCached = UniqueTagText(TagPatternName); - } - return *patternNameCached; + return m_patternName; } //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::SetPatternName(const QString &qsName) { - *patternNameCached = qsName; + m_patternName = qsName; CheckTagExists(TagPatternName); - setTagText(TagPatternName, *patternNameCached); + setTagText(TagPatternName, m_patternName); patternLabelWasChanged = true; modified = true; emit patternChanged(false); @@ -953,19 +947,15 @@ void VAbstractPattern::SetPatternName(const QString &qsName) //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetCompanyName() const { - if (*companyNameCached == unknownCharacter) - { - *companyNameCached = UniqueTagText(TagCompanyName); - } - return *companyNameCached; + return m_companyName; } //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::SetCompanyName(const QString& qsName) { - *companyNameCached = qsName; + m_companyName = qsName; CheckTagExists(TagCompanyName); - setTagText(TagCompanyName, *companyNameCached); + setTagText(TagCompanyName, m_companyName); patternLabelWasChanged = true; modified = true; emit patternChanged(false); @@ -974,19 +964,15 @@ void VAbstractPattern::SetCompanyName(const QString& qsName) //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetPatternNumber() const { - if (*patternNumberCached == unknownCharacter) - { - *patternNumberCached = UniqueTagText(TagPatternNum); - } - return *patternNumberCached; + return m_patternNumber; } //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::SetPatternNumber(const QString& qsNum) { - *patternNumberCached = qsNum; + m_patternNumber = qsNum; CheckTagExists(TagPatternNum); - setTagText(TagPatternNum, *patternNumberCached); + setTagText(TagPatternNum, m_patternNumber); patternLabelWasChanged = true; modified = true; emit patternChanged(false); @@ -1043,34 +1029,15 @@ void VAbstractPattern::SetCustomerEmail(const QString &email) //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetLabelDateFormat() const { - if (*labelDateFormatCached == unknownCharacter) - { - const QString globalLabelDateFormat = VAbstractApplication::VApp()->Settings()->GetLabelDateFormat(); - - const QDomNodeList list = elementsByTagName(TagPatternLabel); - if (list.isEmpty()) - { - return globalLabelDateFormat; - } - - try - { - *labelDateFormatCached = GetParametrString(list.at(0).toElement(), AttrDateFormat); - } - catch (const VExceptionEmptyParameter &) - { - return globalLabelDateFormat; - } - } - return *labelDateFormatCached; + return m_labelDateFormat; } //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::SetLabelDateFormat(const QString &format) { - *labelDateFormatCached = format; + m_labelDateFormat = format; QDomElement tag = CheckTagExists(TagPatternLabel); - SetAttribute(tag, AttrDateFormat, *labelDateFormatCached); + SetAttribute(tag, AttrDateFormat, m_labelDateFormat); patternLabelWasChanged = true; modified = true; emit patternChanged(false); @@ -1142,7 +1109,8 @@ bool VAbstractPattern::SetWatermarkPath(const QString &path) emit patternChanged(false); patternLabelWasChanged = true; - *WatermarkPathCached = path; + m_watermarkPath = path; + modified = true; return true; } else @@ -1151,7 +1119,8 @@ bool VAbstractPattern::SetWatermarkPath(const QString &path) { emit patternChanged(false); patternLabelWasChanged = true; - *WatermarkPathCached = path; + m_watermarkPath = path; + modified = true; return true; } else @@ -1165,11 +1134,7 @@ bool VAbstractPattern::SetWatermarkPath(const QString &path) //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetWatermarkPath() const { - if (*WatermarkPathCached == unknownCharacter) - { - *WatermarkPathCached = UniqueTagText(TagWatermark); - } - return *WatermarkPathCached; + return m_watermarkPath; } //--------------------------------------------------------------------------------------------------------------------- @@ -1235,6 +1200,31 @@ bool VAbstractPattern::GetPatternWasChanged() const return patternLabelWasChanged; } +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::GetPassmarkLengthVariable() const +{ + const QDomElement pattern = documentElement(); + + if (pattern.isNull()) + { + return {}; + } + + return GetParametrEmptyString(pattern, AttrPassmarkLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetPassmarkLengthVariable(const QString &name) +{ + QDomElement pattern = documentElement(); + + if (not pattern.isNull()) + { + SetAttribute(pattern, AttrPassmarkLength, name); + modified = true; + } +} + //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetImage() const { @@ -2277,6 +2267,73 @@ bool VAbstractPattern::GroupHasItem(const QDomElement &groupDomElement, quint32 return result; } +//--------------------------------------------------------------------------------------------------------------------- +auto VAbstractPattern::ReadUnits() const -> Unit +{ + Unit units = StrToUnits(UniqueTagText(TagUnit, unitCM)); + + if (units == Unit::Px) + { + units = Unit::Cm; + } + + return units; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::ReadPatternNumber() const +{ + return UniqueTagText(TagPatternNum); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::ReadLabelDateFormat() const +{ + const QString globalLabelDateFormat = VAbstractApplication::VApp()->Settings()->GetLabelDateFormat(); + + const QDomNodeList list = elementsByTagName(TagPatternLabel); + if (list.isEmpty()) + { + return globalLabelDateFormat; + } + + QString labelDateFormat; + + try + { + labelDateFormat = GetParametrString(list.at(0).toElement(), AttrDateFormat); + } + catch (const VExceptionEmptyParameter &) + { + return globalLabelDateFormat; + } + return labelDateFormat; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::ReadPatternName() const +{ + return UniqueTagText(TagPatternName); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::ReadMPath() const +{ + return UniqueTagText(TagMeasurements); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::ReadWatermarkPath() const +{ + return UniqueTagText(TagWatermark); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::ReadCompanyName() const +{ + return UniqueTagText(TagCompanyName); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief Adds an item to the given group with the given toolId and objectId @@ -2455,6 +2512,12 @@ VContainer VAbstractPattern::GetCompletePPData(const QString &name) const return VContainer(nullptr, nullptr, VContainer::UniqueNamespace()); } +//--------------------------------------------------------------------------------------------------------------------- +Unit VAbstractPattern::Units() const +{ + return m_units; +} + //--------------------------------------------------------------------------------------------------------------------- QStringList VAbstractPattern::FilterGroupTags(const QString &tags) { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 668b35c98..581407873 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -192,6 +192,9 @@ public: void SetPatternWasChanged(bool changed); bool GetPatternWasChanged() const; + QString GetPassmarkLengthVariable() const; + void SetPassmarkLengthVariable(const QString &name); + QString GetImage() const; QString GetImageExtension() const; void SetImage(const QString &text, const QString &extension); @@ -233,6 +236,8 @@ public: virtual VContainer GetCompleteData() const; virtual VContainer GetCompletePPData(const QString &name) const; + auto Units() const -> Unit; + static const QString TagPattern; static const QString TagCalculation; static const QString TagModeling; @@ -396,6 +401,14 @@ protected: /** @brief modified keep state of the document for cases that do not cover QUndoStack*/ mutable bool modified; + Unit m_units{Unit::LAST_UNIT_DO_NOT_USE}; + QString m_patternNumber{}; + QString m_labelDateFormat{}; + QString m_patternName{}; + QString m_MPath{}; + QString m_watermarkPath{}; + QString m_companyName{}; + /** @brief tools list with pointer on tools. */ static QHash tools; /** @brief patternLabelLines list to speed up reading a template by many pieces. */ @@ -420,7 +433,16 @@ protected: QVector getLocalHistory(const QString &draw) const; - bool GroupHasItem(const QDomElement &groupDomElement, quint32 toolId, quint32 objectId); + bool GroupHasItem(const QDomElement &groupDomElement, quint32 toolId, quint32 objectId); + + auto ReadUnits() const -> Unit; + auto ReadPatternNumber() const ->QString; + auto ReadLabelDateFormat() const ->QString; + auto ReadPatternName() const ->QString; + auto ReadMPath() const ->QString; + auto ReadWatermarkPath() const -> QString; + auto ReadCompanyName() const -> QString; + private: Q_DISABLE_COPY(VAbstractPattern) diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 2d3efa581..b4394eecd 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -232,8 +232,6 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2) } return false; } - -Unit mUnitCached = Unit::LAST_UNIT_DO_NOT_USE; } // namespace Q_LOGGING_CATEGORY(vXML, "v.xml") @@ -636,22 +634,6 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement) return id; } -//--------------------------------------------------------------------------------------------------------------------- -Unit VDomDocument::MUnit() const -{ - if (mUnitCached == Unit::LAST_UNIT_DO_NOT_USE) - { - mUnitCached = StrToUnits(UniqueTagText(TagUnit, unitCM)); - - if (mUnitCached == Unit::Px) - { - mUnitCached = Unit::Cm; - } - } - - return mUnitCached; -} - //--------------------------------------------------------------------------------------------------------------------- QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal) const { diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 238851546..97a5f0c57 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -118,8 +118,6 @@ public: static qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue); static quint32 GetParametrId(const QDomElement& domElement); - Unit MUnit() const; - virtual void setXMLContent(const QString &fileName); static QString UnitsHelpString(); diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index f5479ce1e..024bc38a8 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -60,8 +60,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.10"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.10.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.11"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.11.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -242,7 +242,8 @@ QString VPatternConverter::XSDSchema(int ver) const std::make_pair(FORMAT_VERSION(0, 8, 7), QStringLiteral("://schema/pattern/v0.8.7.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 8), QStringLiteral("://schema/pattern/v0.8.8.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 9), QStringLiteral("://schema/pattern/v0.8.9.xsd")), - std::make_pair(FORMAT_VERSION(0, 8, 10), CurrentSchema) + std::make_pair(FORMAT_VERSION(0, 8, 10), QStringLiteral("://schema/pattern/v0.8.10.xsd")), + std::make_pair(FORMAT_VERSION(0, 8, 11), CurrentSchema) }; if (schemas.contains(ver)) @@ -503,6 +504,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 10))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 10)): + ToV0_8_11(); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 11))); + Q_FALLTHROUGH(); + case (FORMAT_VERSION(0, 8, 11)): break; default: InvalidVersion(m_ver); @@ -520,7 +525,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 10), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 11), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -1192,6 +1197,16 @@ void VPatternConverter::ToV0_8_10() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_8_11() +{ + // TODO. Delete if minimal supported version is 0.8.11 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 11), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.8.11")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 8088e470f..64534111d 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4); - static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 10); + static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 11); protected: virtual int MinVer() const override; @@ -133,6 +133,7 @@ private: void ToV0_8_8(); void ToV0_8_9(); void ToV0_8_10(); + void ToV0_8_11(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index c90ed01c9..34c2d9018 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -345,7 +345,7 @@ void VVSTConverter::AddNewTagsForV0_5_0() return GetParametrInt(baseTag, QStringLiteral("base"), QChar('0')); }; - const Unit units = MUnit(); + const Unit units = Units(); { const int step = static_cast(UnitConvertor(6, Unit::Cm, units)); diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 6ae147f8f..9f5feb51c 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -109,10 +109,7 @@ const QString VMeasurements::DimensionZ = QStringLiteral("z"); namespace { -using VDimensions = QMap; - Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) -Q_GLOBAL_STATIC(VDimensions, dimensionsCached) //--------------------------------------------------------------------------------------------------------------------- QString FileComment() @@ -124,8 +121,7 @@ QString FileComment() //--------------------------------------------------------------------------------------------------------------------- VMeasurements::VMeasurements(VContainer *data) - :VDomDocument(), - data(data), + : data(data), type(MeasurementsType::Unknown) { SCASSERT(data != nullptr) @@ -133,8 +129,7 @@ VMeasurements::VMeasurements(VContainer *data) //--------------------------------------------------------------------------------------------------------------------- VMeasurements::VMeasurements(Unit unit, VContainer *data) - :VDomDocument(), - data(data), + : data(data), type(MeasurementsType::Individual) { SCASSERT(data != nullptr) @@ -145,9 +140,8 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data) //--------------------------------------------------------------------------------------------------------------------- VMeasurements::VMeasurements(Unit unit, const QVector &dimensions, VContainer *data) - :VDomDocument(), - data(data), - type(MeasurementsType::Multisize) + : data(data), + type(MeasurementsType::Multisize) { SCASSERT(data != nullptr) @@ -159,6 +153,8 @@ void VMeasurements::setXMLContent(const QString &fileName) { VDomDocument::setXMLContent(fileName); type = ReadType(); + m_units = ReadUnits(); + m_dimensions = ReadDimensions(); } //--------------------------------------------------------------------------------------------------------------------- @@ -277,6 +273,12 @@ void VMeasurements::MoveBottom(const QString &name) } } +//--------------------------------------------------------------------------------------------------------------------- +auto VMeasurements::Units() const -> Unit +{ + return m_units; +} + //--------------------------------------------------------------------------------------------------------------------- void VMeasurements::StoreNames(bool store) { @@ -327,25 +329,25 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons if (not specialUnits) { - base = UnitConvertor(base, MUnit(), *data->GetPatternUnit()); - shiftA = UnitConvertor(shiftA, MUnit(), *data->GetPatternUnit()); - shiftB = UnitConvertor(shiftB, MUnit(), *data->GetPatternUnit()); - shiftC = UnitConvertor(shiftC, MUnit(), *data->GetPatternUnit()); + base = UnitConvertor(base, Units(), *data->GetPatternUnit()); + shiftA = UnitConvertor(shiftA, Units(), *data->GetPatternUnit()); + shiftB = UnitConvertor(shiftB, Units(), *data->GetPatternUnit()); + shiftC = UnitConvertor(shiftC, Units(), *data->GetPatternUnit()); QMutableMapIterator iterator(corrections); while (iterator.hasNext()) { iterator.next(); - iterator.setValue(UnitConvertor(iterator.value(), MUnit(), *data->GetPatternUnit())); + iterator.setValue(UnitConvertor(iterator.value(), Units(), *data->GetPatternUnit())); } - convertedBaseA = UnitConvertor(convertedBaseA, MUnit(), *data->GetPatternUnit()); - convertedBaseB = UnitConvertor(convertedBaseB, MUnit(), *data->GetPatternUnit()); - convertedBaseC = UnitConvertor(convertedBaseC, MUnit(), *data->GetPatternUnit()); + convertedBaseA = UnitConvertor(convertedBaseA, Units(), *data->GetPatternUnit()); + convertedBaseB = UnitConvertor(convertedBaseB, Units(), *data->GetPatternUnit()); + convertedBaseC = UnitConvertor(convertedBaseC, Units(), *data->GetPatternUnit()); - convertedStepA = UnitConvertor(convertedStepA, MUnit(), *data->GetPatternUnit()); - convertedStepB = UnitConvertor(convertedStepB, MUnit(), *data->GetPatternUnit()); - convertedStepC = UnitConvertor(convertedStepC, MUnit(), *data->GetPatternUnit()); + convertedStepA = UnitConvertor(convertedStepA, Units(), *data->GetPatternUnit()); + convertedStepB = UnitConvertor(convertedStepB, Units(), *data->GetPatternUnit()); + convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit()); } meash = QSharedPointer::create(static_cast(i), name, @@ -380,7 +382,7 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons if (not specialUnits) { - value = UnitConvertor(value, MUnit(), *data->GetPatternUnit()); + value = UnitConvertor(value, Units(), *data->GetPatternUnit()); } meash = QSharedPointer::create(data, static_cast(i), name, value, formula, ok); @@ -846,61 +848,9 @@ QString VMeasurements::MeasurementForDimension(IMD type) const } //--------------------------------------------------------------------------------------------------------------------- -auto VMeasurements::Dimensions() const -> QMap +auto VMeasurements::Dimensions() const -> VDimensions { - if (type != MeasurementsType::Multisize) - { - return QMap(); - } - - if (dimensionsCached->isEmpty()) - { - const Unit units = MUnit(); - const QDomNodeList list = elementsByTagName(TagDimension); - for (int i=0; i < list.size(); ++i) - { - const QDomElement dom = list.at(i).toElement(); - const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType)); - const qreal min = GetParametrDouble(dom, AttrMin, QChar('0')); - const qreal max = GetParametrDouble(dom, AttrMax, QChar('0')); - const qreal step = GetParametrDouble(dom, AttrStep, QStringLiteral("-1")); - const qreal base = GetParametrDouble(dom, AttrBase, QChar('0')); - - const DimesionLabels labels = ReadDimensionLabels(dom); - - if (type == MeasurementDimension::X) - { - auto dimension = QSharedPointer::create(units, min, max, step); - dimension->SetBaseValue(base); - dimension->SetLabels(labels); - dimensionsCached->insert(type, dimension); - } - else if (type == MeasurementDimension::Y) - { - auto dimension = QSharedPointer::create(units, min, max, step); - dimension->SetBaseValue(base); - dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr)); - dimension->SetLabels(labels); - dimensionsCached->insert(type, dimension); - } - else if (type == MeasurementDimension::W) - { - auto dimension = QSharedPointer::create(units, min, max, step); - dimension->SetBaseValue(base); - dimension->SetLabels(labels); - dimensionsCached->insert(type, dimension); - } - else if (type == MeasurementDimension::Z) - { - auto dimension = QSharedPointer::create(units, min, max, step); - dimension->SetBaseValue(base); - dimension->SetLabels(labels); - dimensionsCached->insert(type, dimension); - } - } - } - - return *dimensionsCached; + return m_dimensions; } //--------------------------------------------------------------------------------------------------------------------- @@ -976,7 +926,7 @@ void VMeasurements::SetDimensionLabels(const QMapclear(); // Invalidate cache + m_dimensions = ReadDimensions(); // Refresh cache } //--------------------------------------------------------------------------------------------------------------------- @@ -1187,6 +1137,10 @@ void VMeasurements::CreateEmptyMultisizeFile(Unit unit, this->appendChild(mElement); insertBefore(createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild()); + + // Cache data + m_units = unit; + m_dimensions = ReadDimensions(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1215,6 +1169,10 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit) this->appendChild(mElement); insertBefore(createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild()); + + // Cache data + m_units = unit; + m_dimensions = ReadDimensions(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1246,7 +1204,7 @@ QDomElement VMeasurements::CreateDimensions(const QVectorelementsByTagName(tag); if (nodeList.isEmpty()) @@ -1332,6 +1290,76 @@ MeasurementsType VMeasurements::ReadType() const } } +//--------------------------------------------------------------------------------------------------------------------- +auto VMeasurements::ReadUnits() const -> Unit +{ + Unit units = StrToUnits(UniqueTagText(TagUnit, unitCM)); + + if (units == Unit::Px) + { + units = Unit::Cm; + } + + return units; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VMeasurements::ReadDimensions() const -> VDimensions +{ + if (type != MeasurementsType::Multisize) + { + return {}; + } + + VDimensions dimensions; + + const Unit units = Units(); + const QDomNodeList list = elementsByTagName(TagDimension); + for (int i=0; i < list.size(); ++i) + { + const QDomElement dom = list.at(i).toElement(); + const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType)); + const qreal min = GetParametrDouble(dom, AttrMin, QChar('0')); + const qreal max = GetParametrDouble(dom, AttrMax, QChar('0')); + const qreal step = GetParametrDouble(dom, AttrStep, QStringLiteral("-1")); + const qreal base = GetParametrDouble(dom, AttrBase, QChar('0')); + + const DimesionLabels labels = ReadDimensionLabels(dom); + + if (type == MeasurementDimension::X) + { + auto dimension = QSharedPointer::create(units, min, max, step); + dimension->SetBaseValue(base); + dimension->SetLabels(labels); + dimensions.insert(type, dimension); + } + else if (type == MeasurementDimension::Y) + { + auto dimension = QSharedPointer::create(units, min, max, step); + dimension->SetBaseValue(base); + dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr)); + dimension->SetLabels(labels); + dimensions.insert(type, dimension); + } + else if (type == MeasurementDimension::W) + { + auto dimension = QSharedPointer::create(units, min, max, step); + dimension->SetBaseValue(base); + dimension->SetLabels(labels); + dimensions.insert(type, dimension); + } + else if (type == MeasurementDimension::Z) + { + auto dimension = QSharedPointer::create(units, min, max, step); + dimension->SetBaseValue(base); + dimension->SetLabels(labels); + dimensions.insert(type, dimension); + } + } + + return dimensions; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VMeasurements::EvalFormula(VContainer *data, const QString &formula, bool *ok) const { diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index 22f17f906..05054710e 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -44,6 +44,8 @@ class VContainer; enum class GenderType : qint8 { Male, Female, Unknown }; +using VDimensions = QMap; + class VMeasurements : public VDomDocument { Q_DECLARE_TR_FUNCTIONS(VMeasurements) @@ -65,6 +67,8 @@ public: void MoveDown(const QString &name); void MoveBottom(const QString &name); + auto Units() const -> Unit; + void StoreNames(bool store); void ReadMeasurements(qreal baseA, qreal baseB=0, qreal baseC=0) const; @@ -117,7 +121,7 @@ public: QString MeasurementForDimension(IMD type) const; - auto Dimensions() const -> QMap; + auto Dimensions() const -> VDimensions; auto GetRestrictions() const -> QMap; void SetRestrictions(const QMap &restrictions); @@ -201,6 +205,10 @@ private: VContainer *data; MeasurementsType type; + // Cache data to quick access + Unit m_units{Unit::LAST_UNIT_DO_NOT_USE}; + VDimensions m_dimensions{}; + /** @brief m_keepNames store names in container to check uniqueness. */ bool m_keepNames{true}; @@ -214,6 +222,8 @@ private: QDomElement MakeEmpty(const QString &name, const QString &formula); QDomElement FindM(const QString &name) const; MeasurementsType ReadType() const; + auto ReadUnits() const -> Unit; + auto ReadDimensions() const -> VDimensions; qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const; diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 0c8aad32f..16b7ca37d 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1665,10 +1665,8 @@ qreal VSAPoint::PassmarkLength(qreal width) const passmarkLength = qMin(passmarkLength, maxPassmarkLength); return passmarkLength; } - else - { - return m_passmarkLength; - } + + return m_passmarkLength; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/debugbreak.h b/src/libs/vmisc/debugbreak.h index c40850901..89a4aebf8 100644 --- a/src/libs/vmisc/debugbreak.h +++ b/src/libs/vmisc/debugbreak.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2018, Scott Tsai +/* Copyright (c) 2011-2021, Scott Tsai * * All rights reserved. * @@ -23,7 +23,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #ifndef DEBUG_BREAK_H #define DEBUG_BREAK_H @@ -50,7 +49,7 @@ __inline__ static void trap_instruction(void) #elif defined(__thumb__) #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION /* FIXME: handle __THUMB_INTERWORK__ */ -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* See 'arm-linux-tdep.c' in GDB source. @@ -82,7 +81,7 @@ __inline__ static void trap_instruction(void) } #elif defined(__arm__) && !defined(__thumb__) #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* See 'arm-linux-tdep.c' in GDB source, @@ -95,7 +94,7 @@ __inline__ static void trap_instruction(void) #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_TRAP #elif defined(__aarch64__) #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* See 'aarch64-tdep.c' in GDB source, @@ -105,7 +104,7 @@ __inline__ static void trap_instruction(void) #elif defined(__powerpc__) /* PPC 32 or 64-bit, big or little endian */ #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* See 'rs6000-tdep.c' in GDB source, @@ -119,6 +118,17 @@ __inline__ static void trap_instruction(void) * The workaround is the same as ARM Thumb mode: use debugbreak-gdb.py * or manually jump over the instruction. */ } +#elif defined(__riscv) + /* RISC-V 32 or 64-bit, whether the "C" extension + * for compressed, 16-bit instructions are supported or not */ + #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION +__attribute__((always_inline)) +__inline__ static void trap_instruction(void) +{ + /* See 'riscv-tdep.c' in GDB source, + * 'riscv_sw_breakpoint_from_kind' */ + __asm__ volatile(".4byte 0x00100073"); +} #else #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP #endif @@ -127,20 +137,20 @@ __inline__ static void trap_instruction(void) #ifndef DEBUG_BREAK_IMPL #error "debugbreak.h is not supported on this target" #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void debug_break(void) { trap_instruction(); } #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void debug_break(void) { __builtin_trap(); } #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP #include -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void debug_break(void) { raise(SIGTRAP); diff --git a/src/libs/vmisc/literals.cpp b/src/libs/vmisc/literals.cpp index 926a04b10..a0faaaa90 100644 --- a/src/libs/vmisc/literals.cpp +++ b/src/libs/vmisc/literals.cpp @@ -34,4 +34,3 @@ const QString preferencesOtherIcon = QStringLiteral("preferences-other"); const QString degreeSymbol = QStringLiteral("°"); const QString trueStr = QStringLiteral("true"); const QString falseStr = QStringLiteral("false"); -const QString unknownCharacter = QStringLiteral("�"); diff --git a/src/libs/vmisc/literals.h b/src/libs/vmisc/literals.h index 798a84181..d20a07865 100644 --- a/src/libs/vmisc/literals.h +++ b/src/libs/vmisc/literals.h @@ -40,6 +40,5 @@ extern const QString preferencesOtherIcon; extern const QString degreeSymbol; extern const QString trueStr; extern const QString falseStr; -extern const QString unknownCharacter; #endif // LITERALS_H diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index 7595071a6..05ed47232 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -42,7 +42,7 @@ extern const int MAJOR_VERSION = 0; extern const int MINOR_VERSION = 7; -extern const int DEBUG_VERSION = 46; +extern const int DEBUG_VERSION = 47; extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); diff --git a/src/libs/vmisc/projectversion.h b/src/libs/vmisc/projectversion.h index be2f7a35c..690534416 100644 --- a/src/libs/vmisc/projectversion.h +++ b/src/libs/vmisc/projectversion.h @@ -49,8 +49,8 @@ extern const QString APP_VERSION_STR; // Change version number in projectversion.cpp too. // Synchronize valentina.nsi -#define VER_FILEVERSION 0,7,46 -#define VER_FILEVERSION_STR "0.7.46\0" +#define VER_FILEVERSION 0,7,47 +#define VER_FILEVERSION_STR "0.7.47\0" #define V_PRERELEASE // Mark prerelease builds diff --git a/src/libs/vmisc/vmisc.pro b/src/libs/vmisc/vmisc.pro index 38e39515b..eb0333d8e 100644 --- a/src/libs/vmisc/vmisc.pro +++ b/src/libs/vmisc/vmisc.pro @@ -90,6 +90,6 @@ CONFIG(debug, debug|release){ } } -DEFINES += "LATEST_TAG_DISTANCE=$$FindLatestTagDistance()" # Make available latest tag distance number in sources. +DEFINES += LATEST_TAG_DISTANCE=\\\"$$FindLatestTagDistance()\\\" # Make available latest tag distance number in sources. include (../libs.pri) diff --git a/src/libs/vpatterndb/vpassmark.cpp b/src/libs/vpatterndb/vpassmark.cpp index 7e552e790..f7135acde 100644 --- a/src/libs/vpatterndb/vpassmark.cpp +++ b/src/libs/vpatterndb/vpassmark.cpp @@ -537,6 +537,43 @@ QVector CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType return passmarksLines; } +//--------------------------------------------------------------------------------------------------------------------- +auto PassmarkLength(const VPiecePassmarkData &passmarkData, qreal width, bool &ok) -> qreal +{ + qreal length = 0; + if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength()) + { + if (passmarkData.globalPassmarkLength > accuracyPointOnLine) + { + ok = true; + return passmarkData.globalPassmarkLength; + } + + length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength); + + if (length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " + "than minimal allowed.") + .arg(passmarkData.nodeName, passmarkData.pieceName); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + + ok = false; + return length; + } + + ok = true; + return length; + } + + length = passmarkData.passmarkSAPoint.GetPasskmarkLength(); + + ok = true; + return length; +} + //--------------------------------------------------------------------------------------------------------------------- QVector PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const VPiecePassmarkData &passmarkData, const QPointF &seamPassmarkSAPoint, const QVector &seamAllowance) @@ -572,14 +609,11 @@ QVector PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const return QVector(); } - const qreal length = passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth); - if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + bool ok = false; + const qreal length = PassmarkLength(passmarkData, passmarkData.passmarkSAPoint.MaxLocalSA(passmarkData.saWidth), + ok); + if (not ok) { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " - "than minimal allowed.") - .arg(passmarkData.nodeName, passmarkData.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; return QVector(); } @@ -624,6 +658,7 @@ QJsonObject VPiecePassmarkData::toJson() const {"isShowSecondPassmark", isShowSecondPassmark}, {"passmarkIndex", passmarkIndex}, {"id", static_cast(id)}, + {"globalPassmarkLength", static_cast(globalPassmarkLength)}, }; return dataObject; @@ -781,15 +816,11 @@ QVector VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const qreal length = 0; if (not piece.IsSeamAllowanceBuiltIn()) { - length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth); - if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + bool ok = false; + length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok); + if (not ok) { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " - "than minimal allowed.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - return QVector(); + return {}; } } else @@ -888,34 +919,23 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa if (intersections.last() != m_data.passmarkSAPoint) { line = QLineF(intersections.last(), m_data.passmarkSAPoint); - if (not m_data.passmarkSAPoint.IsManualPasskmarkLength()) + + bool ok = false; + const qreal length = PassmarkLength(m_data, width, ok); + if (not ok) { - const qreal length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength); - if (length <= accuracyPointOnLine) - { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is " - "less than minimal allowed.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - return QLineF(); - } - line.setLength(length); - } - else - { - line.setLength(m_data.passmarkSAPoint.GetPasskmarkLength()); + return QLineF(); } + line.setLength(length); + return line; } - else - { - const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch " - "collapse.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - } + + const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch " + "collapse.") + .arg(m_data.nodeName, m_data.pieceName); + VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } else { @@ -931,21 +951,17 @@ QVector VPassmark::SAPassmarkBaseLine(const QVector &seamAllowa if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward) { - const qreal length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth); - if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + bool ok = false; + const qreal length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok); + + if (not ok) { - const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " - "than minimal allowed.") - .arg(m_data.nodeName, m_data.pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; - } - else - { - QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint); - line.setLength(length); - return QVector({line}); + return {}; } + + QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint); + line.setLength(length); + return {line}; } else if (m_data.passmarkAngleType == PassmarkAngleType::Bisector) { diff --git a/src/libs/vpatterndb/vpassmark.h b/src/libs/vpatterndb/vpassmark.h index f4cf693e2..648b7e34f 100644 --- a/src/libs/vpatterndb/vpassmark.h +++ b/src/libs/vpatterndb/vpassmark.h @@ -61,6 +61,7 @@ struct VPiecePassmarkData bool isShowSecondPassmark{true}; int passmarkIndex{-1}; vidtype id{NULL_ID}; + qreal globalPassmarkLength{0}; QJsonObject toJson() const; }; @@ -102,7 +103,6 @@ private: bool m_null{true}; QVector MakeSAPassmark(const QVector &seamAllowance, PassmarkSide side) const; - }; #endif // VPASSMARK_H diff --git a/src/libs/vpatterndb/vpatterndb.pro b/src/libs/vpatterndb/vpatterndb.pro index 49c48e227..ecaab14f1 100644 --- a/src/libs/vpatterndb/vpatterndb.pro +++ b/src/libs/vpatterndb/vpatterndb.pro @@ -7,7 +7,7 @@ # File with common stuff for whole project include(../../../common.pri) -QT += core widgets printsupport +QT += core widgets printsupport xmlpatterns concurrent xml # Name of the library TARGET = vpatterndb diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 959cca32f..8d1eba71a 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -38,6 +38,7 @@ #include "../vmisc/compatibility.h" #include "../ifc/exception/vexceptioninvalidnotch.h" #include "../vlayout/testpath.h" +#include "../ifc/xml/vabstractpattern.h" #include #include @@ -1106,6 +1107,7 @@ VPassmark VPiece::CreatePassmark(const QVector &path, int previousIn passmarkData.isShowSecondPassmark = path.at(passmarkIndex).IsShowSecondPassmark(); passmarkData.passmarkIndex = passmarkIndex; passmarkData.id = path.at(passmarkIndex).GetId(); + passmarkData.globalPassmarkLength = ToPixel(GlobalPassmarkLength(data), *data->GetPatternUnit()); return VPassmark(passmarkData); } @@ -1170,6 +1172,39 @@ QJsonObject VPiece::DBToJson(const VContainer *data) const return dbObject; } +//--------------------------------------------------------------------------------------------------------------------- +auto VPiece::GlobalPassmarkLength(const VContainer *data) const -> qreal +{ + qreal length = 0; + QString passmarkLengthVariable = VAbstractValApplication::VApp()->getCurrentDocument()->GetPassmarkLengthVariable(); + if (passmarkLengthVariable.isEmpty()) + { + return 0; + } + + try + { + QSharedPointer var = data->GetVariable(passmarkLengthVariable); + length = *var->GetValue(); + + if (length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Invalid global value for a passmark length. Piece '%1'. Length is " + "less than minimal allowed.") + .arg(GetName()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + } + } + catch (const VExceptionBadId &) + { + length = 0; + } + + return length; +} + //--------------------------------------------------------------------------------------------------------------------- void VPiece::DumpPiece(const VPiece &piece, const VContainer *data) { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 9edb23976..674baecb0 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -158,6 +158,8 @@ private: QJsonObject MainPathToJson() const; QJsonObject DBToJson(const VContainer *data) const; + + qreal GlobalPassmarkLength(const VContainer *data) const; }; Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE); diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index 4e814f445..13cf270b0 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -266,6 +266,11 @@ void AbstractTest::PassmarkDataFromJson(const QString &json, VPiecePassmarkData vidtype id; AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("id"), id, QString::number(NULL_ID)); data.id = id; + + qreal globalPassmarkLength; + AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("globalPassmarkLength"), globalPassmarkLength, + QString::number(NULL_ID)); + data.globalPassmarkLength = globalPassmarkLength; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/dialogtoolbox.cpp b/src/libs/vtools/dialogs/dialogtoolbox.cpp index a2ce91c1d..8e74f2bb5 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.cpp +++ b/src/libs/vtools/dialogs/dialogtoolbox.cpp @@ -36,6 +36,12 @@ #include "../vpatterndb/variables/vcurvelength.h" #include "../ifc/exception/vexceptionbadid.h" #include "../vpatterndb/vcontainer.h" +#include "../vgeometry/vellipticalarc.h" +#include "../vgeometry/varc.h" +#include "../vgeometry/vcubicbezier.h" +#include "../vgeometry/vcubicbezierpath.h" +#include "../vgeometry/vspline.h" +#include "../vgeometry/vsplinepath.h" #include #include @@ -106,7 +112,20 @@ bool DoubleCurve(const VPieceNode &firstNode, const VPieceNode &secondNode) return false; } + +//--------------------------------------------------------------------------------------------------------------------- +template +auto CurveAliases(const QString &alias1, const QString &alias2) -> QPair +{ + T curve1; + curve1.SetAliasSuffix(alias1); + + T curve2; + curve2.SetAliasSuffix(alias2); + + return qMakePair(curve1.GetAlias(), curve2.GetAlias()); } +} // namespace //--------------------------------------------------------------------------------------------------------------------- VPieceNode RowNode(QListWidget *listWidget, int i) @@ -527,3 +546,33 @@ QIcon LineColor(int size, const QString &color) pix.fill(QColor(color)); return QIcon(pix); } + +//--------------------------------------------------------------------------------------------------------------------- +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Wswitch-default") +auto SegmentAliases(GOType curveType, const QString &alias1, const QString &alias2) -> QPair +{ + switch(curveType) + { + case GOType::EllipticalArc: + return CurveAliases(alias1, alias2); + case GOType::Arc: + return CurveAliases(alias1, alias2); + case GOType::CubicBezier: + return CurveAliases(alias1, alias2); + case GOType::Spline: + return CurveAliases(alias1, alias2); + case GOType::CubicBezierPath: + return CurveAliases(alias1, alias2); + case GOType::SplinePath: + return CurveAliases(alias1, alias2); + case GOType::Point: + case GOType::PlaceLabel: + case GOType::Unknown: + Q_UNREACHABLE(); + break; + } + + return {}; +} +QT_WARNING_POP diff --git a/src/libs/vtools/dialogs/dialogtoolbox.h b/src/libs/vtools/dialogs/dialogtoolbox.h index ec7b1ee4b..bba25526b 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.h +++ b/src/libs/vtools/dialogs/dialogtoolbox.h @@ -34,6 +34,7 @@ #include "../vpatterndb/variables/vinternalvariable.h" #include "../vmisc/typedef.h" +#include "../vgeometry/vgeometrydef.h" class QPlainTextEdit; class QPushButton; @@ -88,5 +89,6 @@ QFont NodeFont(QFont font, bool nodeExcluded = false); void CurrentCurveLength(vidtype curveId, VContainer *data); void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar=4); QIcon LineColor(int size, const QString &color); +auto SegmentAliases(GOType curveType, const QString &alias1, const QString &alias2) -> QPair; #endif // DIALOGTOOLBOX_H diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index c7facc36a..d3dc6ecc0 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -51,6 +51,8 @@ #include "../support/dialogeditwrongformula.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" +#include "../qmuparser/qmudef.h" +#include "../dialogtoolbox.h" #include "ui_dialogcurveintersectaxis.h" //--------------------------------------------------------------------------------------------------------------------- @@ -95,6 +97,8 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, quint }); connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::DeployAngleTextEdit); connect(timerFormula, &QTimer::timeout, this, &DialogCurveIntersectAxis::EvalAngle); + connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCurveIntersectAxis::ValidateAlias); + connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCurveIntersectAxis::ValidateAlias); vis = new VisToolCurveIntersectAxis(data); @@ -352,6 +356,46 @@ void DialogCurveIntersectAxis::closeEvent(QCloseEvent *event) DialogTool::closeEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::ValidateAlias() +{ + QRegularExpression rx(NameRegExp()); + + const QSharedPointer curve = data->GeometricObject(getCurveId()); + QPair alias = SegmentAliases(curve->getType(), GetAliasSuffix1(), GetAliasSuffix2()); + + + if (not GetAliasSuffix1().isEmpty() && + (not rx.match(alias.first).hasMatch() || + (originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(alias.first)) || + alias.first == alias.second)) + { + flagAlias1 = false; + ChangeColor(ui->labelAlias1, errorColor); + } + else + { + flagAlias1 = true; + ChangeColor(ui->labelAlias1, OkColor(this)); + } + + if (not GetAliasSuffix2().isEmpty() && + (not rx.match(alias.second).hasMatch() || + (originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(alias.second)) || + alias.first == alias.second)) + { + flagAlias2 = false; + ChangeColor(ui->labelAlias2, errorColor); + } + else + { + flagAlias2 = true; + ChangeColor(ui->labelAlias2, OkColor(this)); + } + + CheckState(); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogCurveIntersectAxis::SetNotes(const QString ¬es) { @@ -363,3 +407,31 @@ QString DialogCurveIntersectAxis::GetNotes() const { return ui->plainTextEditToolNotes->toPlainText(); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::SetAliasSuffix1(const QString &alias) +{ + originAliasSuffix1 = alias; + ui->lineEditAlias1->setText(originAliasSuffix1); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCurveIntersectAxis::GetAliasSuffix1() const +{ + return ui->lineEditAlias1->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::SetAliasSuffix2(const QString &alias) +{ + originAliasSuffix2 = alias; + ui->lineEditAlias2->setText(originAliasSuffix2); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCurveIntersectAxis::GetAliasSuffix2() const +{ + return ui->lineEditAlias2->text(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h index 6bb117784..d79fb93e1 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h @@ -72,6 +72,12 @@ public: void SetNotes(const QString ¬es); QString GetNotes() const; + void SetAliasSuffix1(const QString &alias); + QString GetAliasSuffix1() const; + + void SetAliasSuffix2(const QString &alias); + QString GetAliasSuffix2() const; + virtual void ShowDialog(bool click) override; public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; @@ -86,6 +92,8 @@ protected: virtual void SaveData() override; virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; +private slots: + void ValidateAlias(); private: Q_DISABLE_COPY(DialogCurveIntersectAxis) Ui::DialogCurveIntersectAxis *ui; @@ -101,12 +109,17 @@ private: bool flagFormula; bool flagName; + bool flagAlias1{true}; + bool flagAlias2{true}; + + QString originAliasSuffix1{}; + QString originAliasSuffix2{}; }; //--------------------------------------------------------------------------------------------------------------------- inline bool DialogCurveIntersectAxis::IsValid() const { - return flagFormula && flagName; + return flagFormula && flagName && flagAlias1 && flagAlias2; } #endif // DIALOGCURVEINTERSECTAXIS_H diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.ui b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.ui index 42d222f6c..0d6038518 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.ui +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.ui @@ -6,8 +6,8 @@ 0 0 - 335 - 331 + 324 + 394 @@ -320,6 +320,34 @@ + + + + Alias1: + + + + + + + true + + + + + + + Alias2: + + + + + + + true + + + diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index ec0bbb4d9..2a484473b 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -219,7 +219,7 @@ void DialogCutArc::ValidateAlias() if (not GetAliasSuffix1().isEmpty() && (not rx.match(arc1.GetAlias()).hasMatch() || - (originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(arc1.GetAlias())) || + (originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(arc1.GetAlias())) || arc1.GetAlias() == arc2.GetAlias())) { flagAlias1 = false; diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index 30dd1a12e..fc1795152 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -227,7 +227,7 @@ void DialogCutSpline::ValidateAlias() if (not GetAliasSuffix1().isEmpty() && (not rx.match(spl1.GetAlias()).hasMatch() || - (originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(spl1.GetAlias())) || + (originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(spl1.GetAlias())) || spl1.GetAlias() == spl2.GetAlias())) { flagAlias1 = false; diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index 44e5c6175..90f5305cb 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -227,7 +227,7 @@ void DialogCutSplinePath::ValidateAlias() if (not GetAliasSuffix1().isEmpty() && (not rx.match(path1.GetAlias()).hasMatch() || - (originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(path1.GetAlias())) || + (originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(path1.GetAlias())) || path1.GetAlias() == path2.GetAlias())) { flagAlias1 = false; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp index 653aa4bd0..b16ce1858 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp @@ -38,7 +38,9 @@ #include "../../visualization/path/vistoolpointofintersectioncurves.h" #include "../../visualization/visualization.h" #include "../vmisc/vabstractapplication.h" -#include "dialogtool.h" +#include "../qmuparser/qmudef.h" +#include "../dialogtoolbox.h" +#include "../vpatterndb/vcontainer.h" #include "ui_dialogpointofintersectioncurves.h" //--------------------------------------------------------------------------------------------------------------------- @@ -72,6 +74,10 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine this, &DialogPointOfIntersectionCurves::CurveChanged); connect(ui->comboBoxCurve2, &QComboBox::currentTextChanged, this, &DialogPointOfIntersectionCurves::CurveChanged); + connect(ui->lineEditCurve1Alias1, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias); + connect(ui->lineEditCurve1Alias2, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias); + connect(ui->lineEditCurve2Alias1, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias); + connect(ui->lineEditCurve2Alias2, &QLineEdit::textEdited, this, &DialogPointOfIntersectionCurves::ValidateAlias); vis = new VisToolPointOfIntersectionCurves(data); @@ -252,6 +258,65 @@ void DialogPointOfIntersectionCurves::CurveChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::ValidateAlias() +{ + QRegularExpression rx(NameRegExp()); + + const QSharedPointer curve1 = data->GeometricObject(GetFirstCurveId()); + QPair curve1Alias = SegmentAliases(curve1->getType(), GetCurve1AliasSuffix1(), + GetCurve1AliasSuffix2()); + + const QSharedPointer curve2 = data->GeometricObject(GetSecondCurveId()); + QPair curve2Alias = SegmentAliases(curve2->getType(), GetCurve2AliasSuffix1(), + GetCurve2AliasSuffix2()); + + QSet uniqueAliases; + int countAliases = 0; + + auto CountUniqueAliases = [&countAliases, &uniqueAliases](const QString &alias) + { + if (not alias.isEmpty()) + { + uniqueAliases.insert(alias); + ++countAliases; + } + }; + + CountUniqueAliases(curve1Alias.first); + CountUniqueAliases(curve1Alias.second); + CountUniqueAliases(curve2Alias.first); + CountUniqueAliases(curve2Alias.second); + + auto Validate = [countAliases, uniqueAliases, rx, this](const QString &originalSuffix, const QString &suffix, + const QString &alias, bool &flagAlias, QLabel *label) + { + if (not suffix.isEmpty() && + (not rx.match(alias).hasMatch() || (originalSuffix != suffix && not data->IsUnique(alias)) || + countAliases != uniqueAliases.size())) + { + flagAlias = false; + ChangeColor(label, errorColor); + } + else + { + flagAlias = true; + ChangeColor(label, OkColor(this)); + } + }; + + Validate(originCurve1AliasSuffix1, GetCurve1AliasSuffix1(), curve1Alias.first, flagCurve1Alias1, + ui->labelCurve1Alias1); + Validate(originCurve1AliasSuffix2, GetCurve1AliasSuffix2(), curve1Alias.second, flagCurve1Alias2, + ui->labelCurve1Alias2); + Validate(originCurve2AliasSuffix1, GetCurve2AliasSuffix1(), curve2Alias.first, flagCurve2Alias1, + ui->labelCurve2Alias1); + Validate(originCurve2AliasSuffix2, GetCurve2AliasSuffix2(), curve2Alias.second, flagCurve2Alias2, + ui->labelCurve2Alias2); + + CheckState(); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfIntersectionCurves::SetNotes(const QString ¬es) { @@ -263,3 +328,59 @@ QString DialogPointOfIntersectionCurves::GetNotes() const { return ui->plainTextEditToolNotes->toPlainText(); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetCurve1AliasSuffix1(const QString &alias) +{ + originCurve1AliasSuffix1 = alias; + ui->lineEditCurve1Alias1->setText(originCurve1AliasSuffix1); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogPointOfIntersectionCurves::GetCurve1AliasSuffix1() const +{ + return ui->lineEditCurve1Alias1->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetCurve1AliasSuffix2(const QString &alias) +{ + originCurve1AliasSuffix2 = alias; + ui->lineEditCurve1Alias2->setText(originCurve1AliasSuffix2); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogPointOfIntersectionCurves::GetCurve1AliasSuffix2() const +{ + return ui->lineEditCurve1Alias2->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetCurve2AliasSuffix1(const QString &alias) +{ + originCurve2AliasSuffix1 = alias; + ui->lineEditCurve2Alias1->setText(originCurve2AliasSuffix1); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogPointOfIntersectionCurves::GetCurve2AliasSuffix1() const +{ + return ui->lineEditCurve2Alias1->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetCurve2AliasSuffix2(const QString &alias) +{ + originCurve2AliasSuffix2 = alias; + ui->lineEditCurve2Alias2->setText(originCurve2AliasSuffix2); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogPointOfIntersectionCurves::GetCurve2AliasSuffix2() const +{ + return ui->lineEditCurve2Alias2->text(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h index 734a4a35f..f8b07aa62 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h @@ -69,6 +69,18 @@ public: void SetNotes(const QString ¬es); QString GetNotes() const; + void SetCurve1AliasSuffix1(const QString &alias); + QString GetCurve1AliasSuffix1() const; + + void SetCurve1AliasSuffix2(const QString &alias); + QString GetCurve1AliasSuffix2() const; + + void SetCurve2AliasSuffix1(const QString &alias); + QString GetCurve2AliasSuffix1() const; + + void SetCurve2AliasSuffix2(const QString &alias); + QString GetCurve2AliasSuffix2() const; + public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; @@ -83,6 +95,7 @@ protected: private slots: void CurveChanged(); + void ValidateAlias(); private: Q_DISABLE_COPY(DialogPointOfIntersectionCurves) @@ -93,12 +106,21 @@ private: bool flagName; bool flagError; + bool flagCurve1Alias1{true}; + bool flagCurve1Alias2{true}; + bool flagCurve2Alias1{true}; + bool flagCurve2Alias2{true}; + + QString originCurve1AliasSuffix1{}; + QString originCurve1AliasSuffix2{}; + QString originCurve2AliasSuffix1{}; + QString originCurve2AliasSuffix2{}; }; //--------------------------------------------------------------------------------------------------------------------- inline bool DialogPointOfIntersectionCurves::IsValid() const { - return flagName && flagError; + return flagName && flagError && flagCurve1Alias1 && flagCurve1Alias2 && flagCurve2Alias1 && flagCurve2Alias2; } #endif // DIALOGPOINTOFINTERSECTIONCURVES_H diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui index 202dce314..b49926786 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui @@ -6,8 +6,8 @@ 0 0 - 304 - 242 + 324 + 463 @@ -17,7 +17,7 @@ :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - + @@ -27,95 +27,170 @@ Tool - - - QFormLayout::ExpandingFieldsGrow - - - - - - 0 - 0 - - - - First curve: + + + + + + + + 0 + 0 + + + + First curve: + + + + + + + + + + + + + + + 0 + 0 + + + + Second curve: + + + + + + + + + + + 0 + 0 + + + + Point label: + + + + + + + + 0 + 0 + + + + Unique label + + + Choose unique label. + + + + + + + Vertical correction: + + + + + + + + + + Horizontal correction: + + + + + + + + + + + + Curve 1 + + + + + Alias1: + + + + + + + true + + + + + + + Alias2: + + + + + + + true + + + + - - - - + + + + Curve 2 + + + + + Alias1: + + + + + + + true + + + + + + + Alias2: + + + + + + + true + + + + - - - - - 0 - 0 - - - - Second curve: - - - - - - - - - - - 0 - 0 - - - - Point label: - - - - - - - - 0 - 0 - - - - Unique label - - - Choose unique label. - - - - - - - Vertical correction: - - - - - - - - - - Horizontal correction: - - - - - - diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index c64823d52..d95ce21a7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -200,6 +200,6 @@ void VToolCut::ReadToolAttributes(const QDomElement &domElement) { VToolSinglePoint::ReadToolAttributes(domElement); - m_aliasSuffix1 = doc->GetParametrEmptyString(domElement, AttrAlias1); - m_aliasSuffix2 = doc->GetParametrEmptyString(domElement, AttrAlias2); + m_aliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias1); + m_aliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias2); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index 7104a6d23..e59ee7e37 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -298,8 +298,12 @@ QString VToolCutArc::MakeToolTip() const VArc ar1; VArc ar2; arc->CutArc(VAbstractValApplication::VApp()->toPixel(length), ar1, ar2); + ar1.setId(m_id + 1); + ar1.SetAliasSuffix(m_aliasSuffix1); + ar2.setId(m_id + 2); + ar2.SetAliasSuffix(m_aliasSuffix2); auto ArcToolTip = [arcStr, lengthStr, startAngleStr, endAngleStr, radiusStr](QString toolTip, const VArc &arc, const QString &arcNumber) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index 6a0e332c8..b290ea1a1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -290,7 +290,10 @@ QString VToolCutSpline::MakeToolTip() const QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3); VSpline spline1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(point)); + spline1.SetAliasSuffix(m_aliasSuffix1); + VSpline spline2 = VSpline(VPointF(point), spl2p2, spl2p3, spl->GetP4()); + spline2.SetAliasSuffix(m_aliasSuffix2); const QString curveStr = tr("Curve"); const QString lengthStr = tr("length"); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index d7747b075..927e1a804 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -388,6 +388,9 @@ QString VToolCutSplinePath::MakeToolTip() const VAbstractValApplication::VApp()->toPixel(length), splPath, "X", &splPath1, &splPath2); delete p; // Don't need this point + splPath1->SetAliasSuffix(m_aliasSuffix1); + splPath2->SetAliasSuffix(m_aliasSuffix2); + const QString curveStr = tr("Curve"); const QString lengthStr = tr("length"); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index b1260c3dc..e988feda5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -76,7 +76,10 @@ VToolCurveIntersectAxis::VToolCurveIntersectAxis(const VToolCurveIntersectAxisIn :VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), initData.basePointId, 0, initData.notes, parent), formulaAngle(initData.formulaAngle), - curveId(initData.curveId) + curveId(initData.curveId), + m_segments(initData.segments), + m_aliasSuffix1(initData.aliasSuffix1), + m_aliasSuffix2(initData.aliasSuffix2) { ToolCreation(initData.typeCreation); } @@ -96,6 +99,8 @@ void VToolCurveIntersectAxis::setDialog() dialogTool->setCurveId(curveId); dialogTool->SetPointName(p->name()); dialogTool->SetNotes(m_notes); + dialogTool->SetAliasSuffix1(m_aliasSuffix1); + dialogTool->SetAliasSuffix2(m_aliasSuffix2); } //--------------------------------------------------------------------------------------------------------------------- @@ -120,6 +125,8 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const QPointerGetNotes(); + initData.aliasSuffix1 = dialogTool->GetAliasSuffix1(); + initData.aliasSuffix2 = dialogTool->GetAliasSuffix2(); VToolCurveIntersectAxis *point = Create(initData); if (point != nullptr) @@ -160,14 +167,16 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis initData.data->getNextId(); initData.data->getNextId(); - VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data); + initData.segments = VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, + initData.data, initData.aliasSuffix1, initData.aliasSuffix2); } else { initData.data->UpdateGObject(initData.id, p); initData.data->AddLine(initData.basePointId, initData.id); - VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data); + initData.segments = VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, + initData.data, initData.aliasSuffix1, initData.aliasSuffix2); if (initData.parse != Document::FullParse) { @@ -186,6 +195,10 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis initData.doc->IncrementReferens(curve->getIdTool()); return point; } + + auto *tool = qobject_cast(VAbstractPattern::getTool(initData.id)); + tool->SetSegments(initData.segments); + return nullptr; } @@ -264,6 +277,10 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement, QList doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId())); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), + dialogTool->GetAliasSuffix1().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), + dialogTool->GetAliasSuffix2().isEmpty()); const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); @@ -278,6 +295,8 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointerSetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrCurve, curveId); + doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty()); } //--------------------------------------------------------------------------------------------------------------------- @@ -285,11 +304,13 @@ void VToolCurveIntersectAxis::ReadToolAttributes(const QDomElement &domElement) { VToolLinePoint::ReadToolAttributes(domElement); - m_lineType = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); - lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); - basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); - curveId = doc->GetParametrUInt(domElement, AttrCurve, NULL_ID_STR); - formulaAngle = doc->GetParametrString(domElement, AttrAngle, QString()); + m_lineType = VAbstractPattern::GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = VAbstractPattern::GetParametrString(domElement, AttrLineColor, ColorBlack); + basePointId = VAbstractPattern::GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); + curveId = VAbstractPattern::GetParametrUInt(domElement, AttrCurve, NULL_ID_STR); + formulaAngle = VAbstractPattern::GetParametrString(domElement, AttrAngle, QString()); + m_aliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias1); + m_aliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrAlias2); } //--------------------------------------------------------------------------------------------------------------------- @@ -297,7 +318,7 @@ void VToolCurveIntersectAxis::SetVisualization() { if (not vis.isNull()) { - VisToolCurveIntersectAxis *visual = qobject_cast(vis); + auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) visual->setObject1Id(curveId); @@ -308,3 +329,34 @@ void VToolCurveIntersectAxis::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCurveIntersectAxis::MakeToolTip() const +{ + const QSharedPointer first = VAbstractTool::data.GeometricObject(basePointId); + const QSharedPointer second = VAbstractTool::data.GeometricObject(m_id); + + const QLineF line(static_cast(*first), static_cast(*second)); + + const QString toolTip = QString("" + "" + "" + "" + "" + "" + "
%6: %7
%1: %2 %3
%4: %5°
%8: %9
%10: %11
") + .arg(tr("Length")) // 1 + .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) // 2 + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) // 3, 4 + .arg(line.angle()) // 5 + .arg(tr("Label"), second->name(), /* 6, 7 */ + tr("Segment 1"), m_segments.first, /* 8, 9 */ + tr("Segment 2"), m_segments.second); /* 10, 11 */ + return toolTip; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::SetSegments(const QPair &segments) +{ + m_segments = segments; +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h index 4bf4f7acd..8f0f5a02c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h @@ -48,16 +48,12 @@ template class QSharedPointer; struct VToolCurveIntersectAxisInitData : VToolLinePointInitData { - VToolCurveIntersectAxisInitData() - : VToolLinePointInitData(), - formulaAngle('0'), - basePointId(NULL_ID), - curveId(NULL_ID) - {} - - QString formulaAngle; - quint32 basePointId; - quint32 curveId; + QString formulaAngle{'0'}; + quint32 basePointId{NULL_ID}; + quint32 curveId{NULL_ID}; + QPair segments{}; + QString aliasSuffix1{}; + QString aliasSuffix2{}; }; class VToolCurveIntersectAxis : public VToolLinePoint @@ -92,12 +88,18 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; + virtual auto MakeToolTip() const -> QString override; + + void SetSegments(const QPair &segments); private: Q_DISABLE_COPY(VToolCurveIntersectAxis) QString formulaAngle; quint32 curveId; + QPair m_segments{}; + QString m_aliasSuffix1{}; + QString m_aliasSuffix2{}; - VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr); + explicit VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr); template static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index 113c467b3..e859fc58a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -62,7 +62,13 @@ VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(const VToolPointO firstCurveId(initData.firstCurveId), secondCurveId(initData.secondCurveId), vCrossPoint(initData.vCrossPoint), - hCrossPoint(initData.hCrossPoint) + hCrossPoint(initData.hCrossPoint), + m_curve1Segments(initData.curve1Segments), + m_curve2Segments(initData.curve2Segments), + m_curve1AliasSuffix1(initData.curve1AliasSuffix1), + m_curve1AliasSuffix2(initData.curve1AliasSuffix2), + m_curve2AliasSuffix1(initData.curve2AliasSuffix1), + m_curve2AliasSuffix2(initData.curve2AliasSuffix2) { ToolCreation(initData.typeCreation); } @@ -80,6 +86,10 @@ void VToolPointOfIntersectionCurves::setDialog() dialogTool->SetHCrossPoint(hCrossPoint); dialogTool->SetPointName(p->name()); dialogTool->SetNotes(m_notes); + dialogTool->SetCurve1AliasSuffix1(m_curve1AliasSuffix1); + dialogTool->SetCurve1AliasSuffix2(m_curve1AliasSuffix2); + dialogTool->SetCurve2AliasSuffix1(m_curve2AliasSuffix1); + dialogTool->SetCurve2AliasSuffix2(m_curve2AliasSuffix2); } //--------------------------------------------------------------------------------------------------------------------- @@ -104,6 +114,10 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const QPo initData.parse = Document::FullParse; initData.typeCreation = Source::FromGui; initData.notes = dialogTool->GetNotes(); + initData.curve1AliasSuffix1 = dialogTool->GetCurve1AliasSuffix1(); + initData.curve1AliasSuffix2 = dialogTool->GetCurve1AliasSuffix2(); + initData.curve2AliasSuffix1 = dialogTool->GetCurve2AliasSuffix1(); + initData.curve2AliasSuffix2 = dialogTool->GetCurve2AliasSuffix2(); VToolPointOfIntersectionCurves *point = Create(initData); if (point != nullptr) @@ -141,19 +155,32 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPoin { initData.id = initData.data->AddGObject(p); - VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, initData.firstCurveId, initData.data); - VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, initData.secondCurveId, initData.data); + initData.curve1Segments = VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, + initData.firstCurveId, initData.data, + initData.curve1AliasSuffix1, + initData.curve1AliasSuffix2); + initData.curve2Segments = VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, + initData.secondCurveId, initData.data, + initData.curve2AliasSuffix1, + initData.curve2AliasSuffix2); } else { initData.data->UpdateGObject(initData.id, p); - VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, initData.firstCurveId, initData.data); - VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, initData.secondCurveId, initData.data); + initData.curve1Segments = VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, + initData.firstCurveId, initData.data, + initData.curve1AliasSuffix1, + initData.curve1AliasSuffix2); + initData.curve2Segments = VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, + initData.secondCurveId, initData.data, + initData.curve2AliasSuffix1, + initData.curve2AliasSuffix2); if (initData.parse != Document::FullParse) { initData.doc->UpdateToolData(initData.id, initData.data); + } } @@ -168,6 +195,11 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPoin initData.doc->IncrementReferens(curve2->getIdTool()); return point; } + + auto *tool = qobject_cast(VAbstractPattern::getTool(initData.id)); + tool->SetCurve1Segments(initData.curve1Segments); + tool->SetCurve2Segments(initData.curve2Segments); + return nullptr; } @@ -367,7 +399,7 @@ void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement, QList &newDependencies) { SCASSERT(not m_dialog.isNull()) - auto dialogTool = qobject_cast(m_dialog); + auto *dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) AddDependence(oldDependencies, firstCurveId); @@ -380,6 +412,14 @@ void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement, QListSetAttribute(domElement, AttrCurve2, QString().setNum(dialogTool->GetSecondCurveId())); doc->SetAttribute(domElement, AttrVCrossPoint, QString().setNum(static_cast(dialogTool->GetVCrossPoint()))); doc->SetAttribute(domElement, AttrHCrossPoint, QString().setNum(static_cast(dialogTool->GetHCrossPoint()))); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias1, dialogTool->GetCurve1AliasSuffix1(), + dialogTool->GetCurve1AliasSuffix1().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias2, dialogTool->GetCurve1AliasSuffix2(), + dialogTool->GetCurve1AliasSuffix2().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias1, dialogTool->GetCurve2AliasSuffix1(), + dialogTool->GetCurve2AliasSuffix1().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias2, dialogTool->GetCurve2AliasSuffix2(), + dialogTool->GetCurve2AliasSuffix2().isEmpty()); const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); @@ -395,6 +435,10 @@ void VToolPointOfIntersectionCurves::SaveOptions(QDomElement &tag, QSharedPointe doc->SetAttribute(tag, AttrCurve2, secondCurveId); doc->SetAttribute(tag, AttrVCrossPoint, static_cast(vCrossPoint)); doc->SetAttribute(tag, AttrHCrossPoint, static_cast(hCrossPoint)); + doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias1, m_curve1AliasSuffix1, m_curve1AliasSuffix1.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias2, m_curve1AliasSuffix2, m_curve1AliasSuffix2.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias1, m_curve2AliasSuffix1, m_curve2AliasSuffix1.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias2, m_curve2AliasSuffix2, m_curve2AliasSuffix2.isEmpty()); } //--------------------------------------------------------------------------------------------------------------------- @@ -402,10 +446,16 @@ void VToolPointOfIntersectionCurves::ReadToolAttributes(const QDomElement &domEl { VToolSinglePoint::ReadToolAttributes(domElement); - firstCurveId = doc->GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR); - secondCurveId = doc->GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR); - vCrossPoint = static_cast(doc->GetParametrUInt(domElement, AttrVCrossPoint, QChar('1'))); - hCrossPoint = static_cast(doc->GetParametrUInt(domElement, AttrHCrossPoint, QChar('1'))); + firstCurveId = VAbstractPattern::GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR); + secondCurveId = VAbstractPattern::GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR); + vCrossPoint = static_cast(VAbstractPattern::GetParametrUInt(domElement, AttrVCrossPoint, + QChar('1'))); + hCrossPoint = static_cast(VAbstractPattern::GetParametrUInt(domElement, AttrHCrossPoint, + QChar('1'))); + m_curve1AliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve1Alias1); + m_curve1AliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve1Alias2); + m_curve2AliasSuffix1 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve2Alias1); + m_curve2AliasSuffix2 = VAbstractPattern::GetParametrEmptyString(domElement, AttrCurve2Alias2); } //--------------------------------------------------------------------------------------------------------------------- @@ -423,3 +473,36 @@ void VToolPointOfIntersectionCurves::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +auto VToolPointOfIntersectionCurves::MakeToolTip() const -> QString +{ + const QSharedPointer p = VAbstractTool::data.GeometricObject(m_id); + + const QString toolTip = QString("" + "" + "" + "" + "" + "" + "
%1: %2
%3: %4
%5: %6
%7: %8
%9: %10
") + .arg(tr("Label"), p->name(), /* 1, 2 */ + tr("Curve 1 segment 1"), m_curve1Segments.first, /* 3, 4 */ + tr("Curve 1 segment 2"), m_curve1Segments.second) /* 5, 6 */ + .arg(tr("Curve 2 segment 1"), m_curve2Segments.first, /* 7, 8 */ + tr("Curve 2 segment 2"), m_curve2Segments.second); /* 9, 10 */ + + return toolTip; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SetCurve1Segments(const QPair &segments) +{ + m_curve1Segments = segments; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SetCurve2Segments(const QPair &segments) +{ + m_curve2Segments = segments; +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h index 245399c2e..f316f5ca4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h @@ -47,18 +47,16 @@ template class QSharedPointer; struct VToolPointOfIntersectionCurvesInitData : VToolSinglePointInitData { - VToolPointOfIntersectionCurvesInitData() - : VToolSinglePointInitData(), - firstCurveId(NULL_ID), - secondCurveId(NULL_ID), - vCrossPoint(VCrossCurvesPoint::HighestPoint), - hCrossPoint(HCrossCurvesPoint::LeftmostPoint) - {} - - quint32 firstCurveId; - quint32 secondCurveId; - VCrossCurvesPoint vCrossPoint; - HCrossCurvesPoint hCrossPoint; + quint32 firstCurveId{NULL_ID}; + quint32 secondCurveId{NULL_ID}; + VCrossCurvesPoint vCrossPoint{VCrossCurvesPoint::HighestPoint}; + HCrossCurvesPoint hCrossPoint{HCrossCurvesPoint::LeftmostPoint}; + QPair curve1Segments{}; + QPair curve2Segments{}; + QString curve1AliasSuffix1{}; + QString curve1AliasSuffix2{}; + QString curve2AliasSuffix1{}; + QString curve2AliasSuffix2{}; }; class VToolPointOfIntersectionCurves : public VToolSinglePoint @@ -94,6 +92,10 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; + virtual auto MakeToolTip() const -> QString override; + + void SetCurve1Segments(const QPair &segments); + void SetCurve2Segments(const QPair &segments); private: Q_DISABLE_COPY(VToolPointOfIntersectionCurves) @@ -103,6 +105,14 @@ private: VCrossCurvesPoint vCrossPoint; HCrossCurvesPoint hCrossPoint; + QPair m_curve1Segments{}; + QPair m_curve2Segments{}; + + QString m_curve1AliasSuffix1{}; + QString m_curve1AliasSuffix2{}; + QString m_curve2AliasSuffix1{}; + QString m_curve2AliasSuffix2{}; + explicit VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData, QGraphicsItem *parent = nullptr); }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 96d2fbab9..a91245fbe 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -395,17 +395,16 @@ void VToolSinglePoint::ToolSelectionType(const SelectionType &type) //--------------------------------------------------------------------------------------------------------------------- QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") -void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, - VContainer *data) +auto VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, + VContainer *data, const QString &alias1, + const QString &alias2) -> QPair { switch(curveType) { case GOType::EllipticalArc: - InitArc(data, segLength, p, curveId); - break; + return InitArc(data, segLength, p, curveId, alias1, alias2); case GOType::Arc: - InitArc(data, segLength, p, curveId); - break; + return InitArc(data, segLength, p, curveId, alias1, alias2); case GOType::CubicBezier: case GOType::Spline: { @@ -444,12 +443,20 @@ void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo delete spl2; } + spline1->SetAliasSuffix(alias1); + spline2->SetAliasSuffix(alias2); + data->RegisterUniqueName(spline1); data->AddSpline(spline1, NULL_ID, p->id()); data->RegisterUniqueName(spline2); data->AddSpline(spline2, NULL_ID, p->id()); - break; + + // Because we don't store segments, but only data about them we must register the names manually + data->RegisterUniqueName(spline1); + data->RegisterUniqueName(spline2); + + return qMakePair(spline1->ObjectName(), spline2->ObjectName()); } case GOType::CubicBezierPath: case GOType::SplinePath: @@ -492,12 +499,20 @@ void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo delete splPath2; } + splP1->SetAliasSuffix(alias1); + splP2->SetAliasSuffix(alias2); + data->RegisterUniqueName(splP1); data->AddSpline(splP1, NULL_ID, p->id()); data->RegisterUniqueName(splP2); data->AddSpline(splP2, NULL_ID, p->id()); - break; + + // Because we don't store segments, but only data about them we must register the names manually + data->RegisterUniqueName(splP1); + data->RegisterUniqueName(splP2); + + return qMakePair(splP1->ObjectName(), splP2->ObjectName()); } case GOType::Point: case GOType::PlaceLabel: @@ -505,6 +520,8 @@ void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo Q_UNREACHABLE(); break; } + + return {}; } QT_WARNING_POP diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 6fae77723..93a86a224 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -108,15 +108,19 @@ protected: virtual void ChangeLabelVisibility(quint32 id, bool visible) override; template - static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId); - static void InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, VContainer *data); + static QPair InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId, + const QString &alias1, const QString &alias2); + static QPair InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, + VContainer *data, const QString &alias1, const QString &alias2); private: Q_DISABLE_COPY(VToolSinglePoint) }; //--------------------------------------------------------------------------------------------------------------------- template -inline void VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId) +inline auto VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const VPointF *p, + quint32 curveId, const QString &alias1, + const QString &alias2) -> QPair { QSharedPointer a1; QSharedPointer a2; @@ -138,6 +142,9 @@ inline void VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const V arc1.setId(p->id() + 1); arc2.setId(p->id() + 2); + arc1.SetAliasSuffix(alias1); + arc2.SetAliasSuffix(alias2); + if (not VFuzzyComparePossibleNulls(segLength, -1)) { a1 = QSharedPointer(new Item(arc1)); @@ -155,6 +162,12 @@ inline void VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const V data->AddArc(a1, arc1.id(), p->id()); data->AddArc(a2, arc2.id(), p->id()); + + // Because we don't store segments, but only data about them we must register the names manually + data->RegisterUniqueName(a1); + data->RegisterUniqueName(a2); + + return qMakePair(arc1.ObjectName(), arc2.ObjectName()); } #endif // VTOOLSINGLEPOINT_H diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 9bc5d8561..6815a0c8f 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -713,6 +713,13 @@ void VToolSeamAllowance::UpdatePatternInfo() } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::UpdatePassmarks() +{ + const VPiece detail = VAbstractTool::data.GetPiece(m_id); + m_passmarks->setPath(detail.PassmarksPath(getData())); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VToolDetail::UpdateGrainline updates the grain line item @@ -1296,6 +1303,7 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem); connect(m_sceneDetails, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove); connect(m_sceneDetails, &VMainGraphicsScene::ItemSelection, this, &VToolSeamAllowance::ToolSelectionType); + connect(m_sceneDetails, &VMainGraphicsScene::UpdatePassmarks, this, &VToolSeamAllowance::UpdatePassmarks); ConnectOutsideSignals(); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 4c0fd8219..a481c40b6 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -133,6 +133,7 @@ public slots: void Highlight(quint32 id); void UpdateDetailLabel(); void UpdatePatternInfo(); + void UpdatePassmarks(); void ShowOptions(); void DeleteFromMenu(); protected slots: diff --git a/src/libs/vwidgets/vmaingraphicsscene.cpp b/src/libs/vwidgets/vmaingraphicsscene.cpp index 4e0dbf058..8e43d0c26 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.cpp +++ b/src/libs/vwidgets/vmaingraphicsscene.cpp @@ -319,6 +319,12 @@ void VMainGraphicsScene::HighlightItem(quint32 id) emit HighlightDetail(id); } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::UpdatePiecePassmarks() +{ + emit UpdatePassmarks(); +} + //--------------------------------------------------------------------------------------------------------------------- void VMainGraphicsScene::ToggleLabelSelection(bool enabled) { diff --git a/src/libs/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index 8179cacbd..aced01546 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -74,6 +74,7 @@ public slots: void EnableDetailsMode(bool mode); void ItemsSelection(const SelectionType &type); void HighlightItem(quint32 id); + void UpdatePiecePassmarks(); void ToggleLabelSelection(bool enabled); void TogglePointSelection(bool enabled); @@ -123,6 +124,7 @@ signals: void CurveDetailsMode(bool mode); void ItemSelection(const SelectionType &type); void HighlightDetail(quint32 id); + void UpdatePassmarks(); void EnableLabelItemSelection(bool enable); void EnablePointItemSelection(bool enable); diff --git a/src/test/CollectionTest/CollectionTest.pro b/src/test/CollectionTest/CollectionTest.pro index dbde17e42..109207bd0 100644 --- a/src/test/CollectionTest/CollectionTest.pro +++ b/src/test/CollectionTest/CollectionTest.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += testlib widgets printsupport concurrent xml +QT += testlib widgets printsupport concurrent xml xmlpatterns QT -= gui diff --git a/src/test/TranslationsTest/TranslationsTest.pro b/src/test/TranslationsTest/TranslationsTest.pro index 919ae2f77..d3c4b34ee 100644 --- a/src/test/TranslationsTest/TranslationsTest.pro +++ b/src/test/TranslationsTest/TranslationsTest.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += testlib widgets xml printsupport +QT += testlib widgets xml printsupport concurrent xmlpatterns QT -= gui