diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 40183cc34..99434e6d5 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -77,7 +77,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) == 48, "Not all tools was used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in switch."); switch (item->type()) { @@ -210,7 +210,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) == 48, "Not all tools was used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in switch."); switch (currentItem->type()) { @@ -354,7 +354,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in switch."); switch (currentItem->type()) { diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index bd177bdea..8b57fdadf 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -208,7 +208,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) == 48, "Not all tools was used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used in history."); const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) @@ -381,6 +381,7 @@ QString DialogHistory::Record(const VToolRecord &tool) //Because "history" not only show history of pattern, but help restore current data for each pattern's //piece, we need add record about details and nodes, but don't show them. case Tool::Detail: + case Tool::Piece: case Tool::UnionDetails: case Tool::NodeArc: case Tool::NodePoint: diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 83f54631d..74c7fdc71 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -52,6 +52,7 @@ #include "tools/drawTools/drawtools.h" #include "../vtools/dialogs/tooldialogs.h" #include "tools/vtooldetail.h" +#include "tools/vtoolseamallowance.h" #include "tools/vtooluniondetails.h" #include "dialogs/dialogs.h" #include "dialogs/vwidgetgroups.h" @@ -935,8 +936,10 @@ void MainWindow::ToolPointOfContact(bool checked) void MainWindow::ToolDetail(bool checked) { ToolSelectAllDrawObjects(); - SetToolButton(checked, Tool::Detail, "://cursor/new_detail_cursor.png", - tr("Select main path objects clockwise."), &MainWindow::ClosedDialogDetail); + SetToolButtonWithApply(checked, Tool::Piece, "://cursor/new_detail_cursor.png", + tr("Select main path objects clockwise."), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -946,12 +949,12 @@ void MainWindow::ToolDetail(bool checked) */ void MainWindow::ClosedDialogDetail(int result) { -// if (result == QDialog::Accepted) -// { -// VToolDetail::Create(dialogTool, sceneDetails, doc, pattern); -// } + if (result == QDialog::Accepted) + { + VToolDetail::Create(dialogTool, sceneDetails, doc, pattern); + } ArrowTool(); -// doc->LiteParseTree(Document::LiteParse); + doc->LiteParseTree(Document::LiteParse); } //--------------------------------------------------------------------------------------------------------------------- @@ -1773,7 +1776,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) == 48, "Not all tools was handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was handled."); qCDebug(vMainWindow, "Canceling tool."); delete dialogTool; @@ -1859,6 +1862,9 @@ void MainWindow::CancelTool() case Tool::Detail: ui->toolButtonNewDetail->setChecked(false); break; + case Tool::Piece: + ui->toolButtonNewDetail->setChecked(false); + break; case Tool::Height: ui->toolButtonHeight->setChecked(false); break; @@ -2971,7 +2977,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) == 48, "Not all tools were handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools were handled."); //Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); @@ -3291,7 +3297,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) == 48, "Not all tools was handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was handled."); if (currentTool == lastUsedTool) { @@ -3381,6 +3387,10 @@ void MainWindow::LastUsedTool() ui->toolButtonNewDetail->setChecked(true); ToolDetail(true); break; + case Tool::Piece: + ui->toolButtonNewDetail->setChecked(true); + ToolDetail(true); + break; case Tool::Height: ui->toolButtonHeight->setChecked(true); ToolHeight(true); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 624f5ff2e..d50dcf7fb 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -608,142 +608,142 @@ void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const */ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document &parse) { - Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); - try - { - VDetail detail; - const quint32 id = GetParametrId(domElement); - detail.setName(GetParametrString(domElement, AttrName, "")); - detail.setMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0"))); - detail.setMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0"))); - detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1")); - detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); - detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1")); - detail.setForbidFlipping(GetParametrUInt(domElement, VToolDetail::AttrForbidFlipping, - QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()))); - detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); +// Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); +// try +// { +// VDetail detail; +// const quint32 id = GetParametrId(domElement); +// detail.setName(GetParametrString(domElement, AttrName, "")); +// detail.setMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0"))); +// detail.setMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0"))); +// detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1")); +// detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); +// detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1")); +// detail.setForbidFlipping(GetParametrUInt(domElement, VToolDetail::AttrForbidFlipping, +// QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping()))); +// detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); - QStringList types = QStringList() << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline - << VToolDetail::NodeSplinePath; - const QDomNodeList nodeList = domElement.childNodes(); - const qint32 num = nodeList.size(); - for (qint32 i = 0; i < num; ++i) - { - const QDomElement element = nodeList.at(i).toElement(); - if (element.isNull() == false) - { - if (element.tagName() == VToolDetail::TagNode) - { - const quint32 id = GetParametrUInt(element, AttrIdObject, NULL_ID_STR); - const qreal mx = qApp->toPixel(GetParametrDouble(element, AttrMx, "0.0")); - const qreal my = qApp->toPixel(GetParametrDouble(element, AttrMy, "0.0")); - const bool reverse = GetParametrUInt(element, VToolDetail::AttrReverse, "0"); - const NodeDetail nodeType = NodeDetail::Contour; +// QStringList types = QStringList() << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline +// << VToolDetail::NodeSplinePath; +// const QDomNodeList nodeList = domElement.childNodes(); +// const qint32 num = nodeList.size(); +// for (qint32 i = 0; i < num; ++i) +// { +// const QDomElement element = nodeList.at(i).toElement(); +// if (element.isNull() == false) +// { +// if (element.tagName() == VToolDetail::TagNode) +// { +// const quint32 id = GetParametrUInt(element, AttrIdObject, NULL_ID_STR); +// const qreal mx = qApp->toPixel(GetParametrDouble(element, AttrMx, "0.0")); +// const qreal my = qApp->toPixel(GetParametrDouble(element, AttrMy, "0.0")); +// const bool reverse = GetParametrUInt(element, VToolDetail::AttrReverse, "0"); +// const NodeDetail nodeType = NodeDetail::Contour; - const QString t = GetParametrString(element, AttrType, "NodePoint"); - Tool tool; +// const QString t = GetParametrString(element, AttrType, "NodePoint"); +// Tool tool; - switch (types.indexOf(t)) - { - case 0: // VToolDetail::NodePoint - tool = Tool::NodePoint; - break; - case 1: // VToolDetail::NodeArc - tool = Tool::NodeArc; - break; - case 2: // VToolDetail::NodeSpline - tool = Tool::NodeSpline; - break; - case 3: // VToolDetail::NodeSplinePath - tool = Tool::NodeSplinePath; - break; - default: - VException e(tr("Wrong tag name '%1'.").arg(t)); - throw e; - } - detail.append(VNodeDetail(id, tool, nodeType, mx, my, reverse)); - } - else if (element.tagName() == TagData) - { - bool bVisible = GetParametrBool(element, AttrVisible, trueStr); - detail.GetPatternPieceData().SetVisible(bVisible); - try - { - QString qsLetter = GetParametrString(element, AttrLetter, ""); - detail.GetPatternPieceData().SetLetter(qsLetter); - } catch(...) - { - detail.GetPatternPieceData().SetLetter(""); - } - QPointF ptPos; - ptPos.setX(GetParametrDouble(element, AttrMx, "0")); - ptPos.setY(GetParametrDouble(element, AttrMy, "0")); - detail.GetPatternPieceData().SetPos(ptPos); - qreal dLW = GetParametrDouble(element, VToolDetail::AttrWidth, "0"); - detail.GetPatternPieceData().SetLabelWidth(dLW); - qreal dLH = GetParametrDouble(element, VToolDetail::AttrHeight, "0"); - detail.GetPatternPieceData().SetLabelHeight(dLH); - int iFS = static_cast(GetParametrUInt(element, VToolDetail::AttrFont, "0")); - detail.GetPatternPieceData().SetFontSize(iFS); - qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0"); - detail.GetPatternPieceData().SetRotation(dRot); +// switch (types.indexOf(t)) +// { +// case 0: // VToolDetail::NodePoint +// tool = Tool::NodePoint; +// break; +// case 1: // VToolDetail::NodeArc +// tool = Tool::NodeArc; +// break; +// case 2: // VToolDetail::NodeSpline +// tool = Tool::NodeSpline; +// break; +// case 3: // VToolDetail::NodeSplinePath +// tool = Tool::NodeSplinePath; +// break; +// default: +// VException e(tr("Wrong tag name '%1'.").arg(t)); +// throw e; +// } +// detail.append(VNodeDetail(id, tool, nodeType, mx, my, reverse)); +// } +// else if (element.tagName() == TagData) +// { +// bool bVisible = GetParametrBool(element, AttrVisible, trueStr); +// detail.GetPatternPieceData().SetVisible(bVisible); +// try +// { +// QString qsLetter = GetParametrString(element, AttrLetter, ""); +// detail.GetPatternPieceData().SetLetter(qsLetter); +// } catch(...) +// { +// detail.GetPatternPieceData().SetLetter(""); +// } +// QPointF ptPos; +// ptPos.setX(GetParametrDouble(element, AttrMx, "0")); +// ptPos.setY(GetParametrDouble(element, AttrMy, "0")); +// detail.GetPatternPieceData().SetPos(ptPos); +// qreal dLW = GetParametrDouble(element, VToolDetail::AttrWidth, "0"); +// detail.GetPatternPieceData().SetLabelWidth(dLW); +// qreal dLH = GetParametrDouble(element, VToolDetail::AttrHeight, "0"); +// detail.GetPatternPieceData().SetLabelHeight(dLH); +// int iFS = static_cast(GetParametrUInt(element, VToolDetail::AttrFont, "0")); +// detail.GetPatternPieceData().SetFontSize(iFS); +// qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0"); +// detail.GetPatternPieceData().SetRotation(dRot); - QDomNodeList nodeListMCP = element.childNodes(); - for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP) - { - MaterialCutPlacement mcp; - QDomElement domMCP = nodeListMCP.at(iMCP).toElement(); - mcp.m_eMaterial = MaterialType(GetParametrUInt(domMCP, AttrMaterial, 0)); - if (mcp.m_eMaterial == MaterialType::mtUserDefined) - { - mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, ""); - } - mcp.m_iCutNumber = static_cast(GetParametrUInt(domMCP, AttrCutNumber, 0)); - mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0)); - detail.GetPatternPieceData().Append(mcp); - } - } - else if (element.tagName() == TagPatternInfo) - { - detail.GetPatternInfo().SetVisible(GetParametrBool(element, AttrVisible, trueStr)); - QPointF ptPos; - ptPos.setX(GetParametrDouble(element, AttrMx, "0")); - ptPos.setY(GetParametrDouble(element, AttrMy, "0")); - detail.GetPatternInfo().SetPos(ptPos); - qreal dLW = GetParametrDouble(element, VToolDetail::AttrWidth, "0"); - detail.GetPatternInfo().SetLabelWidth(dLW); - qreal dLH = GetParametrDouble(element, VToolDetail::AttrHeight, "0"); - detail.GetPatternInfo().SetLabelHeight(dLH); - int iFS = static_cast(GetParametrUInt(element, VToolDetail::AttrFont, "0")); - detail.GetPatternInfo().SetFontSize(iFS); - qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0"); - detail.GetPatternInfo().SetRotation(dRot); - } - else if (element.tagName() == TagGrainline) - { - detail.GetGrainlineGeometry().SetVisible(GetParametrBool(element, AttrVisible, falseStr)); - QPointF ptPos; - ptPos.setX(GetParametrDouble(element, AttrMx, "0")); - ptPos.setY(GetParametrDouble(element, AttrMy, "0")); - detail.GetGrainlineGeometry().SetPos(ptPos); - QString qsLength = GetParametrString(element, AttrLength, "0"); - detail.GetGrainlineGeometry().SetLength(qsLength); - QString qsRot = GetParametrString(element, VToolDetail::AttrRotation, "90"); - detail.GetGrainlineGeometry().SetRotation(qsRot); - VGrainlineGeometry::ArrowType eAT = - VGrainlineGeometry::ArrowType(GetParametrUInt(element, AttrArrows, "0")); - detail.GetGrainlineGeometry().SetArrowType(eAT); - } - } - } - VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Source::FromFile); - } - catch (const VExceptionBadId &e) - { - VExceptionObjectError excep(tr("Error creating or updating detail"), domElement); - excep.AddMoreInformation(e.ErrorMessage()); - throw excep; - } +// QDomNodeList nodeListMCP = element.childNodes(); +// for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP) +// { +// MaterialCutPlacement mcp; +// QDomElement domMCP = nodeListMCP.at(iMCP).toElement(); +// mcp.m_eMaterial = MaterialType(GetParametrUInt(domMCP, AttrMaterial, 0)); +// if (mcp.m_eMaterial == MaterialType::mtUserDefined) +// { +// mcp.m_qsMaterialUserDef = GetParametrString(domMCP, AttrUserDefined, ""); +// } +// mcp.m_iCutNumber = static_cast(GetParametrUInt(domMCP, AttrCutNumber, 0)); +// mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0)); +// detail.GetPatternPieceData().Append(mcp); +// } +// } +// else if (element.tagName() == TagPatternInfo) +// { +// detail.GetPatternInfo().SetVisible(GetParametrBool(element, AttrVisible, trueStr)); +// QPointF ptPos; +// ptPos.setX(GetParametrDouble(element, AttrMx, "0")); +// ptPos.setY(GetParametrDouble(element, AttrMy, "0")); +// detail.GetPatternInfo().SetPos(ptPos); +// qreal dLW = GetParametrDouble(element, VToolDetail::AttrWidth, "0"); +// detail.GetPatternInfo().SetLabelWidth(dLW); +// qreal dLH = GetParametrDouble(element, VToolDetail::AttrHeight, "0"); +// detail.GetPatternInfo().SetLabelHeight(dLH); +// int iFS = static_cast(GetParametrUInt(element, VToolDetail::AttrFont, "0")); +// detail.GetPatternInfo().SetFontSize(iFS); +// qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0"); +// detail.GetPatternInfo().SetRotation(dRot); +// } +// else if (element.tagName() == TagGrainline) +// { +// detail.GetGrainlineGeometry().SetVisible(GetParametrBool(element, AttrVisible, falseStr)); +// QPointF ptPos; +// ptPos.setX(GetParametrDouble(element, AttrMx, "0")); +// ptPos.setY(GetParametrDouble(element, AttrMy, "0")); +// detail.GetGrainlineGeometry().SetPos(ptPos); +// QString qsLength = GetParametrString(element, AttrLength, "0"); +// detail.GetGrainlineGeometry().SetLength(qsLength); +// QString qsRot = GetParametrString(element, VToolDetail::AttrRotation, "90"); +// detail.GetGrainlineGeometry().SetRotation(qsRot); +// VGrainlineGeometry::ArrowType eAT = +// VGrainlineGeometry::ArrowType(GetParametrUInt(element, AttrArrows, "0")); +// detail.GetGrainlineGeometry().SetArrowType(eAT); +// } +// } +// } +// VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Source::FromFile); +// } +// catch (const VExceptionBadId &e) +// { +// VExceptionObjectError excep(tr("Error creating or updating detail"), domElement); +// excep.AddMoreInformation(e.ErrorMessage()); +// throw excep; +// } } //--------------------------------------------------------------------------------------------------------------------- @@ -3442,7 +3442,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) == 48, "Not all tools was used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49, "Not all tools was used."); QRectF rec; @@ -3565,6 +3565,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const break; //These tools are not accesseble in Draw mode, but still 'history' contains them. case Tool::Detail: + case Tool::Piece: case Tool::UnionDetails: case Tool::NodeArc: case Tool::NodePoint: diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index c7ed109f2..05076bd9f 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1422,7 +1422,7 @@ QStringList VAbstractPattern::ListPointExpressions() const { // Check if new tool doesn't bring new attribute with a formula. // If no just increment number - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 48); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; const QDomNodeList list = elementsByTagName(TagPoint); @@ -1493,7 +1493,7 @@ QStringList VAbstractPattern::ListArcExpressions() const { // Check if new tool doesn't bring new attribute with a formula. // If no just increment number - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 48); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; const QDomNodeList list = elementsByTagName(TagArc); @@ -1554,7 +1554,7 @@ QStringList VAbstractPattern::ListPathPointExpressions() const { // Check if new tool doesn't bring new attribute with a formula. // If no just increment number - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 48); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; const QDomNodeList list = elementsByTagName(AttrPathPoint); @@ -1620,7 +1620,7 @@ QStringList VAbstractPattern::ListOperationExpressions() const { // Check if new tool doesn't bring new attribute with a formula. // If no just increment number - Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 48); + Q_STATIC_ASSERT(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 49); QStringList expressions; const QDomNodeList list = elementsByTagName(TagOperation); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index debc5166b..a5c420e90 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -92,6 +92,7 @@ enum class Tool : ToolVisHolderType CutSplinePath, PointOfContact, Detail, + Piece, NodePoint, NodeArc, NodeSpline, diff --git a/src/libs/vtools/tools/tools.pri b/src/libs/vtools/tools/tools.pri index 4f4536aae..563ab6573 100644 --- a/src/libs/vtools/tools/tools.pri +++ b/src/libs/vtools/tools/tools.pri @@ -57,7 +57,8 @@ HEADERS += \ $$PWD/drawTools/operation/vabstractoperation.h \ $$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.h \ $$PWD/drawTools/operation/flipping/vabstractflipping.h \ - $$PWD/drawTools/operation/vtoolmove.h + $$PWD/drawTools/operation/vtoolmove.h \ + $$PWD/vtoolseamallowance.h SOURCES += \ $$PWD/vtooldetail.cpp \ @@ -112,4 +113,5 @@ SOURCES += \ $$PWD/drawTools/operation/vabstractoperation.cpp \ $$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.cpp \ $$PWD/drawTools/operation/flipping/vabstractflipping.cpp \ - $$PWD/drawTools/operation/vtoolmove.cpp + $$PWD/drawTools/operation/vtoolmove.cpp \ + $$PWD/vtoolseamallowance.cpp diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp new file mode 100644 index 000000000..62b260af5 --- /dev/null +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -0,0 +1,559 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 6 11, 2016 + ** + ** @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) 2016 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 "vtoolseamallowance.h" +#include "../dialogs/tools/dialogseamallowance.h" +#include "../vpatterndb/vpiecenode.h" +#include "nodeDetails/vnodearc.h" +#include "nodeDetails/vnodepoint.h" +#include "nodeDetails/vnodespline.h" +#include "nodeDetails/vnodesplinepath.h" +#include "../vgeometry/varc.h" +#include "../vgeometry/vcubicbezier.h" +#include "../vgeometry/vcubicbezierpath.h" +#include "../vgeometry/vpointf.h" +#include "../vgeometry/vspline.h" +#include "../vgeometry/vsplinepath.h" +#include "../ifc/xml/vpatternconverter.h" +#include "../undocommands/addpiece.h" + +#include +#include + +// Current version of seam allowance tag nned for backward compatibility +const quint8 VToolSeamAllowance::pieceVersion = 2; + +const QString VToolSeamAllowance::TagNodes = QStringLiteral("nodes"); +const QString VToolSeamAllowance::TagNode = QStringLiteral("node"); + +const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); +const QString VToolSeamAllowance::AttrNodeReverse = QStringLiteral("reverse"); + +const QString VToolSeamAllowance::NodeArc = QStringLiteral("NodeArc"); +const QString VToolSeamAllowance::NodePoint = QStringLiteral("NodePoint"); +const QString VToolSeamAllowance::NodeSpline = QStringLiteral("NodeSpline"); +const QString VToolSeamAllowance::NodeSplinePath = QStringLiteral("NodeSplinePath"); + +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance::~VToolSeamAllowance() +{ + delete m_dialog; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance *VToolSeamAllowance::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogSeamAllowance *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + VPiece detail = dialogTool->GetPiece(); + QVector nodes; + qApp->getUndoStack()->beginMacro("add detail"); + for (int i = 0; i< detail.CountNodes(); ++i) + { + quint32 id = 0; + VPieceNode nodeD = detail.at(i); + switch (nodeD.GetTypeTool()) + { + case (Tool::NodePoint): + { + id = CreateNode(data, nodeD.GetId()); + VNodePoint::Create(doc, data, scene, id, nodeD.GetId(), Document::FullParse, Source::FromGui); + } + break; + case (Tool::NodeArc): + { + id = CreateNode(data, nodeD.GetId()); + VNodeArc::Create(doc, data, id, nodeD.GetId(), Document::FullParse, Source::FromGui); + } + break; + case (Tool::NodeSpline): + { + const auto obj = data->GetGObject(nodeD.GetId()); + if (obj->getType() == GOType::Spline) + { + id = CreateNode(data, nodeD.GetId()); + } + else + { + id = CreateNode(data, nodeD.GetId()); + } + VNodeSpline::Create(doc, data, id, nodeD.GetId(), Document::FullParse, Source::FromGui); + } + break; + case (Tool::NodeSplinePath): + { + const auto obj = data->GetGObject(nodeD.GetId()); + if (obj->getType() == GOType::SplinePath) + { + id = CreateNode(data, nodeD.GetId()); + } + else + { + id = CreateNode(data, nodeD.GetId()); + } + VNodeSplinePath::Create(doc, data, id, nodeD.GetId(), Document::FullParse, Source::FromGui); + } + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."<m_dialog = dialogTool; + } + return piece; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance *VToolSeamAllowance::Create(quint32 id, const VPiece &newPiece, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation, const QString &drawName) +{ + if (typeCreation == Source::FromGui || typeCreation == Source::FromTool) + { + id = data->AddPiece(newPiece); + } + else + { + data->UpdatePiece(id, newPiece); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VAbstractTool::AddRecord(id, Tool::Piece, doc); + if (parse == Document::FullParse) + { + VToolSeamAllowance *piece = new VToolSeamAllowance(doc, data, id, typeCreation, scene, drawName); + scene->addItem(piece); + connect(piece, &VToolSeamAllowance::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::EnableDetailItemHover, piece, &VToolSeamAllowance::AllowHover); + connect(scene, &VMainGraphicsScene::EnableDetailItemSelection, piece, &VToolSeamAllowance::AllowSelecting); + connect(scene, &VMainGraphicsScene::HighlightDetail, piece, &VToolSeamAllowance::Highlight); + doc->AddTool(id, piece); + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node) +{ + QDomElement nod = doc->createElement(TagNode); + + doc->SetAttribute(nod, AttrIdObject, node.GetId()); + + if (node.GetTypeTool() != Tool::NodePoint) + { + doc->SetAttribute(nod, AttrNodeReverse, static_cast(node.GetReverse())); + } + + switch (node.GetTypeTool()) + { + case (Tool::NodeArc): + doc->SetAttribute(nod, AttrType, NodeArc); + break; + case (Tool::NodePoint): + doc->SetAttribute(nod, AttrType, NodePoint); + break; + case (Tool::NodeSpline): + doc->SetAttribute(nod, AttrType, NodeSpline); + break; + case (Tool::NodeSplinePath): + doc->SetAttribute(nod, AttrType, NodeSplinePath); + break; + default: + qDebug()<<"May be wrong tool type!!! Ignoring."< 0) + { + QDomElement nodesElement = doc->createElement(TagNodes); + for (int i = 0; i < piece.CountNodes(); ++i) + { + AddNode(doc, nodesElement, piece.at(i)); + } + domElement.appendChild(nodesElement); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolSeamAllowance::getTagName() const +{ + return VAbstractPattern::TagDetail; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::ShowVisualization(bool show) +{ + Q_UNUSED(show) +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::GroupVisibility(quint32 object, bool visible) +{ + Q_UNUSED(object); + Q_UNUSED(visible); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::FullUpdateFromFile() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::FullUpdateFromGuiOk(int result) +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::EnableToolMove(bool move) +{ + setFlag(QGraphicsItem::ItemIsMovable, move); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::AllowHover(bool enabled) +{ + setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::AllowSelecting(bool enabled) +{ + setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::Highlight(quint32 id) +{ + setSelected(this->id == id); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::AddToFile() +{ + const VPiece piece = VAbstractTool::data.GetPiece(id); + + QDomElement domElement = doc->createElement(getTagName()); + + doc->SetAttribute(domElement, VDomDocument::AttrId, id); + doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); + doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx())); + doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy())); + + // nodes + AddNodes(doc, domElement, piece); + + AddPiece *addDet = new AddPiece(domElement, doc, piece, m_drawName); + connect(addDet, &AddPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); + qApp->getUndoStack()->push(addDet); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::RefreshDataInFile() +{ + QDomElement domElement = doc->elementById(id); + if (domElement.isElement()) + { + // Refresh only parts that we possibly need to update + { + // TODO. Delete if minimal supported version is 0.5.0 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 5, 0), + "Time to refactor the code."); + doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QVariant VToolSeamAllowance::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + return VNoBrushScalePathItem::itemChange(change, value); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + // Special for not selectable item first need to call standard mousePressEvent then accept event + VNoBrushScalePathItem::mousePressEvent(event); + + // Somehow clicking on notselectable object do not clean previous selections. + if (not (flags() & ItemIsSelectable) && scene()) + { + scene()->clearSelection(); + } + + if (flags() & QGraphicsItem::ItemIsMovable) + { + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + SetOverrideCursor(cursorArrowCloseHand, 1, 1); + } + } + + if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) + { + doc->SelectedDetail(id); + emit ChoosedTool(id, SceneObject::Detail); + } + + event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + { + //Disable cursor-arrow-closehand + RestoreOverrideCursor(cursorArrowCloseHand); + } + VNoBrushScalePathItem::mouseReleaseEvent(event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + if (flags() & QGraphicsItem::ItemIsMovable) + { + SetOverrideCursor(cursorArrowOpenHand, 1, 1); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + if (flags() & QGraphicsItem::ItemIsMovable) + { + SetOverrideCursor(cursorArrowOpenHand, 1, 1); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + //Disable cursor-arrow-openhand + if (flags() & QGraphicsItem::ItemIsMovable) + { + RestoreOverrideCursor(cursorArrowOpenHand); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + QMenu menu; + QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); + +// QAction *inLayoutOption = menu.addAction(tr("In layout")); +// inLayoutOption->setCheckable(true); +// const VDetail detail = VAbstractTool::data.GetDetail(id); +// inLayoutOption->setChecked(detail.IsInLayout()); + +// QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); +// _referens > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true); + + QAction *selectedAction = menu.exec(event->screenPos()); + if (selectedAction == actionOption) + { + m_dialog = new DialogSeamAllowance(getData(), id, qApp->getMainWindow()); + m_dialog->setModal(true); + connect(m_dialog, &DialogTool::DialogClosed, this, &VToolSeamAllowance::FullUpdateFromGuiOk); + SetDialog(); + m_dialog->show(); + } +// else if (selectedAction == inLayoutOption) +// { +// ToggleDetailInLayout *togglePrint = new ToggleDetailInLayout(id, selectedAction->isChecked(), +// &(VAbstractTool::data), doc); +// connect(togglePrint, &ToggleDetailInLayout::UpdateList, doc, &VAbstractPattern::CheckInLayoutList); +// qApp->getUndoStack()->push(togglePrint); +// } +// else if (selectedAction == actionRemove) +// { +// try +// { +// DeleteTool(); +// } +// catch(const VExceptionToolWasDeleted &e) +// { +// Q_UNUSED(e); +// return;//Leave this method immediately!!! +// } +// return; //Leave this method immediately after call!!! + // } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event) +{ + VNoBrushScalePathItem::keyReleaseEvent ( event ); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::SetDialog() +{ + SCASSERT(m_dialog != nullptr); + DialogSeamAllowance *dialogTool = qobject_cast(m_dialog); + SCASSERT(dialogTool != nullptr); + dialogTool->SetPiece(VAbstractTool::data.GetPiece(id)); + dialogTool->EnableApply(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, + const Source &typeCreation, VMainGraphicsScene *scene, + const QString &drawName, QGraphicsItem *parent) + : VAbstractTool(doc, data, id), + VNoBrushScalePathItem(parent), + m_dialog(nullptr), + m_sceneDetails(scene), + m_drawName(drawName) +{ + VPiece detail = data->GetPiece(id); + for (int i = 0; i< detail.CountNodes(); ++i) + { + switch (detail.at(i).GetTypeTool()) + { + case (Tool::NodePoint): + { + VNodePoint *tool = InitTool(scene, detail.at(i)); + connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent); + break; + } + case (Tool::NodeArc): + doc->IncrementReferens(detail.at(i).GetId()); + break; + case (Tool::NodeSpline): + doc->IncrementReferens(detail.at(i).GetId()); + break; + case (Tool::NodeSplinePath): + doc->IncrementReferens(detail.at(i).GetId()); + break; + default: + qDebug()<<"Get wrong tool type. Ignore."; + break; + } + } + this->setFlag(QGraphicsItem::ItemIsMovable, true); + this->setFlag(QGraphicsItem::ItemIsSelectable, true); + RefreshGeometry(); + + this->setBrush(QBrush(Qt::Dense7Pattern)); + + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus + + connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove); + //connect(scene, &VMainGraphicsScene::ItemClicked, this, &VToolSeamAllowance::ResetChildren); + if (typeCreation == Source::FromGui || typeCreation == Source::FromTool) + { + AddToFile(); + if (typeCreation != Source::FromTool) + { + qApp->getUndoStack()->endMacro(); + } + } + else + { + RefreshDataInFile(); + } + setAcceptHoverEvents(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::RefreshGeometry() +{ + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); + + const VPiece detail = VAbstractTool::data.GetPiece(id); + QPainterPath mainPath = detail.MainPathPath(this->getData()); + this->setPath(mainPath); + this->setPos(detail.GetMx(), detail.GetMy()); + + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::DeleteTool(bool ask) +{ + +} + +//--------------------------------------------------------------------------------------------------------------------- +template +/** + * @brief CreateNode create new node for detail. + * @param data container. + * @param id id parent object. + * @return id for new object. + */ +quint32 VToolSeamAllowance::CreateNode(VContainer *data, const quint32 &id) +{ + //We can't use exist object. Need create new. + T *node = new T(*data->GeometricObject(id).data()); + node->setMode(Draw::Modeling); + return data->AddGObject(node); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +/** + * @brief InitTool initial node item on scene + * @param scene pointer to scene. + * @param node node of detail. + */ +Tool *VToolSeamAllowance::InitTool(VMainGraphicsScene *scene, const VPieceNode &node) +{ + QHash* tools = doc->getTools(); + SCASSERT(tools != nullptr); + Tool *tool = qobject_cast(tools->value(node.GetId())); + SCASSERT(tool != nullptr); + connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + tool->setParentItem(this); + tool->SetParentType(ParentType::Item); + doc->IncrementReferens(node.GetId()); + return tool; +} diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h new file mode 100644 index 000000000..836849aa9 --- /dev/null +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -0,0 +1,123 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 6 11, 2016 + ** + ** @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) 2016 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 VTOOLSEAMALLOWANCE_H +#define VTOOLSEAMALLOWANCE_H + +#include +#include +#include + +#include "../vwidgets/vnobrushscalepathitem.h" +#include "vabstracttool.h" + +class VMainGraphicsScene; +class DialogTool; +class VPiece; + +class VToolSeamAllowance : public VAbstractTool, public VNoBrushScalePathItem +{ + Q_OBJECT +public: + virtual ~VToolSeamAllowance(); + + static VToolSeamAllowance* Create(DialogTool *m_dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); + static VToolSeamAllowance* Create(quint32 id, const VPiece &newPiece, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation, const QString &m_drawName = QString()); + + static const quint8 pieceVersion; + + static const QString TagNodes; + static const QString TagNode; + + static const QString AttrVersion; + static const QString AttrNodeReverse; + + static const QString NodeArc; + static const QString NodePoint; + static const QString NodeSpline; + static const QString NodeSplinePath; + + static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node); + static void AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiece &piece); + + virtual int type() const Q_DECL_OVERRIDE {return Type;} + enum { Type = UserType + static_cast(Tool::Piece)}; + + virtual QString getTagName() const Q_DECL_OVERRIDE; + virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; +public slots: + virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; + virtual void FullUpdateFromGuiOk(int result); + void EnableToolMove(bool move); + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; + void Highlight(quint32 id); +protected: + virtual void AddToFile () Q_DECL_OVERRIDE; + virtual void RefreshDataInFile() Q_DECL_OVERRIDE; + virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; + virtual void mousePressEvent( QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverMoveEvent( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE {} + +private: + Q_DISABLE_COPY(VToolSeamAllowance) + + /** @brief dialog dialog options. */ + DialogTool *m_dialog; + + /** @brief sceneDetails pointer to the scene. */ + VMainGraphicsScene *m_sceneDetails; + QString m_drawName; + + void SetDialog(); + + template + static quint32 CreateNode(VContainer *data, const quint32 &id); + + VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, + VMainGraphicsScene *scene, const QString &m_drawName, QGraphicsItem * parent = nullptr); + + void RefreshGeometry (); + + template + Tool* InitTool(VMainGraphicsScene *scene, const VPieceNode &node); + + virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE; +}; + +#endif // VTOOLSEAMALLOWANCE_H