diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 0e6bfe0c7..f4bfc1d12 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -78,7 +78,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser() void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in switch."); switch (item->type()) { @@ -205,7 +205,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions() } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in switch."); switch (currentItem->type()) { @@ -350,7 +350,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VPE::VProperty *property) } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in switch."); switch (currentItem->type()) { diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index aa01d7f64..3a767a7cf 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -212,7 +212,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QString DialogHistory::Record(const VToolRecord &tool) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in history."); const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) @@ -408,6 +408,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::Pin: case Tool::PlaceLabel: case Tool::InsertNode: + case Tool::DuplicateDetail: return QString(); } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index ba1faff63..a15642ffa 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -613,7 +613,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons dialogTool = QSharedPointer(new Dialog(pattern, 0, this)); // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Check if need to extend."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Check if need to extend."); switch(t) { @@ -1107,8 +1107,32 @@ void MainWindow::ToolUnionDetails(bool checked) */ void MainWindow::ClosedDialogUnionDetails(int result) { - ClosedDialog(result); - doc->LiteParseTree(Document::LiteParse); + ClosedDialog(result);// Avoid error: Template function as signal or slot +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolDuplicateDetail(bool checked) +{ + ToolSelectDetail(); + SetToolButton(checked, Tool::DuplicateDetail, ":/cursor/duplicate_detail_cursor.png", + tr("Select detail"), &MainWindow::ClosedDialogDuplicateDetail); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClosedDialogDuplicateDetail(int result) +{ + SCASSERT(not dialogTool.isNull()) + if (result == QDialog::Accepted) + { + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr) + + QGraphicsItem *tool = dynamic_cast(VToolSeamAllowance::Duplicate(dialogTool, scene, doc, + pattern)); + // Do not check for nullptr! See issue #719. + ui->view->itemClicked(tool); + } + ArrowTool(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1985,7 +2009,7 @@ void MainWindow::InitToolButtons() } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Check if all tools were connected."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Check if all tools were connected."); connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); @@ -2008,6 +2032,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline); connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath); connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails); + connect(ui->toolButtonDuplicateDetail, &QToolButton::clicked, this, &MainWindow::ToolDuplicateDetail); connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc); connect(ui->toolButtonLineIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolLineIntersectAxis); connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); @@ -2062,7 +2087,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void MainWindow::CancelTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); dialogTool.clear(); @@ -2172,6 +2197,9 @@ void MainWindow::CancelTool() case Tool::UnionDetails: ui->toolButtonUnionDetails->setChecked(false); break; + case Tool::DuplicateDetail: + ui->toolButtonDuplicateDetail->setChecked(false); + break; case Tool::CutArc: ui->toolButtonArcCutPoint->setChecked(false); break; @@ -3424,7 +3452,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QT_WARNING_POP // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled."); //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); @@ -3480,6 +3508,7 @@ QT_WARNING_POP //Modeling Tools ui->toolButtonUnionDetails->setEnabled(modelingTools); ui->toolButtonDetailExportAs->setEnabled(modelingTools); + ui->toolButtonDuplicateDetail->setEnabled(modelingTools); //Layout tools ui->toolButtonLayoutSettings->setEnabled(layoutTools); @@ -3752,7 +3781,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void MainWindow::LastUsedTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled."); if (currentTool == lastUsedTool) { @@ -3875,6 +3904,10 @@ void MainWindow::LastUsedTool() ui->toolButtonUnionDetails->setChecked(true); ToolUnionDetails(true); break; + case Tool::DuplicateDetail: + ui->toolButtonDuplicateDetail->setChecked(true); + ToolDuplicateDetail(true); + break; case Tool::CutArc: ui->toolButtonArcCutPoint->setChecked(true); ToolCutArc(true); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 47e6a76a0..386f04058 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -150,6 +150,7 @@ private slots: void ToolTriangle(bool checked); void ToolPointOfIntersection(bool checked); void ToolUnionDetails(bool checked); + void ToolDuplicateDetail(bool checked); void ToolGroup(bool checked); void ToolRotation(bool checked); void ToolFlippingByLine(bool checked); @@ -178,6 +179,7 @@ private slots: void Open(); void ClosedDialogUnionDetails(int result); + void ClosedDialogDuplicateDetail(int result); void ClosedDialogGroup(int result); void ClosedDialogPiecePath(int result); void ClosedDialogPin(int result); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index b81b324b6..f2ae0f667 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -48,7 +48,7 @@ Export details skiping the Layout stage - 7 + 6 @@ -1550,6 +1550,32 @@ + + + + false + + + Duplicate detail tool + + + ... + + + + :/toolicon/32x32/duplicate_detail.png:/toolicon/32x32/duplicate_detail.png + + + + 32 + 32 + + + + true + + + diff --git a/src/app/valentina/share/resources/cursor.qrc b/src/app/valentina/share/resources/cursor.qrc index 1ef61e19d..52afe1836 100644 --- a/src/app/valentina/share/resources/cursor.qrc +++ b/src/app/valentina/share/resources/cursor.qrc @@ -86,5 +86,7 @@ cursor/insert_node_cursor@2x.png cursor/place_label_cursor@2x.png cursor/place_label_cursor.png + cursor/duplicate_detail_cursor.png + cursor/duplicate_detail_cursor@2x.png diff --git a/src/app/valentina/share/resources/cursor/duplicate_detail_cursor.png b/src/app/valentina/share/resources/cursor/duplicate_detail_cursor.png new file mode 100644 index 000000000..9ce8097ec Binary files /dev/null and b/src/app/valentina/share/resources/cursor/duplicate_detail_cursor.png differ diff --git a/src/app/valentina/share/resources/cursor/duplicate_detail_cursor@2x.png b/src/app/valentina/share/resources/cursor/duplicate_detail_cursor@2x.png new file mode 100644 index 000000000..8bc268962 Binary files /dev/null and b/src/app/valentina/share/resources/cursor/duplicate_detail_cursor@2x.png differ diff --git a/src/app/valentina/share/resources/toolicon.qrc b/src/app/valentina/share/resources/toolicon.qrc index 85d04ac5c..a7b969906 100644 --- a/src/app/valentina/share/resources/toolicon.qrc +++ b/src/app/valentina/share/resources/toolicon.qrc @@ -84,5 +84,7 @@ toolicon/32x32/insert_node@2x.png toolicon/32x32/place_label@2x.png toolicon/32x32/place_label.png + toolicon/32x32/duplicate_detail.png + toolicon/32x32/duplicate_detail@2x.png diff --git a/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail.png b/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail.png new file mode 100644 index 000000000..ac021c364 Binary files /dev/null and b/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail.png differ diff --git a/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail@2x.png b/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail@2x.png new file mode 100644 index 000000000..a4fc05ae0 Binary files /dev/null and b/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail@2x.png differ diff --git a/src/app/valentina/share/resources/toolicon/svg/duplicate_detail.svg b/src/app/valentina/share/resources/toolicon/svg/duplicate_detail.svg new file mode 100644 index 000000000..585975a52 --- /dev/null +++ b/src/app/valentina/share/resources/toolicon/svg/duplicate_detail.svg @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 4f6387df2..1a224c2e6 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -4166,7 +4166,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") QRectF VPattern::ActiveDrawBoundingRect() const { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used."); QRectF rec; @@ -4247,6 +4247,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::Pin: case Tool::InsertNode: case Tool::PlaceLabel: + case Tool::DuplicateDetail: break; } } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 170fdf218..c17775469 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1771,7 +1771,7 @@ QVector VAbstractPattern::ListPointExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment a number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagPoint); @@ -1799,7 +1799,7 @@ QVector VAbstractPattern::ListArcExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagArc); @@ -1823,7 +1823,7 @@ QVector VAbstractPattern::ListElArcExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagElArc); @@ -1856,7 +1856,7 @@ QVector VAbstractPattern::ListPathPointExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(AttrPathPoint); @@ -1894,7 +1894,7 @@ QVector VAbstractPattern::ListOperationExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagOperation); @@ -1916,7 +1916,7 @@ QVector VAbstractPattern::ListNodesExpressions(const QDomElement // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; @@ -1939,7 +1939,7 @@ QVector VAbstractPattern::ListPathExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagPath); @@ -1977,7 +1977,7 @@ QVector VAbstractPattern::ListPieceExpressions() const // Check if new tool doesn't bring new attribute with a formula. // If no just increment number. // If new tool bring absolutely new type and has formula(s) create new method to cover it. - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 54); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 55); QVector expressions; const QDomNodeList list = elementsByTagName(TagDetail); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 4f67cd982..899ae9f63 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -171,6 +171,7 @@ enum class Tool : ToolVisHolderType Pin, InsertNode, PlaceLabel, + DuplicateDetail, LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used }; @@ -222,6 +223,7 @@ enum class Vis : ToolVisHolderType ToolPiecePath, ToolSpecialPoint, ToolPlaceLabel, + ToolDuplicateDetail, PieceSpecialPoints, NoBrush, CurvePathItem, diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 9df554fc8..ddba6edce 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -47,7 +47,8 @@ HEADERS += \ $$PWD/tools/piece/dialogpin.h \ $$PWD/tools/piece/dialoginsertnode.h \ $$PWD/support/dialogeditlabel.h \ - $$PWD/tools/piece/dialogplacelabel.h + $$PWD/tools/piece/dialogplacelabel.h \ + $$PWD/tools/piece/dialogduplicatedetail.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -94,7 +95,8 @@ SOURCES += \ $$PWD/tools/piece/dialogpin.cpp \ $$PWD/tools/piece/dialoginsertnode.cpp \ $$PWD/support/dialogeditlabel.cpp \ - $$PWD/tools/piece/dialogplacelabel.cpp + $$PWD/tools/piece/dialogplacelabel.cpp \ + $$PWD/tools/piece/dialogduplicatedetail.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -146,4 +148,5 @@ FORMS += \ $$PWD/tools/piece/tabs/tabpassmarks.ui \ $$PWD/support/dialogeditlabel.ui \ $$PWD/tools/piece/dialogplacelabel.ui \ - $$PWD/tools/piece/tabs/tabplacelabels.ui + $$PWD/tools/piece/tabs/tabplacelabels.ui \ + $$PWD/tools/piece/dialogduplicatedetail.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index 0db5a3721..58d46f9e5 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -70,6 +70,7 @@ #include "tools/piece/dialogpin.h" #include "tools/piece/dialoginsertnode.h" #include "tools/piece/dialogplacelabel.h" +#include "tools/piece/dialogduplicatedetail.h" #include "support/dialogeditwrongformula.h" #include "support/dialogundo.h" diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp new file mode 100644 index 000000000..9a75421cb --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp @@ -0,0 +1,93 @@ +/************************************************************************ + ** + ** @file dialogduplicatedetail.cpp + ** @author Roman Telezhynskyi + ** @date 25 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#include "dialogduplicatedetail.h" +#include "ui_dialogduplicatedetail.h" +#include "../vwidgets/vabstractmainwindow.h" +#include "../../../visualization/path/vistoolduplicatedetail.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogDuplicateDetail::DialogDuplicateDetail(const VContainer *data, const quint32 &toolId, QWidget *parent) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogDuplicateDetail), + m_idDetail(NULL_ID), + m_mx(0), + m_my(0), + m_firstRelease(false) +{ + ui->setupUi(this); + InitOkCancel(ui); + + vis = new VisToolDuplicateDetail(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogDuplicateDetail::~DialogDuplicateDetail() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDuplicateDetail::ShowDialog(bool click) +{ + if (prepare) + { + if (click) + { + // The check need to ignore first release of mouse button. + // User should have chance to place piece. + if (not m_firstRelease) + { + m_firstRelease = true; + return; + } + + VisToolDuplicateDetail *piece = qobject_cast(vis); + SCASSERT(piece != nullptr) + + m_mx = piece->Mx(); + m_my = piece->My(); + emit ToolTip(""); + DialogAccepted(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogDuplicateDetail::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Detail && id > NULL_ID) + { + m_idDetail = id; + emit ToolTip(tr("Click to place duplicate")); + vis->VisualMode(id); + prepare = true; + } + } +} diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h new file mode 100644 index 000000000..d36a0186b --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h @@ -0,0 +1,80 @@ +/************************************************************************ + ** + ** @file dialogduplicatedetail.h + ** @author Roman Telezhynskyi + ** @date 25 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#ifndef DIALOGDUPLICATEDETAIL_H +#define DIALOGDUPLICATEDETAIL_H + +#include "../dialogtool.h" + +namespace Ui +{ + class DialogDuplicateDetail; +} + +class DialogDuplicateDetail : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogDuplicateDetail(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + virtual ~DialogDuplicateDetail(); + + quint32 Duplicate() const; + qreal MoveDuplicateX() const; + qreal MoveDuplicateY() const; + + virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; +private: + Q_DISABLE_COPY(DialogDuplicateDetail) + Ui::DialogDuplicateDetail *ui; + quint32 m_idDetail; + qreal m_mx; + qreal m_my; + bool m_firstRelease; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 DialogDuplicateDetail::Duplicate() const +{ + return m_idDetail; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal DialogDuplicateDetail::MoveDuplicateX() const +{ + return m_mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal DialogDuplicateDetail::MoveDuplicateY() const +{ + return m_my; +} + +#endif // DIALOGDUPLICATEDETAIL_H diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.ui b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.ui new file mode 100644 index 000000000..fa187e416 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.ui @@ -0,0 +1,80 @@ + + + DialogDuplicateDetail + + + + 0 + 0 + 184 + 66 + + + + Dialog duplicate detail + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + The dialog is never shown. + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogDuplicateDetail + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogDuplicateDetail + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 6791982e6..c9009fecf 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -28,6 +28,7 @@ #include "vtoolseamallowance.h" #include "../dialogs/tools/piece/dialogseamallowance.h" +#include "../dialogs/tools/piece/dialogduplicatedetail.h" #include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/calculator.h" @@ -151,6 +152,35 @@ VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initD return piece; } +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance *VToolSeamAllowance::Duplicate(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) +{ + SCASSERT(not dialog.isNull()); + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) + + VToolSeamAllowanceInitData initData; + initData.scene = scene; + initData.doc = doc; + initData.data = data; + initData.parse = Document::FullParse; + initData.typeCreation = Source::FromGui; + +// initData.detail = dialogTool->GetPiece(); + initData.width = initData.detail.GetFormulaSAWidth(); + +// initData.detail.GetPath().SetNodes(PrepareNodes(initData.detail.GetPath(), scene, doc, data)); + + return Duplicate(initData); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance *VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData) +{ + return nullptr; +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::RemoveWithConfirm(bool ask) { @@ -1005,11 +1035,6 @@ QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change } } } - // Don't forget to update geometry, because first change never call full parse - VPiece detail = VAbstractTool::data.GetPiece(m_id); - detail.SetMx(newPos.x()); - detail.SetMy(newPos.y()); - VAbstractTool::data.UpdatePiece(m_id, detail); changeFinished = true; } diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 401c2971e..c13742e52 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -64,6 +64,9 @@ public: static VToolSeamAllowance* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData); + static VToolSeamAllowance* Duplicate(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); + static VToolSeamAllowance* Duplicate(VToolSeamAllowanceInitData &initData); static const quint8 pieceVersion; diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp new file mode 100644 index 000000000..971eeaf90 --- /dev/null +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp @@ -0,0 +1,69 @@ +/************************************************************************ + ** + ** @file vistoolduplicatedetail.cpp + ** @author Roman Telezhynskyi + ** @date 25 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#include "vistoolduplicatedetail.h" +#include "../vpatterndb/vcontainer.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolDuplicateDetail::VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent) + : VisPath(data, parent), + m_start(), + m_started(false), + m_diff() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolDuplicateDetail::RefreshGeometry() +{ + const VPiece piece = Visualization::data->GetPiece(object1Id); + + if (not m_started) + { + m_start = Visualization::scenePos; + m_started = true; + } + else + { + m_diff = Visualization::scenePos - m_start; + setPos(m_diff); + } + + DrawPath(this, PiecePath(piece), mainColor, Qt::SolidLine, Qt::RoundCap); +} + +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VisToolDuplicateDetail::PiecePath(const VPiece &piece) const +{ + if (not piece.IsHideMainPath() || not piece.IsSeamAllowance() || piece.IsSeamAllowanceBuiltIn()) + { + return piece.MainPathPath(Visualization::data); + } + else + { + return piece.SeamAllowancePath(Visualization::data); + } +} diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.h b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h new file mode 100644 index 000000000..a306211c5 --- /dev/null +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file vistoolduplicatedetail.h + ** @author Roman Telezhynskyi + ** @date 25 10, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#ifndef VISTOOLDUPLICATEDETAIL_H +#define VISTOOLDUPLICATEDETAIL_H + +#include "vispath.h" +#include "../vpatterndb/vpiece.h" + +class VisToolDuplicateDetail : public VisPath +{ + Q_OBJECT +public: + VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent = nullptr); + virtual ~VisToolDuplicateDetail() = default; + + qreal Mx() const; + qreal My() const; + + virtual void RefreshGeometry() Q_DECL_OVERRIDE; + virtual int type() const Q_DECL_OVERRIDE {return Type;} + enum { Type = UserType + static_cast(Vis::ToolDuplicateDetail)}; +private: + Q_DISABLE_COPY(VisToolDuplicateDetail) + QPointF m_start; + bool m_started; + QPointF m_diff; + + QPainterPath PiecePath(const VPiece &piece) const; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal VisToolDuplicateDetail::Mx() const +{ + return m_diff.x(); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline qreal VisToolDuplicateDetail::My() const +{ + return m_diff.y(); +} + +#endif // VISTOOLDUPLICATEDETAIL_H diff --git a/src/libs/vtools/visualization/visualization.pri b/src/libs/vtools/visualization/visualization.pri index 5f9aac564..2eef73604 100644 --- a/src/libs/vtools/visualization/visualization.pri +++ b/src/libs/vtools/visualization/visualization.pri @@ -42,7 +42,8 @@ HEADERS += \ $$PWD/path/vistoolpiece.h \ $$PWD/path/vistoolpiecepath.h \ $$PWD/path/vispiecespecialpoints.h \ - $$PWD/line/vistoolspecialpoint.h + $$PWD/line/vistoolspecialpoint.h \ + $$PWD/path/vistoolduplicatedetail.h SOURCES += \ $$PWD/visualization.cpp \ @@ -85,4 +86,5 @@ SOURCES += \ $$PWD/path/vistoolpiece.cpp \ $$PWD/path/vistoolpiecepath.cpp \ $$PWD/path/vispiecespecialpoints.cpp \ - $$PWD/line/vistoolspecialpoint.cpp + $$PWD/line/vistoolspecialpoint.cpp \ + $$PWD/path/vistoolduplicatedetail.cpp