Resolved issue #573. New tool: 'Move Point'.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-10-04 17:34:37 +03:00
parent 0127f745c6
commit abce5439a5
48 changed files with 3153 additions and 93 deletions

View File

@ -40,6 +40,7 @@
- Added "All/None" menu in detail list area for easier handling of many parts.
- [#560] Flipped pattern pieces in Layout.
- [#138] New tool: 'Mirror Point' or 'Symmetric Point'.
- [#573] New tool: 'Move Point'.
# Version 0.4.5
- [#435] Valentina doesn't change the cursor.

View File

@ -75,7 +75,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) == 47, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was used in switch.");
switch (item->type())
{
@ -191,6 +191,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolFlippingByAxis::Type:
ShowOptionsToolFlippingByAxis(item);
break;
case VToolMove::Type:
ShowOptionsToolMove(item);
break;
default:
break;
}
@ -205,7 +208,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) == 47, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was used in switch.");
switch (currentItem->type())
{
@ -311,6 +314,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolFlippingByAxis::Type:
UpdateOptionsToolFlippingByAxis();
break;
case VToolMove::Type:
UpdateOptionsToolMove();
break;
default:
break;
}
@ -346,7 +352,7 @@ void VToolOptionsPropertyBrowser::userChangedData(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) == 47, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was used in switch.");
switch (currentItem->type())
{
@ -446,6 +452,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolFlippingByAxis::Type:
ChangeDataToolFlippingByAxis(prop);
break;
case VToolMove::Type:
ChangeDataToolMove(prop);
break;
default:
break;
}
@ -1643,6 +1652,33 @@ void VToolOptionsPropertyBrowser::ChangeDataToolRotation(VProperty *property)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolMove(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
VToolMove *i = qgraphicsitem_cast<VToolMove *>(currentItem);
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 38: // AttrSuffix
SetOperationSuffix<VToolMove>(value.toString());
break;
case 5: // AttrAngle
i->SetFormulaAngle(value.value<VFormula>());
break;
case 4: // AttrLength
i->SetFormulaLength(value.value<VFormula>());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByLine(VProperty *property)
{
@ -2077,6 +2113,18 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolRotation(QGraphicsItem *item)
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolMove(QGraphicsItem *item)
{
VToolMove *i = qgraphicsitem_cast<VToolMove *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Tool move"));
AddPropertyOperationSuffix(i, tr("Suffix"));
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), AttrLength);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolFlippingByLine(QGraphicsItem *item)
{
@ -2558,6 +2606,21 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolRotation()
idToProperty[AttrAngle]->setValue(valueAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolMove()
{
VToolMove *i = qgraphicsitem_cast<VToolMove *>(currentItem);
idToProperty[AttrSuffix]->setValue(i->Suffix());
QVariant valueAngle;
valueAngle.setValue(i->GetFormulaAngle());
idToProperty[AttrAngle]->setValue(valueAngle);
QVariant valueLength;
valueLength.setValue(i->GetFormulaLength());
idToProperty[AttrLength]->setValue(valueLength);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByLine()
{

View File

@ -158,6 +158,7 @@ private:
void ChangeDataToolLineIntersectAxis(VPE::VProperty *property);
void ChangeDataToolCurveIntersectAxis(VPE::VProperty *property);
void ChangeDataToolRotation(VPE::VProperty *property);
void ChangeDataToolMove(VPE::VProperty *property);
void ChangeDataToolFlippingByLine(VPE::VProperty *property);
void ChangeDataToolFlippingByAxis(VPE::VProperty *property);
@ -191,6 +192,7 @@ private:
void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item);
void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item);
void ShowOptionsToolRotation(QGraphicsItem *item);
void ShowOptionsToolMove(QGraphicsItem *item);
void ShowOptionsToolFlippingByLine(QGraphicsItem *item);
void ShowOptionsToolFlippingByAxis(QGraphicsItem *item);
@ -224,6 +226,7 @@ private:
void UpdateOptionsToolLineIntersectAxis();
void UpdateOptionsToolCurveIntersectAxis();
void UpdateOptionsToolRotation();
void UpdateOptionsToolMove();
void UpdateOptionsToolFlippingByLine();
void UpdateOptionsToolFlippingByAxis();
};

View File

@ -207,7 +207,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) == 47, "Not all tools was used in history.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was used in history.");
const QDomElement domElem = doc->elementById(tool.getId());
if (domElem.isElement() == false)
@ -389,6 +389,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::Rotation:
case Tool::FlippingByLine:
case Tool::FlippingByAxis:
case Tool::Move:
return QString();
}
}

View File

@ -1058,7 +1058,18 @@ void MainWindow::ToolFlippingByAxis(bool checked)
":/cursor/flipping_axis_cursor.png",
tr("Select one or more objects, <b>Enter</b> - confirm selection"),
&MainWindow::ClosedDialogWithApply<VToolFlippingByAxis>,
&MainWindow::ApplyDialog<VToolFlippingByAxis>);
&MainWindow::ApplyDialog<VToolFlippingByAxis>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolMove(bool checked)
{
ToolSelectOperationObjects();
SetToolButtonWithApply<DialogMove>(checked, Tool::Move,
":/cursor/move_cursor.png",
tr("Select one or more objects, <b>Enter</b> - confirm selection"),
&MainWindow::ClosedDialogWithApply<VToolMove>,
&MainWindow::ApplyDialog<VToolMove>);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1732,6 +1743,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonRotation, &QToolButton::clicked, this, &MainWindow::ToolRotation);
connect(ui->toolButtonFlippingByLine, &QToolButton::clicked, this, &MainWindow::ToolFlippingByLine);
connect(ui->toolButtonFlippingByAxis, &QToolButton::clicked, this, &MainWindow::ToolFlippingByAxis);
connect(ui->toolButtonMove, &QToolButton::clicked, this, &MainWindow::ToolMove);
connect(ui->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint);
connect(ui->toolButtonLayoutExportAs, &QToolButton::clicked, this, &MainWindow::ExportLayoutAs);
}
@ -1761,7 +1773,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) == 47, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was handled.");
qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool;
@ -1907,6 +1919,9 @@ void MainWindow::CancelTool()
case Tool::FlippingByAxis:
ui->toolButtonFlippingByAxis->setChecked(false);
break;
case Tool::Move:
ui->toolButtonMove->setChecked(false);
break;
}
// Crash: using CRTL+Z while using line tool.
@ -2956,7 +2971,7 @@ void MainWindow::SetEnableTool(bool enable)
}
// This check helps to find missed tools
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47, "Not all tools were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools were handled.");
//Drawing Tools
ui->toolButtonEndLine->setEnabled(drawTools);
@ -2993,6 +3008,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonRotation->setEnabled(drawTools);
ui->toolButtonFlippingByLine->setEnabled(drawTools);
ui->toolButtonFlippingByAxis->setEnabled(drawTools);
ui->toolButtonMove->setEnabled(drawTools);
ui->toolButtonMidpoint->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools);
@ -3275,7 +3291,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) == 47, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was handled.");
if (currentTool == lastUsedTool)
{
@ -3449,6 +3465,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonFlippingByAxis->setChecked(true);
ToolFlippingByAxis(true);
break;
case Tool::Move:
ui->toolButtonMove->setChecked(true);
ToolMove(true);
break;
}
}

View File

@ -141,6 +141,7 @@ private slots:
void ToolRotation(bool checked);
void ToolFlippingByLine(bool checked);
void ToolFlippingByAxis(bool checked);
void ToolMove(bool checked);
void ToolCutArc(bool checked);
void ToolLineIntersectAxis(bool checked);
void ToolCurveIntersectAxis(bool checked);

View File

@ -14,7 +14,7 @@
<string>Valentina</string>
</property>
<property name="windowIcon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<property name="locale">
@ -69,7 +69,7 @@
<string>Tools for creating points.</string>
</property>
<attribute name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/toolsectionpoint.png</normaloff>:/icon/16x16/toolsectionpoint.png</iconset>
</attribute>
<attribute name="label">
@ -94,7 +94,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/along_line.png</normaloff>:/toolicon/32x32/along_line.png</iconset>
</property>
<property name="iconSize">
@ -120,7 +120,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/normal.png</normaloff>:/toolicon/32x32/normal.png</iconset>
</property>
<property name="iconSize">
@ -146,7 +146,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/bisector.png</normaloff>:/toolicon/32x32/bisector.png</iconset>
</property>
<property name="iconSize">
@ -172,7 +172,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/shoulder.png</normaloff>:/toolicon/32x32/shoulder.png</iconset>
</property>
<property name="iconSize">
@ -198,7 +198,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/point_of_contact.png</normaloff>:/toolicon/32x32/point_of_contact.png</iconset>
</property>
<property name="iconSize">
@ -224,7 +224,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/triangle.png</normaloff>:/toolicon/32x32/triangle.png</iconset>
</property>
<property name="iconSize">
@ -250,7 +250,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/point_of_intersection.png</normaloff>:/toolicon/32x32/point_of_intersection.png</iconset>
</property>
<property name="iconSize">
@ -276,7 +276,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/height.png</normaloff>:/toolicon/32x32/height.png</iconset>
</property>
<property name="iconSize">
@ -302,7 +302,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/line_intersect_axis.png</normaloff>:/toolicon/32x32/line_intersect_axis.png</iconset>
</property>
<property name="iconSize">
@ -328,7 +328,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/true_darts.png</normaloff>:/toolicon/32x32/true_darts.png</iconset>
</property>
<property name="iconSize">
@ -354,7 +354,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -380,7 +380,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/midpoint.png</normaloff>:/toolicon/32x32/midpoint.png</iconset>
</property>
<property name="iconSize">
@ -406,7 +406,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/segment.png</normaloff>:/toolicon/32x32/segment.png</iconset>
</property>
<property name="iconSize">
@ -427,7 +427,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>117</width>
<height>110</height>
</rect>
</property>
@ -441,7 +441,7 @@
<string>Tools for creating lines.</string>
</property>
<attribute name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/toolsectionline.png</normaloff>:/icon/16x16/toolsectionline.png</iconset>
</attribute>
<attribute name="label">
@ -463,7 +463,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -489,7 +489,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/line.png</normaloff>:/toolicon/32x32/line.png</iconset>
</property>
<property name="iconSize">
@ -515,7 +515,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/intersect.png</normaloff>:/toolicon/32x32/intersect.png</iconset>
</property>
<property name="iconSize">
@ -536,7 +536,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>117</width>
<height>248</height>
</rect>
</property>
@ -550,7 +550,7 @@
<string>Tools for creating curves.</string>
</property>
<attribute name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/toolsectioncurve.png</normaloff>:/icon/16x16/toolsectioncurve.png</iconset>
</attribute>
<attribute name="label">
@ -572,7 +572,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/spline_cut_point.png</normaloff>:/toolicon/32x32/spline_cut_point.png</iconset>
</property>
<property name="iconSize">
@ -598,7 +598,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/cubic_bezier.png</normaloff>:/toolicon/32x32/cubic_bezier.png</iconset>
</property>
<property name="iconSize">
@ -624,7 +624,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/splinePath.png</normaloff>:/toolicon/32x32/splinePath.png</iconset>
</property>
<property name="iconSize">
@ -650,7 +650,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/splinePath_cut_point.png</normaloff>:/toolicon/32x32/splinePath_cut_point.png</iconset>
</property>
<property name="iconSize">
@ -673,7 +673,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/cubic_bezier_path.png</normaloff>:/toolicon/32x32/cubic_bezier_path.png</iconset>
</property>
<property name="iconSize">
@ -699,7 +699,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/intersection_curves.png</normaloff>:/toolicon/32x32/intersection_curves.png</iconset>
</property>
<property name="iconSize">
@ -725,7 +725,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/curve_intersect_axis.png</normaloff>:/toolicon/32x32/curve_intersect_axis.png</iconset>
</property>
<property name="iconSize">
@ -751,7 +751,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -777,7 +777,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/spline.png</normaloff>:/toolicon/32x32/spline.png</iconset>
</property>
<property name="iconSize">
@ -798,7 +798,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>117</width>
<height>248</height>
</rect>
</property>
@ -812,7 +812,7 @@
<string>Tools for creating arcs.</string>
</property>
<attribute name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/toolsectionarc.png</normaloff>:/icon/16x16/toolsectionarc.png</iconset>
</attribute>
<attribute name="label">
@ -834,7 +834,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/arc.png</normaloff>:/toolicon/32x32/arc.png</iconset>
</property>
<property name="iconSize">
@ -860,7 +860,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/arc_cut.png</normaloff>:/toolicon/32x32/arc_cut.png</iconset>
</property>
<property name="iconSize">
@ -886,7 +886,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/arc_intersect_axis.png</normaloff>:/toolicon/32x32/arc_intersect_axis.png</iconset>
</property>
<property name="iconSize">
@ -912,7 +912,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/point_of_intersection_arcs.png</normaloff>:/toolicon/32x32/point_of_intersection_arcs.png</iconset>
</property>
<property name="iconSize">
@ -938,7 +938,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/point_of_intersection_circles.png</normaloff>:/toolicon/32x32/point_of_intersection_circles.png</iconset>
</property>
<property name="iconSize">
@ -964,7 +964,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/point_from_circle_and_tangent.png</normaloff>:/toolicon/32x32/point_from_circle_and_tangent.png</iconset>
</property>
<property name="iconSize">
@ -990,7 +990,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/point_from_arc_and_tangent.png</normaloff>:/toolicon/32x32/point_from_arc_and_tangent.png</iconset>
</property>
<property name="iconSize">
@ -1016,7 +1016,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/arc_with_length.png</normaloff>:/toolicon/32x32/arc_with_length.png</iconset>
</property>
<property name="iconSize">
@ -1042,7 +1042,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -1068,7 +1068,7 @@
</rect>
</property>
<attribute name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/operations.png</normaloff>:/icon/16x16/operations.png</iconset>
</attribute>
<attribute name="label">
@ -1090,7 +1090,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -1116,7 +1116,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/group_plus.png</normaloff>:/toolicon/32x32/group_plus.png</iconset>
</property>
<property name="iconSize">
@ -1142,7 +1142,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/rotation.png</normaloff>:/toolicon/32x32/rotation.png</iconset>
</property>
<property name="iconSize">
@ -1168,7 +1168,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/flipping_line.png</normaloff>:/toolicon/32x32/flipping_line.png</iconset>
</property>
<property name="iconSize">
@ -1194,7 +1194,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/flipping_axis.png</normaloff>:/toolicon/32x32/flipping_axis.png</iconset>
</property>
<property name="iconSize">
@ -1208,6 +1208,32 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QToolButton" name="toolButtonMove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Move objects</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/move.png</normaloff>:/toolicon/32x32/move.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="page_5">
@ -1215,7 +1241,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<width>117</width>
<height>104</height>
</rect>
</property>
@ -1229,7 +1255,7 @@
<string>Tools for creating details.</string>
</property>
<attribute name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/toolsectiondetail.png</normaloff>:/icon/16x16/toolsectiondetail.png</iconset>
</attribute>
<attribute name="label">
@ -1251,7 +1277,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -1277,7 +1303,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/new_detail.png</normaloff>:/toolicon/32x32/new_detail.png</iconset>
</property>
<property name="iconSize">
@ -1303,7 +1329,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/union.png</normaloff>:/toolicon/32x32/union.png</iconset>
</property>
<property name="iconSize">
@ -1329,7 +1355,7 @@
</rect>
</property>
<attribute name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/toolsectionlayout.png</normaloff>:/icon/16x16/toolsectionlayout.png</iconset>
</attribute>
<attribute name="label">
@ -1380,7 +1406,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/export_to_picture_document.png</normaloff>:/icon/32x32/export_to_picture_document.png</iconset>
</property>
<property name="iconSize">
@ -1826,7 +1852,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/draw.png</normaloff>:/icon/32x32/draw.png</iconset>
</property>
<property name="text">
@ -1850,7 +1876,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/kontur.png</normaloff>:/icon/32x32/kontur.png</iconset>
</property>
<property name="text">
@ -1874,7 +1900,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="text">
@ -1892,7 +1918,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/new_draw.png</normaloff>:/icon/32x32/new_draw.png</iconset>
</property>
<property name="text">
@ -1913,7 +1939,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/option_draw.png</normaloff>:/icon/32x32/option_draw.png</iconset>
</property>
<property name="text">
@ -1937,7 +1963,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/table.png</normaloff>:/icon/32x32/table.png</iconset>
</property>
<property name="text">
@ -1961,7 +1987,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/history.png</normaloff>:/icon/32x32/history.png</iconset>
</property>
<property name="text">
@ -1982,7 +2008,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/layout.png</normaloff>:/icon/32x32/layout.png</iconset>
</property>
<property name="text">
@ -2247,7 +2273,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/pdf.png</normaloff>:/icon/32x32/pdf.png</iconset>
</property>
<property name="text">
@ -2337,7 +2363,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/export_to_picture_document.png</normaloff>:/icon/32x32/export_to_picture_document.png</iconset>
</property>
<property name="text">
@ -2414,7 +2440,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/syncM.png</normaloff>:/icon/32x32/syncM.png</iconset>
</property>
<property name="text">
@ -2453,6 +2479,9 @@
<header>vmaingraphicsview.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
<include location="share/resources/toolicon.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -74,5 +74,7 @@
<file>cursor/flipping_line_cursor.png</file>
<file>cursor/flipping_axis_cursor.png</file>
<file>cursor/flipping_axis_cursor@2x.png</file>
<file>cursor/move_cursor.png</file>
<file>cursor/move_cursor@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -72,5 +72,7 @@
<file>toolicon/32x32/flipping_line.png</file>
<file>toolicon/32x32/flipping_axis.png</file>
<file>toolicon/32x32/flipping_axis@2x.png</file>
<file>toolicon/32x32/move.png</file>
<file>toolicon/32x32/move@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
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:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
id="svg2985"
inkscape:version="0.91 r"
sodipodi:docname="moving.svg"
inkscape:export-filename="/home/dismine/CAD/Valentina_0.5.x/valentina/src/app/valentina/share/resources/toolicon/32x32/moving@2x.png"
inkscape:export-xdpi="183.09656"
inkscape:export-ydpi="183.09656">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1855"
inkscape:window-height="1056"
id="namedview12"
showgrid="false"
inkscape:zoom="11.189427"
inkscape:cx="-20.65711"
inkscape:cy="17.916139"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg2985" />
<defs
id="defs2987">
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="marker4515"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path4517"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="TriangleInL"
orient="auto"
refY="0.0"
refX="0.0"
id="TriangleInL"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path4274"
d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(-0.8)" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="marker4443"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path4445"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lstart"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path4141"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="TriangleOutL"
orient="auto"
refY="0.0"
refX="0.0"
id="TriangleOutL"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path4283"
d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8)" />
</marker>
</defs>
<metadata
id="metadata2990">
<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>
<path
inkscape:connector-curvature="0"
style="fill:#f70000;fill-opacity:1;stroke:#f70000;stroke-width:2.40142107;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path2985-2-9-3-5"
d="m 30.568187,4.1706391 a 2.6159858,2.697521 0 0 1 -5.231971,0 2.6159858,2.697521 0 1 1 5.231971,0 z" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:2.56853676;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path2985-2-9-3"
d="m 7.2847855,27.609193 a 2.8452232,2.8373884 0 0 1 -5.6904461,0 2.8452232,2.8373884 0 1 1 5.6904461,0 z" />
<path
style="fill:#000000"
d="m 11.486434,17.126775 c 2.481404,-2.537702 4.476369,-4.643916 4.433253,-4.680479 -0.04311,-0.03657 -1.317602,-0.561306 -2.832196,-1.166099 -1.514591,-0.604792 -2.814212,-1.144975 -2.88805,-1.200408 -0.160041,-0.1201531 -0.19441,-0.5437624 -0.0514,-0.6335841 0.05555,-0.034889 3.284489,-0.5101456 7.175416,-1.0561174 4.929476,-0.6916999 7.132384,-0.9638939 7.265617,-0.8977485 0.105166,0.052213 0.193428,0.1730439 0.196138,0.2685214 0.01187,0.4157045 -1.315064,13.7895066 -1.378777,13.8970036 -0.0937,0.158105 -0.525661,0.158503 -0.662446,6.27e-4 -0.05963,-0.06883 -0.656883,-1.257143 -1.327228,-2.640692 -0.670344,-1.383553 -1.268068,-2.600588 -1.328272,-2.704524 -0.09543,-0.164748 -0.696798,0.411264 -4.69077,4.492961 -2.519722,2.575067 -4.623899,4.682504 -4.675953,4.683197 -0.05205,6.8e-4 -0.9128181,-0.749445 -1.912808,-1.666958 C 7.6399461,22.749856 6.987936,22.08043 6.9827926,21.947499 6.9774627,21.809845 8.4825598,20.198776 11.486437,17.126747 Z"
id="path3347"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -2604,6 +2604,51 @@ void VPattern::ParseToolFlippingByAxis(VMainGraphicsScene *scene, QDomElement &d
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
{
SCASSERT(scene != nullptr);
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
try
{
quint32 id = NULL_ID;
ToolsCommonAttributes(domElement, id);
const QString angle = GetParametrString(domElement, AttrAngle, "0");
QString a = angle;//need for saving fixed formula;
const QString length = GetParametrString(domElement, AttrLength, "0");
QString len = length;//need for saving fixed formula;
const QString suffix = GetParametrString(domElement, AttrSuffix, "");
QVector<quint32> source;
QVector<DestinationItem> destination;
VAbstractOperation::ExtractData(this, domElement, source, destination);
VToolMove::Create(id, a, len, suffix, source, destination, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (a != angle || len != length)
{
SetAttribute(domElement, AttrAngle, a);
SetAttribute(domElement, AttrLength, len);
modified = true;
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
catch (qmu::QmuParserError &e)
{
VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement);
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
throw excep;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPattern::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
{
@ -2856,7 +2901,8 @@ void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &dom
const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/
<< VToolFlippingByLine::ToolType /*1*/
<< VToolFlippingByAxis::ToolType; /*2*/
<< VToolFlippingByAxis::ToolType /*2*/
<< VToolMove::ToolType; /*3*/
switch (opers.indexOf(type))
{
@ -2869,6 +2915,9 @@ void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &dom
case 2: //VToolFlippingByAxis::ToolType
ParseToolFlippingByAxis(scene, domElement, parse);
break;
case 3: //VToolMove::ToolType
ParseToolMove(scene, domElement, parse);
break;
default:
VException e(tr("Unknown operation type '%1'.").arg(type));
throw e;
@ -3375,7 +3424,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) == 47, "Not all tools was used.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48, "Not all tools was used.");
QRectF rec;
@ -3493,6 +3542,9 @@ QRectF VPattern::ActiveDrawBoundingRect() const
case Tool::FlippingByAxis:
rec = ToolBoundingRect<VToolFlippingByAxis>(rec, tool.getId());
break;
case Tool::Move:
rec = ToolBoundingRect<VToolMove>(rec, tool.getId());
break;
//These tools are not accesseble in Draw mode, but still 'history' contains them.
case Tool::Detail:
case Tool::UnionDetails:

View File

@ -196,6 +196,7 @@ private:
void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolFlippingByAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;

View File

@ -19,6 +19,7 @@
<file>schema/pattern/v0.3.3.xsd</file>
<file>schema/pattern/v0.3.4.xsd</file>
<file>schema/pattern/v0.3.5.xsd</file>
<file>schema/pattern/v0.3.6.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

View File

@ -0,0 +1,582 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document-->
<xs:element name="pattern">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="version" type="formatVersion"></xs:element>
<xs:element name="unit" type="units"></xs:element>
<xs:element name="image" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="extension" type="imageExtension"></xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="heights">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="h92" type="xs:boolean"></xs:attribute>
<xs:attribute name="h98" type="xs:boolean"></xs:attribute>
<xs:attribute name="h104" type="xs:boolean"></xs:attribute>
<xs:attribute name="h110" type="xs:boolean"></xs:attribute>
<xs:attribute name="h116" type="xs:boolean"></xs:attribute>
<xs:attribute name="h122" type="xs:boolean"></xs:attribute>
<xs:attribute name="h128" type="xs:boolean"></xs:attribute>
<xs:attribute name="h134" type="xs:boolean"></xs:attribute>
<xs:attribute name="h140" type="xs:boolean"></xs:attribute>
<xs:attribute name="h146" type="xs:boolean"></xs:attribute>
<xs:attribute name="h152" type="xs:boolean"></xs:attribute>
<xs:attribute name="h158" type="xs:boolean"></xs:attribute>
<xs:attribute name="h164" type="xs:boolean"></xs:attribute>
<xs:attribute name="h170" type="xs:boolean"></xs:attribute>
<xs:attribute name="h176" type="xs:boolean"></xs:attribute>
<xs:attribute name="h182" type="xs:boolean"></xs:attribute>
<xs:attribute name="h188" type="xs:boolean"></xs:attribute>
<xs:attribute name="h194" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="s22" type="xs:boolean"></xs:attribute>
<xs:attribute name="s24" type="xs:boolean"></xs:attribute>
<xs:attribute name="s26" type="xs:boolean"></xs:attribute>
<xs:attribute name="s28" type="xs:boolean"></xs:attribute>
<xs:attribute name="s30" type="xs:boolean"></xs:attribute>
<xs:attribute name="s32" type="xs:boolean"></xs:attribute>
<xs:attribute name="s34" type="xs:boolean"></xs:attribute>
<xs:attribute name="s36" type="xs:boolean"></xs:attribute>
<xs:attribute name="s38" type="xs:boolean"></xs:attribute>
<xs:attribute name="s40" type="xs:boolean"></xs:attribute>
<xs:attribute name="s42" type="xs:boolean"></xs:attribute>
<xs:attribute name="s44" type="xs:boolean"></xs:attribute>
<xs:attribute name="s46" type="xs:boolean"></xs:attribute>
<xs:attribute name="s48" type="xs:boolean"></xs:attribute>
<xs:attribute name="s50" type="xs:boolean"></xs:attribute>
<xs:attribute name="s52" type="xs:boolean"></xs:attribute>
<xs:attribute name="s54" type="xs:boolean"></xs:attribute>
<xs:attribute name="s56" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"></xs:attribute>
<xs:attribute name="defHeight" type="baseHeight"></xs:attribute>
<xs:attribute name="defSize" type="baseSize"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="patternName" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="showDate" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="showMeasurements" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="description" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="name" type="shortName" use="required"></xs:attribute>
<xs:attribute name="formula" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="incrementName">
<xs:selector xpath="increment"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="x" type="xs:double"></xs:attribute>
<xs:attribute name="y" type="xs:double"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="shortName"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="basePoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="pShoulder" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="splinePath" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="spline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="axisP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="axisP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="arc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="crossPoint" type="crossType"></xs:attribute>
<xs:attribute name="vCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="hCrossPoint" type="crossType"></xs:attribute>
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="name1" type="shortName"></xs:attribute>
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
<xs:attribute name="my1" type="xs:double"></xs:attribute>
<xs:attribute name="name2" type="shortName"></xs:attribute>
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
<xs:attribute name="my2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="operation" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="source" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="destination" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="suffix" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="axisType" type="axisType"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="kAsm2" type="xs:string"></xs:attribute>
<xs:attribute name="pSpline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="length1" type="xs:string"></xs:attribute>
<xs:attribute name="length2" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="kCurve" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:double"></xs:attribute>
<xs:attribute name="kAsm2" type="xs:double"></xs:attribute>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="length1" type="xs:string"></xs:attribute>
<xs:attribute name="length2" type="xs:string"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point4" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="duplicate" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="det" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="children" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="data" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="mcp" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="cutNumber" type="xs:unsignedInt"/>
<xs:attribute name="userDef" type="xs:string"/>
<xs:attribute name="material" type="materialType"/>
<xs:attribute name="placement" type="placementType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="letter" type="xs:string"></xs:attribute>
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
<xs:attribute name="fontSize" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="height" type="xs:double"></xs:attribute>
<xs:attribute name="rotation" type="xs:double"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
<xs:attribute name="fontSize" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="height" type="xs:double"></xs:attribute>
<xs:attribute name="rotation" type="xs:double"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="supplement" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="closed" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="forbidFlipping" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inLayout" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="groups" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="object" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="tool" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementsTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="standard"/>
<xs:enumeration value="individual"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="imageExtension">
<xs:restriction base="xs:string">
<xs:enumeration value="PNG"/>
<xs:enumeration value="JPG"/>
<xs:enumeration value="BMP"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="colors">
<xs:restriction base="xs:string">
<xs:enumeration value="black"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
<xs:enumeration value="darkRed"/>
<xs:enumeration value="darkGreen"/>
<xs:enumeration value="darkBlue"/>
<xs:enumeration value="yellow"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseHeight">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="92"/>
<xs:enumeration value="98"/>
<xs:enumeration value="104"/>
<xs:enumeration value="110"/>
<xs:enumeration value="116"/>
<xs:enumeration value="122"/>
<xs:enumeration value="128"/>
<xs:enumeration value="134"/>
<xs:enumeration value="140"/>
<xs:enumeration value="146"/>
<xs:enumeration value="152"/>
<xs:enumeration value="158"/>
<xs:enumeration value="164"/>
<xs:enumeration value="170"/>
<xs:enumeration value="176"/>
<xs:enumeration value="182"/>
<xs:enumeration value="188"/>
<xs:enumeration value="194"/>
<xs:enumeration value="920"/>
<xs:enumeration value="980"/>
<xs:enumeration value="1040"/>
<xs:enumeration value="1100"/>
<xs:enumeration value="1160"/>
<xs:enumeration value="1220"/>
<xs:enumeration value="1280"/>
<xs:enumeration value="1340"/>
<xs:enumeration value="1400"/>
<xs:enumeration value="1460"/>
<xs:enumeration value="1520"/>
<xs:enumeration value="1580"/>
<xs:enumeration value="1640"/>
<xs:enumeration value="1700"/>
<xs:enumeration value="1760"/>
<xs:enumeration value="1820"/>
<xs:enumeration value="1880"/>
<xs:enumeration value="1940"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseSize">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="22"/>
<xs:enumeration value="24"/>
<xs:enumeration value="26"/>
<xs:enumeration value="28"/>
<xs:enumeration value="30"/>
<xs:enumeration value="32"/>
<xs:enumeration value="34"/>
<xs:enumeration value="36"/>
<xs:enumeration value="38"/>
<xs:enumeration value="40"/>
<xs:enumeration value="42"/>
<xs:enumeration value="44"/>
<xs:enumeration value="46"/>
<xs:enumeration value="48"/>
<xs:enumeration value="50"/>
<xs:enumeration value="52"/>
<xs:enumeration value="54"/>
<xs:enumeration value="56"/>
<xs:enumeration value="220"/>
<xs:enumeration value="240"/>
<xs:enumeration value="260"/>
<xs:enumeration value="280"/>
<xs:enumeration value="300"/>
<xs:enumeration value="320"/>
<xs:enumeration value="340"/>
<xs:enumeration value="360"/>
<xs:enumeration value="380"/>
<xs:enumeration value="400"/>
<xs:enumeration value="420"/>
<xs:enumeration value="440"/>
<xs:enumeration value="460"/>
<xs:enumeration value="480"/>
<xs:enumeration value="500"/>
<xs:enumeration value="520"/>
<xs:enumeration value="540"/>
<xs:enumeration value="560"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="crossType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="axisType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="materialType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--Fabric-->
<xs:enumeration value="1"/><!--Lining-->
<xs:enumeration value="2"/><!--Interfacing-->
<xs:enumeration value="3"/><!--Interlining-->
<xs:enumeration value="4"/><!--UserDefined-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="placementType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--No placement-->
<xs:enumeration value="1"/><!--Cut on Fold-->
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -1372,7 +1372,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<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagPoint);
@ -1443,7 +1443,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<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagArc);
@ -1504,7 +1504,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<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48);
QStringList expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint);
@ -1570,7 +1570,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<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 48);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagOperation);
@ -1587,6 +1587,15 @@ QStringList VAbstractPattern::ListOperationExpressions() const
{
Q_UNUSED(e)
}
try
{
expressions.append(GetParametrString(dom, AttrLength));
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
}
return expressions;

View File

@ -58,8 +58,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.5");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.5.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.6");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.6.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -169,6 +169,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000304):
return QStringLiteral("://schema/pattern/v0.3.4.xsd");
case (0x000305):
return QStringLiteral("://schema/pattern/v0.3.5.xsd");
case (0x000306):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -256,6 +258,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000305), fileName);
V_FALLTHROUGH
case (0x000305):
ToV0_3_6();
ValidateXML(XSDSchema(0x000306), fileName);
V_FALLTHROUGH
case (0x000306):
break;
default:
break;
@ -423,6 +429,13 @@ void VPatternConverter::ToV0_3_5()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_3_6()
{
SetVersion(QStringLiteral("0.3.6"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -55,10 +55,10 @@ public:
// GCC 4.6 doesn't allow constexpr and const together
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406
static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 5);
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 6);
#else
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 5);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 6);
#endif
protected:
@ -94,6 +94,7 @@ private:
void ToV0_3_3();
void ToV0_3_4();
void ToV0_3_5();
void ToV0_3_6();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -145,6 +145,19 @@ VArc VArc::Flip(const QLineF &axis, const QString &prefix) const
return arc;
}
//---------------------------------------------------------------------------------------------------------------------
VArc VArc::Move(qreal length, qreal angle, const QString &prefix) const
{
const VPointF center = GetCenter().Move(length, angle);
const QPointF p1 = VPointF::MovePF(GetP1(), length, angle);
const QPointF p2 = VPointF::MovePF(GetP2(), length, angle);
VArc arc(center, GetRadius(), QLineF(center, p1).angle(), QLineF(center, p2).angle());
arc.setName(name() + prefix);
return arc;
}
//---------------------------------------------------------------------------------------------------------------------
VArc::~VArc()
{}

View File

@ -64,6 +64,7 @@ public:
VArc& operator= (const VArc &arc);
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
VArc Flip(const QLineF &axis, const QString &prefix = QString()) const;
VArc Move(qreal length, qreal angle, const QString &prefix = QString()) const;
virtual ~VArc() Q_DECL_OVERRIDE;
QString GetFormulaRadius () const;

View File

@ -90,6 +90,18 @@ VCubicBezier VCubicBezier::Flip(const QLineF &axis, const QString &prefix) const
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier VCubicBezier::Move(qreal length, qreal angle, const QString &prefix) const
{
const VPointF p1 = GetP1().Move(length, angle);
const VPointF p2 = GetP2().Move(length, angle);
const VPointF p3 = GetP3().Move(length, angle);
const VPointF p4 = GetP4().Move(length, angle);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier::~VCubicBezier()
{

View File

@ -54,6 +54,7 @@ public:
VCubicBezier &operator=(const VCubicBezier &curve);
VCubicBezier Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
VCubicBezier Flip(const QLineF &axis, const QString &prefix = QString()) const;
VCubicBezier Move(qreal length, qreal angle, const QString &prefix = QString()) const;
virtual ~VCubicBezier();
virtual VPointF GetP1() const Q_DECL_OVERRIDE;

View File

@ -104,6 +104,19 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString &prefix) const
{
const QVector<VPointF> points = GetCubicPath();
VCubicBezierPath curve;
for(int i=0; i < points.size(); ++i)
{
curve.append(points.at(i).Move(length, angle));
}
curve.setName(name() + prefix);
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath::~VCubicBezierPath()
{

View File

@ -57,6 +57,7 @@ public:
VCubicBezierPath &operator=(const VCubicBezierPath &curve);
VCubicBezierPath Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
VCubicBezierPath Flip(const QLineF &axis, const QString &prefix = QString()) const;
VCubicBezierPath Move(qreal length, qreal angle, const QString &prefix = QString()) const;
virtual ~VCubicBezierPath();
VPointF &operator[](int indx);

View File

@ -148,6 +148,19 @@ VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) c
return elArc;
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) const
{
const VPointF center = GetCenter().Move(length, angle);
const QPointF p1 = VPointF::MovePF(GetP1(), length, angle);
const QPointF p2 = VPointF::MovePF(GetP2(), length, angle);
const qreal f1 = QLineF(center, p1).angle() - GetRotationAngle();
const qreal f2 = QLineF(center, p2).angle() - GetRotationAngle();
VEllipticalArc elArc(center, GetRadius1(), GetRadius2(), f1, f2, GetRotationAngle());
elArc.setName(name() + prefix);
return elArc;
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::~VEllipticalArc()
{}

View File

@ -64,6 +64,7 @@ public:
VEllipticalArc& operator= (const VEllipticalArc &arc);
VEllipticalArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
VEllipticalArc Flip(const QLineF &axis, const QString &prefix = QString()) const;
VEllipticalArc Move(qreal length, qreal angle, const QString &prefix = QString()) const;
virtual ~VEllipticalArc() Q_DECL_OVERRIDE;

View File

@ -121,6 +121,13 @@ VPointF VPointF::Flip(const QLineF &axis, const QString &prefix) const
return VPointF(p, name() + prefix, mx(), my());
}
//---------------------------------------------------------------------------------------------------------------------
VPointF VPointF::Move(qreal length, qreal angle, const QString &prefix) const
{
const QPointF p = MovePF(toQPointF(), length, angle);
return VPointF(p, name() + prefix, mx(), my());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mx return offset name respect to x
@ -221,3 +228,11 @@ QPointF VPointF::FlipPF(const QLineF &axis, const QPointF &point)
const QTransform matrix = FlippingMatrix(axis);
return matrix.map(point);
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VPointF::MovePF(const QPointF &originPoint, qreal length, qreal angle)
{
QLineF line(originPoint.x(), originPoint.y(), originPoint.x() + length, originPoint.y());
line.setAngle(angle);
return line.p2();
}

View File

@ -66,6 +66,7 @@ public:
operator QPointF() const;
VPointF Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
VPointF Flip(const QLineF &axis, const QString &prefix = QString()) const;
VPointF Move(qreal length, qreal angle, const QString &prefix = QString()) const;
qreal mx() const;
qreal my() const;
void setMx(qreal mx);
@ -78,6 +79,7 @@ public:
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
static QPointF FlipPF(const QLineF &axis, const QPointF &point);
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle);
private:
QSharedDataPointer<VPointFData> d;
};

View File

@ -140,6 +140,20 @@ VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const
{
const VPointF p1 = GetP1().Move(length, angle);
const VPointF p4 = GetP4().Move(length, angle);
const QPointF p2 = VPointF::MovePF(GetP2(), length, angle);
const QPointF p3 = VPointF::MovePF(GetP3(), length, angle);
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
VSpline::~VSpline()
{}

View File

@ -64,6 +64,7 @@ public:
const QString &c2LengthFormula, quint32 idObject = 0, Draw mode = Draw::Calculation);
VSpline Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
VSpline Flip(const QLineF &axis, const QString &prefix = QString()) const;
VSpline Move(qreal length, qreal angle, const QString &prefix = QString()) const;
virtual ~VSpline();
VSpline &operator=(const VSpline &spl);

View File

@ -144,6 +144,28 @@ VSplinePath VSplinePath::Flip(const QLineF &axis, const QString &prefix) const
return splPath;
}
//---------------------------------------------------------------------------------------------------------------------
VSplinePath VSplinePath::Move(qreal length, qreal angle, const QString &prefix) const
{
QVector<VSplinePoint> newPoints(CountPoints());
for (qint32 i = 1; i <= CountSubSpl(); ++i)
{
const VSpline spl = GetSpline(i).Move(length, angle);
newPoints[i-1].SetP(spl.GetP1());
newPoints[i-1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(spl.GetP4());
newPoints[i].SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula());
newPoints[i].SetLength1(spl.GetC2Length(), spl.GetC2LengthFormula());
}
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
return splPath;
}
//---------------------------------------------------------------------------------------------------------------------
VSplinePath::~VSplinePath()
{}

View File

@ -62,6 +62,7 @@ public:
VSplinePath(const VSplinePath& splPath);
VSplinePath Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
VSplinePath Flip(const QLineF &axis, const QString &prefix = QString()) const;
VSplinePath Move(qreal length, qreal angle, const QString &prefix = QString()) const;
virtual ~VSplinePath() Q_DECL_OVERRIDE;
VSplinePath &operator=(const VSplinePath &path);

View File

@ -111,6 +111,7 @@ enum class Tool : ToolVisHolderType
Rotation,
FlippingByLine,
FlippingByAxis,
Move,
Midpoint,
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
};
@ -154,7 +155,8 @@ enum class Vis : ToolVisHolderType
ToolTrueDarts,
ToolRotation,
ToolFlippingByLine,
ToolFlippingByAxis
ToolFlippingByAxis,
ToolMove
};
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, CurveCLength, LineAngle, CurveAngle,

View File

@ -40,7 +40,8 @@ HEADERS += \
$$PWD/tools/dialoggroup.h \
$$PWD/tools/dialogrotation.h \
$$PWD/tools/dialogflippingbyline.h \
$$PWD/tools/dialogflippingbyaxis.h
$$PWD/tools/dialogflippingbyaxis.h \
$$PWD/tools/dialogmove.h
SOURCES += \
@ -81,7 +82,8 @@ SOURCES += \
$$PWD/tools/dialoggroup.cpp \
$$PWD/tools/dialogrotation.cpp \
$$PWD/tools/dialogflippingbyline.cpp \
$$PWD/tools/dialogflippingbyaxis.cpp
$$PWD/tools/dialogflippingbyaxis.cpp \
$$PWD/tools/dialogmove.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \
@ -120,4 +122,5 @@ FORMS += \
$$PWD/tools/dialoggroup.ui \
$$PWD/tools/dialogrotation.ui \
$$PWD/tools/dialogflippingbyline.ui \
$$PWD/tools/dialogflippingbyaxis.ui
$$PWD/tools/dialogflippingbyaxis.ui \
$$PWD/tools/dialogmove.ui

View File

@ -64,6 +64,7 @@
#include "tools/dialogrotation.h"
#include "tools/dialogflippingbyline.h"
#include "tools/dialogflippingbyaxis.h"
#include "tools/dialogmove.h"
#include "support/dialogeditwrongformula.h"
#include "support/dialogundo.h"

View File

@ -0,0 +1,421 @@
/************************************************************************
**
** @file dialogmove.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 30 9, 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
** <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 "dialogmove.h"
#include <QColor>
#include <QComboBox>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QLineF>
#include <QPlainTextEdit>
#include <QPointF>
#include <QPointer>
#include <QPushButton>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QSharedPointer>
#include <QStringList>
#include <QTimer>
#include <QToolButton>
#include <Qt>
#include <new>
#include "../../visualization/visualization.h"
#include "../../visualization/line/operation/vistoolmove.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/xml/vdomdocument.h"
#include "../qmuparser/qmudef.h"
#include "../support/dialogeditwrongformula.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractmainwindow.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "ui_dialogmove.h"
class QCloseEvent;
class QWidget;
//---------------------------------------------------------------------------------------------------------------------
DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogMove),
flagAngle(false),
flagLength(false),
timerAngle(nullptr),
timerLength(nullptr),
formulaAngle(),
formulaLength(),
formulaBaseHeightAngle(0),
formulaBaseHeightLength(0),
objects(),
stage1(true),
m_suffix()
{
ui->setupUi(this);
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
ui->plainTextEditAngle->installEventFilter(this);
this->formulaBaseHeightLength = ui->plainTextEditLength->height();
ui->plainTextEditLength->installEventFilter(this);
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
timerAngle = new QTimer(this);
connect(timerAngle, &QTimer::timeout, this, &DialogMove::EvalAngle);
timerLength = new QTimer(this);
connect(timerLength, &QTimer::timeout, this, &DialogMove::EvalLength);
InitOkCancelApply(ui);
flagName = true;
CheckState();
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogMove::SuffixChanged);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogMove::FXAngle);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogMove::FXLength);
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, &DialogMove::AngleChanged);
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, &DialogMove::LengthChanged);
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogMove::DeployAngleTextEdit);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
vis = new VisToolMove(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogMove::~DialogMove()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogMove::GetAngle() const
{
return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetAngle(const QString &value)
{
formulaAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (formulaAngle.length() > 80)
{
this->DeployAngleTextEdit();
}
ui->plainTextEditAngle->setPlainText(formulaAngle);
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr);
operation->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditAngle);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogMove::GetLength() const
{
return qApp->TrVars()->TryFormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetLength(const QString &value)
{
formulaLength = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (formulaLength.length() > 80)
{
this->DeployLengthTextEdit();
}
ui->plainTextEditLength->setPlainText(formulaLength);
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr);
operation->SetLength(formulaLength);
MoveCursorToEnd(ui->plainTextEditLength);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogMove::GetSuffix() const
{
return m_suffix;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetSuffix(const QString &value)
{
m_suffix = value;
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogMove::GetObjects() const
{
return objects.toVector();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
{
return;
}
stage1 = false;
prepare = true;
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
scene->clearSelection();
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->VisualMode();
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(operation, &VisToolMove::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
scene->ToggleArcSelection(false);
scene->ToggleSplineSelection(false);
scene->ToggleSplinePathSelection(false);
scene->ToggleArcHover(false);
scene->ToggleSplineHover(false);
scene->ToggleSplinePathHover(false);
}
else if (not stage1 && prepare && click)
{
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr);
if (operation->LengthValue() > 0)
{
SetAngle(operation->Angle());//Show in dialog angle that a user choose
SetLength(operation->Length());
setModal(true);
emit ToolTip("");
timerAngle->start();
timerLength->start();
show();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ChosenObject(quint32 id, const SceneObject &type)
{
Q_UNUSED(id);
Q_UNUSED(type);
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool)
{
Q_UNUSED(tool)
if (stage1)
{
if (selected)
{
if (not objects.contains(object))
{
objects.append(object);
}
}
else
{
objects.removeOne(object);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::DeployAngleTextEdit()
{
DeployFormula(ui->plainTextEditAngle, ui->pushButtonGrowAngle, formulaBaseHeightAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::DeployLengthTextEdit()
{
DeployFormula(ui->plainTextEditLength, ui->pushButtonGrowLength, formulaBaseHeightLength);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::AngleChanged()
{
labelEditFormula = ui->labelEditAngle;
labelResultCalculation = ui->labelResultAngle;
ValFormulaChanged(flagAngle, ui->plainTextEditAngle, timerAngle, degreeSymbol);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::LengthChanged()
{
labelEditFormula = ui->labelEditLength;
labelResultCalculation = ui->labelResultLength;
ValFormulaChanged(flagLength, ui->plainTextEditLength, timerLength, degreeSymbol);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::FXAngle()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit angle"));
dialog->SetFormula(GetAngle());
dialog->setPostfix(degreeSymbol);
if (dialog->exec() == QDialog::Accepted)
{
SetAngle(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::FXLength()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetLength());
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetLength(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SuffixChanged()
{
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit)
{
const QString suffix = edit->text();
if (suffix.isEmpty())
{
flagName = false;
ChangeColor(ui->labelSuffix, Qt::red);
CheckState();
return;
}
else
{
if (m_suffix != suffix)
{
QRegularExpression rx(NameRegExp());
const QStringList uniqueNames = data->AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i)
{
const QString name = uniqueNames.at(i) + suffix;
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
{
flagName = false;
ChangeColor(ui->labelSuffix, Qt::red);
CheckState();
return;
}
}
}
}
flagName = true;
ChangeColor(ui->labelSuffix, okColor);
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagAngle && flagLength && flagName);
SCASSERT(bApply != nullptr);
bApply->setEnabled(bOk->isEnabled());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowVisualization()
{
AddVisualization<VisToolMove>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SaveData()
{
m_suffix = ui->lineEditSuffix->text();
formulaAngle = ui->plainTextEditAngle->toPlainText();
formulaAngle.replace("\n", " ");
formulaLength = ui->plainTextEditLength->toPlainText();
formulaLength.replace("\n", " ");
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->SetAngle(formulaAngle);
operation->SetLength(formulaLength);
operation->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::closeEvent(QCloseEvent *event)
{
ui->plainTextEditAngle->blockSignals(true);
ui->plainTextEditLength->blockSignals(true);
DialogTool::closeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::EvalAngle()
{
labelEditFormula = ui->labelEditAngle;
Eval(ui->plainTextEditAngle->toPlainText(), flagAngle, ui->labelResultAngle, degreeSymbol, false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::EvalLength()
{
labelEditFormula = ui->labelEditLength;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
}

View File

@ -0,0 +1,133 @@
/************************************************************************
**
** @file dialogmove.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 30 9, 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
** <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 DIALOGMOVING_H
#define DIALOGMOVING_H
#include <qcompilerdetection.h>
#include <QList>
#include <QMetaObject>
#include <QObject>
#include <QString>
#include <QVector>
#include <QtGlobal>
#include "../vmisc/def.h"
#include "dialogtool.h"
class QCloseEvent;
class QTimer;
class QWidget;
class VContainer;
namespace Ui
{
class DialogMove;
}
class DialogMove : public DialogTool
{
Q_OBJECT
public:
explicit DialogMove(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
virtual ~DialogMove();
QString GetAngle() const;
void SetAngle(const QString &value);
QString GetLength() const;
void SetLength(const QString &value);
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) Q_DECL_OVERRIDE;
private slots:
/** @brief DeployAngleTextEdit grow or shrink formula input */
void DeployAngleTextEdit();
void DeployLengthTextEdit();
void AngleChanged();
void LengthChanged();
void FXAngle();
void FXLength();
void SuffixChanged();
protected:
virtual void CheckState() Q_DECL_OVERRIDE;
virtual void ShowVisualization() Q_DECL_OVERRIDE;
/** @brief SaveData Put dialog data in local variables */
virtual void SaveData() Q_DECL_OVERRIDE;
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(DialogMove)
Ui::DialogMove *ui;
/** @brief flagAngle true if value of angle is correct */
bool flagAngle;
bool flagLength;
/** @brief timerAngle timer of check formula of angle */
QTimer *timerAngle;
QTimer *timerLength;
/** @brief angle formula of angle */
QString formulaAngle;
QString formulaLength;
/** @brief formulaBaseHeightAngle base height defined by dialogui */
int formulaBaseHeightAngle;
int formulaBaseHeightLength;
QList<quint32> objects;
bool stage1;
QString m_suffix;
void EvalAngle();
void EvalLength();
};
#endif // DIALOGMOVING_H

View File

@ -0,0 +1,450 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogMove</class>
<widget class="QDialog" name="DialogMove">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>232</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</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>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Angle:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprAngle">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calulation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowAngle">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Length:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprLength">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calulation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="labelSuffix">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Suffix:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditSuffix"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|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>DialogMove</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>DialogMove</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

@ -61,5 +61,6 @@
#include "operation/vtoolrotation.h"
#include "operation/flipping/vtoolflippingbyline.h"
#include "operation/flipping/vtoolflippingbyaxis.h"
#include "operation/vtoolmove.h"
#endif // DRAWTOOLS_H

View File

@ -0,0 +1,480 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 1 10, 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
** <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 "vtoolmove.h"
#include <limits.h>
#include <qiterator.h>
#include <QColor>
#include <QDomNode>
#include <QDomNodeList>
#include <QMapIterator>
#include <QPoint>
#include <QSharedPointer>
#include <QStaticStringData>
#include <QStringData>
#include <QStringDataPtr>
#include <QUndoStack>
#include <new>
#include "../../../dialogs/tools/dialogtool.h"
#include "../../../dialogs/tools/dialogmove.h"
#include "../../../visualization/line/operation/vistoolmove.h"
#include "../../../visualization/visualization.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
#include "../vgeometry/vsplinepath.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vmisc/diagnostic.h"
#include "../vmisc/logging.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../vdrawtool.h"
class QDomElement;
class QGraphicsSceneContextMenuEvent;
class QPainter;
class QStyleOptionGraphicsItem;
class QWidget;
template <class T> class QSharedPointer;
const QString VToolMove::ToolType = QStringLiteral("moving");
//---------------------------------------------------------------------------------------------------------------------
VToolMove::~VToolMove()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::setDialog()
{
SCASSERT(dialog != nullptr);
DialogMove *dialogTool = qobject_cast<DialogMove*>(dialog);
SCASSERT(dialogTool != nullptr);
dialogTool->SetAngle(formulaAngle);
dialogTool->SetLength(formulaLength);
dialogTool->SetSuffix(suffix);
}
//---------------------------------------------------------------------------------------------------------------------
VToolMove *VToolMove::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogMove *dialogTool = qobject_cast<DialogMove*>(dialog);
SCASSERT(dialogTool != nullptr);
QString angle = dialogTool->GetAngle();
QString length = dialogTool->GetLength();
const QString suffix = dialogTool->GetSuffix();
const QVector<quint32> source = dialogTool->GetObjects();
VToolMove* operation = Create(0, angle, length, suffix, source, QVector<DestinationItem>(), scene, doc, data,
Document::FullParse, Source::FromGui);
if (operation != nullptr)
{
operation->dialog = dialogTool;
}
return operation;
}
//---------------------------------------------------------------------------------------------------------------------
VToolMove *VToolMove::Create(quint32 _id, QString &formulaAngle, QString &formulaLength,
const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{
qreal calcAngle = 0;
qreal calcLength = 0;
calcAngle = CheckFormula(_id, formulaAngle, data);
calcLength = qApp->toPixel(CheckFormula(_id, formulaLength, data));
QVector<DestinationItem> dest = destination;
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
dest.clear();// Try to avoid mistake, value must be empty
id = data->getNextId();//Just reserve id for tool
for (int i = 0; i < source.size(); ++i)
{
const quint32 idObject = source.at(i);
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
dest.append(CreatePoint(id, idObject, calcAngle, calcLength, suffix, data));
break;
case GOType::Arc:
dest.append(CreateArc(id, idObject, calcAngle, calcLength, suffix, data));
break;
case GOType::EllipticalArc:
//dest.append(CreateItem<VEllipticalArc>(id, idObject, angle, suffix));
break;
case GOType::Spline:
dest.append(CreateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data));
break;
case GOType::SplinePath:
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, calcAngle, calcLength, suffix,
data));
break;
case GOType::CubicBezier:
dest.append(CreateCurve<VCubicBezier>(id, idObject, calcAngle, calcLength, suffix, data));
break;
case GOType::CubicBezierPath:
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, calcAngle, calcLength, suffix,
data));
break;
case GOType::Unknown:
break;
}
QT_WARNING_POP
}
}
else
{
for (int i = 0; i < source.size(); ++i)
{
const quint32 idObject = source.at(i);
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
UpdatePoint(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id, dest.at(i).mx,
dest.at(i).my);
break;
case GOType::Arc:
UpdateArc(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
break;
case GOType::EllipticalArc:
//dest.append(UpdateItem<VEllipticalArc>(id, idObject, oPoint, angle, suffix, data));
break;
case GOType::Spline:
UpdateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
break;
case GOType::SplinePath:
UpdateCurveWithSegments<VSplinePath>(id, idObject, calcAngle, calcLength, suffix, data,
dest.at(i).id);
break;
case GOType::CubicBezier:
UpdateCurve<VCubicBezier>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
break;
case GOType::CubicBezierPath:
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, calcAngle, calcLength, suffix, data,
dest.at(i).id);
break;
case GOType::Unknown:
break;
}
QT_WARNING_POP
}
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Move, doc);
if (parse == Document::FullParse)
{
VToolMove *tool = new VToolMove(doc, data, id, formulaAngle, formulaLength, suffix, source, dest,
typeCreation);
scene->addItem(tool);
InitOperationToolConnections(scene, tool);
doc->AddTool(id, tool);
for (int i = 0; i < source.size(); ++i)
{
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
}
return tool;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolMove::GetFormulaAngle() const
{
VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(id);
fAngle.setPostfix(degreeSymbol);
return fAngle;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::SetFormulaAngle(const VFormula &value)
{
if (value.error() == false)
{
formulaAngle = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolMove::GetFormulaLength() const
{
VFormula fLength(formulaLength, getData());
fLength.setCheckZero(true);
fLength.setToolId(id);
fLength.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
return fLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::SetFormulaLength(const VFormula &value)
{
if (value.error() == false)
{
formulaLength = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::ShowVisualization(bool show)
{
ShowToolVisualization<VisToolMove>(show);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::SetVisualization()
{
if (not vis.isNull())
{
VisToolMove *visual = qobject_cast<VisToolMove *>(vis);
SCASSERT(visual != nullptr);
visual->SetObjects(source);
visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
visual->SetLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator()));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogMove *dialogTool = qobject_cast<DialogMove*>(dialog);
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
QString length = dialogTool->GetLength();
doc->SetAttribute(domElement, AttrLength, length);
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::ReadToolAttributes(const QDomElement &domElement)
{
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "0");
formulaLength = doc->GetParametrString(domElement, AttrLength, "0");
suffix = doc->GetParametrString(domElement, AttrSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VDrawTool::SaveOptions(tag, obj);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrSuffix, suffix);
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
try
{
ContextMenu<DialogMove>(this, event);
}
catch(const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e);
return;//Leave this method immediately!!!
}
}
//---------------------------------------------------------------------------------------------------------------------
VToolMove::VToolMove(VAbstractPattern *doc, VContainer *data, quint32 id,
const QString &formulaAngle, const QString &formulaLength, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const Source &typeCreation, QGraphicsItem *parent)
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
formulaAngle(formulaAngle),
formulaLength(formulaLength)
{
InitOperatedObjects();
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------
DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal angle,
qreal length, const QString &suffix, VContainer *data)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
VPointF moved = point->Move(length, angle, suffix);
moved.setIdObject(idTool);
DestinationItem item;
item.mx = moved.mx();
item.my = moved.my();
item.id = data->AddGObject(new VPointF(moved));
return item;
}
//---------------------------------------------------------------------------------------------------------------------
DestinationItem VToolMove::CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data)
{
const DestinationItem item = CreateItem<VArc>(idTool, idItem, angle, length, suffix, data);
data->AddArc(data->GeometricObject<VArc>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id, qreal mx, qreal my)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
VPointF moved = point->Move(length, angle, suffix);
moved.setIdObject(idTool);
moved.setMx(mx);
moved.setMy(my);
data->UpdateGObject(id, new VPointF(moved));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id)
{
UpdateItem<VArc>(idTool, idItem, angle, length, suffix, data, id);
data->AddArc(data->GeometricObject<VArc>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolMove::CreateItem(quint32 idTool, quint32 idItem, qreal angle,
qreal length, const QString &suffix, VContainer *data)
{
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
Item moved = i->Move(length, angle, suffix);
moved.setIdObject(idTool);
DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
item.id = data->AddGObject(new Item(moved));
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolMove::CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length,
const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, angle, length, suffix, data);
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolMove::CreateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle,
qreal length, const QString &suffix,
VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, angle, length, suffix, data);
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolMove::UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id)
{
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
Item moved = i->Move(length, angle, suffix);
moved.setIdObject(idTool);
data->UpdateGObject(id, new Item(moved));
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolMove::UpdateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, angle, length, suffix, data, id);
data->AddSpline(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolMove::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length,
const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, angle, length, suffix, data, id);
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
}

View File

@ -0,0 +1,128 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 1 10, 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
** <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 VTOOLMOVING_H
#define VTOOLMOVING_H
#include <qcompilerdetection.h>
#include <QMap>
#include <QMetaObject>
#include <QObject>
#include <QString>
#include <QVector>
#include <QtGlobal>
#include "vabstractoperation.h"
#include "../vgeometry/vgeometrydef.h"
#include "../vmisc/def.h"
#include "../ifc/xml/vabstractpattern.h"
class DialogTool;
class QDomElement;
class QGraphicsSceneContextMenuEvent;
class QPointF;
class VContainer;
class VGObject;
class VMainGraphicsScene;
template <class T> class QSharedPointer;
class VFormula;
class VToolMove : public VAbstractOperation
{
Q_OBJECT
public:
virtual ~VToolMove();
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolMove* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolMove* Create(quint32 _id, QString &formulaAngle, QString &formulaLength, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Move)};
VFormula GetFormulaAngle() const;
void SetFormulaAngle(const VFormula &value);
VFormula GetFormulaLength() const;
void SetFormulaLength(const VFormula &value);
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
protected:
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolMove)
QString formulaAngle;
QString formulaLength;
VToolMove(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formulaAngle,
const QString &formulaLength, const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, const Source &typeCreation,
QGraphicsItem *parent = nullptr);
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data);
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data);
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data);
template <class Item>
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data);
template <class Item>
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length,
const QString &suffix, VContainer *data);
static void UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id, qreal mx, qreal my);
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id);
static void UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id);
template <class Item>
static void UpdateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id);
template <class Item>
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length,
const QString &suffix, VContainer *data, quint32 id);
};
#endif // VTOOLMOVING_H

View File

@ -55,7 +55,8 @@ HEADERS += \
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.h \
$$PWD/drawTools/operation/vabstractoperation.h \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.h \
$$PWD/drawTools/operation/flipping/vabstractflipping.h
$$PWD/drawTools/operation/flipping/vabstractflipping.h \
$$PWD/drawTools/operation/vtoolmove.h
SOURCES += \
$$PWD/vtooldetail.cpp \
@ -108,4 +109,5 @@ SOURCES += \
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.cpp \
$$PWD/drawTools/operation/vabstractoperation.cpp \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.cpp \
$$PWD/drawTools/operation/flipping/vabstractflipping.cpp
$$PWD/drawTools/operation/flipping/vabstractflipping.cpp \
$$PWD/drawTools/operation/vtoolmove.cpp

View File

@ -0,0 +1,319 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 1 10, 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
** <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 "vistoolmove.h"
#include <limits.h>
#include <QGraphicsLineItem>
#include <QGraphicsPathItem>
#include <QGuiApplication>
#include <QLineF>
#include <QPainterPath>
#include <QSharedPointer>
#include <Qt>
#include <QtAlgorithms>
#include <new>
#include "../ifc/xml/vdomdocument.h"
#include "../vmisc/diagnostic.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vgeometrydef.h"
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
#include "../vgeometry/vsplinepath.h"
#include "../vmisc/vabstractapplication.h"
#include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "visoperation.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolMove::VisToolMove(const VContainer *data, QGraphicsItem *parent)
: VisOperation(data, parent),
angle(0),
length(0),
pointOrigin(nullptr),
pointFinish(nullptr)
{
pointOrigin = InitPoint(supportColor2, this);
pointFinish = InitPoint(supportColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolMove::~VisToolMove()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::RefreshGeometry()
{
if (objects.isEmpty())
{
return;
}
int iPoint = -1;
int iCurve = -1;
const QVector<QGraphicsItem *> originObjects = CreateOriginObjects(iPoint, iCurve);
const QPointF origin = GetOriginPoint(originObjects);
DrawPoint(pointOrigin, origin, supportColor2);
qreal tempAngle = 0;
qreal tempLength = 0;
QLineF line;
if (qFuzzyIsNull(length))
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{
line = QLineF(origin, Visualization::scenePos);
line.setAngle(CorrectAngle(line.angle()));
}
else
{
line = QLineF(origin, Visualization::scenePos);
}
tempAngle = line.angle();
tempLength = line.length();
}
else
{
line = VGObject::BuildLine(origin, length, angle);
tempAngle = angle;
tempLength = length;
}
DrawLine(this, line, supportColor2, Qt::DashLine);
DrawPoint(pointFinish, line.p2(), supportColor);
static const QString prefix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
Visualization::toolTip = tr("Length = %1%2, angle = %3°, <b>Shift</b> - sticking angle, "
"<b>Mouse click</b> - finish creation")
.arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(tempLength)),
qApp->Settings()->GetOsSeparator()))
.arg(prefix)
.arg(tempAngle);
CreateMovedObjects(iPoint, iCurve, tempLength, tempAngle);
}
//---------------------------------------------------------------------------------------------------------------------
QString VisToolMove::Angle() const
{
return QString::number(line().angle());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::SetAngle(const QString &expression)
{
angle = FindVal(expression, Visualization::data->PlainVariables());
}
//---------------------------------------------------------------------------------------------------------------------
QString VisToolMove::Length() const
{
return QString::number(LengthValue());
}
//---------------------------------------------------------------------------------------------------------------------
qreal VisToolMove::LengthValue() const
{
return qApp->fromPixel(line().length());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::SetLength(const QString &expression)
{
length = FindVal(expression, Visualization::data->PlainVariables());
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
QGraphicsPathItem *VisToolMove::AddOriginCurve(quint32 id, int &i)
{
const QSharedPointer<Item> curve = Visualization::data->template GeometricObject<Item>(id);
++i;
QGraphicsPathItem *path = GetCurve(i, supportColor2);
DrawPath(path, curve->GetPath(PathDirection::Show), supportColor2, Qt::SolidLine, Qt::RoundCap);
return path;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
int VisToolMove::AddMovedCurve(qreal angle, qreal length, quint32 id, int i)
{
const QSharedPointer<Item> curve = Visualization::data->template GeometricObject<Item>(id);
++i;
QGraphicsPathItem *path = GetCurve(i, supportColor);
const Item moved = curve->Move(length, angle);
DrawPath(path, moved.GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap);
return i;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VisToolMove::GetOriginPoint(const QVector<QGraphicsItem *> &objects)
{
QRectF boundingRect;
for (int i=0; i < objects.size(); ++i)
{
QGraphicsItem *object = objects.at(i);
if (object)
{
QRectF childrenRect = object->childrenBoundingRect();
//map to scene coordinate.
childrenRect.translate(object->scenePos());
QRectF itemRect = object->boundingRect();
//map to scene coordinate.
itemRect.translate(object->scenePos());
boundingRect = boundingRect.united(itemRect);
boundingRect = boundingRect.united(childrenRect);
}
}
return boundingRect.center();
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
QVector<QGraphicsItem *> VisToolMove::CreateOriginObjects(int &iPoint, int &iCurve)
{
QVector<QGraphicsItem *> originObjects;
for (int i = 0; i < objects.size(); ++i)
{
const quint32 id = objects.at(i);
const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id);
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
{
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
++iPoint;
QGraphicsEllipseItem *point = GetPoint(iPoint, supportColor2);
DrawPoint(point, *p, supportColor2);
originObjects.append(point);
break;
}
case GOType::Arc:
originObjects.append(AddOriginCurve<VArc>(id, iCurve));
break;
case GOType::EllipticalArc:
originObjects.append(AddOriginCurve<VEllipticalArc>(id, iCurve));
break;
case GOType::Spline:
originObjects.append(AddOriginCurve<VSpline>(id, iCurve));
break;
case GOType::SplinePath:
originObjects.append(AddOriginCurve<VSplinePath>(id, iCurve));
break;
case GOType::CubicBezier:
originObjects.append(AddOriginCurve<VCubicBezier>(id, iCurve));
break;
case GOType::CubicBezierPath:
originObjects.append(AddOriginCurve<VCubicBezierPath>(id, iCurve));
break;
case GOType::Unknown:
break;
}
}
return originObjects;
}
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
void VisToolMove::CreateMovedObjects(int &iPoint, int &iCurve, qreal length, qreal angle)
{
for (int i = 0; i < objects.size(); ++i)
{
const quint32 id = objects.at(i);
const QSharedPointer<VGObject> obj = Visualization::data->GetGObject(id);
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects was handled.");
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
{
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
++iPoint;
QGraphicsEllipseItem *point = GetPoint(iPoint, supportColor);
DrawPoint(point, p->Move(length, angle), supportColor);
break;
}
case GOType::Arc:
iCurve = AddMovedCurve<VArc>(angle, length, id, iCurve);
break;
case GOType::EllipticalArc:
iCurve = AddMovedCurve<VEllipticalArc>(angle, length, id, iCurve);
break;
case GOType::Spline:
iCurve = AddMovedCurve<VSpline>(angle, length, id, iCurve);
break;
case GOType::SplinePath:
iCurve = AddMovedCurve<VSplinePath>(angle, length, id, iCurve);
break;
case GOType::CubicBezier:
iCurve = AddMovedCurve<VCubicBezier>(angle, length, id, iCurve);
break;
case GOType::CubicBezierPath:
iCurve = AddMovedCurve<VCubicBezierPath>(angle, length, id, iCurve);
break;
case GOType::Unknown:
break;
}
}
}
QT_WARNING_POP

View File

@ -0,0 +1,86 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 1 10, 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
** <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 VISTOOLMOVE_H
#define VISTOOLMOVE_H
#include <qcompilerdetection.h>
#include <QColor>
#include <QGraphicsItem>
#include <QMetaObject>
#include <QObject>
#include <QPointF>
#include <QString>
#include <QVector>
#include <QtGlobal>
#include "../ifc/ifcdef.h"
#include "../vmisc/def.h"
#include "visoperation.h"
class QPointF;
class VContainer;
class VisToolMove : public VisOperation
{
Q_OBJECT
public:
explicit VisToolMove(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolMove();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
QString Angle() const;
void SetAngle(const QString &expression);
QString Length() const;
qreal LengthValue() const;
void SetLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolMove)};
private:
Q_DISABLE_COPY(VisToolMove)
qreal angle;
qreal length;
QGraphicsEllipseItem *pointOrigin;
QGraphicsEllipseItem *pointFinish;
template <class Item>
QGraphicsPathItem *AddOriginCurve(quint32 id, int &i);
template <class Item>
int AddMovedCurve(qreal angle, qreal length, quint32 id, int i);
static QPointF GetOriginPoint(const QVector<QGraphicsItem *> &objects);
QVector<QGraphicsItem *> CreateOriginObjects(int &iPoint, int &iCurve);
void CreateMovedObjects(int &iPoint, int &iCurve, qreal length, qreal angle);
};
#endif // VISTOOLMOVE_H

View File

@ -36,7 +36,8 @@ HEADERS += \
$$PWD/path/vistoolcubicbezier.h \
$$PWD/path/vistoolcubicbezierpath.h \
$$PWD/line/operation/visoperation.h \
$$PWD/line/operation/vistoolflippingbyaxis.h
$$PWD/line/operation/vistoolflippingbyaxis.h \
$$PWD/line/operation/vistoolmove.h
SOURCES += \
$$PWD/visualization.cpp \
@ -73,4 +74,5 @@ SOURCES += \
$$PWD/path/vistoolcubicbezier.cpp \
$$PWD/path/vistoolcubicbezierpath.cpp \
$$PWD/line/operation/visoperation.cpp \
$$PWD/line/operation/vistoolflippingbyaxis.cpp
$$PWD/line/operation/vistoolflippingbyaxis.cpp \
$$PWD/line/operation/vistoolmove.cpp