Resolved issue #772. New tool Duplicate detail.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-10-26 17:26:17 +03:00
commit 003d7e7483
43 changed files with 1111 additions and 202 deletions

View File

@ -29,6 +29,7 @@
- [#768] New feature. Custom curve approximation scale.
- [#759] Add place label tool.
- [#771] Improve tool Point at intersection of arc and line.
- [#772] New tool Duplicate detail.
# Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used in switch.");
switch (currentItem->type())
{

View File

@ -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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used in history.");
Q_STATIC_ASSERT_X(static_cast<int>(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();
}
}

View File

@ -260,7 +260,7 @@ void MainWindow::AddPP(const QString &PPName)
comboBoxDraws->blockSignals(true);
comboBoxDraws->addItem(PPName);
pattern->ClearGObjects();
pattern->ClearCalculationGObjects();
//Create single point
ui->view->itemClicked(nullptr);//hide options previous tool
const QString label = doc->GenerateLabel(LabelType::NewPatternPiece);
@ -613,7 +613,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
dialogTool = QSharedPointer<Dialog>(new Dialog(pattern, 0, this));
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Check if need to extend.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Check if need to extend.");
switch(t)
{
@ -1107,8 +1107,31 @@ void MainWindow::ToolUnionDetails(bool checked)
*/
void MainWindow::ClosedDialogUnionDetails(int result)
{
ClosedDialog<VToolUnionDetails>(result);
doc->LiteParseTree(Document::LiteParse);
ClosedDialog<VToolUnionDetails>(result);// Avoid error: Template function as signal or slot
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolDuplicateDetail(bool checked)
{
ToolSelectDetail();
SetToolButton<DialogDuplicateDetail>(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<VMainGraphicsScene *>(currentScene);
SCASSERT(scene != nullptr)
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(VToolSeamAllowance::Duplicate(dialogTool, scene, doc));
// Do not check for nullptr! See issue #719.
ui->view->itemClicked(tool);
}
ArrowTool();
}
//---------------------------------------------------------------------------------------------------------------------
@ -1985,7 +2008,7 @@ void MainWindow::InitToolButtons()
}
// This check helps to find missed tools
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Check if all tools were connected.");
Q_STATIC_ASSERT_X(static_cast<int>(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 +2031,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 +2086,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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled.");
qCDebug(vMainWindow, "Canceling tool.");
dialogTool.clear();
@ -2172,6 +2196,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 +3451,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
QT_WARNING_POP
// This check helps to find missed tools
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled.");
//Drawing Tools
ui->toolButtonEndLine->setEnabled(drawTools);
@ -3480,6 +3507,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 +3780,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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were handled.");
if (currentTool == lastUsedTool)
{
@ -3875,6 +3903,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);

View File

@ -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);

View File

@ -48,7 +48,7 @@
<string>Export details skiping the Layout stage</string>
</property>
<property name="currentIndex">
<number>7</number>
<number>6</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
@ -1550,6 +1550,32 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QToolButton" name="toolButtonDuplicateDetail">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Duplicate detail tool</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/duplicate_detail.png</normaloff>:/toolicon/32x32/duplicate_detail.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutPage">

View File

@ -86,5 +86,7 @@
<file>cursor/insert_node_cursor@2x.png</file>
<file>cursor/place_label_cursor@2x.png</file>
<file>cursor/place_label_cursor.png</file>
<file>cursor/duplicate_detail_cursor.png</file>
<file>cursor/duplicate_detail_cursor@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -84,5 +84,7 @@
<file>toolicon/32x32/insert_node@2x.png</file>
<file>toolicon/32x32/place_label@2x.png</file>
<file>toolicon/32x32/place_label.png</file>
<file>toolicon/32x32/duplicate_detail.png</file>
<file>toolicon/32x32/duplicate_detail@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
viewBox="0 0 32 32.000001"
id="svg8396"
version="1.1"
inkscape:version="0.92.2 (unknown)"
sodipodi:docname="duplicate_detail.svg"
inkscape:export-filename="/home/dismine/CAD/Valentina_0.6.x/valentina/src/app/valentina/share/resources/toolicon/32x32/duplicate_detail.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<defs
id="defs8398">
<linearGradient
id="linearGradient2464"
osb:paint="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop2462" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient9078">
<stop
style="stop-color:#84ab5a;stop-opacity:1"
offset="0"
id="stop9080" />
<stop
style="stop-color:#3b560b;stop-opacity:0.96078432"
offset="1"
id="stop9082" />
</linearGradient>
<linearGradient
id="linearGradient9060"
inkscape:collect="always">
<stop
id="stop9070"
offset="0"
style="stop-color:#bfd190;stop-opacity:1" />
<stop
id="stop9072"
offset="1"
style="stop-color:#648e2c;stop-opacity:1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9060"
id="linearGradient9066"
x1="24.510012"
y1="1037.5343"
x2="24.510012"
y2="1050.8309"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-9.5,-0.5)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9060"
id="linearGradient9076"
gradientUnits="userSpaceOnUse"
x1="24.189611"
y1="17.372341"
x2="24.189611"
y2="30.428661"
gradientTransform="translate(-9.5,-0.5)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9078"
id="linearGradient9084"
x1="27.273466"
y1="16.050688"
x2="27.453691"
y2="30.668961"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-9.5,-0.5)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9060"
id="linearGradient9086"
gradientUnits="userSpaceOnUse"
x1="24.510012"
y1="1037.5343"
x2="24.510012"
y2="1050.8309"
gradientTransform="translate(-9.5,-0.5)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9060"
id="linearGradient9088"
gradientUnits="userSpaceOnUse"
x1="24.510012"
y1="1037.5343"
x2="24.510012"
y2="1050.8309"
gradientTransform="translate(-9.5,-0.5)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient9060"
id="linearGradient9090"
gradientUnits="userSpaceOnUse"
x1="24.510012"
y1="1037.5343"
x2="24.510012"
y2="1050.8309"
gradientTransform="translate(-9.5,-0.5)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="8.8277862"
inkscape:cx="-30.633024"
inkscape:cy="14.30082"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata8401">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1020.3622)">
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.25;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
d="m 18.253934,1026.4091 c -2.709075,-1.0524 -3.884497,-2.8171 -4.25,-6 l -8.9999995,4 c 1.6204375,5.4081 2.7946849,13.9946 -4,13 l -1.00000002,12.097 9.00000002,1.903 2.9999995,-10 2,10.25 h 4.25 z"
id="path8501"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccc" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.25;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 27.503934,1026.6591 c -2.709075,-1.0524 -3.884497,-2.8171 -4.25,-6 l -9,4 c 1.620438,5.4081 2.794685,13.9946 -4,13 l -1,12.097 9,1.903 3,-10 2,10.25 h 4.25 z"
id="path8501-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccc" />
<g
id="g9054"
style="fill:url(#linearGradient9066);fill-opacity:1;fill-rule:nonzero"
transform="translate(-0.42188663,0.7488442)">
<path
id="rect9043"
transform="translate(0,1020.3622)"
d="M 22.761719,16 C 22.340152,16 22,16.340152 22,16.761719 V 21 H 17.761719 C 17.340152,21 17,21.340152 17,21.761719 v 3.476562 C 17,25.659848 17.340152,26 17.761719,26 H 22 v 4.238281 C 22,30.659848 22.340152,31 22.761719,31 h 3.476562 C 26.659848,31 27,30.659848 27,30.238281 V 26 h 4.238281 C 31.659848,26 32,25.659848 32,25.238281 V 21.761719 C 32,21.340152 31.659848,21 31.238281,21 H 27 V 16.761719 C 27,16.340152 26.659848,16 26.238281,16 Z"
style="fill:url(#linearGradient9076);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient9084);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path9048"
d="m 17.902378,1042.2696 h 4.165206"
style="fill:url(#linearGradient9086);fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
<path
style="fill:url(#linearGradient9088);fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
d="m 26.953692,1042.2696 h 4.165206"
id="path9050"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path9052"
d="m 22.922949,1037.1832 h 3.175378"
style="fill:url(#linearGradient9090);fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54, "Not all tools were used.");
Q_STATIC_ASSERT_X(static_cast<int>(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;
}
}

View File

@ -1771,7 +1771,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagPoint);
@ -1799,7 +1799,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagArc);
@ -1823,7 +1823,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagElArc);
@ -1856,7 +1856,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint);
@ -1894,7 +1894,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagOperation);
@ -1916,7 +1916,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
@ -1939,7 +1939,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagPath);
@ -1977,7 +1977,7 @@ QVector<VFormulaField> 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<int>(Tool::LAST_ONE_DO_NOT_USE) == 54);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55);
QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagDetail);
@ -2420,3 +2420,21 @@ void VAbstractPattern::SetGroupVisivility(quint32 id, bool visible)
qDebug("Can't get group by id = %u.", id);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::PieceDrawName(quint32 id)
{
const QDomElement detail = elementById(id, VAbstractPattern::TagDetail);
if (detail.isNull())
{
return QString();
}
const QDomElement draw = detail.parentNode().parentNode().toElement();
if (draw.isNull() || not draw.hasAttribute(VAbstractPattern::AttrName))
{
return QString();
}
return draw.attribute(VAbstractPattern::AttrName);
}

View File

@ -198,6 +198,8 @@ public:
bool GetGroupVisivility(quint32 id);
void SetGroupVisivility(quint32 id, bool visible);
QString PieceDrawName(quint32 id);
static const QString TagPattern;
static const QString TagCalculation;
static const QString TagModeling;

View File

@ -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,

View File

@ -103,10 +103,7 @@ VContainer::VContainer(const VContainer &data)
//---------------------------------------------------------------------------------------------------------------------
VContainer::~VContainer()
{
ClearGObjects();
ClearVariables();
}
{}
//---------------------------------------------------------------------------------------------------------------------
/**
@ -115,9 +112,20 @@ VContainer::~VContainer()
* @return point
*/
// cppcheck-suppress unusedFunction
const QSharedPointer<VGObject> VContainer::GetGObject(quint32 id)const
const QSharedPointer<VGObject> VContainer::GetGObject(quint32 id) const
{
return GetObject(d->gObjects, id);
if (d->calculationObjects.contains(id))
{
return d->calculationObjects.value(id);
}
else if (d->modelingObjects->contains(id))
{
return d->modelingObjects->value(id);
}
else
{
throw VExceptionBadId(tr("Can't find object"), id);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -129,26 +137,6 @@ const QSharedPointer<VGObject> VContainer::GetFakeGObject(quint32 id)
return pointer;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetObject return object from container
* @param obj container
* @param id id of object
* @return Object
*/
template <typename key, typename val>
const val VContainer::GetObject(const QHash<key, val> &obj, key id) const
{
if (obj.contains(id))
{
return obj.value(id);
}
else
{
throw VExceptionBadId(tr("Can't find object"), id);
}
}
//---------------------------------------------------------------------------------------------------------------------
VPiece VContainer::GetPiece(quint32 id) const
{
@ -192,8 +180,27 @@ quint32 VContainer::AddGObject(VGObject *obj)
quint32 VContainer::AddGObject(const QSharedPointer<VGObject> &obj)
{
SCASSERT(not obj.isNull())
if (obj->getMode() == Draw::Layout)
{
qWarning("Can't add an object with mode 'Layout'");
return NULL_ID;
}
uniqueNames.insert(obj->name());
return AddObject(d->gObjects, obj);
const quint32 id = getNextId();
obj->setId(id);
if (obj->getMode() == Draw::Calculation)
{
d->calculationObjects.insert(id, obj);
}
else if (obj->getMode() == Draw::Modeling)
{
d->modelingObjects->insert(id, obj);
}
return id;
}
//---------------------------------------------------------------------------------------------------------------------
@ -290,33 +297,14 @@ void VContainer::ClearForFullParse()
*/
void VContainer::ClearGObjects()
{
d->gObjects.clear();
d->calculationObjects.clear();
d->modelingObjects->clear();
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::ClearCalculationGObjects()
{
if (not d->gObjects.isEmpty()) //-V807
{
QVector<quint32> keys;
QHash<quint32, QSharedPointer<VGObject> >::iterator i;
for (i = d->gObjects.begin(); i != d->gObjects.end(); ++i)
{
if (i.value()->getMode() == Draw::Calculation)
{
i.value().clear();
keys.append(i.key());
}
}
// We can't delete objects in previous loop it will destroy the iterator.
if (not keys.isEmpty())
{
for (int i = 0; i < keys.size(); ++i)
{
d->gObjects.remove(keys.at(i));
}
}
}
d->calculationObjects.clear();
}
//---------------------------------------------------------------------------------------------------------------------
@ -464,23 +452,6 @@ void VContainer::RemovePiece(quint32 id)
d->pieces->remove(id);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddObject add object to container
* @param obj container
* @param value object
* @return id of object in container
*/
template <typename key, typename val>
quint32 VContainer::AddObject(QHash<key, val> &obj, val value)
{
SCASSERT(value != nullptr)
const quint32 id = getNextId();
value->setId(id);
obj[id] = value;
return id;
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::UpdatePiece(quint32 id, const VPiece &detail)
{
@ -678,9 +649,9 @@ qreal *VContainer::rheight()
* @brief data container with datagObjects return container of gObjects
* @return pointer on container of gObjects
*/
const QHash<quint32, QSharedPointer<VGObject> > *VContainer::DataGObjects() const
const QHash<quint32, QSharedPointer<VGObject> > *VContainer::CalculationGObjects() const
{
return &d->gObjects;
return &d->calculationObjects;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -69,7 +69,8 @@ class VContainerData : public QSharedData //-V690
public:
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit)
: gObjects(QHash<quint32, QSharedPointer<VGObject> >()),
: calculationObjects(QHash<quint32, QSharedPointer<VGObject> >()),
modelingObjects(QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>>::create()),
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
pieces(QSharedPointer<QHash<quint32, VPiece>>::create()),
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>::create()),
@ -79,7 +80,8 @@ public:
VContainerData(const VContainerData &data)
: QSharedData(data),
gObjects(data.gObjects),
calculationObjects(data.calculationObjects),
modelingObjects(data.modelingObjects),
variables(data.variables),
pieces(data.pieces),
piecePaths(data.piecePaths),
@ -89,10 +91,8 @@ public:
virtual ~VContainerData();
/**
* @brief gObjects graphicals objects of pattern.
*/
QHash<quint32, QSharedPointer<VGObject> > gObjects;
QHash<quint32, QSharedPointer<VGObject> > calculationObjects;
QSharedPointer<QHash<quint32, QSharedPointer<VGObject>>> modelingObjects;
/**
* @brief variables container for measurements, increments, lines lengths, lines angles, arcs lengths, curve lengths
@ -184,7 +184,7 @@ public:
void RemoveIncrement(const QString& name);
const QHash<quint32, QSharedPointer<VGObject> > *DataGObjects() const;
const QHash<quint32, QSharedPointer<VGObject> > *CalculationGObjects() const;
const QHash<quint32, VPiece> *DataPieces() const;
const QHash<QString, QSharedPointer<VInternalVariable>> *DataVariables() const;
@ -219,16 +219,9 @@ private:
template <class T>
uint qHash( const QSharedPointer<T> &p );
template <typename key, typename val>
// cppcheck-suppress functionStatic
const val GetObject(const QHash<key, val> &obj, key id) const;
template <typename T>
void UpdateObject(const quint32 &id, const QSharedPointer<T> &point);
template <typename key, typename val>
static quint32 AddObject(QHash<key, val> &obj, val value);
template <typename T>
const QMap<QString, QSharedPointer<T> > DataVar(const VarType &type) const;
};
@ -248,25 +241,23 @@ const QSharedPointer<T> VContainer::GeometricObject(const quint32 &id) const
throw VExceptionBadId(tr("Can't find object"), id);
}
QSharedPointer<VGObject> gObj = QSharedPointer<VGObject>();
if (d->gObjects.contains(id))
QSharedPointer<VGObject> gObj;
if (d->calculationObjects.contains(id))
{
gObj = d->gObjects.value(id);
gObj = d->calculationObjects.value(id);
}
else if (d->modelingObjects->contains(id))
{
gObj = d->modelingObjects->value(id);
}
else
{
throw VExceptionBadId(tr("Can't find object"), id);
}
try
{
QSharedPointer<T> obj = qSharedPointerDynamicCast<T>(gObj);
SCASSERT(obj.isNull() == false)
return obj;
}
catch (const std::bad_alloc &)
{
throw VExceptionBadId(tr("Can't cast object"), id);
}
}
@ -375,19 +366,39 @@ void VContainer::UpdateObject(const quint32 &id, const QSharedPointer<T> &point)
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
SCASSERT(point.isNull() == false)
point->setId(id);
if (d->gObjects.contains(id))
if (d->calculationObjects.contains(id) && point->getMode() == Draw::Calculation)
{
QSharedPointer<T> obj = qSharedPointerDynamicCast<T>(d->gObjects.value(id));
QSharedPointer<T> obj = qSharedPointerDynamicCast<T>(d->calculationObjects.value(id));
if (obj.isNull())
{
throw VExceptionBadId(tr("Can't cast object"), id);
}
*obj = *point;
}
else if (d->modelingObjects->contains(id) && point->getMode() == Draw::Modeling)
{
QSharedPointer<T> obj = qSharedPointerDynamicCast<T>(d->modelingObjects->value(id));
if (obj.isNull())
{
throw VExceptionBadId(tr("Can't cast object"), id);
}
*obj = *point;
}
else if (point->getMode() == Draw::Calculation)
{
d->calculationObjects.insert(id, point);
}
else if (point->getMode() == Draw::Modeling)
{
d->modelingObjects->insert(id, point);
}
else
{
d->gObjects.insert(id, point);
qWarning("Can't update an object with mode 'Layout'");
return;
}
UpdateId(id);
}
#endif // VCONTAINER_H

View File

@ -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

View File

@ -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"

View File

@ -215,7 +215,7 @@ void DialogTool::FillComboBoxSplines(QComboBox *box) const
SCASSERT(box != nullptr)
box->blockSignals(true);
const auto objs = data->DataGObjects();
const auto objs = data->CalculationGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
@ -239,7 +239,7 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const
SCASSERT(box != nullptr)
box->blockSignals(true);
const auto objs = data->DataGObjects();
const auto objs = data->CalculationGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
@ -261,7 +261,7 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const
void DialogTool::FillComboBoxCurves(QComboBox *box) const
{
SCASSERT(box != nullptr)
const auto objs = data->DataGObjects();
const auto objs = data->CalculationGObjects();
QMap<QString, quint32> list;
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
@ -269,12 +269,12 @@ void DialogTool::FillComboBoxCurves(QComboBox *box) const
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if ((obj->getType() == GOType::Arc
if (obj->getType() == GOType::Arc
|| obj->getType() == GOType::EllipticalArc
|| obj->getType() == GOType::Spline
|| obj->getType() == GOType::SplinePath
|| obj->getType() == GOType::CubicBezier
|| obj->getType() == GOType::CubicBezierPath) && obj->getMode() == Draw::Calculation)
|| obj->getType() == GOType::CubicBezierPath)
{
PrepareList<VAbstractCurve>(list, i.key());
}
@ -683,8 +683,7 @@ void DialogTool::InitNodeAngles(QComboBox *box)
//---------------------------------------------------------------------------------------------------------------------
bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const
{
return (obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath) &&
obj->getMode() == Draw::Calculation;
return obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath;
}
//---------------------------------------------------------------------------------------------------------------------
@ -1010,8 +1009,7 @@ void DialogTool::PrepareList(QMap<QString, quint32> &list, quint32 id) const
//---------------------------------------------------------------------------------------------------------------------
bool DialogTool::IsSpline(const QSharedPointer<VGObject> &obj) const
{
return (obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier) &&
obj->getMode() == Draw::Calculation;
return obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier;
}
//---------------------------------------------------------------------------------------------------------------------
@ -1290,7 +1288,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
SCASSERT(box != nullptr)
box->blockSignals(true);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->CalculationGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
@ -1300,7 +1298,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
if (i.key() != toolId && i.key() != ch1 && i.key() != ch2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
if (obj->getType() == gType)
{
PrepareList<GObject>(list, i.key());
}

View File

@ -0,0 +1,93 @@
/************************************************************************
**
** @file dialogduplicatedetail.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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<VisToolDuplicateDetail *>(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;
}
}
}

View File

@ -0,0 +1,80 @@
/************************************************************************
**
** @file dialogduplicatedetail.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogDuplicateDetail</class>
<widget class="QDialog" name="DialogDuplicateDetail">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>184</width>
<height>66</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog duplicate detail</string>
</property>
<property name="windowIcon">
<iconset resource="../../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string notr="true">The dialog is never shown.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogDuplicateDetail</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogDuplicateDetail</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -59,7 +59,7 @@ VNodeArc::VNodeArc(const VAbstractNodeInitData &initData, QObject *qoParent)
* @brief Create help create tool.
* @param initData init data.
*/
void VNodeArc::Create(VAbstractNodeInitData initData)
void VNodeArc::Create(const VAbstractNodeInitData &initData)
{
if (initData.parse == Document::FullParse)
{

View File

@ -47,7 +47,7 @@ class VNodeArc :public VAbstractNode
{
Q_OBJECT
public:
static void Create(VAbstractNodeInitData initData);
static void Create(const VAbstractNodeInitData &initData);
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;

View File

@ -42,7 +42,7 @@
const QString VNodeEllipticalArc::ToolType = QStringLiteral("modeling");
//---------------------------------------------------------------------------------------------------------------------
void VNodeEllipticalArc::Create(VAbstractNodeInitData initData)
void VNodeEllipticalArc::Create(const VAbstractNodeInitData &initData)
{
if (initData.parse == Document::FullParse)
{

View File

@ -44,7 +44,7 @@ class VNodeEllipticalArc :public VAbstractNode
{
Q_OBJECT
public:
static void Create(VAbstractNodeInitData initData);
static void Create(const VAbstractNodeInitData &initData);
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;

View File

@ -85,7 +85,7 @@ VNodePoint::VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent,
* @brief Create help create tool.
* @param initData init data.
*/
void VNodePoint::Create(VAbstractNodeInitData initData)
void VNodePoint::Create(const VAbstractNodeInitData &initData)
{
if (initData.parse == Document::FullParse)
{

View File

@ -50,7 +50,7 @@ class VNodePoint: public VAbstractNode, public VScenePoint
{
Q_OBJECT
public:
static void Create(VAbstractNodeInitData initData);
static void Create(const VAbstractNodeInitData &initData);
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -60,7 +60,7 @@ VNodeSpline::VNodeSpline(const VAbstractNodeInitData &initData, QObject *qoParen
* @param initData init data.
* @return pointer to node.
*/
VNodeSpline *VNodeSpline::Create(VAbstractNodeInitData initData)
VNodeSpline *VNodeSpline::Create(const VAbstractNodeInitData &initData)
{
VNodeSpline *spl = nullptr;
if (initData.parse == Document::FullParse)

View File

@ -47,7 +47,7 @@ class VNodeSpline:public VAbstractNode
{
Q_OBJECT
public:
static VNodeSpline *Create(VAbstractNodeInitData initData);
static VNodeSpline *Create(const VAbstractNodeInitData &initData);
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;

View File

@ -59,7 +59,7 @@ VNodeSplinePath::VNodeSplinePath(const VAbstractNodeInitData &initData, QObject
* @brief Create help create tool.
* @param initData init data.
*/
void VNodeSplinePath::Create(VAbstractNodeInitData initData)
void VNodeSplinePath::Create(const VAbstractNodeInitData &initData)
{
if (initData.parse == Document::FullParse)
{

View File

@ -47,7 +47,7 @@ class VNodeSplinePath : public VAbstractNode
{
Q_OBJECT
public:
static void Create(VAbstractNodeInitData initData);
static void Create(const VAbstractNodeInitData &initData);
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;

View File

@ -83,35 +83,6 @@ template <class T> class QSharedPointer;
const QString VAbstractTool::AttrInUse = QStringLiteral("inUse");
namespace
{
//---------------------------------------------------------------------------------------------------------------------
quint32 CreateNodeSpline(VContainer *data, quint32 id)
{
if (data->GetGObject(id)->getType() == GOType::Spline)
{
return VAbstractTool::CreateNode<VSpline>(data, id);
}
else
{
return VAbstractTool::CreateNode<VCubicBezier>(data, id);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 CreateNodeSplinePath(VContainer *data, quint32 id)
{
if (data->GetGObject(id)->getType() == GOType::SplinePath)
{
return VAbstractTool::CreateNode<VSplinePath>(data, id);
}
else
{
return VAbstractTool::CreateNode<VCubicBezierPath>(data, id);
}
}
}//static functions
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VAbstractTool container.
@ -379,7 +350,7 @@ QMap<QString, QString> VAbstractTool::ColorsList()
// cppcheck-suppress unusedFunction
QMap<QString, quint32> VAbstractTool::PointsList() const
{
const QHash<quint32, QSharedPointer<VGObject> > *objs = data.DataGObjects();
const QHash<quint32, QSharedPointer<VGObject> > *objs = data.CalculationGObjects();
QMap<QString, quint32> list;
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
@ -387,7 +358,7 @@ QMap<QString, quint32> VAbstractTool::PointsList() const
if (i.key() != m_id)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation)
if (obj->getType() == GOType::Point)
{
const QSharedPointer<VPointF> point = data.GeometricObject<VPointF>(i.key());
list[point->name()] = i.key();
@ -694,3 +665,29 @@ quint32 VAbstractTool::PrepareNode(const VPieceNode &node, VMainGraphicsScene *s
}
return initData.id;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VAbstractTool::CreateNodeSpline(VContainer *data, quint32 id)
{
if (data->GetGObject(id)->getType() == GOType::Spline)
{
return VAbstractTool::CreateNode<VSpline>(data, id);
}
else
{
return VAbstractTool::CreateNode<VCubicBezier>(data, id);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VAbstractTool::CreateNodeSplinePath(VContainer *data, quint32 id)
{
if (data->GetGObject(id)->getType() == GOType::SplinePath)
{
return VAbstractTool::CreateNode<VSplinePath>(data, id);
}
else
{
return VAbstractTool::CreateNode<VCubicBezierPath>(data, id);
}
}

View File

@ -110,8 +110,6 @@ public:
virtual void ShowVisualization(bool show) =0;
virtual void ChangeLabelPosition(quint32 id, const QPointF &pos);
template<typename T>
static quint32 CreateNode(VContainer *data, quint32 id);
public slots:
/**
* @brief FullUpdateFromFile update tool data form file.
@ -162,6 +160,11 @@ protected:
virtual void DeleteToolWithConfirm(bool ask = true);
static int ConfirmDeletion();
template<typename T>
static quint32 CreateNode(VContainer *data, quint32 id);
static quint32 CreateNodeSpline(VContainer *data, quint32 id);
static quint32 CreateNodeSplinePath(VContainer *data, quint32 id);
template <typename T>
void AddVisualization();

View File

@ -28,17 +28,13 @@
#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"
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "nodeDetails/vnodearc.h"
#include "nodeDetails/vnodeellipticalarc.h"
#include "nodeDetails/vnodepoint.h"
#include "nodeDetails/vnodespline.h"
#include "nodeDetails/vnodesplinepath.h"
#include "nodeDetails/vtoolpiecepath.h"
#include "nodeDetails/nodedetails.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vcubicbezier.h"
@ -46,6 +42,7 @@
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
#include "../vgeometry/vsplinepath.h"
#include "../vgeometry/vplacelabelitem.h"
#include "../ifc/xml/vpatternconverter.h"
#include "../undocommands/addpiece.h"
#include "../undocommands/deletepiece.h"
@ -151,6 +148,50 @@ VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initD
return piece;
}
//---------------------------------------------------------------------------------------------------------------------
VToolSeamAllowance *VToolSeamAllowance::Duplicate(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
VAbstractPattern *doc)
{
SCASSERT(not dialog.isNull());
QSharedPointer<DialogDuplicateDetail> dialogTool = dialog.objectCast<DialogDuplicateDetail>();
SCASSERT(not dialogTool.isNull())
VToolSeamAllowanceInitData initData;
initData.scene = scene;
initData.doc = doc;
initData.parse = Document::FullParse;
initData.typeCreation = Source::FromGui;
initData.drawName = doc->PieceDrawName(dialogTool->Duplicate());
VContainer toolData = VAbstractPattern::getTool(dialogTool->Duplicate())->getData();
initData.data = &toolData;
VPiece detail = initData.data->GetPiece(dialogTool->Duplicate());
detail.SetMx(dialogTool->MoveDuplicateX());
detail.SetMy(dialogTool->MoveDuplicateY());
initData.detail = detail;
initData.width = initData.detail.GetFormulaSAWidth();
return Duplicate(initData);
}
//---------------------------------------------------------------------------------------------------------------------
VToolSeamAllowance *VToolSeamAllowance::Duplicate(VToolSeamAllowanceInitData &initData)
{
VPiece dupDetail = initData.detail;
QMap<quint32, quint32> replacements;
dupDetail.GetPath().SetNodes(DuplicateNodes(initData.detail.GetPath(), initData, replacements));
dupDetail.SetCustomSARecords(DuplicateCustomSARecords(initData.detail.GetCustomSARecords(), initData,
replacements));
dupDetail.SetInternalPaths(DuplicateInternalPaths(initData.detail.GetInternalPaths(), initData));
dupDetail.SetPins(DuplicatePins(initData.detail.GetPins(), initData));
dupDetail.SetPlaceLabels(DuplicatePlaceLabels(initData.detail.GetPlaceLabels(), initData));
initData.detail = dupDetail;
return VToolSeamAllowance::Create(initData);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::RemoveWithConfirm(bool ask)
{
@ -1005,11 +1046,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;
}
@ -1741,3 +1777,179 @@ void VToolSeamAllowance::AddPointRecords(VAbstractPattern *doc, QDomElement &dom
domElement.appendChild(pinsElement);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolSeamAllowance::DuplicateNode(const VPieceNode &node, const VToolSeamAllowanceInitData &initData)
{
SCASSERT(initData.scene != nullptr)
SCASSERT(initData.doc != nullptr)
SCASSERT(initData.data != nullptr)
const QSharedPointer<VGObject> gobj = initData.data->GetGObject(node.GetId());
VAbstractNodeInitData initNodeData;
initNodeData.idObject = gobj->getIdObject();
initNodeData.doc = initData.doc;
initNodeData.data = initData.data;
initNodeData.parse = Document::FullParse;
initNodeData.typeCreation = Source::FromGui;
initNodeData.scene = initData.scene;
initNodeData.drawName = initData.drawName;
switch (node.GetTypeTool())
{
case (Tool::NodePoint):
initNodeData.id = VAbstractTool::CreateNode<VPointF>(initData.data, gobj->getIdObject());
VNodePoint::Create(initNodeData);
break;
case (Tool::NodeArc):
initNodeData.id = VAbstractTool::CreateNode<VArc>(initData.data, gobj->getIdObject());
VNodeArc::Create(initNodeData);
break;
case (Tool::NodeElArc):
initNodeData.id = VAbstractTool::CreateNode<VEllipticalArc>(initData.data, gobj->getIdObject());
VNodeEllipticalArc::Create(initNodeData);
break;
case (Tool::NodeSpline):
initNodeData.id = VAbstractTool::CreateNodeSpline(initData.data, gobj->getIdObject());
VNodeSpline::Create(initNodeData);
break;
case (Tool::NodeSplinePath):
initNodeData.id = VAbstractTool::CreateNodeSplinePath(initData.data, gobj->getIdObject());
VNodeSplinePath::Create(initNodeData);
break;
default:
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
return initNodeData.id;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolSeamAllowance::DuplicatePiecePath(quint32 id, const VToolSeamAllowanceInitData &initData)
{
VPiecePath path = initData.data->GetPiecePath(id);
VPiecePath newPath = path;
QMap<quint32, quint32> recordReplacements; // Not used
newPath.SetNodes(DuplicateNodes(path, initData, recordReplacements));
const quint32 idPath = initData.data->AddPiecePath(newPath);
VToolPiecePathInitData initNodeData;
initNodeData.id = idPath;
initNodeData.idObject = NULL_ID; // piece id
initNodeData.scene = initData.scene;
initNodeData.doc = initData.doc;
initNodeData.data = initData.data;
initNodeData.parse = Document::FullParse;
initNodeData.typeCreation = Source::FromTool;
initNodeData.drawName = initData.drawName;
initNodeData.path = newPath;
VToolPiecePath::Create(initNodeData);
return idPath;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<CustomSARecord> VToolSeamAllowance::DuplicateCustomSARecords(const QVector<CustomSARecord> &records,
const VToolSeamAllowanceInitData &initData,
const QMap<quint32, quint32> &replacements)
{
QVector<CustomSARecord> newRecords;
for(int i=0; i < records.size(); ++i)
{
CustomSARecord record = records.at(i);
record.path = DuplicatePiecePath(record.path, initData);
record.startPoint = replacements.value(record.startPoint, NULL_ID);
record.endPoint = replacements.value(record.endPoint, NULL_ID);
newRecords.append(record);
}
return newRecords;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> VToolSeamAllowance::DuplicateInternalPaths(const QVector<quint32> &iPaths,
const VToolSeamAllowanceInitData &initData)
{
QVector<quint32> newPaths;
for(int i=0; i < iPaths.size(); ++i)
{
newPaths.append(DuplicatePiecePath(iPaths.at(i), initData));
}
return newPaths;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> VToolSeamAllowance::DuplicatePins(const QVector<quint32> &pins,
const VToolSeamAllowanceInitData &initData)
{
QVector<quint32> newPins;
for(int i=0; i < pins.size(); ++i)
{
QSharedPointer<VPointF> pin = initData.data->GeometricObject<VPointF>(pins.at(i));
VToolPinInitData initNodeData;
initNodeData.id = initData.data->AddGObject(new VPointF(*pin));
initNodeData.pointId = pin->getIdObject();
initNodeData.idObject = NULL_ID; // piece id
initNodeData.doc = initData.doc;
initNodeData.data = initData.data;
initNodeData.parse = Document::FullParse;
initNodeData.typeCreation = Source::FromTool;
initNodeData.drawName = initData.drawName;
VToolPin::Create(initNodeData);
newPins.append(initNodeData.id);
}
return newPins;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> VToolSeamAllowance::DuplicatePlaceLabels(const QVector<quint32> &placeLabels,
const VToolSeamAllowanceInitData &initData)
{
QVector<quint32> newPlaceLabels;
for(int i=0; i < placeLabels.size(); ++i)
{
QSharedPointer<VPlaceLabelItem> label = initData.data->GeometricObject<VPlaceLabelItem>(placeLabels.at(i));
VToolPlaceLabelInitData initNodeData;
initNodeData.idObject = NULL_ID; // piece id
initNodeData.doc = initData.doc;
initNodeData.data = initData.data;
initNodeData.parse = Document::FullParse;
initNodeData.typeCreation = Source::FromTool;
initNodeData.drawName = initData.drawName;
initNodeData.width = label->GetWidthFormula();
initNodeData.height = label->GetHeightFormula();
initNodeData.angle = label->GetAngleFormula();
initNodeData.type = label->GetLabelType();
initNodeData.centerPoint = label->GetCenterPoint();
initNodeData.id = initNodeData.data->AddGObject(new VPlaceLabelItem(*label));
VToolPlaceLabel::Create(initNodeData);
newPlaceLabels.append(initNodeData.id);
}
return newPlaceLabels;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VPieceNode> VToolSeamAllowance::DuplicateNodes(const VPiecePath &path,
const VToolSeamAllowanceInitData &initData,
QMap<quint32, quint32> &replacements)
{
QVector<VPieceNode> nodes;
for (int i = 0; i< path.CountNodes(); ++i)
{
VPieceNode nodeD = path.at(i);
const quint32 oldId = nodeD.GetId();
const quint32 id = DuplicateNode(nodeD, initData);
if (id > NULL_ID)
{
nodeD.SetId(id);
nodes.append(nodeD);
replacements.insert(oldId, id);
}
}
return nodes;
}

View File

@ -64,6 +64,9 @@ public:
static VToolSeamAllowance* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data);
static VToolSeamAllowance* Create(VToolSeamAllowanceInitData &initData);
static VToolSeamAllowance* Duplicate(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
VAbstractPattern *doc);
static VToolSeamAllowance* Duplicate(VToolSeamAllowanceInitData &initData);
static const quint8 pieceVersion;
@ -197,6 +200,22 @@ private:
static void AddPointRecords(VAbstractPattern *doc, QDomElement &domElement, const QVector<quint32> &records,
const QString &tag);
static QVector<VPieceNode> DuplicateNodes(const VPiecePath &path, const VToolSeamAllowanceInitData &initData,
QMap<quint32, quint32> &replacements);
static quint32 DuplicateNode(const VPieceNode &node, const VToolSeamAllowanceInitData &initData);
static quint32 DuplicatePiecePath(quint32 id, const VToolSeamAllowanceInitData &initData);
static QVector<CustomSARecord> DuplicateCustomSARecords(const QVector<CustomSARecord> &records,
const VToolSeamAllowanceInitData &initData,
const QMap<quint32, quint32> &replacements);
static QVector<quint32> DuplicateInternalPaths(const QVector<quint32> &iPaths,
const VToolSeamAllowanceInitData &initData);
static QVector<quint32> DuplicatePins(const QVector<quint32> &pins, const VToolSeamAllowanceInitData &initData);
static QVector<quint32> DuplicatePlaceLabels(const QVector<quint32> &placeLabels,
const VToolSeamAllowanceInitData &initData);
};
#endif // VTOOLSEAMALLOWANCE_H

View File

@ -1538,19 +1538,38 @@ void CreateUnitedDetail(const VToolUnionDetailsInitData &initData, qreal dx, qre
VToolSeamAllowance::Create(pieceInitData);
auto RemoveDetail = [initData](quint32 id)
auto DuplicateDetail = [initData](quint32 id)
{
VToolSeamAllowanceInitData initPieceData;
initPieceData.scene = initData.scene;
initPieceData.doc = initData.doc;
initPieceData.parse = Document::FullParse;
initPieceData.typeCreation = Source::FromGui;
initPieceData.drawName = initData.doc->PieceDrawName(id);
VContainer toolData = VAbstractPattern::getTool(id)->getData();
initPieceData.data = &toolData;
initPieceData.detail = initData.data->GetPiece(id);
initPieceData.width = initPieceData.detail.GetFormulaSAWidth();
VToolSeamAllowance::Duplicate(initPieceData);
};
if (initData.retainPieces)
{
DuplicateDetail(initData.d1id);
DuplicateDetail(initData.d2id);
}
auto RemoveDetail = [](quint32 id)
{
VToolSeamAllowance *toolDet = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(id));
SCASSERT(toolDet != nullptr);
bool ask = false;
toolDet->RemoveWithConfirm(ask);
toolDet->RemoveWithConfirm(false);
};
if (not initData.retainPieces)
{
RemoveDetail(initData.d1id);
RemoveDetail(initData.d2id);
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,69 @@
/************************************************************************
**
** @file vistoolduplicatedetail.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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);
}
}

View File

@ -0,0 +1,68 @@
/************************************************************************
**
** @file vistoolduplicatedetail.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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<int>(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

View File

@ -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