diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 09e22849e..8e0e356bd 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -76,7 +76,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) == 51, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch."); switch (item->type()) { @@ -203,7 +203,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) == 51, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in switch."); switch (currentItem->type()) { @@ -348,7 +348,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) == 51, "Not all tools were used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "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 a168827b8..216fec813 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) == 51, "Not all tools were used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used in history."); const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) @@ -405,6 +405,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::FlippingByAxis: case Tool::Move: case Tool::PiecePath: + case Tool::Pin: return QString(); } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 25f2e1090..cb4631ef6 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -576,6 +576,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons dialogTool->Build(t); break; case Tool::PiecePath: + case Tool::Pin: dialogTool->SetPiecesList(doc->GetActivePPPieces()); break; default: @@ -995,6 +996,14 @@ void MainWindow::ToolPiecePath(bool checked) &MainWindow::ClosedDialogPiecePath); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolPin(bool checked) +{ + ToolSelectAllDrawObjects(); + SetToolButton(checked, Tool::Pin, "://cursor/pin_cursor.png", tr("Select pin point"), + &MainWindow::ClosedDialogPin); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolHeight handler tool height. @@ -1144,6 +1153,18 @@ void MainWindow::ClosedDialogPiecePath(int result) doc->LiteParseTree(Document::LiteParse); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClosedDialogPin(int result) +{ +// SCASSERT(dialogTool != nullptr); +// if (result == QDialog::Accepted) +// { +// VToolPin::Create(dialogTool, sceneDetails, doc, pattern); +// } + ArrowTool(); +// doc->LiteParseTree(Document::LiteParse); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolCutArc handler tool cutArc. @@ -1760,7 +1781,7 @@ void MainWindow::InitToolButtons() } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Check if all tools were connected."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Check if all tools were connected."); connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); @@ -1806,6 +1827,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint); connect(ui->toolButtonLayoutExportAs, &QToolButton::clicked, this, &MainWindow::ExportLayoutAs); connect(ui->toolButtonEllipticalArc, &QToolButton::clicked, this, &MainWindow::ToolEllipticalArc); + connect(ui->toolButtonPin, &QToolButton::clicked, this, &MainWindow::ToolPin); } //--------------------------------------------------------------------------------------------------------------------- @@ -1833,7 +1855,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) == 51, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); delete dialogTool; @@ -1989,6 +2011,9 @@ void MainWindow::CancelTool() case Tool::EllipticalArc: ui->toolButtonEllipticalArc->setChecked(false); break; + case Tool::Pin: + ui->toolButtonPin->setChecked(false); + break; } // Crash: using CRTL+Z while using line tool. @@ -3040,7 +3065,7 @@ void MainWindow::SetEnableTool(bool enable) } // This check helps to find missed tools - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 51, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled."); //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); @@ -3081,6 +3106,7 @@ void MainWindow::SetEnableTool(bool enable) ui->toolButtonMove->setEnabled(drawTools); ui->toolButtonMidpoint->setEnabled(drawTools); ui->toolButtonEllipticalArc->setEnabled(drawTools); + ui->toolButtonPin->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools); @@ -3362,7 +3388,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) == 51, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were handled."); if (currentTool == lastUsedTool) { @@ -3549,6 +3575,10 @@ void MainWindow::LastUsedTool() ui->toolButtonEllipticalArc->setChecked(true); ToolEllipticalArc(true); break; + case Tool::Pin: + ui->toolButtonPin->setChecked(true); + ToolPin(true); + break; } } diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 61e5999f1..34a5ad998 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -138,6 +138,7 @@ private slots: void ToolPointOfContact(bool checked); void ToolDetail(bool checked); void ToolPiecePath(bool checked); + void ToolPin(bool checked); void ToolHeight(bool checked); void ToolTriangle(bool checked); void ToolPointOfIntersection(bool checked); @@ -171,6 +172,7 @@ private slots: void ClosedDialogUnionDetails(int result); void ClosedDialogGroup(int result); void ClosedDialogPiecePath(int result); + void ClosedDialogPin(int result); void LoadIndividual(); void LoadStandard(); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 34f5c066a..306bddd01 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -48,7 +48,7 @@ Tools - 5 + 6 @@ -1144,7 +1144,7 @@ 0 0 130 - 356 + 326 @@ -1449,6 +1449,32 @@ + + + + false + + + Pin tool + + + ... + + + + :/toolicon/32x32/pin.png:/toolicon/32x32/pin.png + + + + 32 + 32 + + + + true + + + @@ -1457,7 +1483,7 @@ 0 0 130 - 356 + 326 @@ -2574,8 +2600,8 @@ - + diff --git a/src/app/valentina/share/resources/cursor.qrc b/src/app/valentina/share/resources/cursor.qrc index 44323cc41..4a3771e1c 100644 --- a/src/app/valentina/share/resources/cursor.qrc +++ b/src/app/valentina/share/resources/cursor.qrc @@ -80,5 +80,7 @@ cursor/el_arc_cursor@2x.png cursor/path_cursor.png cursor/path_cursor@2x.png + cursor/pin_cursor.png + cursor/pin_cursor@2x.png diff --git a/src/app/valentina/share/resources/cursor/pin_cursor.png b/src/app/valentina/share/resources/cursor/pin_cursor.png new file mode 100644 index 000000000..53e753cc1 Binary files /dev/null and b/src/app/valentina/share/resources/cursor/pin_cursor.png differ diff --git a/src/app/valentina/share/resources/cursor/pin_cursor@2x.png b/src/app/valentina/share/resources/cursor/pin_cursor@2x.png new file mode 100644 index 000000000..dfcf1c8ef Binary files /dev/null and b/src/app/valentina/share/resources/cursor/pin_cursor@2x.png differ diff --git a/src/app/valentina/share/resources/toolicon.qrc b/src/app/valentina/share/resources/toolicon.qrc index 528ab18c2..0fd19e3bf 100644 --- a/src/app/valentina/share/resources/toolicon.qrc +++ b/src/app/valentina/share/resources/toolicon.qrc @@ -78,5 +78,7 @@ toolicon/32x32/el_arc@2x.png toolicon/32x32/path.png toolicon/32x32/path@2x.png + toolicon/32x32/pin.png + toolicon/32x32/pin@2x.png diff --git a/src/app/valentina/share/resources/toolicon/32x32/pin.png b/src/app/valentina/share/resources/toolicon/32x32/pin.png new file mode 100644 index 000000000..baf52a929 Binary files /dev/null and b/src/app/valentina/share/resources/toolicon/32x32/pin.png differ diff --git a/src/app/valentina/share/resources/toolicon/32x32/pin@2x.png b/src/app/valentina/share/resources/toolicon/32x32/pin@2x.png new file mode 100644 index 000000000..859002f9a Binary files /dev/null and b/src/app/valentina/share/resources/toolicon/32x32/pin@2x.png differ diff --git a/src/app/valentina/share/resources/toolicon/svg/pin.svg b/src/app/valentina/share/resources/toolicon/svg/pin.svg new file mode 100644 index 000000000..efee98b4c --- /dev/null +++ b/src/app/valentina/share/resources/toolicon/svg/pin.svg @@ -0,0 +1,81 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 44e9d964e..5d512ea19 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -3726,7 +3726,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) == 51, "Not all tools were used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52, "Not all tools were used."); QRectF rec; @@ -3860,6 +3860,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::NodeSplinePath: case Tool::Group: case Tool::PiecePath: + case Tool::Pin: break; } } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 122428173..aa49d48e7 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1588,7 +1588,7 @@ QStringList 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) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagPoint); @@ -1660,7 +1660,7 @@ QStringList 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) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagArc); @@ -1714,7 +1714,7 @@ QStringList 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) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagElArc); @@ -1785,7 +1785,7 @@ QStringList 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) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(AttrPathPoint); @@ -1852,7 +1852,7 @@ QStringList 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) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagOperation); @@ -1907,7 +1907,7 @@ QStringList 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) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagPath); @@ -1960,7 +1960,7 @@ QStringList 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) == 51); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 52); QStringList expressions; const QDomNodeList list = elementsByTagName(TagDetail); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 15a5ef7aa..7d09481a9 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -147,6 +147,7 @@ enum class Tool : ToolVisHolderType Move, Midpoint, EllipticalArc, + Pin, LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used }; @@ -193,7 +194,8 @@ enum class Vis : ToolVisHolderType ToolMove, ToolEllipticalArc, ToolPiece, - ToolPiecePath + ToolPiecePath, + ToolPin }; enum class VarType : char { Measurement, Increment, LineLength, CurveLength, CurveCLength, LineAngle, CurveAngle, diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index d21b0a6ba..135de7182 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -43,7 +43,8 @@ HEADERS += \ $$PWD/tools/dialogmove.h \ $$PWD/tools/dialogellipticalarc.h \ $$PWD/tools/dialogseamallowance.h \ - $$PWD/tools/dialogpiecepath.h + $$PWD/tools/dialogpiecepath.h \ + $$PWD/tools/dialogpin.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -86,7 +87,8 @@ SOURCES += \ $$PWD/tools/dialogmove.cpp \ $$PWD/tools/dialogellipticalarc.cpp \ $$PWD/tools/dialogseamallowance.cpp \ - $$PWD/tools/dialogpiecepath.cpp + $$PWD/tools/dialogpiecepath.cpp \ + $$PWD/tools/dialogpin.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -128,4 +130,5 @@ FORMS += \ $$PWD/tools/dialogmove.ui \ $$PWD/tools/dialogellipticalarc.ui \ $$PWD/tools/dialogseamallowance.ui \ - $$PWD/tools/dialogpiecepath.ui + $$PWD/tools/dialogpiecepath.ui \ + $$PWD/tools/dialogpin.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index b42272af1..a98fe7402 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -67,6 +67,7 @@ #include "tools/dialogmove.h" #include "tools/dialogellipticalarc.h" #include "tools/dialogpiecepath.h" +#include "tools/dialogpin.h" #include "support/dialogeditwrongformula.h" #include "support/dialogundo.h" diff --git a/src/libs/vtools/dialogs/tools/dialogpin.cpp b/src/libs/vtools/dialogs/tools/dialogpin.cpp new file mode 100644 index 000000000..1c820f7df --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogpin.cpp @@ -0,0 +1,204 @@ +/************************************************************************ + ** + ** @file dialogpin.cpp + ** @author Roman Telezhynskyi + ** @date 31 1, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine 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 "dialogpin.h" +#include "ui_dialogpin.h" +#include "visualization/line/vistoolpin.h" +#include "../../tools/vabstracttool.h" +#include "../../tools/vtoolseamallowance.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogPin::DialogPin(const VContainer *data, quint32 toolId, QWidget *parent) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogPin), + m_showMode(false), + m_flagPoint(false) +{ + ui->setupUi(this); + InitOkCancel(ui); + + FillComboBoxPoints(ui->comboBoxPoint); + + flagError = false; + CheckState(); + + vis = new VisToolPin(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPin::~DialogPin() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::EnbleShowMode(bool disable) +{ + m_showMode = disable; + ui->comboBoxPiece->setDisabled(m_showMode); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPin::GetPieceId() const +{ + return getCurrentObjectId(ui->comboBoxPiece); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::SetPieceId(quint32 id) +{ + if (ui->comboBoxPiece->count() <= 0) + { + const VPiece piece = data->GetPiece(id); + ui->comboBoxPiece->addItem(piece.GetName(), id); + } + else + { + const qint32 index = ui->comboBoxPiece->findData(id); + if (index != -1) + { + ui->comboBoxPiece->setCurrentIndex(index); + } + else + { + ui->comboBoxPiece->setCurrentIndex(0); + } + } + + CheckPieces(); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPin::GetPointId() const +{ + return getCurrentObjectId(ui->comboBoxPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::SetPointId(quint32 id) +{ + setCurrentPointId(ui->comboBoxPoint, id); + + VisToolPin *point = qobject_cast(vis); + SCASSERT(point != nullptr) + point->setObject1Id(id); + + CheckPoint(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::SetPiecesList(const QVector &list) +{ + for (int i=0; i < list.size(); ++i) + { + const VPiece piece = data->GetPiece(list.at(i)); + ui->comboBoxPiece->addItem(piece.GetName(), list.at(i)); + } + + CheckPieces(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::ChosenObject(quint32 id, const SceneObject &type) +{ + if (not prepare) + { + if (type == SceneObject::Point) + { + if (SetObject(id, ui->comboBoxPoint, "")) + { + vis->VisualMode(id); + CheckPoint(); + prepare = true; + this->setModal(true); + this->show(); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::CheckState() +{ + SCASSERT(bOk != nullptr); + bOk->setEnabled(m_flagPoint && flagError); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::ShowVisualization() +{ + AddVisualization(); + + if (m_showMode) + { + VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(GetPieceId())); + SCASSERT(tool != nullptr); + auto visPoint = qobject_cast(vis); + SCASSERT(visPoint != nullptr); + visPoint->setParentItem(tool); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::CheckPieces() +{ + if (not m_showMode) + { + QColor color = okColor; + if (ui->comboBoxPiece->count() <= 0) + { + flagError = false; + color = errorColor; + } + else + { + flagError = true; + color = okColor; + } + ChangeColor(ui->labelPiece, color); + CheckState(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPin::CheckPoint() +{ + QColor color = okColor; + if (ui->comboBoxPoint->currentIndex() != -1) + { + m_flagPoint = true; + color = okColor; + } + else + { + m_flagPoint = false; + color = errorColor; + } + ChangeColor(ui->labelPoint, color); + CheckState(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogpin.h b/src/libs/vtools/dialogs/tools/dialogpin.h new file mode 100644 index 000000000..ed13b2eb6 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogpin.h @@ -0,0 +1,73 @@ +/************************************************************************ + ** + ** @file dialogpin.h + ** @author Roman Telezhynskyi + ** @date 31 1, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine 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 DIALOGPIN_H +#define DIALOGPIN_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogPin; +} + +class DialogPin : public DialogTool +{ + Q_OBJECT +public: + explicit DialogPin(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); + virtual ~DialogPin(); + + void EnbleShowMode(bool disable); + + quint32 GetPieceId() const; + void SetPieceId(quint32 id); + + quint32 GetPointId() const; + void SetPointId(quint32 id); + + virtual void SetPiecesList(const QVector &list) Q_DECL_OVERRIDE; + +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; + +protected: + virtual void CheckState() Q_DECL_OVERRIDE; + virtual void ShowVisualization() Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(DialogPin) + Ui::DialogPin *ui; + bool m_showMode; + bool m_flagPoint; + + void CheckPieces(); + void CheckPoint(); +}; + +#endif // DIALOGPIN_H diff --git a/src/libs/vtools/dialogs/tools/dialogpin.ui b/src/libs/vtools/dialogs/tools/dialogpin.ui new file mode 100644 index 000000000..682ffb9a1 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogpin.ui @@ -0,0 +1,91 @@ + + + DialogPin + + + + 0 + 0 + 194 + 114 + + + + Dialog + + + Pin tool + + + + + + + + Point: + + + + + + + + + + Piece: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DialogPin + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPin + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/libs/vtools/visualization/line/vistoolpin.cpp b/src/libs/vtools/visualization/line/vistoolpin.cpp new file mode 100644 index 000000000..b942795b6 --- /dev/null +++ b/src/libs/vtools/visualization/line/vistoolpin.cpp @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 31 1, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine 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 "vistoolpin.h" +#include "../vwidgets/vsimplepoint.h" +#include "../vgeometry/vpointf.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPin::VisToolPin(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), + m_point(nullptr) +{ + this->mainColor = Qt::red; + this->setZValue(2);// Show on top real tool + + m_point = new VSimplePoint(NULL_ID, mainColor, *Visualization::data->GetPatternUnit(), &factor); + m_point->SetPointHighlight(true); + m_point->setParentItem(this); + m_point->SetVisualizationMode(true); + m_point->setVisible(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPin::~VisToolPin() +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPin::RefreshGeometry() +{ + if (object1Id > NULL_ID) + { + const QSharedPointer point = Visualization::data->GeometricObject(object1Id); + + m_point->SetOnlyPoint(mode == Mode::Creation); + m_point->RefreshGeometry(*point); + m_point->setVisible(true); + } +} + diff --git a/src/libs/vtools/visualization/line/vistoolpin.h b/src/libs/vtools/visualization/line/vistoolpin.h new file mode 100644 index 000000000..a8075c42a --- /dev/null +++ b/src/libs/vtools/visualization/line/vistoolpin.h @@ -0,0 +1,51 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 31 1, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine 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 VISTOOLPIN_H +#define VISTOOLPIN_H + +#include "visline.h" + +class VSimplePoint; + +class VisToolPin : public VisLine +{ + Q_OBJECT +public: + explicit VisToolPin(const VContainer *data, QGraphicsItem *parent = nullptr); + virtual ~VisToolPin() Q_DECL_OVERRIDE; + + virtual void RefreshGeometry() Q_DECL_OVERRIDE; + virtual int type() const Q_DECL_OVERRIDE {return Type;} + enum { Type = UserType + static_cast(Vis::ToolPin)}; +private: + Q_DISABLE_COPY(VisToolPin) + VSimplePoint *m_point; +}; + +#endif // VISTOOLPIN_H diff --git a/src/libs/vtools/visualization/visualization.pri b/src/libs/vtools/visualization/visualization.pri index 6231eacf9..042360691 100644 --- a/src/libs/vtools/visualization/visualization.pri +++ b/src/libs/vtools/visualization/visualization.pri @@ -40,7 +40,8 @@ HEADERS += \ $$PWD/line/operation/vistoolmove.h \ $$PWD/path/vistoolellipticalarc.h \ $$PWD/path/vistoolpiece.h \ - $$PWD/path/vistoolpiecepath.h + $$PWD/path/vistoolpiecepath.h \ + $$PWD/line/vistoolpin.h SOURCES += \ $$PWD/visualization.cpp \ @@ -81,4 +82,5 @@ SOURCES += \ $$PWD/line/operation/vistoolmove.cpp \ $$PWD/path/vistoolellipticalarc.cpp \ $$PWD/path/vistoolpiece.cpp \ - $$PWD/path/vistoolpiecepath.cpp + $$PWD/path/vistoolpiecepath.cpp \ + $$PWD/line/vistoolpin.cpp