Merged develop into feature, removing the conflicts

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-09-20 19:29:49 +02:00
commit 5f1d7a357a
93 changed files with 5255 additions and 930 deletions

View File

@ -39,6 +39,7 @@
- [#424] Improve Formula Wizard dialog.
- 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'.
# 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) == 45, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47, "Not all tools was used in switch.");
switch (item->type())
{
@ -185,6 +185,12 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolRotation::Type:
ShowOptionsToolRotation(item);
break;
case VToolFlippingByLine::Type:
ShowOptionsToolFlippingByLine(item);
break;
case VToolFlippingByAxis::Type:
ShowOptionsToolFlippingByAxis(item);
break;
default:
break;
}
@ -199,7 +205,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
}
// This check helps to find missed tools in the switch
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47, "Not all tools was used in switch.");
switch (currentItem->type())
{
@ -299,6 +305,12 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolRotation::Type:
UpdateOptionsToolRotation();
break;
case VToolFlippingByLine::Type:
UpdateOptionsToolFlippingByLine();
break;
case VToolFlippingByAxis::Type:
UpdateOptionsToolFlippingByAxis();
break;
default:
break;
}
@ -334,7 +346,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) == 45, "Not all tools was used in switch.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47, "Not all tools was used in switch.");
switch (currentItem->type())
{
@ -428,6 +440,12 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolRotation::Type:
ChangeDataToolRotation(prop);
break;
case VToolFlippingByLine::Type:
ChangeDataToolFlippingByLine(prop);
break;
case VToolFlippingByAxis::Type:
ChangeDataToolFlippingByAxis(prop);
break;
default:
break;
}
@ -556,6 +574,16 @@ void VToolOptionsPropertyBrowser::AddPropertyHCrossPoint(Tool *i, const QString
AddProperty(itemProperty, AttrHCrossPoint);
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyAxisType(Tool *i, const QString &propertyName)
{
auto itemProperty = new VEnumProperty(propertyName);
itemProperty->setLiterals(QStringList()<< tr("Vertical axis") << tr("Horizontal axis"));
itemProperty->setValue(static_cast<int>(i->GetAxisType())-1);
AddProperty(itemProperty, AttrAxisType);
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName,
@ -772,6 +800,20 @@ void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(const QVariant &value)
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::SetAxisType(const QVariant &value)
{
if (auto i = qgraphicsitem_cast<Tool *>(currentItem))
{
i->SetAxisType(GetCrossPoint<AxisType>(value));
}
else
{
qWarning()<<"Can't cast item";
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::AddProperty(VProperty *property, const QString &id)
{
@ -1601,6 +1643,50 @@ void VToolOptionsPropertyBrowser::ChangeDataToolRotation(VProperty *property)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByLine(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
switch (PropertiesList().indexOf(id))
{
case 38: // AttrSuffix
SetOperationSuffix<VToolFlippingByLine>(value.toString());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByAxis(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
switch (PropertiesList().indexOf(id))
{
case 39: // AttrAxisType
{
const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole);
SetAxisType<VToolFlippingByAxis>(value);
break;
}
case 38: // AttrSuffix
SetOperationSuffix<VToolFlippingByAxis>(value.toString());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item)
{
@ -1991,6 +2077,27 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolRotation(QGraphicsItem *item)
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolFlippingByLine(QGraphicsItem *item)
{
VToolFlippingByLine *i = qgraphicsitem_cast<VToolFlippingByLine *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Tool flipping by line"));
AddPropertyOperationSuffix(i, tr("Suffix"));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolFlippingByAxis(QGraphicsItem *item)
{
VToolFlippingByAxis *i = qgraphicsitem_cast<VToolFlippingByAxis *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Tool flipping by axis"));
AddPropertyAxisType(i, tr("Axis type"));
AddPropertyOperationSuffix(i, tr("Suffix"));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint()
{
@ -2451,6 +2558,21 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolRotation()
idToProperty[AttrAngle]->setValue(valueAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByLine()
{
VToolFlippingByLine *i = qgraphicsitem_cast<VToolFlippingByLine *>(currentItem);
idToProperty[AttrSuffix]->setValue(i->Suffix());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByAxis()
{
VToolFlippingByAxis *i = qgraphicsitem_cast<VToolFlippingByAxis *>(currentItem);
idToProperty[AttrAxisType]->setValue(static_cast<int>(i->GetAxisType())-1);
idToProperty[AttrSuffix]->setValue(i->Suffix());
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
{
@ -2492,6 +2614,7 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
<< AttrHCrossPoint /* 35 */
<< AttrLength1 /* 36 */
<< AttrLength2 /* 37 */
<< AttrSuffix; /* 38 */
<< AttrSuffix /* 38 */
<< AttrAxisType; /* 39 */
return attr;
}

View File

@ -90,6 +90,9 @@ private:
template<class Tool>
void SetHCrossCurvesPoint(const QVariant &value);
template<class Tool>
void SetAxisType(const QVariant &value);
template<class Tool>
void AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly = false);
@ -111,6 +114,9 @@ private:
template<class Tool>
void AddPropertyHCrossPoint(Tool *i, const QString &propertyName);
template<class Tool>
void AddPropertyAxisType(Tool *i, const QString &propertyName);
template<class Tool>
void AddPropertyLineType(Tool *i, const QString &propertyName, const QMap<QString, QIcon> &styles);
@ -152,6 +158,8 @@ private:
void ChangeDataToolLineIntersectAxis(VPE::VProperty *property);
void ChangeDataToolCurveIntersectAxis(VPE::VProperty *property);
void ChangeDataToolRotation(VPE::VProperty *property);
void ChangeDataToolFlippingByLine(VPE::VProperty *property);
void ChangeDataToolFlippingByAxis(VPE::VProperty *property);
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
void ShowOptionsToolEndLine(QGraphicsItem *item);
@ -183,6 +191,8 @@ private:
void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item);
void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item);
void ShowOptionsToolRotation(QGraphicsItem *item);
void ShowOptionsToolFlippingByLine(QGraphicsItem *item);
void ShowOptionsToolFlippingByAxis(QGraphicsItem *item);
void UpdateOptionsToolSinglePoint();
void UpdateOptionsToolEndLine();
@ -214,6 +224,8 @@ private:
void UpdateOptionsToolLineIntersectAxis();
void UpdateOptionsToolCurveIntersectAxis();
void UpdateOptionsToolRotation();
void UpdateOptionsToolFlippingByLine();
void UpdateOptionsToolFlippingByAxis();
};
#endif // VTOOLOPTIONSPROPERTYBROWSER_H

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

View File

@ -1033,6 +1033,28 @@ void MainWindow::ToolRotation(bool checked)
&MainWindow::ApplyDialog<VToolRotation>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolFlippingByLine(bool checked)
{
ToolSelectOperationObjects();
SetToolButtonWithApply<DialogFlippingByLine>(checked, Tool::FlippingByLine,
":/cursor/flipping_line_cursor.png",
tr("Select one or more objects, <b>Enter</b> - confirm selection"),
&MainWindow::ClosedDialogWithApply<VToolFlippingByLine>,
&MainWindow::ApplyDialog<VToolFlippingByLine>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolFlippingByAxis(bool checked)
{
ToolSelectOperationObjects();
SetToolButtonWithApply<DialogFlippingByAxis>(checked, Tool::FlippingByAxis,
":/cursor/flipping_axis_cursor.png",
tr("Select one or more objects, <b>Enter</b> - confirm selection"),
&MainWindow::ClosedDialogWithApply<VToolFlippingByAxis>,
&MainWindow::ApplyDialog<VToolFlippingByAxis>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ClosedDialogGroup(int result)
{
@ -1702,6 +1724,8 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup);
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->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint);
connect(ui->toolButtonLayoutExportAs, &QToolButton::clicked, this, &MainWindow::ExportLayoutAs);
}
@ -1731,7 +1755,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) == 45, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47, "Not all tools was handled.");
qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool;
@ -1871,6 +1895,12 @@ void MainWindow::CancelTool()
case Tool::Rotation:
ui->toolButtonRotation->setChecked(false);
break;
case Tool::FlippingByLine:
ui->toolButtonFlippingByLine->setChecked(false);
break;
case Tool::FlippingByAxis:
ui->toolButtonFlippingByAxis->setChecked(false);
break;
}
// Crash: using CRTL+Z while using line tool.
@ -2919,6 +2949,9 @@ void MainWindow::SetEnableTool(bool enable)
break;
}
// 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.");
//Drawing Tools
ui->toolButtonEndLine->setEnabled(drawTools);
ui->toolButtonLine->setEnabled(drawTools);
@ -2952,6 +2985,8 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonTrueDarts->setEnabled(drawTools);
ui->toolButtonGroup->setEnabled(drawTools);
ui->toolButtonRotation->setEnabled(drawTools);
ui->toolButtonFlippingByLine->setEnabled(drawTools);
ui->toolButtonFlippingByAxis->setEnabled(drawTools);
ui->toolButtonMidpoint->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools);
@ -3234,7 +3269,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) == 45, "Not all tools was handled.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47, "Not all tools was handled.");
if (currentTool == lastUsedTool)
{
@ -3400,6 +3435,14 @@ void MainWindow::LastUsedTool()
ui->toolButtonRotation->setChecked(true);
ToolRotation(true);
break;
case Tool::FlippingByLine:
ui->toolButtonFlippingByLine->setChecked(true);
ToolFlippingByLine(true);
break;
case Tool::FlippingByAxis:
ui->toolButtonFlippingByAxis->setChecked(true);
ToolFlippingByAxis(true);
break;
}
}

View File

@ -139,6 +139,8 @@ private slots:
void ToolUnionDetails(bool checked);
void ToolGroup(bool checked);
void ToolRotation(bool checked);
void ToolFlippingByLine(bool checked);
void ToolFlippingByAxis(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 resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<property name="locale">
@ -48,14 +48,14 @@
<string>Tools</string>
</property>
<property name="currentIndex">
<number>6</number>
<number>4</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>117</width>
<height>358</height>
</rect>
</property>
@ -69,7 +69,7 @@
<string>Tools for creating points.</string>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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>100</width>
<width>130</width>
<height>110</height>
</rect>
</property>
@ -441,7 +441,7 @@
<string>Tools for creating lines.</string>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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>100</width>
<width>130</width>
<height>248</height>
</rect>
</property>
@ -550,7 +550,7 @@
<string>Tools for creating curves.</string>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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>100</width>
<width>130</width>
<height>248</height>
</rect>
</property>
@ -812,7 +812,7 @@
<string>Tools for creating arcs.</string>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -1063,12 +1063,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>104</height>
<width>130</width>
<height>356</height>
</rect>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<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 resource="share/resources/toolicon.qrc">
<iconset>
<normaloff>:/toolicon/32x32/rotation.png</normaloff>:/toolicon/32x32/rotation.png</iconset>
</property>
<property name="iconSize">
@ -1156,6 +1156,58 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QToolButton" name="toolButtonFlippingByLine">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Flipping objects by line</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/toolicon/32x32/flipping_line.png</normaloff>:/toolicon/32x32/flipping_line.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="toolButtonFlippingByAxis">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Flipping objects by axis</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/toolicon/32x32/flipping_axis.png</normaloff>:/toolicon/32x32/flipping_axis.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">
@ -1163,7 +1215,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>130</width>
<height>104</height>
</rect>
</property>
@ -1177,7 +1229,7 @@
<string>Tools for creating details.</string>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/16x16/toolsectiondetail.png</normaloff>:/icon/16x16/toolsectiondetail.png</iconset>
</attribute>
<attribute name="label">
@ -1199,7 +1251,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="iconSize">
@ -1225,7 +1277,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<iconset>
<normaloff>:/toolicon/32x32/new_detail.png</normaloff>:/toolicon/32x32/new_detail.png</iconset>
</property>
<property name="iconSize">
@ -1251,7 +1303,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<iconset>
<normaloff>:/toolicon/32x32/union.png</normaloff>:/toolicon/32x32/union.png</iconset>
</property>
<property name="iconSize">
@ -1277,7 +1329,7 @@
</rect>
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/16x16/toolsectionlayout.png</normaloff>:/icon/16x16/toolsectionlayout.png</iconset>
</attribute>
<attribute name="label">
@ -1328,7 +1380,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/export_to_picture_document.png</normaloff>:/icon/32x32/export_to_picture_document.png</iconset>
</property>
<property name="iconSize">
@ -1774,7 +1826,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/draw.png</normaloff>:/icon/32x32/draw.png</iconset>
</property>
<property name="text">
@ -1798,7 +1850,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/kontur.png</normaloff>:/icon/32x32/kontur.png</iconset>
</property>
<property name="text">
@ -1822,7 +1874,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="text">
@ -1840,7 +1892,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/new_draw.png</normaloff>:/icon/32x32/new_draw.png</iconset>
</property>
<property name="text">
@ -1861,7 +1913,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/option_draw.png</normaloff>:/icon/32x32/option_draw.png</iconset>
</property>
<property name="text">
@ -1885,7 +1937,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/table.png</normaloff>:/icon/32x32/table.png</iconset>
</property>
<property name="text">
@ -1909,7 +1961,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/history.png</normaloff>:/icon/32x32/history.png</iconset>
</property>
<property name="text">
@ -1930,7 +1982,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/layout.png</normaloff>:/icon/32x32/layout.png</iconset>
</property>
<property name="text">
@ -2195,7 +2247,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/pdf.png</normaloff>:/icon/32x32/pdf.png</iconset>
</property>
<property name="text">
@ -2285,7 +2337,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/export_to_picture_document.png</normaloff>:/icon/32x32/export_to_picture_document.png</iconset>
</property>
<property name="text">
@ -2362,7 +2414,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<iconset>
<normaloff>:/icon/32x32/syncM.png</normaloff>:/icon/32x32/syncM.png</iconset>
</property>
<property name="text">
@ -2401,9 +2453,6 @@
<header>vmaingraphicsview.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
<include location="share/resources/toolicon.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@ -70,5 +70,9 @@
<file>cursor/rotation_cursor@2x.png</file>
<file>cursor/midpoint_cursor.png</file>
<file>cursor/midpoint_cursor@2x.png</file>
<file>cursor/flipping_line_cursor@2x.png</file>
<file>cursor/flipping_line_cursor.png</file>
<file>cursor/flipping_axis_cursor.png</file>
<file>cursor/flipping_axis_cursor@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -68,5 +68,9 @@
<file>toolicon/32x32/rotation@2x.png</file>
<file>toolicon/32x32/midpoint.png</file>
<file>toolicon/32x32/midpoint@2x.png</file>
<file>toolicon/32x32/flipping_line@2x.png</file>
<file>toolicon/32x32/flipping_line.png</file>
<file>toolicon/32x32/flipping_axis.png</file>
<file>toolicon/32x32/flipping_axis@2x.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns: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="flipping_axis.svg"
inkscape:export-filename="/home/dismine/CAD/Valentina/src/app/share/resources/icon/32x32/point_of_contact.png"
inkscape:export-xdpi="92"
inkscape:export-ydpi="92">
<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="1.217807"
inkscape:cy="19.48315"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg2985" />
<defs
id="defs2987">
<linearGradient
id="linearGradient4142"
osb:paint="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4144" />
</linearGradient>
</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
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.94585049;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 12.014344,1.2619817 11.81709,30.968318 1.165289,30.770275 Z"
id="path3336"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.619;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3.238,1.619;stroke-dashoffset:1.29519995;stroke-opacity:1"
d="M 15.818683,0.54124145 15.907695,31.464269"
id="path3340"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.56700003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path2985-2-9-3"
d="m 17.662185,15.314756 a 1.7373301,1.7294948 0 0 1 -3.47466,0 1.7373301,1.7294948 0 1 1 3.47466,0 z" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ff0034;stroke-width:1.94585049;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 19.867224,1.2387291 20.064478,30.945065 30.716279,30.747022 Z"
id="path3336-5"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,82 @@
<?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="flipping_line.svg"
inkscape:export-filename="/home/dismine/CAD/Valentina/src/app/share/resources/icon/32x32/point_of_contact.png"
inkscape:export-xdpi="92"
inkscape:export-ydpi="92">
<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="7.9121197"
inkscape:cx="21.55347"
inkscape:cy="24.569283"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg2985" />
<defs
id="defs2987" />
<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
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.90600002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1.5658875,1.7702081 25.903239,1.347147 1.5658875,25.250103 Z"
id="path4136"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.5784626;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 29.899487,2.4822417 1.4448327,30.426215"
id="path4138"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.56700003;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.806658,3.5000351 a 1.7373301,1.7294948 0 0 1 -3.47466,0 1.7373301,1.7294948 0 1 1 3.47466,0 z" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.56700003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path2985-2-9-3"
d="m 4.568231,29.217478 a 1.7373301,1.7294948 0 0 1 -3.47466,0 1.7373301,1.7294948 0 1 1 3.47466,0 z" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ff0034;stroke-width:1.85944629;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 30.518196,30.169295 6.5134588,30.577521 30.518196,7.5127354 Z"
id="path4136-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -2532,7 +2532,7 @@ void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElem
QVector<quint32> source;
QVector<DestinationItem> destination;
VToolRotation::ExtractData(this, domElement, source, destination);
VAbstractOperation::ExtractData(this, domElement, source, destination);
VToolRotation::Create(id, center, a, suffix, source, destination, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -2557,6 +2557,66 @@ void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElem
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseToolFlippingByLine(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 quint32 p1 = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
const quint32 p2 = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
const QString suffix = GetParametrString(domElement, AttrSuffix, "");
QVector<quint32> source;
QVector<DestinationItem> destination;
VAbstractOperation::ExtractData(this, domElement, source, destination);
VToolFlippingByLine::Create(id, p1, p2, suffix, source, destination, scene, this, data, parse,
Source::FromFile);
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating operation of flipping by line"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseToolFlippingByAxis(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 quint32 origin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
const auto axisType = static_cast<AxisType>(GetParametrUInt(domElement, AttrAxisType, "1"));
const QString suffix = GetParametrString(domElement, AttrSuffix, "");
QVector<quint32> source;
QVector<DestinationItem> destination;
VAbstractOperation::ExtractData(this, domElement, source, destination);
VToolFlippingByAxis::Create(id, origin, axisType, suffix, source, destination, scene, this, data, parse,
Source::FromFile);
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating operation of flipping by axis"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPattern::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
{
@ -2807,13 +2867,21 @@ void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &dom
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of operation is empty");
const QStringList opers = QStringList() << VToolRotation::ToolType; /*0*/
const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/
<< VToolFlippingByLine::ToolType /*1*/
<< VToolFlippingByAxis::ToolType; /*2*/
switch (opers.indexOf(type))
{
case 0: //VToolRotation::ToolType
ParseToolRotation(scene, domElement, parse);
break;
case 1: //VToolFlippingByLine::ToolType
ParseToolFlippingByLine(scene, domElement, parse);
break;
case 2: //VToolFlippingByAxis::ToolType
ParseToolFlippingByAxis(scene, domElement, parse);
break;
default:
VException e(tr("Unknown operation type '%1'.").arg(type));
throw e;
@ -3319,7 +3387,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) == 45, "Not all tools was used.");
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47, "Not all tools was used.");
QRectF rec;
@ -3431,6 +3499,12 @@ QRectF VPattern::ActiveDrawBoundingRect() const
case Tool::Rotation:
rec = ToolBoundingRect<VToolRotation>(rec, tool.getId());
break;
case Tool::FlippingByLine:
rec = ToolBoundingRect<VToolFlippingByLine>(rec, tool.getId());
break;
case Tool::FlippingByAxis:
rec = ToolBoundingRect<VToolFlippingByAxis>(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

@ -194,6 +194,8 @@ private:
void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
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);
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;

View File

@ -124,6 +124,7 @@ const QString AttrSecondArc = QStringLiteral("secondArc");
const QString AttrCrossPoint = QStringLiteral("crossPoint");
const QString AttrVCrossPoint = QStringLiteral("vCrossPoint");
const QString AttrHCrossPoint = QStringLiteral("hCrossPoint");
const QString AttrAxisType = QStringLiteral("axisType");
const QString AttrC1Center = QStringLiteral("c1Center");
const QString AttrC2Center = QStringLiteral("c2Center");
const QString AttrC1Radius = QStringLiteral("c1Radius");

View File

@ -125,6 +125,7 @@ extern const QString AttrSecondArc;
extern const QString AttrCrossPoint;
extern const QString AttrVCrossPoint;
extern const QString AttrHCrossPoint;
extern const QString AttrAxisType;
extern const QString AttrC1Center;
extern const QString AttrC2Center;
extern const QString AttrC1Radius;

View File

@ -18,6 +18,7 @@
<file>schema/pattern/v0.3.2.xsd</file>
<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/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>
@ -28,5 +29,6 @@
<file>schema/individual_measurements/v0.3.2.xsd</file>
<file>schema/individual_measurements/v0.3.3.xsd</file>
<file>schema/pattern/v0.3.5.xsd</file>
<file>schema/pattern/v0.3.6.xsd</file>
</qresource>
</RCC>

View File

@ -209,6 +209,9 @@
<xs:attribute name="angle" 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">
@ -362,7 +365,7 @@
<xs:attribute name="rotation" type="xs:double"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
<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>
@ -373,15 +376,6 @@
<xs:attribute name="rotation" type="xs:double"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="grainline" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="rotation" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
@ -563,6 +557,12 @@
<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-->
@ -578,4 +578,4 @@
<xs:enumeration value="1"/><!--Cut on Fold-->
</xs:restriction>
</xs:simpleType>
</xs:schema>
</xs:schema>

View File

@ -0,0 +1,590 @@
<?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="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="grainline" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="rotation" type="xs:string"></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

@ -1373,7 +1373,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) == 45);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagPoint);
@ -1444,7 +1444,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) == 45);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagArc);
@ -1505,7 +1505,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) == 45);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
QStringList expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint);
@ -1571,7 +1571,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) == 45);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagOperation);

View File

@ -53,6 +53,7 @@ enum class LabelType : char {NewPatternPiece, NewLabel};
enum class CrossCirclesPoint : char {FirstPoint = 1, SecondPoint = 2};
enum class VCrossCurvesPoint : char {HighestPoint = 1, LowestPoint = 2};
enum class HCrossCurvesPoint : char {LeftmostPoint = 1, RightmostPoint = 2};
enum class AxisType : char {VerticalAxis = 1, HorizontalAxis = 2};
class VContainer;
class VDataTool;

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);
@ -254,7 +256,12 @@ void VPatternConverter::ApplyPatches()
case (0x000304):
ToV0_3_5();
ValidateXML(XSDSchema(0x000305), fileName);
V_FALLTHROUGH
case (0x000305):
ToV0_3_6();
ValidateXML(XSDSchema(0x000306), fileName);
V_FALLTHROUGH
case (0x000306):
break;
default:
break;
@ -422,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

@ -131,6 +131,20 @@ VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref
return arc;
}
//---------------------------------------------------------------------------------------------------------------------
VArc VArc::Flip(const QLineF &axis, const QString &prefix) const
{
const VPointF center = GetCenter().Flip(axis);
const QPointF p1 = VPointF::FlipPF(axis, GetP1());
const QPointF p2 = VPointF::FlipPF(axis, GetP2());
VArc arc(center, GetRadius(), QLineF(center, p1).angle(), QLineF(center, p2).angle());
arc.setName(name() + prefix);
arc.SetFlipped(true);
return arc;
}
//---------------------------------------------------------------------------------------------------------------------
VArc::~VArc()
{}

View File

@ -63,6 +63,7 @@ public:
VArc(const VArc &arc);
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;
virtual ~VArc() Q_DECL_OVERRIDE;
QString GetFormulaRadius () const;

View File

@ -78,6 +78,18 @@ VCubicBezier VCubicBezier::Rotate(const QPointF &originPoint, qreal degrees, con
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier VCubicBezier::Flip(const QLineF &axis, const QString &prefix) const
{
const VPointF p1 = GetP1().Flip(axis);
const VPointF p2 = GetP2().Flip(axis);
const VPointF p3 = GetP3().Flip(axis);
const VPointF p4 = GetP4().Flip(axis);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier::~VCubicBezier()
{

View File

@ -53,6 +53,7 @@ public:
Draw mode = Draw::Calculation);
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;
virtual ~VCubicBezier();
virtual VPointF GetP1() const Q_DECL_OVERRIDE;

View File

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

View File

@ -56,6 +56,7 @@ public:
VCubicBezierPath(const QVector<VPointF> &points, quint32 idObject = 0, Draw mode = Draw::Calculation);
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;
virtual ~VCubicBezierPath();
VPointF &operator[](int indx);

View File

@ -134,6 +134,20 @@ VEllipticalArc VEllipticalArc::Rotate(const QPointF &originPoint, qreal degrees,
return elArc;
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) const
{
const VPointF center = GetCenter().Flip(axis);
const QPointF p1 = VPointF::FlipPF(axis, GetP1());
const QPointF p2 = VPointF::FlipPF(axis, GetP2());
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);
elArc.SetFlipped(true);
return elArc;
}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::~VEllipticalArc()
{}

View File

@ -63,6 +63,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;
virtual ~VEllipticalArc() Q_DECL_OVERRIDE;
@ -99,6 +100,7 @@ private:
static int GetQuadransRad(qreal &rad);
};
Q_DECLARE_METATYPE(VEllipticalArc)
Q_DECLARE_TYPEINFO(VEllipticalArc, Q_MOVABLE_TYPE);
#endif // VELLIPTICALARC_H

View File

@ -33,6 +33,7 @@
#include <QPoint>
#include <QPointF>
#include <QRectF>
#include <QTransform>
#include "../vmisc/def.h"
#include "../vmisc/vmath.h"
@ -575,3 +576,39 @@ int VGObject::GetLengthContour(const QVector<QPointF> &contour, const QVector<QP
}
return qFloor(length);
}
//---------------------------------------------------------------------------------------------------------------------
QTransform VGObject::FlippingMatrix(const QLineF &axis)
{
QTransform matrix;
if (axis.isNull())
{
return matrix;
}
const QLineF axisOX = QLineF(axis.x2(), axis.y2(), axis.x2() + 100, axis.y2()); // Ox axis
const qreal angle = axis.angleTo(axisOX);
const QPointF p2 = axis.p2();
QTransform m;
m.translate(p2.x(), p2.y());
m.rotate(-angle);
m.translate(-p2.x(), -p2.y());
matrix *= m;
m.reset();
m.translate(p2.x(), p2.y());
m.scale(m.m11(), m.m22()*-1);
m.translate(-p2.x(), -p2.y());
matrix *= m;
m.reset();
m.translate(p2.x(), p2.y());
m.rotate(-(360-angle));
m.translate(-p2.x(), -p2.y());
matrix *= m;
return matrix;
}

View File

@ -42,6 +42,7 @@ class QPoint;
class QPointF;
class QRectF;
class VGObjectData;
class QTransform;
/**
* @brief The VGObject class keep information graphical objects.
@ -93,6 +94,8 @@ public:
static int GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints);
static double accuracyPointOnLine;
protected:
static QTransform FlippingMatrix(const QLineF &axis);
private:
QSharedDataPointer<VGObjectData> d;

View File

@ -31,6 +31,7 @@
#include <QLineF>
#include <QPointF>
#include <QString>
#include <QTransform>
//---------------------------------------------------------------------------------------------------------------------
/**
@ -113,6 +114,13 @@ VPointF VPointF::Rotate(const QPointF &originPoint, qreal degrees, const QString
return VPointF(p, name() + prefix, mx(), my());
}
//---------------------------------------------------------------------------------------------------------------------
VPointF VPointF::Flip(const QLineF &axis, const QString &prefix) const
{
const QPointF p = FlipPF(axis, toQPointF());
return VPointF(p, name() + prefix, mx(), my());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mx return offset name respect to x
@ -206,3 +214,10 @@ QPointF VPointF::RotatePF(const QPointF &originPoint, const QPointF &point, qrea
axis.setAngle(axis.angle() + degrees);
return axis.p2();
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VPointF::FlipPF(const QLineF &axis, const QPointF &point)
{
const QTransform matrix = FlippingMatrix(axis);
return matrix.map(point);
}

View File

@ -65,6 +65,7 @@ public:
VPointF &operator=(const VPointF &point);
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;
qreal mx() const;
qreal my() const;
void setMx(qreal mx);
@ -76,6 +77,7 @@ public:
void setY(const qreal &value);
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
static QPointF FlipPF(const QLineF &axis, const QPointF &point);
private:
QSharedDataPointer<VPointFData> d;
};

View File

@ -126,6 +126,20 @@ VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const
{
const VPointF p1 = GetP1().Flip(axis);
const VPointF p4 = GetP4().Flip(axis);
const QPointF p2 = VPointF::FlipPF(axis, GetP2());
const QPointF p3 = VPointF::FlipPF(axis, GetP3());
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
return spl;
}
//---------------------------------------------------------------------------------------------------------------------
VSpline::~VSpline()
{}

View File

@ -63,6 +63,7 @@ public:
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
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;
virtual ~VSpline();
VSpline &operator=(const VSpline &spl);

View File

@ -122,6 +122,28 @@ VSplinePath VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const
return splPath;
}
//---------------------------------------------------------------------------------------------------------------------
VSplinePath VSplinePath::Flip(const QLineF &axis, const QString &prefix) const
{
QVector<VSplinePoint> newPoints(CountPoints());
for (qint32 i = 1; i <= CountSubSpl(); ++i)
{
const VSpline spl = GetSpline(i).Flip(axis);
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

@ -61,6 +61,7 @@ public:
VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject = 0, Draw mode = Draw::Calculation);
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;
virtual ~VSplinePath() Q_DECL_OVERRIDE;
VSplinePath &operator=(const VSplinePath &path);

View File

@ -109,6 +109,8 @@ enum class Tool : ToolVisHolderType
UnionDetails,
Group,
Rotation,
FlippingByLine,
FlippingByAxis,
Midpoint,
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
};
@ -121,6 +123,7 @@ enum class Vis : ToolVisHolderType
SimpleCurve,
Line,
Path,
Operation,
ToolAlongLine,
ToolArc,
ToolArcWithLength,
@ -149,7 +152,9 @@ enum class Vis : ToolVisHolderType
ToolLineIntersectAxis,
ToolCurveIntersectAxis,
ToolTrueDarts,
ToolRotation
ToolRotation,
ToolFlippingByLine,
ToolFlippingByAxis
};
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, LineAngle, CurveAngle, ArcRadius,

View File

@ -62,22 +62,45 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
doc(nullptr),
openingPattern(false)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
QString rules;
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
// Qt < 5.2 didn't feature categorized logging
// Do nothing
#else
// In Qt 5.2 need manualy enable debug information for categories. This work
// because Qt doesn't provide debug information for categories itself. And in this
// case will show our messages. Another situation with Qt 5.3 that has many debug
// messages itself. We don't need this information and can turn on later if need.
// But here Qt already show our debug messages without enabling.
QLoggingCategory::setFilterRules("*.debug=true\n");
rules += QLatin1String("*.debug=true\n");
#endif // QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
#endif // QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 1)
#if defined(V_NO_ASSERT)
// Ignore SSL-related warnings
// See issue #528: Error: QSslSocket: cannot resolve SSLv2_client_method.
rules += QLatin1String("qt.network.ssl.warning=false\n");
// See issue #568: Certificate checking on Mac OS X.
rules += QLatin1String("qt.network.ssl.critical=false\n"
"qt.network.ssl.fatal=false\n");
#endif //defined(V_NO_ASSERT)
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 4, 1)
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
if (not rules.isEmpty())
{
QLoggingCategory::setFilterRules(rules);
}
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
// Enable support for HiDPI bitmap resources
setAttribute(Qt::AA_UseHighDpiPixmaps);
@ -90,14 +113,6 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
// Connect this slot with VApplication::aboutToQuit.
Settings()->sync();
});
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 1)
#if defined(V_NO_ASSERT)
// Ignore SSL-related warnings
// See issue #528: Error: QSslSocket: cannot resolve SSLv2_client_method.
qputenv("QT_LOGGING_RULES", "qt.network.ssl.warning=false");
#endif //defined(V_NO_ASSERT)
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 4, 1)
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -38,7 +38,9 @@ HEADERS += \
$$PWD/tools/dialogcubicbezier.h \
$$PWD/tools/dialogcubicbezierpath.h \
$$PWD/tools/dialoggroup.h \
$$PWD/tools/dialogrotation.h
$$PWD/tools/dialogrotation.h \
$$PWD/tools/dialogflippingbyline.h \
$$PWD/tools/dialogflippingbyaxis.h
SOURCES += \
@ -77,7 +79,9 @@ SOURCES += \
$$PWD/tools/dialogcubicbezier.cpp \
$$PWD/tools/dialogcubicbezierpath.cpp \
$$PWD/tools/dialoggroup.cpp \
$$PWD/tools/dialogrotation.cpp
$$PWD/tools/dialogrotation.cpp \
$$PWD/tools/dialogflippingbyline.cpp \
$$PWD/tools/dialogflippingbyaxis.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \
@ -114,4 +118,6 @@ FORMS += \
$$PWD/tools/dialogcubicbezier.ui \
$$PWD/tools/dialogcubicbezierpath.ui \
$$PWD/tools/dialoggroup.ui \
$$PWD/tools/dialogrotation.ui
$$PWD/tools/dialogrotation.ui \
$$PWD/tools/dialogflippingbyline.ui \
$$PWD/tools/dialogflippingbyaxis.ui

View File

@ -62,6 +62,8 @@
#include "tools/dialogtruedarts.h"
#include "tools/dialoggroup.h"
#include "tools/dialogrotation.h"
#include "tools/dialogflippingbyline.h"
#include "tools/dialogflippingbyaxis.h"
#include "support/dialogeditwrongformula.h"
#include "support/dialogundo.h"

View File

@ -0,0 +1,326 @@
/************************************************************************
**
** @file dialogflippingbyaxis.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 "dialogflippingbyaxis.h"
#include <QColor>
#include <QComboBox>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPointF>
#include <QPointer>
#include <QPushButton>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QSharedPointer>
#include <QStringList>
#include <QToolButton>
#include <Qt>
#include <new>
#include "../../visualization/visualization.h"
#include "../../visualization/line/operation/vistoolflippingbyaxis.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/xml/vdomdocument.h"
#include "../qmuparser/qmudef.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vabstractmainwindow.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "ui_dialogflippingbyaxis.h"
//---------------------------------------------------------------------------------------------------------------------
DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogFlippingByAxis),
objects(),
stage1(true),
m_suffix()
{
ui->setupUi(this);
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxOriginPoint);
FillComboBoxAxisType(ui->comboBoxAxisType);
flagName = true;
CheckState();
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByAxis::SuffixChanged);
connect(ui->comboBoxOriginPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogFlippingByAxis::PointChanged);
vis = new VisToolFlippingByAxis(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogFlippingByAxis::~DialogFlippingByAxis()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogFlippingByAxis::GetOriginPointId() const
{
return getCurrentObjectId(ui->comboBoxOriginPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetOriginPointId(quint32 value)
{
ChangeCurrentData(ui->comboBoxOriginPoint, value);
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr);
operation->SetOriginPointId(value);
}
//---------------------------------------------------------------------------------------------------------------------
AxisType DialogFlippingByAxis::GetAxisType() const
{
return getCurrentCrossPoint<AxisType>(ui->comboBoxAxisType);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetAxisType(AxisType type)
{
auto index = ui->comboBoxAxisType->findData(static_cast<int>(type));
if (index != -1)
{
ui->comboBoxAxisType->setCurrentIndex(index);
auto operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr);
operation->SetAxisType(type);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogFlippingByAxis::GetSuffix() const
{
return m_suffix;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetSuffix(const QString &value)
{
m_suffix = value;
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogFlippingByAxis::GetObjects() const
{
return objects.toVector();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
{
return;
}
stage1 = false;
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
scene->clearSelection();
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->VisualMode();
scene->ToggleArcSelection(false);
scene->ToggleSplineSelection(false);
scene->ToggleSplinePathSelection(false);
scene->ToggleArcHover(false);
scene->ToggleSplineHover(false);
scene->ToggleSplinePathHover(false);
emit ToolTip(tr("Select origin point"));
}
else if (not stage1 && prepare && click)
{
setModal(true);
emit ToolTip("");
show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ChosenObject(quint32 id, const SceneObject &type)
{
if (not stage1 && not prepare)// After first choose we ignore all objects
{
if (type == SceneObject::Point)
{
if (objects.contains(id))
{
emit ToolTip(tr("Select origin point that is not part of the list of objects"));
return;
}
if (SetObject(id, ui->comboBoxOriginPoint, ""))
{
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr);
operation->SetOriginPointId(id);
operation->RefreshGeometry();
prepare = true;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::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 DialogFlippingByAxis::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 DialogFlippingByAxis::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagError && flagName);
SCASSERT(bApply != nullptr);
bApply->setEnabled(bOk->isEnabled());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowVisualization()
{
AddVisualization<VisToolFlippingByAxis>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SaveData()
{
m_suffix = ui->lineEditSuffix->text();
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->SetOriginPointId(GetOriginPointId());
operation->SetAxisType(GetAxisType());
operation->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::PointChanged()
{
QColor color = okColor;
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = okColor;
}
ChangeColor(ui->labelOriginPoint, color);
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::FillComboBoxAxisType(QComboBox *box)
{
SCASSERT(box != nullptr);
box->addItem(tr("Vertical axis"), QVariant(static_cast<int>(AxisType::VerticalAxis)));
box->addItem(tr("Horizontal axis"), QVariant(static_cast<int>(AxisType::HorizontalAxis)));
}

View File

@ -0,0 +1,104 @@
/************************************************************************
**
** @file dialogflippingbyaxis.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 DIALOGFLIPPINGBYAXIS_H
#define DIALOGFLIPPINGBYAXIS_H
#include "dialogtool.h"
#include <qcompilerdetection.h>
#include <QList>
#include <QMetaObject>
#include <QObject>
#include <QString>
#include <QVector>
#include <QtGlobal>
#include "../vmisc/def.h"
class QWidget;
class VContainer;
namespace Ui
{
class DialogFlippingByAxis;
}
class DialogFlippingByAxis : public DialogTool
{
Q_OBJECT
public:
explicit DialogFlippingByAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogFlippingByAxis();
quint32 GetOriginPointId() const;
void SetOriginPointId(quint32 value);
AxisType GetAxisType() const;
void SetAxisType(AxisType type);
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:
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;
private slots:
void PointChanged();
private:
Q_DISABLE_COPY(DialogFlippingByAxis)
Ui::DialogFlippingByAxis *ui;
QList<quint32> objects;
bool stage1;
QString m_suffix;
static void FillComboBoxAxisType(QComboBox *box);
};
#endif // DIALOGFLIPPINGBYAXIS_H

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogFlippingByAxis</class>
<widget class="QDialog" name="DialogFlippingByAxis">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>146</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelOriginPoint">
<property name="text">
<string>Origin point:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxOriginPoint"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSuffix">
<property name="text">
<string>Suffix:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditSuffix"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelAxisType">
<property name="text">
<string>Axis type:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxAxisType"/>
</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/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogFlippingByAxis</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>DialogFlippingByAxis</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

@ -0,0 +1,359 @@
/************************************************************************
**
** @file dialogflippingbyline.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 "dialogflippingbyline.h"
#include <QColor>
#include <QComboBox>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QPointF>
#include <QPointer>
#include <QPushButton>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QSharedPointer>
#include <QStringList>
#include <QToolButton>
#include <Qt>
#include <new>
#include "../../visualization/visualization.h"
#include "../../visualization/line/operation/vistoolflippingbyline.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/xml/vdomdocument.h"
#include "../qmuparser/qmudef.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vabstractmainwindow.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "ui_dialogflippingbyline.h"
//---------------------------------------------------------------------------------------------------------------------
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogFlippingByLine),
objects(),
stage1(true),
m_suffix()
{
ui->setupUi(this);
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
flagName = true;
CheckState();
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByLine::SuffixChanged);
connect(ui->comboBoxFirstLinePoint,
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogFlippingByLine::PointChanged);
connect(ui->comboBoxSecondLinePoint,
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogFlippingByLine::PointChanged);
vis = new VisToolFlippingByLine(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogFlippingByLine::~DialogFlippingByLine()
{
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogFlippingByLine::GetFirstLinePointId() const
{
return getCurrentObjectId(ui->comboBoxFirstLinePoint);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetFirstLinePointId(quint32 value)
{
ChangeCurrentData(ui->comboBoxFirstLinePoint, value);
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr);
operation->SetFirstLinePointId(value);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogFlippingByLine::GetSecondLinePointId() const
{
return getCurrentObjectId(ui->comboBoxSecondLinePoint);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetSecondLinePointId(quint32 value)
{
ChangeCurrentData(ui->comboBoxSecondLinePoint, value);
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr);
operation->SetSecondLinePointId(value);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogFlippingByLine::GetSuffix() const
{
return m_suffix;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetSuffix(const QString &value)
{
m_suffix = value;
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogFlippingByLine::GetObjects() const
{
return objects.toVector();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
{
return;
}
stage1 = false;
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
scene->clearSelection();
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->VisualMode();
scene->ToggleArcSelection(false);
scene->ToggleSplineSelection(false);
scene->ToggleSplinePathSelection(false);
scene->ToggleArcHover(false);
scene->ToggleSplineHover(false);
scene->ToggleSplinePathHover(false);
emit ToolTip(tr("Select first line point"));
}
else if (not stage1 && prepare && click)
{
setModal(true);
emit ToolTip("");
show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (not stage1 && not prepare)// After first choose we ignore all objects
{
if (type == SceneObject::Point)
{
switch (number)
{
case 0:
if (objects.contains(id))
{
emit ToolTip(tr("Select first line point that is not part of the list of objects"));
return;
}
if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second line point")))
{
number++;
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr);
operation->SetFirstLinePointId(id);
operation->RefreshGeometry();
}
break;
case 1:
if (objects.contains(id))
{
emit ToolTip(tr("Select second line point that is not part of the list of objects"));
return;
}
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id)
{
if (SetObject(id, ui->comboBoxSecondLinePoint, ""))
{
if (flagError)
{
number = 0;
prepare = true;
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr);
operation->SetSecondLinePointId(id);
operation->RefreshGeometry();
}
}
}
break;
default:
break;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::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 DialogFlippingByLine::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 DialogFlippingByLine::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagError && flagName);
SCASSERT(bApply != nullptr);
bApply->setEnabled(bOk->isEnabled());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowVisualization()
{
AddVisualization<VisToolFlippingByLine>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SaveData()
{
m_suffix = ui->lineEditSuffix->text();
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr);
operation->SetObjects(objects.toVector());
operation->SetFirstLinePointId(GetFirstLinePointId());
operation->SetSecondLinePointId(GetSecondLinePointId());
operation->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::PointChanged()
{
QColor color = okColor;
flagError = true;
ChangeColor(ui->labelFirstLinePoint, color);
ChangeColor(ui->labelSecondLinePoint, color);
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) == getCurrentObjectId(ui->comboBoxSecondLinePoint))
{
flagError = false;
color = errorColor;
ChangeColor(ui->labelFirstLinePoint, color);
ChangeColor(ui->labelSecondLinePoint, color);
}
else if (objects.contains(getCurrentObjectId(ui->comboBoxFirstLinePoint)))
{
flagError = false;
color = errorColor;
ChangeColor(ui->labelFirstLinePoint, color);
}
else if (objects.contains(getCurrentObjectId(ui->comboBoxSecondLinePoint)))
{
flagError = false;
color = errorColor;
ChangeColor(ui->labelSecondLinePoint, color);
}
CheckState();
}

View File

@ -0,0 +1,102 @@
/************************************************************************
**
** @file dialogflippingbyline.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 DIALOGFLIPPINGBYLINE_H
#define DIALOGFLIPPINGBYLINE_H
#include "dialogtool.h"
#include <qcompilerdetection.h>
#include <QList>
#include <QMetaObject>
#include <QObject>
#include <QString>
#include <QVector>
#include <QtGlobal>
#include "../vmisc/def.h"
class QWidget;
class VContainer;
namespace Ui
{
class DialogFlippingByLine;
}
class DialogFlippingByLine : public DialogTool
{
Q_OBJECT
public:
explicit DialogFlippingByLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogFlippingByLine();
quint32 GetFirstLinePointId() const;
void SetFirstLinePointId(quint32 value);
quint32 GetSecondLinePointId() const;
void SetSecondLinePointId(quint32 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:
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;
private slots:
void PointChanged();
private:
Q_DISABLE_COPY(DialogFlippingByLine)
Ui::DialogFlippingByLine *ui;
QList<quint32> objects;
bool stage1;
QString m_suffix;
};
#endif // DIALOGFLIPPINGBYLINE_H

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogFlippingByLine</class>
<widget class="QDialog" name="DialogFlippingByLine">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>146</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="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelFirstLinePoint">
<property name="text">
<string>First line point:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxFirstLinePoint"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSuffix">
<property name="text">
<string>Suffix:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditSuffix"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelSecondLinePoint">
<property name="text">
<string>Second line point:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxSecondLinePoint"/>
</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>DialogFlippingByLine</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>DialogFlippingByLine</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

@ -48,7 +48,7 @@
#include <new>
#include "../../visualization/visualization.h"
#include "../../visualization/line/vistoolrotation.h"
#include "../../visualization/line/operation/vistoolrotation.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/xml/vdomdocument.h"
#include "../qmuparser/qmudef.h"
@ -197,7 +197,7 @@ void DialogRotation::ShowDialog(bool click)
scene->ToggleSplineHover(false);
scene->ToggleSplinePathHover(false);
emit ToolTip("Select origin point");
emit ToolTip(tr("Select origin point"));
}
else if (not stage1 && prepare && click)
{
@ -234,6 +234,7 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
{
if (objects.contains(id))
{
emit ToolTip(tr("Select origin point that is not part of the list of objects"));
return;
}

View File

@ -59,5 +59,7 @@
#include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
#include "toolpoint/tooldoublepoint/vtooltruedarts.h"
#include "operation/vtoolrotation.h"
#include "operation/flipping/vtoolflippingbyline.h"
#include "operation/flipping/vtoolflippingbyaxis.h"
#endif // DRAWTOOLS_H

View File

@ -0,0 +1,195 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 "vabstractflipping.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"
//---------------------------------------------------------------------------------------------------------------------
VAbstractFlipping::~VAbstractFlipping()
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractFlipping::VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
QGraphicsItem *parent)
: VAbstractOperation(doc, data, id, suffix, source, destination, parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFlipping::CreateDestination(Source typeCreation, quint32 &id, QVector<DestinationItem> &dest,
const QVector<quint32> &source, const QPointF &fPoint, const QPointF &sPoint,
const QString &suffix, VAbstractPattern *doc, VContainer *data,
const Document &parse)
{
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, fPoint, sPoint, suffix, data));
break;
case GOType::Arc:
dest.append(CreateArc(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::EllipticalArc:
//dest.append(CreateItem<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix));
break;
case GOType::Spline:
dest.append(CreateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::SplinePath:
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::CubicBezier:
dest.append(CreateCurve<VCubicBezier>(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::CubicBezierPath:
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, fPoint, sPoint, 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, fPoint, sPoint, suffix, data, dest.at(i).id, dest.at(i).mx,
dest.at(i).my);
break;
case GOType::Arc:
UpdateArc(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
break;
case GOType::EllipticalArc:
//dest.append(UpdateItem<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::Spline:
UpdateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
break;
case GOType::SplinePath:
UpdateCurveWithSegments<VSplinePath>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
break;
case GOType::CubicBezier:
UpdateCurve<VCubicBezier>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
break;
case GOType::CubicBezierPath:
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, fPoint, sPoint, suffix, data,
dest.at(i).id);
break;
case GOType::Unknown:
break;
}
QT_WARNING_POP
}
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
DestinationItem item;
item.mx = rotated.mx();
item.my = rotated.my();
item.id = data->AddGObject(new VPointF(rotated));
return item;
}
//---------------------------------------------------------------------------------------------------------------------
DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<VArc>(idTool, idItem, firstPoint, secondPoint, suffix, data);
data->AddArc(data->GeometricObject<VArc>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFlipping::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id,
qreal mx, qreal my)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
rotated.setMx(mx);
rotated.setMy(my);
data->UpdateGObject(id, new VPointF(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFlipping::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<VArc>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
data->AddArc(data->GeometricObject<VArc>(id), id);
}

View File

@ -0,0 +1,151 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 VABSTRACTFLIPPING_H
#define VABSTRACTFLIPPING_H
#include <QtGlobal>
#include "../vabstractoperation.h"
class VAbstractFlipping : public VAbstractOperation
{
Q_OBJECT
public:
virtual ~VAbstractFlipping();
protected:
VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
QGraphicsItem *parent = nullptr);
static void CreateDestination(Source typeCreation, quint32 &id, QVector<DestinationItem> &dest,
const QVector<quint32> &source, const QPointF &fPoint, const QPointF &sPoint,
const QString &suffix, VAbstractPattern *doc, VContainer *data,
const Document &parse);
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my);
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data,
quint32 id);
private:
Q_DISABLE_COPY(VAbstractFlipping)
};
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
item.id = data->AddGObject(new Item(rotated));
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
data->AddCurve(data->GeometricObject<Item>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix,
VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
{
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
data->UpdateGObject(id, new Item(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
data->AddCurve(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data,
quint32 id)
{
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
}
#endif // VABSTRACTFLIPPING_H

View File

@ -0,0 +1,248 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 "vtoolflippingbyaxis.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/dialogflippingbyaxis.h"
#include "../../../../visualization/line/operation/vistoolflippingbyaxis.h"
#include "../../../../visualization/visualization.h"
#include "../vgeometry/vpointf.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 VToolFlippingByAxis::ToolType = QStringLiteral("flippingByAxis");
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByAxis::~VToolFlippingByAxis()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::setDialog()
{
SCASSERT(dialog != nullptr);
DialogFlippingByAxis *dialogTool = qobject_cast<DialogFlippingByAxis*>(dialog);
SCASSERT(dialogTool != nullptr);
dialogTool->SetOriginPointId(m_originPointId);
dialogTool->SetAxisType(m_axisType);
dialogTool->SetSuffix(suffix);
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByAxis *VToolFlippingByAxis::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogFlippingByAxis *dialogTool = qobject_cast<DialogFlippingByAxis*>(dialog);
SCASSERT(dialogTool != nullptr);
const quint32 originPointId = dialogTool->GetOriginPointId();
const AxisType axisType = dialogTool->GetAxisType();
const QString suffix = dialogTool->GetSuffix();
const QVector<quint32> source = dialogTool->GetObjects();
VToolFlippingByAxis* operation = Create(0, originPointId, axisType, suffix, source, QVector<DestinationItem>(),
scene, doc, data, Document::FullParse, Source::FromGui);
if (operation != nullptr)
{
operation->dialog = dialogTool;
}
return operation;
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByAxis *VToolFlippingByAxis::Create(const quint32 _id, quint32 originPointId, AxisType axisType,
const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{
const auto originPoint = *data->GeometricObject<VPointF>(originPointId);
const QPointF fPoint = originPoint;
QPointF sPoint;
if (axisType == AxisType::VerticalAxis)
{
sPoint = QPointF(fPoint.x(), fPoint.y() + 100);
}
else
{
sPoint = QPointF(fPoint.x() + 100, fPoint.y());
}
QVector<DestinationItem> dest = destination;
quint32 id = _id;
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
VDrawTool::AddRecord(id, Tool::FlippingByAxis, doc);
if (parse == Document::FullParse)
{
VToolFlippingByAxis *tool = new VToolFlippingByAxis(doc, data, id, originPointId, axisType, suffix, source,
dest, typeCreation);
scene->addItem(tool);
InitOperationToolConnections(scene, tool);
doc->AddTool(id, tool);
doc->IncrementReferens(originPoint.getIdTool());
for (int i = 0; i < source.size(); ++i)
{
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
}
return tool;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
AxisType VToolFlippingByAxis::GetAxisType() const
{
return m_axisType;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::SetAxisType(AxisType value)
{
m_axisType = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::ShowVisualization(bool show)
{
ShowToolVisualization<VisToolFlippingByAxis>(show);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::SetVisualization()
{
if (vis != nullptr)
{
VisToolFlippingByAxis *visual = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(visual != nullptr);
visual->SetObjects(source);
visual->SetOriginPointId(m_originPointId);
visual->SetAxisType(m_axisType);
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogFlippingByAxis *dialogTool = qobject_cast<DialogFlippingByAxis*>(dialog);
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId()));
doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast<int>(dialogTool->GetAxisType())));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::ReadToolAttributes(const QDomElement &domElement)
{
m_originPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
m_axisType = static_cast<AxisType>(doc->GetParametrUInt(domElement, AttrAxisType, "1"));
suffix = doc->GetParametrString(domElement, AttrSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VDrawTool::SaveOptions(tag, obj);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrCenter, QString().setNum(m_originPointId));
doc->SetAttribute(tag, AttrAxisType, QString().setNum(static_cast<int>(m_axisType)));
doc->SetAttribute(tag, AttrSuffix, suffix);
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
try
{
ContextMenu<DialogFlippingByAxis>(this, event);
}
catch(const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e);
return;//Leave this method immediately!!!
}
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByAxis::VToolFlippingByAxis(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 originPointId,
AxisType axisType, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const Source &typeCreation, QGraphicsItem *parent)
: VAbstractFlipping(doc, data, id, suffix, source, destination, parent),
m_originPointId(originPointId),
m_axisType(axisType)
{
InitOperatedObjects();
ToolCreation(typeCreation);
}

View File

@ -0,0 +1,77 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 VTOOLFLIPPINGBYAXIS_H
#define VTOOLFLIPPINGBYAXIS_H
#include <QtGlobal>
#include "vabstractflipping.h"
class VToolFlippingByAxis : public VAbstractFlipping
{
Q_OBJECT
public:
virtual ~VToolFlippingByAxis();
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolFlippingByAxis* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolFlippingByAxis* Create(const quint32 _id, quint32 originPointId, AxisType axisType,
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::FlippingByAxis)};
AxisType GetAxisType() const;
void SetAxisType(AxisType 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(VToolFlippingByAxis)
quint32 m_originPointId;
AxisType m_axisType;
VToolFlippingByAxis(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 originPointId,
AxisType axisType, const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, const Source &typeCreation,
QGraphicsItem *parent = nullptr);
};
#endif // VTOOLFLIPPINGBYAXIS_H

View File

@ -0,0 +1,227 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 "vtoolflippingbyline.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/dialogflippingbyline.h"
#include "../../../../visualization/line/operation/vistoolflippingbyline.h"
#include "../../../../visualization/visualization.h"
#include "../vgeometry/vpointf.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 VToolFlippingByLine::ToolType = QStringLiteral("flippingByLine");
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByLine::~VToolFlippingByLine()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByLine::setDialog()
{
SCASSERT(dialog != nullptr);
DialogFlippingByLine *dialogTool = qobject_cast<DialogFlippingByLine*>(dialog);
SCASSERT(dialogTool != nullptr);
dialogTool->SetFirstLinePointId(m_firstLinePointId);
dialogTool->SetSecondLinePointId(m_secondLinePointId);
dialogTool->SetSuffix(suffix);
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByLine *VToolFlippingByLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogFlippingByLine *dialogTool = qobject_cast<DialogFlippingByLine*>(dialog);
SCASSERT(dialogTool != nullptr);
const quint32 firstLinePointId = dialogTool->GetFirstLinePointId();
const quint32 secondLinePointId = dialogTool->GetSecondLinePointId();
const QString suffix = dialogTool->GetSuffix();
const QVector<quint32> source = dialogTool->GetObjects();
VToolFlippingByLine* operation = Create(0, firstLinePointId, secondLinePointId, suffix, source,
QVector<DestinationItem>(), scene, doc, data, Document::FullParse,
Source::FromGui);
if (operation != nullptr)
{
operation->dialog = dialogTool;
}
return operation;
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByLine *VToolFlippingByLine::Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{
const auto firstPoint = *data->GeometricObject<VPointF>(firstLinePointId);
const QPointF fPoint = firstPoint;
const auto secondPoint = *data->GeometricObject<VPointF>(secondLinePointId);
const QPointF sPoint = secondPoint;
QVector<DestinationItem> dest = destination;
quint32 id = _id;
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
VDrawTool::AddRecord(id, Tool::FlippingByLine, doc);
if (parse == Document::FullParse)
{
VToolFlippingByLine *tool = new VToolFlippingByLine(doc, data, id, firstLinePointId, secondLinePointId, suffix,
source, dest, typeCreation);
scene->addItem(tool);
InitOperationToolConnections(scene, tool);
doc->AddTool(id, tool);
doc->IncrementReferens(firstPoint.getIdTool());
doc->IncrementReferens(secondPoint.getIdTool());
for (int i = 0; i < source.size(); ++i)
{
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
}
return tool;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByLine::ShowVisualization(bool show)
{
ShowToolVisualization<VisToolFlippingByLine>(show);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByLine::SetVisualization()
{
if (vis != nullptr)
{
VisToolFlippingByLine *visual = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(visual != nullptr);
visual->SetObjects(source);
visual->SetFirstLinePointId(m_firstLinePointId);
visual->SetSecondLinePointId(m_secondLinePointId);
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByLine::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogFlippingByLine *dialogTool = qobject_cast<DialogFlippingByLine*>(dialog);
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId()));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByLine::ReadToolAttributes(const QDomElement &domElement)
{
m_firstLinePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
m_secondLinePointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
suffix = doc->GetParametrString(domElement, AttrSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VDrawTool::SaveOptions(tag, obj);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrP1Line, QString().setNum(m_firstLinePointId));
doc->SetAttribute(tag, AttrP2Line, QString().setNum(m_secondLinePointId));
doc->SetAttribute(tag, AttrSuffix, suffix);
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolFlippingByLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
try
{
ContextMenu<DialogFlippingByLine>(this, event);
}
catch(const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e);
return;//Leave this method immediately!!!
}
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByLine::VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
quint32 secondLinePointId, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const Source &typeCreation, QGraphicsItem *parent)
: VAbstractFlipping(doc, data, id, suffix, source, destination, parent),
m_firstLinePointId(firstLinePointId),
m_secondLinePointId(secondLinePointId)
{
InitOperatedObjects();
ToolCreation(typeCreation);
}

View File

@ -0,0 +1,74 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 VTOOLFLIPPINGBYLINE_H
#define VTOOLFLIPPINGBYLINE_H
#include <QtGlobal>
#include "vabstractflipping.h"
class VToolFlippingByLine : public VAbstractFlipping
{
Q_OBJECT
public:
virtual ~VToolFlippingByLine();
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolFlippingByLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolFlippingByLine* Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
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::FlippingByLine)};
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(VToolFlippingByLine)
quint32 m_firstLinePointId;
quint32 m_secondLinePointId;
VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
quint32 secondLinePointId, const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, const Source &typeCreation,
QGraphicsItem *parent = nullptr);
};
#endif // VTOOLFLIPPINGBYLINE_H

View File

@ -0,0 +1,610 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 "vabstractoperation.h"
#include "../../../undocommands/label/operationmovelabel.h"
#include "../vgeometry/vpointf.h"
const QString VAbstractOperation::TagItem = QStringLiteral("item");
const QString VAbstractOperation::TagSource = QStringLiteral("source");
const QString VAbstractOperation::TagDestination = QStringLiteral("destination");
//---------------------------------------------------------------------------------------------------------------------
VAbstractOperation::~VAbstractOperation()
{
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractOperation::getTagName() const
{
return VAbstractPattern::TagOperation;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::SetEnabled(bool enabled)
{
this->setEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractOperation::Suffix() const
{
return suffix;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::SetSuffix(const QString &suffix)
{
// Don't know if need check name here.
this->suffix = suffix;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::GroupVisibility(quint32 object, bool visible)
{
if (operatedObjects.contains(object))
{
VAbstractSimple *obj = operatedObjects.value(object);
if (obj->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
SCASSERT(item != nullptr);
item->setVisible(visible);
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(obj);
SCASSERT(item != nullptr);
item->setVisible(visible);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(painter);
Q_UNUSED(option);
Q_UNUSED(widget);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
QVector<DestinationItem> &destination)
{
SCASSERT(doc != nullptr)
const QDomNodeList nodeList = domElement.childNodes();
for (qint32 i = 0; i < nodeList.size(); ++i)
{
const QDomElement dataElement = nodeList.at(i).toElement();
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
{
source.clear();
const QDomNodeList srcList = dataElement.childNodes();
for (qint32 j = 0; j < srcList.size(); ++j)
{
const QDomElement element = srcList.at(j).toElement();
if (not element.isNull())
{
source.append(doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
}
}
}
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
{
destination.clear();
const QDomNodeList srcList = dataElement.childNodes();
for (qint32 j = 0; j < srcList.size(); ++j)
{
const QDomElement element = srcList.at(j).toElement();
if (not element.isNull())
{
DestinationItem d;
d.id = doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
d.mx = qApp->toPixel(doc->GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
d.my = qApp->toPixel(doc->GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
destination.append(d);
}
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::FullUpdateFromFile()
{
ReadAttributes();
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
}
}
SetVisualization();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowHover(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setAcceptHoverEvents(enabled);
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->setAcceptHoverEvents(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowSelecting(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowPointHover(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setAcceptHoverEvents(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowPointSelecting(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowPointLabelHover(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->AllowLabelHover(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowPointLabelSelecting(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->AllowLabelSelecting(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowSplineHover(bool enabled)
{
AllowCurveHover(enabled, GOType::Spline);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowSplineSelecting(bool enabled)
{
AllowCurveSelecting(enabled, GOType::Spline);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowSplinePathHover(bool enabled)
{
AllowCurveHover(enabled, GOType::SplinePath);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowSplinePathSelecting(bool enabled)
{
AllowCurveSelecting(enabled, GOType::SplinePath);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowArcHover(bool enabled)
{
AllowCurveHover(enabled, GOType::Arc);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowArcSelecting(bool enabled)
{
AllowCurveSelecting(enabled, GOType::Arc);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
SetEnabled(enabled);
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
i.value()->SetEnabled(enabled);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::ObjectSelected(bool selected, quint32 objId)
{
emit ChangedToolSelection(selected, objId, id);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::DeleteFromLabel()
{
try
{
DeleteTool();
}
catch(const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e);
return;//Leave this method immediately!!!
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::LabelChangePosition(const QPointF &pos, quint32 labelId)
{
if (operatedObjects.contains(labelId))
{
VAbstractSimple *obj = operatedObjects.value(labelId);
if (obj->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
SCASSERT(item != nullptr);
ChangePosition(item, labelId, pos);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractOperation::VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
QGraphicsItem *parent)
: VDrawTool(doc, data, id),
QGraphicsLineItem(parent),
suffix(suffix),
source(source),
destination(destination),
operatedObjects()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AddToFile()
{
QDomElement domElement = doc->createElement(getTagName());
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOptions(domElement, obj);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOptions(domElement, obj);
}
else
{
qCDebug(vTool, "Can't find tool with id = %u", id);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::UpdateNamePosition(quint32 id)
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
auto moveLabel = new OperationMoveLabel(this->id, doc, point->mx(), point->my(), id);
connect(moveLabel, &OperationMoveLabel::ChangePosition, this, &VAbstractOperation::DoChangePosition);
qApp->getUndoStack()->push(moveLabel);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
{
doc->RemoveAllChildren(tag);
QDomElement tagObjects = doc->createElement(TagSource);
for (int i = 0; i < source.size(); ++i)
{
QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, source.at(i));
tagObjects.appendChild(item);
}
tag.appendChild(tagObjects);
tagObjects = doc->createElement(TagDestination);
for (int i = 0; i < destination.size(); ++i)
{
QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, destination.at(i).id);
if (not VFuzzyComparePossibleNulls(destination.at(i).mx, INT_MAX) &&
not VFuzzyComparePossibleNulls(destination.at(i).my, INT_MAX))
{
doc->SetAttribute(item, AttrMx, qApp->fromPixel(destination.at(i).mx));
doc->SetAttribute(item, AttrMy, qApp->fromPixel(destination.at(i).my));
}
tagObjects.appendChild(item);
}
tag.appendChild(tagObjects);
}
//---------------------------------------------------------------------------------------------------------------------
VSimpleCurve *VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveType)
{
VSimpleCurve *curve = new VSimpleCurve(id, QColor(baseColor), *data->GetPatternUnit(), &factor);
curve->setParentItem(this);
curve->SetType(curveType);
connect(curve, &VSimpleCurve::Selected, this, &VAbstractOperation::ObjectSelected);
connect(curve, &VSimpleCurve::ShowContextMenu, [this](QGraphicsSceneContextMenuEvent * event)
{
contextMenuEvent(event);
});
connect(curve, &VSimpleCurve::Delete, this, &VAbstractOperation::DeleteFromLabel);
curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
operatedObjects.insert(id, curve);
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::DoChangePosition(quint32 id, qreal mx, qreal my)
{
if (operatedObjects.contains(id))
{
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
point->setMx(mx);
point->setMy(my);
VAbstractTool::data.UpdateGObject(id, point);
VSimplePoint *item = qobject_cast<VSimplePoint *>(operatedObjects.value(id));
SCASSERT(item != nullptr);
item->RefreshGeometry(*point);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowCurveHover(bool enabled, GOType type)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() != GOType::Point)
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
if (item->GetType() == type)
{
item->setAcceptHoverEvents(enabled);
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowCurveSelecting(bool enabled, GOType type)
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() != GOType::Point)
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
if (item->GetType() == type)
{
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos)
{
const QPointF p = pos - item->pos();
DoChangePosition(id, p.x(), p.y());
UpdateNamePosition(id);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::InitOperatedObjects()
{
for (int i = 0; i < destination.size(); ++i)
{
const DestinationItem object = destination.at(i);
const QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(object.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.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
{
VSimplePoint *point = new VSimplePoint(object.id, QColor(baseColor),
*VAbstractTool::data.GetPatternUnit(), &factor);
point->setParentItem(this);
point->SetType(GOType::Point);
connect(point, &VSimplePoint::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Point);
});
connect(point, &VSimplePoint::Selected, this, &VAbstractOperation::ObjectSelected);
connect(point, &VSimplePoint::ShowContextMenu, [this](QGraphicsSceneContextMenuEvent * event)
{
contextMenuEvent(event);
});
connect(point, &VSimplePoint::Delete, this, &VAbstractOperation::DeleteFromLabel);
connect(point, &VSimplePoint::NameChangedPosition, this, &VAbstractOperation::LabelChangePosition);
point->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(object.id));
operatedObjects.insert(object.id, point);
break;
}
case GOType::Arc:
case GOType::EllipticalArc:
{
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::Arc);
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Arc);
});
break;
}
case GOType::Spline:
case GOType::CubicBezier:
{
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::Spline);
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Spline);
});
break;
}
case GOType::SplinePath:
case GOType::CubicBezierPath:
{
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::SplinePath);
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::SplinePath);
});
break;
}
case GOType::Unknown:
break;
}
QT_WARNING_POP
}
}

View File

@ -0,0 +1,203 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 VABSTRACTOPERATION_H
#define VABSTRACTOPERATION_H
#include <QtGlobal>
#include <qcompilerdetection.h>
#include <QMap>
#include <QMetaObject>
#include <QObject>
#include <QString>
#include <QVector>
#include <QGraphicsLineItem>
#include "../vdrawtool.h"
#include "../vwidgets/vsimplecurve.h"
#include "../vwidgets/vsimplepoint.h"
struct DestinationItem
{
quint32 id;
qreal mx;
qreal my;
};
class VAbstractSimple;
class VAbstractPattern;
class QDomElement;
class QPainter;
class QPointF;
class QStyleOptionGraphicsItem;
class QWidget;
class VContainer;
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
// QGraphicsItem itself produce case where clicking on empty space produce call to QGraphicsItem.
// And i don't know how to fix it.
class VAbstractOperation : public VDrawTool, public QGraphicsLineItem
{
Q_OBJECT
// Fix warning "Class implements the interface QGraphicsItem but does not list it
// in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!"
Q_INTERFACES(QGraphicsItem)
public:
virtual ~VAbstractOperation();
static const QString TagItem;
static const QString TagSource;
static const QString TagDestination;
virtual QString getTagName() const Q_DECL_OVERRIDE;
void SetEnabled(bool enabled);
QString Suffix() const;
void SetSuffix(const QString &suffix);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
static void ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
QVector<DestinationItem> &destination);
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
void AllowPointHover(bool enabled);
void AllowPointSelecting(bool enabled);
void AllowPointLabelHover(bool enabled);
void AllowPointLabelSelecting(bool enabled);
void AllowSplineHover(bool enabled);
void AllowSplineSelecting(bool enabled);
void AllowSplinePathHover(bool enabled);
void AllowSplinePathSelecting(bool enabled);
void AllowArcHover(bool enabled);
void AllowArcSelecting(bool enabled);
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
void ObjectSelected(bool selected, quint32 objId);
void DeleteFromLabel();
void LabelChangePosition(const QPointF &pos, quint32 labelId);
protected:
QString suffix;
QVector<quint32> source;
QVector<DestinationItem> destination;
QMap<quint32, VAbstractSimple *> operatedObjects;
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
QGraphicsItem *parent = nullptr);
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
void UpdateNamePosition(quint32 id);
void SaveSourceDestination(QDomElement &tag);
template <typename T>
void ShowToolVisualization(bool show);
VSimpleCurve *InitCurve(quint32 id, VContainer *data, GOType curveType);
template <typename T>
static void InitOperationToolConnections(VMainGraphicsScene *scene, T *tool);
void InitOperatedObjects();
protected slots:
void DoChangePosition(quint32 id, qreal mx, qreal my);
private:
Q_DISABLE_COPY(VAbstractOperation)
void AllowCurveHover(bool enabled, GOType type);
void AllowCurveSelecting(bool enabled, GOType type);
void ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos);
};
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractOperation::ShowToolVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
AddVisualization<T>();
SetVisualization();
}
else
{
if (T *visual = qobject_cast<T *>(vis))
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractOperation::InitOperationToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
InitDrawToolConnections(scene, tool);
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemHover, tool, &T::AllowPointHover);
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemSelection, tool, &T::AllowPointSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemHover, tool, &T::AllowPointLabelHover);
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, tool, &T::AllowPointLabelSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemHover, tool, &T::AllowSplineHover);
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemSelection, tool, &T::AllowSplineSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemHover, tool, &T::AllowSplinePathHover);
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemSelection, tool, &T::AllowSplinePathSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemHover, tool, &T::AllowArcHover);
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowArcSelecting);
}
#endif // VABSTRACTOPERATION_H

View File

@ -44,8 +44,7 @@
#include "../../../dialogs/tools/dialogtool.h"
#include "../../../dialogs/tools/dialogrotation.h"
#include "../../../undocommands/label/rotationmovelabel.h"
#include "../../../visualization/line/vistoolrotation.h"
#include "../../../visualization/line/operation/vistoolrotation.h"
#include "../../../visualization/visualization.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
@ -66,8 +65,6 @@
#include "../ifc/exception/vexception.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../vwidgets/vsimplecurve.h"
#include "../vwidgets/vsimplepoint.h"
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../vdrawtool.h"
@ -79,90 +76,18 @@ class QStyleOptionGraphicsItem;
class QWidget;
template <class T> class QSharedPointer;
const QString VToolRotation::ToolType = QStringLiteral("rotation");
const QString VToolRotation::TagItem = QStringLiteral("item");
const QString VToolRotation::TagSource = QStringLiteral("source");
const QString VToolRotation::TagDestination = QStringLiteral("destination");
const QString VToolRotation::ToolType = QStringLiteral("rotation");
//---------------------------------------------------------------------------------------------------------------------
VToolRotation::VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
const QString &angle, const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, const Source &typeCreation,
QGraphicsItem *parent)
: VDrawTool(doc, data, id),
QGraphicsLineItem(parent),
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
origPointId(origPointId),
formulaAngle(angle),
suffix(suffix),
source(source),
destination(destination),
rObjects()
formulaAngle(angle)
{
for (int i = 0; i < destination.size(); ++i)
{
const DestinationItem object = destination.at(i);
const QSharedPointer<VGObject> obj = data->GetGObject(object.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.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
{
VSimplePoint *point = new VSimplePoint(object.id, QColor(baseColor), *data->GetPatternUnit(), &factor);
point->setParentItem(this);
point->SetType(GOType::Point);
connect(point, &VSimplePoint::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Point);
});
connect(point, &VSimplePoint::Selected, this, &VToolRotation::ObjectSelected);
connect(point, &VSimplePoint::ShowContextMenu, this, &VToolRotation::contextMenuEvent);
connect(point, &VSimplePoint::Delete, this, &VToolRotation::DeleteFromLabel);
connect(point, &VSimplePoint::NameChangedPosition, this, &VToolRotation::LabelChangePosition);
point->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(object.id));
rObjects.insert(object.id, point);
break;
}
case GOType::Arc:
case GOType::EllipticalArc:
{
VSimpleCurve *curve = InitCurve(object.id, data, GOType::Arc);
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Arc);
});
break;
}
case GOType::Spline:
case GOType::CubicBezier:
{
VSimpleCurve *curve = InitCurve(object.id, data, GOType::Spline);
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Spline);
});
break;
}
case GOType::SplinePath:
case GOType::CubicBezierPath:
{
VSimpleCurve *curve = InitCurve(object.id, data, GOType::SplinePath);
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::SplinePath);
});
break;
}
case GOType::Unknown:
break;
}
QT_WARNING_POP
}
InitOperatedObjects();
ToolCreation(typeCreation);
}
@ -317,7 +242,7 @@ QT_WARNING_POP
{
VToolRotation *tool = new VToolRotation(doc, data, id, origin, angle, suffix, source, dest, typeCreation);
scene->addItem(tool);
InitRotationToolConnections(scene, tool);
InitOperationToolConnections(scene, tool);
doc->AddTool(id, tool);
doc->IncrementReferens(originPoint.getIdTool());
for (int i = 0; i < source.size(); ++i)
@ -329,61 +254,6 @@ QT_WARNING_POP
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
QVector<DestinationItem> &destination)
{
SCASSERT(doc != nullptr)
const QDomNodeList nodeList = domElement.childNodes();
for (qint32 i = 0; i < nodeList.size(); ++i)
{
const QDomElement dataElement = nodeList.at(i).toElement();
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
{
source.clear();
const QDomNodeList srcList = dataElement.childNodes();
for (qint32 j = 0; j < srcList.size(); ++j)
{
const QDomElement element = srcList.at(j).toElement();
if (not element.isNull())
{
source.append(doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
}
}
}
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
{
destination.clear();
const QDomNodeList srcList = dataElement.childNodes();
for (qint32 j = 0; j < srcList.size(); ++j)
{
const QDomElement element = srcList.at(j).toElement();
if (not element.isNull())
{
DestinationItem d;
d.id = doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
d.mx = qApp->toPixel(doc->GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
d.my = qApp->toPixel(doc->GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
destination.append(d);
}
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolRotation::getTagName() const
{
return VAbstractPattern::TagOperation;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::SetEnabled(bool enabled)
{
this->setEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolRotation::GetFormulaAngle() const
{
@ -406,263 +276,12 @@ void VToolRotation::SetFormulaAngle(const VFormula &value)
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolRotation::Suffix() const
{
return suffix;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::SetSuffix(const QString &suffix)
{
// Don't know if need check name here.
this->suffix = suffix;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::GroupVisibility(quint32 object, bool visible)
{
if (rObjects.contains(object))
{
VAbstractSimple *obj = rObjects.value(object);
if (obj->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
SCASSERT(item != nullptr);
item->setVisible(visible);
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(obj);
SCASSERT(item != nullptr);
item->setVisible(visible);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::ShowVisualization(bool show)
{
ShowToolVisualization<VisToolRotation>(show);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::FullUpdateFromFile()
{
ReadAttributes();
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
}
}
SetVisualization();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowHover(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setAcceptHoverEvents(enabled);
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->setAcceptHoverEvents(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowSelecting(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowPointHover(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setAcceptHoverEvents(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowPointSelecting(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowPointLabelHover(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->AllowLabelHover(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowPointLabelSelecting(bool enabled)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr);
item->AllowLabelSelecting(enabled);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowSplineHover(bool enabled)
{
AllowCurveHover(enabled, GOType::Spline);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowSplineSelecting(bool enabled)
{
AllowCurveSelecting(enabled, GOType::Spline);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowSplinePathHover(bool enabled)
{
AllowCurveHover(enabled, GOType::SplinePath);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowSplinePathSelecting(bool enabled)
{
AllowCurveSelecting(enabled, GOType::SplinePath);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowArcHover(bool enabled)
{
AllowCurveHover(enabled, GOType::Arc);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowArcSelecting(bool enabled)
{
AllowCurveSelecting(enabled, GOType::Arc);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AddToFile()
{
QDomElement domElement = doc->createElement(getTagName());
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOptions(domElement, obj);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
SaveOptions(domElement, obj);
}
else
{
qCDebug(vTool, "Can't find tool with id = %u", id);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::SetVisualization()
{
@ -678,63 +297,6 @@ void VToolRotation::SetVisualization()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(painter);
Q_UNUSED(option);
Q_UNUSED(widget);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
SetEnabled(enabled);
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
i.value()->SetEnabled(enabled);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::ObjectSelected(bool selected, quint32 objId)
{
emit ChangedToolSelection(selected, objId, id);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::DeleteFromLabel()
{
try
{
DeleteTool();
}
catch(const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e);
return;//Leave this method immediately!!!
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::LabelChangePosition(const QPointF &pos, quint32 labelId)
{
if (rObjects.contains(labelId))
{
VAbstractSimple *obj = rObjects.value(labelId);
if (obj->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
SCASSERT(item != nullptr);
ChangePosition(item, labelId, pos);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::SaveDialog(QDomElement &domElement)
{
@ -765,33 +327,7 @@ void VToolRotation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrSuffix, suffix);
doc->RemoveAllChildren(tag);
QDomElement tagObjects = doc->createElement(TagSource);
for (int i = 0; i < source.size(); ++i)
{
QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, source.at(i));
tagObjects.appendChild(item);
}
tag.appendChild(tagObjects);
tagObjects = doc->createElement(TagDestination);
for (int i = 0; i < destination.size(); ++i)
{
QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, destination.at(i).id);
if (not VFuzzyComparePossibleNulls(destination.at(i).mx, INT_MAX) &&
not VFuzzyComparePossibleNulls(destination.at(i).my, INT_MAX))
{
doc->SetAttribute(item, AttrMx, qApp->fromPixel(destination.at(i).mx));
doc->SetAttribute(item, AttrMy, qApp->fromPixel(destination.at(i).my));
}
tagObjects.appendChild(item);
}
tag.appendChild(tagObjects);
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
@ -808,32 +344,6 @@ void VToolRotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::DoChangePosition(quint32 id, qreal mx, qreal my)
{
if (rObjects.contains(id))
{
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
point->setMx(mx);
point->setMy(my);
VAbstractTool::data.UpdateGObject(id, point);
VSimplePoint *item = qobject_cast<VSimplePoint *>(rObjects.value(id));
SCASSERT(item != nullptr);
item->RefreshGeometry(*point);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::UpdateNamePosition(quint32 id)
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
auto moveLabel = new RotationMoveLabel(this->id, doc, point->mx(), point->my(), id);
connect(moveLabel, &RotationMoveLabel::ChangePosition, this, &VToolRotation::DoChangePosition);
qApp->getUndoStack()->push(moveLabel);
}
//---------------------------------------------------------------------------------------------------------------------
DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
const QString &suffix, VContainer *data)
@ -942,121 +452,3 @@ void VToolRotation::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, cons
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VToolRotation::ShowToolVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
AddVisualization<T>();
SetVisualization();
}
else
{
if (T *visual = qobject_cast<T *>(vis))
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos)
{
const QPointF p = pos - item->pos();
DoChangePosition(id, p.x(), p.y());
UpdateNamePosition(id);
}
//---------------------------------------------------------------------------------------------------------------------
VSimpleCurve *VToolRotation::InitCurve(quint32 id, VContainer *data, GOType curveType)
{
VSimpleCurve *curve = new VSimpleCurve(id, QColor(baseColor), *data->GetPatternUnit(), &factor);
curve->setParentItem(this);
curve->SetType(curveType);
connect(curve, &VSimpleCurve::Selected, this, &VToolRotation::ObjectSelected);
connect(curve, &VSimpleCurve::ShowContextMenu, this, &VToolRotation::contextMenuEvent);
connect(curve, &VSimpleCurve::Delete, this, &VToolRotation::DeleteFromLabel);
curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
rObjects.insert(id, curve);
return curve;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowCurveHover(bool enabled, GOType type)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() != GOType::Point)
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
if (item->GetType() == type)
{
item->setAcceptHoverEvents(enabled);
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AllowCurveSelecting(bool enabled, GOType type)
{
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() != GOType::Point)
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr);
if (item->GetType() == type)
{
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::AddSourceObject(VAbstractPattern *doc, QDomElement &domElement, quint32 objId)
{
QDomElement obj = doc->createElement(TagItem);
doc->SetAttribute(obj, AttrIdObject, objId);
domElement.appendChild(obj);
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VToolRotation::InitRotationToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
InitDrawToolConnections(scene, tool);
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemHover, tool, &T::AllowPointHover);
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemSelection, tool, &T::AllowPointSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemHover, tool, &T::AllowPointLabelHover);
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, tool, &T::AllowPointLabelSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemHover, tool, &T::AllowSplineHover);
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemSelection, tool, &T::AllowSplineSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemHover, tool, &T::AllowSplinePathHover);
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemSelection, tool, &T::AllowSplinePathSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemHover, tool, &T::AllowArcHover);
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowArcSelecting);
}

View File

@ -30,18 +30,14 @@
#define VTOOLROTATION_H
#include <qcompilerdetection.h>
#include <QDomElement>
#include <QGraphicsItem>
#include <QGraphicsLineItem>
#include <QMap>
#include <QMetaObject>
#include <QObject>
#include <QPointF>
#include <QString>
#include <QVector>
#include <QtGlobal>
#include "../vdrawtool.h"
#include "vabstractoperation.h"
#include "../vgeometry/vgeometrydef.h"
#include "../vmisc/def.h"
#include "../ifc/xml/vabstractpattern.h"
@ -49,35 +45,16 @@
class DialogTool;
class QDomElement;
class QGraphicsSceneContextMenuEvent;
class QPainter;
class QPointF;
class QStyleOptionGraphicsItem;
class QWidget;
class VContainer;
class VGObject;
class VMainGraphicsScene;
template <class T> class QSharedPointer;
struct DestinationItem
{
quint32 id;
qreal mx;
qreal my;
};
class VAbstractSimple;
class VFormula;
class VSimpleCurve;
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
// QGraphicsItem itself produce case where clicking on empty space produce call to QGraphicsItem.
// And i don't know how to fix it.
class VToolRotation : public VDrawTool, public QGraphicsLineItem
class VToolRotation : public VAbstractOperation
{
Q_OBJECT
// Fix warning "Class implements the interface QGraphicsItem but does not list it
// in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!"
Q_INTERFACES(QGraphicsItem)
public:
virtual ~VToolRotation();
virtual void setDialog() Q_DECL_OVERRIDE;
@ -87,85 +64,34 @@ public:
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static void ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
QVector<DestinationItem> &destination);
static const QString ToolType;
static const QString TagItem;
static const QString TagSource;
static const QString TagDestination;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Rotation)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
void SetEnabled(bool enabled);
VFormula GetFormulaAngle() const;
void SetFormulaAngle(const VFormula &value);
QString Suffix() const;
void SetSuffix(const QString &suffix);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
void AllowPointHover(bool enabled);
void AllowPointSelecting(bool enabled);
void AllowPointLabelHover(bool enabled);
void AllowPointLabelSelecting(bool enabled);
void AllowSplineHover(bool enabled);
void AllowSplineSelecting(bool enabled);
void AllowSplinePathHover(bool enabled);
void AllowSplinePathSelecting(bool enabled);
void AllowArcHover(bool enabled);
void AllowArcSelecting(bool enabled);
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
void ObjectSelected(bool selected, quint32 objId);
void DeleteFromLabel();
void LabelChangePosition(const QPointF &pos, quint32 labelId);
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
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 slots:
void DoChangePosition(quint32 id, qreal mx, qreal my);
private:
Q_DISABLE_COPY(VToolRotation)
quint32 origPointId;
QString formulaAngle;
QString suffix;
QVector<quint32> source;
QVector<DestinationItem> destination;
QMap<quint32, VAbstractSimple *> rObjects;
VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
const QString &formulaAngle, const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, const Source &typeCreation,
QGraphicsItem *parent = nullptr);
void UpdateNamePosition(quint32 id);
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
@ -178,8 +104,8 @@ private:
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin,
qreal formulaAngle, const QString &suffix, VContainer *data);
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my);
@ -194,21 +120,6 @@ private:
template <class Item>
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id);
template <typename T>
void ShowToolVisualization(bool show);
void ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos);
VSimpleCurve *InitCurve(quint32 id, VContainer *data, GOType curveType);
template <typename T>
static void InitRotationToolConnections(VMainGraphicsScene *scene, T *tool);
void AllowCurveHover(bool enabled, GOType type);
void AllowCurveSelecting(bool enabled, GOType type);
static void AddSourceObject(VAbstractPattern *doc, QDomElement &domElement, quint32 objId);
};
#endif // VTOOLROTATION_H

View File

@ -50,9 +50,13 @@ HEADERS += \
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h \
$$PWD/drawTools/toolcurve/vtoolcubicbezier.h \
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.h \
$$PWD/drawTools/operation/vtoolrotation.h \
$$PWD/vtextgraphicsitem.h \
$$PWD/vgrainlineitem.h
$$PWD/drawTools/operation/vtoolrotation.h \
$$PWD/vtextgraphicsitem.h \
$$PWD/vgrainlineitem.h \
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.h \
$$PWD/drawTools/operation/vabstractoperation.h \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.h \
$$PWD/drawTools/operation/flipping/vabstractflipping.h
SOURCES += \
$$PWD/vtooldetail.cpp \
@ -102,4 +106,8 @@ SOURCES += \
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.cpp \
$$PWD/drawTools/operation/vtoolrotation.cpp \
$$PWD/vtextgraphicsitem.cpp \
$$PWD/vgrainlineitem.cpp
$$PWD/vgrainlineitem.cpp \
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.cpp \
$$PWD/drawTools/operation/vabstractoperation.cpp \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.cpp \
$$PWD/drawTools/operation/flipping/vabstractflipping.cpp

View File

@ -26,7 +26,7 @@
**
*************************************************************************/
#include "rotationmovelabel.h"
#include "operationmovelabel.h"
#include <QDomNode>
#include <QDomNodeList>
@ -43,8 +43,8 @@
class QUndoCommand;
//---------------------------------------------------------------------------------------------------------------------
RotationMoveLabel::RotationMoveLabel(quint32 idTool, VAbstractPattern *doc, double x, double y, quint32 idPoint,
QUndoCommand *parent)
OperationMoveLabel::OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, double x, double y, quint32 idPoint,
QUndoCommand *parent)
: MoveAbstractLabel(doc, idPoint, x, y, parent),
m_idTool(idTool)
{
@ -69,14 +69,14 @@ RotationMoveLabel::RotationMoveLabel(quint32 idTool, VAbstractPattern *doc, doub
}
//---------------------------------------------------------------------------------------------------------------------
RotationMoveLabel::~RotationMoveLabel()
OperationMoveLabel::~OperationMoveLabel()
{
}
//---------------------------------------------------------------------------------------------------------------------
bool RotationMoveLabel::mergeWith(const QUndoCommand *command)
bool OperationMoveLabel::mergeWith(const QUndoCommand *command)
{
const RotationMoveLabel *moveCommand = static_cast<const RotationMoveLabel *>(command);
const OperationMoveLabel *moveCommand = static_cast<const OperationMoveLabel *>(command);
SCASSERT(moveCommand != nullptr);
if (moveCommand->GetToolId() != m_idTool && moveCommand->GetPointId() != nodeId)
@ -93,13 +93,13 @@ bool RotationMoveLabel::mergeWith(const QUndoCommand *command)
}
//---------------------------------------------------------------------------------------------------------------------
int RotationMoveLabel::id() const
int OperationMoveLabel::id() const
{
return static_cast<int>(UndoCommand::RotationMoveLabel);
}
//---------------------------------------------------------------------------------------------------------------------
void RotationMoveLabel::Do(double mx, double my)
void OperationMoveLabel::Do(double mx, double my)
{
qCDebug(vUndo, "New mx %f", mx);
qCDebug(vUndo, "New my %f", my);
@ -118,7 +118,7 @@ void RotationMoveLabel::Do(double mx, double my)
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement RotationMoveLabel::GetDestinationObject(quint32 idTool, quint32 idPoint) const
QDomElement OperationMoveLabel::GetDestinationObject(quint32 idTool, quint32 idPoint) const
{
const QDomElement tool = doc->elementById(idTool);
if (tool.isElement())

View File

@ -1,6 +1,6 @@
/************************************************************************
**
** @file moverotationlabel.h
** @file operationmovelabel.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 13 5, 2016
**
@ -26,8 +26,8 @@
**
*************************************************************************/
#ifndef ROTATIONMOVELABEL_H
#define ROTATIONMOVELABEL_H
#ifndef OPERATIONMOVELABEL_H
#define OPERATIONMOVELABEL_H
#include <qcompilerdetection.h>
#include <QDomElement>
@ -42,13 +42,13 @@ class QDomElement;
class QUndoCommand;
class VAbstractPattern;
class RotationMoveLabel : public MoveAbstractLabel
class OperationMoveLabel : public MoveAbstractLabel
{
Q_OBJECT
public:
RotationMoveLabel(quint32 idTool, VAbstractPattern *doc, double x, double y, quint32 idPoint,
OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, double x, double y, quint32 idPoint,
QUndoCommand *parent = nullptr);
virtual ~RotationMoveLabel();
virtual ~OperationMoveLabel();
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
virtual int id() const Q_DECL_OVERRIDE;
@ -57,16 +57,16 @@ public:
protected:
virtual void Do(double mx, double my) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(RotationMoveLabel)
Q_DISABLE_COPY(OperationMoveLabel)
quint32 m_idTool;
QDomElement GetDestinationObject(quint32 idTool, quint32 idPoint) const;
};
//---------------------------------------------------------------------------------------------------------------------
inline quint32 RotationMoveLabel::GetToolId() const
inline quint32 OperationMoveLabel::GetToolId() const
{
return m_idTool;
}
#endif // ROTATIONMOVELABEL_H
#endif // OPERATIONMOVELABEL_H

View File

@ -21,9 +21,9 @@ HEADERS += \
$$PWD/label/movedoublelabel.h \
$$PWD/addgroup.h \
$$PWD/delgroup.h \
$$PWD/label/rotationmovelabel.h \
$$PWD/label/moveabstractlabel.h \
$$PWD/toggledetailinlayout.h
$$PWD/toggledetailinlayout.h \
$$PWD/label/operationmovelabel.h
SOURCES += \
$$PWD/addtocalc.cpp \
@ -45,6 +45,6 @@ SOURCES += \
$$PWD/label/movedoublelabel.cpp \
$$PWD/addgroup.cpp \
$$PWD/delgroup.cpp \
$$PWD/label/rotationmovelabel.cpp \
$$PWD/label/moveabstractlabel.cpp \
$$PWD/toggledetailinlayout.cpp
$$PWD/toggledetailinlayout.cpp \
$$PWD/label/operationmovelabel.cpp

View File

@ -0,0 +1,179 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 "visoperation.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"
//---------------------------------------------------------------------------------------------------------------------
VisOperation::VisOperation(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent),
objects(),
supportColor2(Qt::darkGreen),
points(),
curves()
{
}
//---------------------------------------------------------------------------------------------------------------------
VisOperation::~VisOperation()
{
qDeleteAll(points);
qDeleteAll(curves);
}
//---------------------------------------------------------------------------------------------------------------------
void VisOperation::SetObjects(QVector<quint32> objects)
{
this->objects = objects;
}
//---------------------------------------------------------------------------------------------------------------------
void VisOperation::VisualMode(const quint32 &pointId)
{
Q_UNUSED(pointId);
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
Visualization::scenePos = scene->getScenePos();
RefreshGeometry();
AddOnScene();
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *VisOperation::GetPoint(quint32 i, const QColor &color)
{
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
{
return points.at(static_cast<int>(i));
}
else
{
auto point = InitPoint(color, this);
points.append(point);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsPathItem *VisOperation::GetCurve(quint32 i, const QColor &color)
{
if (not curves.isEmpty() && static_cast<quint32>(curves.size() - 1) >= i)
{
return curves.at(static_cast<int>(i));
}
else
{
auto curve = InitItem<QGraphicsPathItem>(color, this);
curves.append(curve);
return curve;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPointF &secondPoint)
{
int iPoint = -1;
int iCurve = -1;
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);
++iPoint;
point = GetPoint(iPoint, supportColor);
if (object1Id != NULL_ID)
{
DrawPoint(point, p->Flip(QLineF(firstPoint, secondPoint)), supportColor);
}
break;
}
case GOType::Arc:
{
iCurve = AddFlippedCurve<VArc>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::EllipticalArc:
{
iCurve = AddFlippedCurve<VEllipticalArc>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::Spline:
{
iCurve = AddFlippedCurve<VSpline>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::SplinePath:
{
iCurve = AddFlippedCurve<VSplinePath>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::CubicBezier:
{
iCurve = AddFlippedCurve<VCubicBezier>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::CubicBezierPath:
{
iCurve = AddFlippedCurve<VCubicBezierPath>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::Unknown:
break;
}
}
}
QT_WARNING_POP

View File

@ -0,0 +1,88 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 VISOPERATION_H
#define VISOPERATION_H
#include <QtGlobal>
#include "../visline.h"
class VisOperation : public VisLine
{
Q_OBJECT
public:
explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisOperation();
void SetObjects(QVector<quint32> objects);
virtual void VisualMode(const quint32 &pointId = NULL_ID) Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolRotation)};
protected:
QVector<quint32> objects;
QColor supportColor2;
QVector<QGraphicsEllipseItem *> points;
QVector<QGraphicsPathItem *> curves;
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color);
QGraphicsPathItem * GetCurve(quint32 i, const QColor &color);
template <class Item>
int AddFlippedCurve(const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, int i);
void RefreshFlippedObjects(const QPointF &firstPoint, const QPointF &secondPoint);
private:
Q_DISABLE_COPY(VisOperation)
};
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
int VisOperation::AddFlippedCurve(const QPointF &firstPoint, const QPointF &secondPoint, 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);
++i;
path = GetCurve(i, supportColor);
if (object1Id != NULL_ID)
{
const Item flipped = curve->Flip(QLineF(firstPoint, secondPoint));
DrawPath(path, flipped.GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap);
}
return i;
}
#endif // VISOPERATION_H

View File

@ -0,0 +1,87 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 "vistoolflippingbyaxis.h"
#include "../vgeometry/vpointf.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolFlippingByAxis::VisToolFlippingByAxis(const VContainer *data, QGraphicsItem *parent)
: VisOperation(data, parent),
m_axisType(AxisType::VerticalAxis),
point1(nullptr)
{
point1 = InitPoint(supportColor2, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolFlippingByAxis::~VisToolFlippingByAxis()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByAxis::RefreshGeometry()
{
if (objects.isEmpty())
{
return;
}
QPointF firstPoint;
QPointF secondPoint;
if (object1Id != NULL_ID)
{
firstPoint = *Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(point1, firstPoint, supportColor2);
if (m_axisType == AxisType::VerticalAxis)
{
secondPoint = QPointF(firstPoint.x(), firstPoint.y() + 100);
}
else
{
secondPoint = QPointF(firstPoint.x() + 100, firstPoint.y());
}
DrawLine(this, Axis(firstPoint, secondPoint), supportColor2, Qt::DashLine);
}
RefreshFlippedObjects(firstPoint, secondPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByAxis::SetOriginPointId(quint32 value)
{
object1Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByAxis::SetAxisType(AxisType value)
{
m_axisType = value;
}

View File

@ -0,0 +1,59 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 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 VISTOOLFLIPPINGBYAXIS_H
#define VISTOOLFLIPPINGBYAXIS_H
#include <QtGlobal>
#include "visoperation.h"
#include "../ifc/xml/vabstractpattern.h"
class VisToolFlippingByAxis : public VisOperation
{
Q_OBJECT
public:
explicit VisToolFlippingByAxis(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolFlippingByAxis();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void SetOriginPointId(quint32 value);
void SetAxisType(AxisType value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByAxis)};
private:
Q_DISABLE_COPY(VisToolFlippingByAxis)
AxisType m_axisType;
QGraphicsEllipseItem *point1;
};
#endif // VISTOOLFLIPPINGBYAXIS_H

View File

@ -0,0 +1,90 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 "vistoolflippingbyline.h"
#include "../vgeometry/vpointf.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolFlippingByLine::VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent)
: VisOperation(data, parent),
object2Id(NULL_ID),
point1(nullptr),
point2(nullptr)
{
point1 = InitPoint(supportColor2, this);
point2 = InitPoint(supportColor2, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolFlippingByLine::~VisToolFlippingByLine()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::RefreshGeometry()
{
if (objects.isEmpty())
{
return;
}
QPointF firstPoint;
QPointF secondPoint;
if (object1Id != NULL_ID)
{
firstPoint = *Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(point1, firstPoint, supportColor2);
if (object2Id == NULL_ID)
{
secondPoint = Visualization::scenePos;
}
else
{
secondPoint = *Visualization::data->GeometricObject<VPointF>(object2Id);
DrawPoint(point2, secondPoint, supportColor2);
}
DrawLine(this, QLineF(firstPoint, secondPoint), supportColor2, Qt::DashLine);
}
RefreshFlippedObjects(firstPoint, secondPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
{
object1Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::SetSecondLinePointId(quint32 value)
{
object2Id = value;
}

View File

@ -0,0 +1,57 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 12 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 VISTOOLFLIPPINGBYLINE_H
#define VISTOOLFLIPPINGBYLINE_H
#include <QtGlobal>
#include "visoperation.h"
class VisToolFlippingByLine : public VisOperation
{
Q_OBJECT
public:
explicit VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolFlippingByLine();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void SetFirstLinePointId(quint32 value);
void SetSecondLinePointId(quint32 value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByLine)};
private:
Q_DISABLE_COPY(VisToolFlippingByLine)
quint32 object2Id;
QGraphicsEllipseItem *point1;
QGraphicsEllipseItem *point2;
};
#endif // VISTOOLFLIPPINGBYLINE_H

View File

@ -53,22 +53,17 @@
#include "../vmisc/vabstractapplication.h"
#include "../vpatterndb/vcontainer.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../visualization.h"
#include "visline.h"
#include "visoperation.h"
class QPointF;
//---------------------------------------------------------------------------------------------------------------------
VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent),
: VisOperation(data, parent),
angle(INT_MIN),
objects(),
point(nullptr),
angleArc(nullptr),
xAxis(nullptr),
supportColor2(Qt::darkGreen),
points(),
curves()
xAxis(nullptr)
{
point = InitPoint(supportColor2, this);
angleArc = InitItem<QGraphicsPathItem>(supportColor2, this);
@ -78,8 +73,6 @@ VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
//---------------------------------------------------------------------------------------------------------------------
VisToolRotation::~VisToolRotation()
{
qDeleteAll(points);
qDeleteAll(curves);
}
//---------------------------------------------------------------------------------------------------------------------
@ -198,12 +191,6 @@ void VisToolRotation::RefreshGeometry()
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::SetObjects(QVector<quint32> objects)
{
this->objects = objects;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::SetOriginPointId(quint32 value)
{
@ -222,51 +209,6 @@ void VisToolRotation::SetAngle(const QString &expression)
angle = FindVal(expression, Visualization::data->PlainVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::VisualMode(const quint32 &pointId)
{
Q_UNUSED(pointId);
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
Visualization::scenePos = scene->getScenePos();
RefreshGeometry();
AddOnScene();
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *VisToolRotation::GetPoint(quint32 i, const QColor &color)
{
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
{
return points.at(static_cast<int>(i));
}
else
{
auto point = InitPoint(color, this);
points.append(point);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsPathItem *VisToolRotation::GetCurve(quint32 i, const QColor &color)
{
if (not curves.isEmpty() && static_cast<quint32>(curves.size() - 1) >= i)
{
return curves.at(static_cast<int>(i));
}
else
{
auto curve = InitItem<QGraphicsPathItem>(color, this);
curves.append(curve);
return curve;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
int VisToolRotation::AddCurve(qreal angle, const QPointF &origin, quint32 id, int i)

View File

@ -41,12 +41,12 @@
#include "../ifc/ifcdef.h"
#include "../vmisc/def.h"
#include "visline.h"
#include "visoperation.h"
class QPointF;
class VContainer;
class VisToolRotation : public VisLine
class VisToolRotation : public VisOperation
{
Q_OBJECT
public:
@ -55,30 +55,19 @@ public:
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void SetObjects(QVector<quint32> objects);
void SetOriginPointId(quint32 value);
QString Angle() const;
void SetAngle(const QString &expression);
virtual void VisualMode(const quint32 &pointId = NULL_ID) Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolRotation)};
private:
Q_DISABLE_COPY(VisToolRotation)
qreal angle;
QVector<quint32> objects;
QGraphicsEllipseItem *point;
QGraphicsPathItem *angleArc;
QGraphicsLineItem *xAxis;
QColor supportColor2;
QVector<QGraphicsEllipseItem *> points;
QVector<QGraphicsPathItem *> curves;
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color);
QGraphicsPathItem * GetCurve(quint32 i, const QColor &color);
template <class Item>
int AddCurve(qreal angle, const QPointF &origin, quint32 id, int i);

View File

@ -22,6 +22,8 @@ HEADERS += \
$$PWD/line/vistoolpointofintersectioncircles.h \
$$PWD/line/vistoolpointfromcircleandtangent.h \
$$PWD/line/vistoolpointfromarcandtangent.h \
$$PWD/line/operation/vistoolrotation.h \
$$PWD/line/operation/vistoolflippingbyline.h \
$$PWD/path/vispath.h \
$$PWD/path/vistoolarc.h \
$$PWD/path/vistoolcutarc.h \
@ -33,7 +35,8 @@ HEADERS += \
$$PWD/path/vistoolpointofintersectioncurves.h \
$$PWD/path/vistoolcubicbezier.h \
$$PWD/path/vistoolcubicbezierpath.h \
visualization/line/vistoolrotation.h
$$PWD/line/operation/visoperation.h \
$$PWD/line/operation/vistoolflippingbyaxis.h
SOURCES += \
$$PWD/visualization.cpp \
@ -56,6 +59,8 @@ SOURCES += \
$$PWD/line/vistoolpointofintersectioncircles.cpp \
$$PWD/line/vistoolpointfromcircleandtangent.cpp \
$$PWD/line/vistoolpointfromarcandtangent.cpp \
$$PWD/line/operation/vistoolrotation.cpp \
$$PWD/line/operation/vistoolflippingbyline.cpp \
$$PWD/path/vispath.cpp \
$$PWD/path/vistoolarc.cpp \
$$PWD/path/vistoolcutarc.cpp \
@ -67,4 +72,5 @@ SOURCES += \
$$PWD/path/vistoolpointofintersectioncurves.cpp \
$$PWD/path/vistoolcubicbezier.cpp \
$$PWD/path/vistoolcubicbezierpath.cpp \
visualization/line/vistoolrotation.cpp
$$PWD/line/operation/visoperation.cpp \
$$PWD/line/operation/vistoolflippingbyaxis.cpp

View File

@ -52,7 +52,8 @@ SOURCES += \
tst_vellipticalarc.cpp \
tst_vcubicbezierpath.cpp \
tst_vgobject.cpp \
tst_vsplinepath.cpp
tst_vsplinepath.cpp \
tst_vpointf.cpp
win32-msvc*:SOURCES += stable.cpp
@ -75,7 +76,8 @@ HEADERS += \
tst_vellipticalarc.h \
tst_vcubicbezierpath.h \
tst_vgobject.h \
tst_vsplinepath.h
tst_vsplinepath.h \
tst_vpointf.h
# Set using ccache. Function enable_ccache() defined in common.pri.
$$enable_ccache()

View File

@ -46,6 +46,7 @@
#include "tst_vcubicbezierpath.h"
#include "tst_vgobject.h"
#include "tst_vsplinepath.h"
#include "tst_vpointf.h"
#include "../vmisc/def.h"
@ -80,6 +81,7 @@ int main(int argc, char** argv)
ASSERT_TEST(new TST_VAbstractCurve());
ASSERT_TEST(new TST_VCubicBezierPath());
ASSERT_TEST(new TST_VGObject());
ASSERT_TEST(new TST_VPointF());
return status;
}

View File

@ -246,3 +246,74 @@ void TST_VArc::TestRotation()
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg));
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VArc::TestFlip_data()
{
QTest::addColumn<QPointF>("center");
QTest::addColumn<qreal>("radius");
QTest::addColumn<qreal>("startAngle");
QTest::addColumn<qreal>("endAngle");
QTest::addColumn<QLineF>("axis");
QTest::addColumn<QString>("prefix");
const qreal radius = 5;
QPointF center(10, 5);
QPointF p1(10, 0);
QPointF p2(5, 5);
QLineF axis(QPointF(4, 6), QPointF(12, 6));
QTest::newRow("Vertical axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle()
<< axis << "a2";
p1 = QPointF(15, 5);
p2 = QPointF(10, 0);
axis = QLineF(QPointF(9, -1), QPointF(9, 6));
QTest::newRow("Horizontal axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle()
<< axis << "a2";
QLineF l(center.x(), center.y(), center.x() + radius, center.y());
l.setAngle(45);
p2 = l.p2();
l.setAngle(225);
p1 = l.p2();
l.setAngle(45+90);
l.setLength(5);
const QPointF p1Axis = l.p2();
axis = QLineF(p1Axis.x(), p1Axis.y(), p1Axis.x() + radius, p1Axis.y());
axis.setAngle(45);
QTest::newRow("Diagonal axis") << center << radius << QLineF(center, p1).angle() << QLineF(center, p2).angle()
<< axis << "a2";
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VArc::TestFlip()
{
QFETCH(QPointF, center);
QFETCH(qreal, radius);
QFETCH(qreal, startAngle);
QFETCH(qreal, endAngle);
QFETCH(QLineF, axis);
QFETCH(QString, prefix);
VArc originArc(center, radius, startAngle, endAngle);
const VArc res = originArc.Flip(axis, prefix);
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QVERIFY2(res.IsFlipped(), qUtf8Printable("The arc is not flipped"));
QCOMPARE(originArc.GetLength()*-1, res.GetLength());
QCOMPARE(originArc.GetRadius(), res.GetRadius());
QCOMPARE(originArc.AngleArc(), res.AngleArc());
}

View File

@ -44,6 +44,8 @@ private slots:
void TestGetPoints();
void TestRotation_data();
void TestRotation();
void TestFlip_data();
void TestFlip();
};
#endif // TST_VARC_H

View File

@ -31,6 +31,7 @@
#include "../vlayout/vabstractdetail.h"
#include "../vmisc/logging.h"
#include <QtGlobal>
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
@ -455,3 +456,43 @@ void TST_VEllipticalArc::TestRotation()
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg));
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VEllipticalArc::TestFlip_data()
{
QTest::addColumn<VEllipticalArc>("elArc");
QTest::addColumn<QLineF>("axis");
QTest::addColumn<QString>("prefix");
const VEllipticalArc elArc(QPointF(), 10., 20.0, 1., 91., 0.);
QLineF axis(QPointF(600, 30), QPointF(600, 1800));
QTest::newRow("Vertical axis") << elArc << axis << "a2";
axis = QLineF(QPointF(600, 30), QPointF(1200, 30));
QTest::newRow("Horizontal axis") << elArc << axis << "a2";
axis = QLineF(QPointF(600, 30), QPointF(600, 1800));
axis.setAngle(45);
QTest::newRow("Diagonal axis") << elArc << axis << "a2";
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VEllipticalArc::TestFlip()
{
QFETCH(VEllipticalArc, elArc);
QFETCH(QLineF, axis);
QFETCH(QString, prefix);
const VEllipticalArc res = elArc.Flip(axis, prefix);
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QCOMPARE(qRound(elArc.GetLength()*-1), qRound(res.GetLength()));
QCOMPARE(elArc.GetRadius1(), res.GetRadius1());
QCOMPARE(elArc.GetRadius2(), res.GetRadius2());
}

View File

@ -51,6 +51,8 @@ private slots:
void TestGetPoints4();
void TestRotation_data();
void TestRotation();
void TestFlip_data();
void TestFlip();
private:
Q_DISABLE_COPY(TST_VEllipticalArc)

View File

@ -0,0 +1,86 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 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 "tst_vpointf.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/logging.h"
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_VPointF::TST_VPointF(QObject *parent)
: QObject(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VPointF::TestFlip_data()
{
QTest::addColumn<VPointF>("originPoint");
QTest::addColumn<QLineF>("axis");
QTest::addColumn<QPointF>("flipped");
QTest::addColumn<QString>("prefix");
VPointF originPoint;
QLineF axis = QLineF(QPointF(5, 0), QPointF(5, 10));
QPointF flipped = QPointF(10, 0);
QTest::newRow("Vertical axis") << originPoint << axis << flipped << "a2";
axis = QLineF(QPointF(0, 5), QPointF(10, 5));
flipped = QPointF(0, 10);
QTest::newRow("Horizontal axis") << originPoint << axis << flipped << "a2";
QLineF l = QLineF(QPointF(), QPointF(10, 0));
l.setAngle(315);
flipped = l.p2();
l.setLength(l.length()/2.0);
axis = QLineF(l.p2(), l.p1());
axis.setAngle(axis.angle()+90);
QTest::newRow("Diagonal axis") << originPoint << axis << flipped << "a2";
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VPointF::TestFlip()
{
QFETCH(VPointF, originPoint);
QFETCH(QLineF, axis);
QFETCH(QPointF, flipped);
QFETCH(QString, prefix);
const VPointF res = originPoint.Flip(axis, prefix);
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QCOMPARE(flipped.toPoint(), res.toQPointF().toPoint());
}

View File

@ -0,0 +1,47 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 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 TST_VPOINTF_H
#define TST_VPOINTF_H
#include <QtCore/QObject>
#include <QtCore/qglobal.h>
class TST_VPointF : public QObject
{
Q_OBJECT
public:
explicit TST_VPointF(QObject *parent = nullptr);
private slots:
void TestFlip_data();
void TestFlip();
private:
Q_DISABLE_COPY(TST_VPointF)
};
#endif // TST_VPOINTF_H

View File

@ -28,6 +28,7 @@
#include "tst_vspline.h"
#include "../vgeometry/vspline.h"
#include "../vmisc/logging.h"
#include <QtTest>
@ -388,6 +389,49 @@ void TST_VSpline::TestLengthByPoint()
QVERIFY(qAbs(resLength - length) < ToPixel(0.5, Unit::Mm));
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VSpline::TestFlip_data()
{
QTest::addColumn<VSpline>("spl");
QTest::addColumn<QLineF>("axis");
QTest::addColumn<QString>("prefix");
VPointF p1(1168.8582803149607, 39.999874015748034, "p1", 5.0000125984251973, 9.9999874015748045);
VPointF p4(681.33729132409951, 1815.7969526662778, "p4", 5.0000125984251973, 9.9999874015748045);
VSpline spl(p1, p4, 229.381, 41.6325, 0.96294100000000005, 1.00054, 1);
QLineF axis(QPointF(600, 30), QPointF(600, 1800));
QTest::newRow("Vertical axis") << spl << axis << "a2";
axis = QLineF(QPointF(600, 30), QPointF(1200, 30));
QTest::newRow("Horizontal axis") << spl << axis << "a2";
axis = QLineF(QPointF(600, 30), QPointF(600, 1800));
axis.setAngle(45);
QTest::newRow("Diagonal axis") << spl << axis << "a2";
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VSpline::TestFlip()
{
QFETCH(VSpline, spl);
QFETCH(QLineF, axis);
QFETCH(QString, prefix);
const VSpline res = spl.Flip(axis, prefix);
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QCOMPARE(spl.GetLength(), res.GetLength());
QCOMPARE(spl.GetC1Length(), res.GetC1Length());
QCOMPARE(spl.GetC2Length(), res.GetC2Length());
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VSpline::CompareSplines(const VSpline &spl1, const VSpline &spl2) const
{

View File

@ -51,6 +51,8 @@ private slots:
void TestParametrT();
void TestLengthByPoint_data();
void TestLengthByPoint();
void TestFlip_data();
void TestFlip();
private:
Q_DISABLE_COPY(TST_VSpline)

View File

@ -135,3 +135,64 @@ void TST_VSplinePath::TestRotation()
}
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VSplinePath::TestFlip_data()
{
QTest::addColumn<QVector<VSplinePoint>>("originPoints");
QTest::addColumn<QLineF>("axis");
QTest::addColumn<QString>("prefix");
QVector<VSplinePoint> originPoints;
{
VPointF pSpline(30, 39.999874015748034, "X", 5.0000125984251973, 9.9999874015748045);
VSplinePoint p(pSpline, 89.208600000000004, "89.2086", 269.20859999999999, "269.209", 0, "0",
153.33618897637794, "4.05702");
originPoints.append(p);
}
{
VPointF pSpline(198.77104389529981, 249.18158602595835, "X", 5.0000125984251973, 9.9999874015748045);
VSplinePoint p(pSpline, 146.43199999999999, "146.432", 326.43200000000002, "326.432",
36.387590551181106, "0.962755", 60.978897637795278, "1.6134");
originPoints.append(p);
}
{
VPointF pSpline(820.42771653543309, 417.95262992125987, "X", 5.0000125984251973, 9.9999874015748045);
VSplinePoint p(pSpline, 173.39500000000001, "173.395", 353.39499999999998, "353.395",
381.23716535433073, "10.0869", 0, "0");
originPoints.append(p);
}
QLineF axis(QPointF(0, 0), QPointF(0, 10));
QTest::newRow("Vertical axis") << originPoints << axis << "a2";
axis = QLineF(QPointF(0, 0), QPointF(10, 0));
QTest::newRow("Horizontal axis") << originPoints << axis << "a2";
axis = QLineF(QPointF(0, 0), QPointF(0, 10));
axis.setAngle(45);
QTest::newRow("Diagonal axis") << originPoints << axis << "a2";
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VSplinePath::TestFlip()
{
QFETCH(QVector<VSplinePoint>, originPoints);
QFETCH(QLineF, axis);
QFETCH(QString, prefix);
const VSplinePath splPath(originPoints);
const VSplinePath res = splPath.Flip(axis, prefix);
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QCOMPARE(splPath.GetLength(), res.GetLength());
QCOMPARE(splPath.CountPoints(), res.CountPoints());
}

View File

@ -39,6 +39,8 @@ public:
private slots:
void TestRotation_data();
void TestRotation();
void TestFlip_data();
void TestFlip();
private:
Q_DISABLE_COPY(TST_VSplinePath)
};