New tool Flipping by axis.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-09-17 12:10:03 +03:00
parent 91c614a2b8
commit 74bc4179ef
43 changed files with 1840 additions and 433 deletions

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) == 46, "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())
{
@ -188,6 +188,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolFlippingByLine::Type:
ShowOptionsToolFlippingByLine(item);
break;
case VToolFlippingByAxis::Type:
ShowOptionsToolFlippingByAxis(item);
break;
default:
break;
}
@ -202,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) == 46, "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())
{
@ -305,6 +308,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolFlippingByLine::Type:
UpdateOptionsToolFlippingByLine();
break;
case VToolFlippingByAxis::Type:
UpdateOptionsToolFlippingByAxis();
break;
default:
break;
}
@ -340,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) == 46, "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())
{
@ -437,6 +443,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolFlippingByLine::Type:
ChangeDataToolFlippingByLine(prop);
break;
case VToolFlippingByAxis::Type:
ChangeDataToolFlippingByAxis(prop);
break;
default:
break;
}
@ -565,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,
@ -781,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)
{
@ -1631,6 +1664,33 @@ void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByLine(VProperty *proper
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByAxis(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
VToolFlippingByAxis *i = qgraphicsitem_cast<VToolFlippingByAxis *>(currentItem);
SCASSERT(i != nullptr);
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)
{
@ -2031,6 +2091,17 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolFlippingByLine(QGraphicsItem *i
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()
{
@ -2498,6 +2569,14 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByLine()
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
{
@ -2539,6 +2618,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);
@ -153,6 +159,7 @@ private:
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);
@ -185,6 +192,7 @@ private:
void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item);
void ShowOptionsToolRotation(QGraphicsItem *item);
void ShowOptionsToolFlippingByLine(QGraphicsItem *item);
void ShowOptionsToolFlippingByAxis(QGraphicsItem *item);
void UpdateOptionsToolSinglePoint();
void UpdateOptionsToolEndLine();
@ -217,6 +225,7 @@ private:
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) == 46, "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)
@ -388,6 +388,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::Group:
case Tool::Rotation:
case Tool::FlippingByLine:
case Tool::FlippingByAxis:
return QString();
}
}

View file

@ -1044,6 +1044,17 @@ void MainWindow::ToolFlippingByLine(bool checked)
&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)
{
@ -1714,6 +1725,7 @@ void MainWindow::InitToolButtons()
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);
}
@ -1743,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) == 46, "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;
@ -1886,6 +1898,9 @@ void MainWindow::CancelTool()
case Tool::FlippingByLine:
ui->toolButtonFlippingByLine->setChecked(false);
break;
case Tool::FlippingByAxis:
ui->toolButtonFlippingByAxis->setChecked(false);
break;
}
// Crash: using CRTL+Z while using line tool.
@ -2934,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);
@ -2968,6 +2986,7 @@ void MainWindow::SetEnableTool(bool enable)
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);
@ -3250,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) == 46, "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)
{
@ -3420,6 +3439,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonFlippingByLine->setChecked(true);
ToolFlippingByLine(true);
break;
case Tool::FlippingByAxis:
ui->toolButtonFlippingByAxis->setChecked(true);
ToolFlippingByAxis(true);
break;
}
}

View file

@ -140,6 +140,7 @@ private slots:
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">
@ -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">
@ -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">
@ -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">
@ -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">
@ -1068,7 +1068,7 @@
</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">
@ -1165,10 +1165,10 @@
<string>Flipping objects by line</string>
</property>
<property name="text">
<string>...</string>
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<iconset>
<normaloff>:/toolicon/32x32/flipping_line.png</normaloff>:/toolicon/32x32/flipping_line.png</iconset>
</property>
<property name="iconSize">
@ -1182,6 +1182,32 @@
</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">
@ -1203,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">
@ -1225,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">
@ -1251,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">
@ -1277,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">
@ -1303,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">
@ -1354,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">
@ -1800,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">
@ -1824,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">
@ -1848,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">
@ -1866,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">
@ -1887,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">
@ -1911,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">
@ -1935,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">
@ -1956,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">
@ -2221,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">
@ -2311,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">
@ -2388,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">
@ -2427,9 +2453,6 @@
<header>vmaingraphicsview.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="share/resources/toolicon.qrc"/>
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View file

@ -72,5 +72,7 @@
<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

View file

@ -70,5 +70,7 @@
<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 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 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

@ -2574,6 +2574,36 @@ void VPattern::ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &d
}
}
//---------------------------------------------------------------------------------------------------------------------
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
{
@ -2825,7 +2855,8 @@ void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &dom
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of operation is empty");
const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/
<< VToolFlippingByLine::ToolType; /*1*/
<< VToolFlippingByLine::ToolType /*1*/
<< VToolFlippingByAxis::ToolType; /*2*/
switch (opers.indexOf(type))
{
@ -2835,6 +2866,9 @@ void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &dom
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;
@ -3340,7 +3374,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) == 46, "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;
@ -3455,6 +3489,9 @@ QRectF VPattern::ActiveDrawBoundingRect() const
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

@ -195,6 +195,7 @@ private:
void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
void ParseToolFlippingByAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
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

@ -211,6 +211,7 @@
<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">
@ -364,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>
@ -556,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-->

View file

@ -1372,7 +1372,7 @@ QStringList VAbstractPattern::ListPointExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagPoint);
@ -1443,7 +1443,7 @@ QStringList VAbstractPattern::ListArcExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagArc);
@ -1504,7 +1504,7 @@ QStringList VAbstractPattern::ListPathPointExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 47);
QStringList expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint);
@ -1570,7 +1570,7 @@ QStringList VAbstractPattern::ListOperationExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
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

@ -110,6 +110,7 @@ enum class Tool : ToolVisHolderType
Group,
Rotation,
FlippingByLine,
FlippingByAxis,
Midpoint,
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
};
@ -152,7 +153,8 @@ enum class Vis : ToolVisHolderType
ToolCurveIntersectAxis,
ToolTrueDarts,
ToolRotation,
ToolFlippingByLine
ToolFlippingByLine,
ToolFlippingByAxis
};
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, LineAngle, CurveAngle, ArcRadius,

View file

@ -39,7 +39,8 @@ HEADERS += \
$$PWD/tools/dialogcubicbezierpath.h \
$$PWD/tools/dialoggroup.h \
$$PWD/tools/dialogrotation.h \
$$PWD/tools/dialogflippingbyline.h
$$PWD/tools/dialogflippingbyline.h \
$$PWD/tools/dialogflippingbyaxis.h
SOURCES += \
@ -79,7 +80,8 @@ SOURCES += \
$$PWD/tools/dialogcubicbezierpath.cpp \
$$PWD/tools/dialoggroup.cpp \
$$PWD/tools/dialogrotation.cpp \
$$PWD/tools/dialogflippingbyline.cpp
$$PWD/tools/dialogflippingbyline.cpp \
$$PWD/tools/dialogflippingbyaxis.cpp
FORMS += \
$$PWD/tools/dialogalongline.ui \
@ -117,4 +119,5 @@ FORMS += \
$$PWD/tools/dialogcubicbezierpath.ui \
$$PWD/tools/dialoggroup.ui \
$$PWD/tools/dialogrotation.ui \
$$PWD/tools/dialogflippingbyline.ui
$$PWD/tools/dialogflippingbyline.ui \
$$PWD/tools/dialogflippingbyaxis.ui

View file

@ -63,6 +63,7 @@
#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,325 @@
/************************************************************************
**
** @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("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))
{
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

@ -81,6 +81,9 @@ DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, const quint32
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);
}

View file

@ -13,6 +13,10 @@
<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">
@ -60,7 +64,9 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>

View file

@ -60,5 +60,6 @@
#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

@ -44,17 +44,9 @@
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../dialogs/tools/dialogflippingbyline.h"
#include "../../../../undocommands/label/operationmovelabel.h"
#include "../../../../visualization/line/operation/vistoolflippingbyline.h"
#include "../../../../visualization/visualization.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
#include "../vgeometry/vsplinepath.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
@ -132,98 +124,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const quint32 _id, quint32 firs
QVector<DestinationItem> dest = destination;
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
dest.clear();// Try to avoid mistake, value must be empty
id = data->getNextId();//Just reserve id for tool
for (int i = 0; i < source.size(); ++i)
{
const quint32 idObject = source.at(i);
const QSharedPointer<VGObject> obj = data->GetGObject(idObject);
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
dest.append(CreatePoint(id, idObject, 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);
}
}
CreateDestination(typeCreation, id, dest, source, fPoint, sPoint, suffix, doc, data, parse);
VDrawTool::AddRecord(id, Tool::FlippingByLine, doc);
if (parse == Document::FullParse)
@ -317,122 +218,10 @@ VToolFlippingByLine::VToolFlippingByLine(VAbstractPattern *doc, VContainer *data
quint32 secondLinePointId, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const Source &typeCreation, QGraphicsItem *parent)
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
: VAbstractFlipping(doc, data, id, suffix, source, destination, parent),
m_firstLinePointId(firstLinePointId),
m_secondLinePointId(secondLinePointId)
{
InitOperatedObjects();
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------
DestinationItem VToolFlippingByLine::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 VToolFlippingByLine::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 VToolFlippingByLine::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 VToolFlippingByLine::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);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolFlippingByLine::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 VToolFlippingByLine::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 VToolFlippingByLine::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 VToolFlippingByLine::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 VToolFlippingByLine::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 VToolFlippingByLine::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);
}

View file

@ -31,9 +31,9 @@
#include <QtGlobal>
#include "../vabstractoperation.h"
#include "vabstractflipping.h"
class VToolFlippingByLine : public VAbstractOperation
class VToolFlippingByLine : public VAbstractFlipping
{
Q_OBJECT
public:
@ -69,36 +69,6 @@ private:
quint32 secondLinePointId, const QString &suffix, const QVector<quint32> &source,
const QVector<DestinationItem> &destination, const Source &typeCreation,
QGraphicsItem *parent = nullptr);
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);
};
#endif // VTOOLFLIPPINGBYLINE_H

View file

@ -53,7 +53,9 @@ HEADERS += \
$$PWD/drawTools/operation/vtoolrotation.h \
$$PWD/vtextgraphicsitem.h \
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.h \
$$PWD/drawTools/operation/vabstractoperation.h
$$PWD/drawTools/operation/vabstractoperation.h \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.h \
$$PWD/drawTools/operation/flipping/vabstractflipping.h
SOURCES += \
$$PWD/vtooldetail.cpp \
@ -104,4 +106,6 @@ SOURCES += \
$$PWD/drawTools/operation/vtoolrotation.cpp \
$$PWD/vtextgraphicsitem.cpp \
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.cpp \
$$PWD/drawTools/operation/vabstractoperation.cpp
$$PWD/drawTools/operation/vabstractoperation.cpp \
$$PWD/drawTools/operation/flipping/vtoolflippingbyaxis.cpp \
$$PWD/drawTools/operation/flipping/vabstractflipping.cpp

View file

@ -27,6 +27,16 @@
*************************************************************************/
#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)
@ -97,3 +107,73 @@ QGraphicsPathItem *VisOperation::GetCurve(quint32 i, const QColor &color)
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

@ -55,8 +55,34 @@ protected:
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

@ -27,16 +27,7 @@
*************************************************************************/
#include "vistoolflippingbyline.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"
//---------------------------------------------------------------------------------------------------------------------
VisToolFlippingByLine::VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent)
@ -55,8 +46,6 @@ VisToolFlippingByLine::~VisToolFlippingByLine()
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
void VisToolFlippingByLine::RefreshGeometry()
{
if (objects.isEmpty())
@ -85,71 +74,8 @@ void VisToolFlippingByLine::RefreshGeometry()
DrawLine(this, QLineF(firstPoint, secondPoint), supportColor2, Qt::DashLine);
}
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 = AddCurve<VArc>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::EllipticalArc:
{
iCurve = AddCurve<VEllipticalArc>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::Spline:
{
iCurve = AddCurve<VSpline>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::SplinePath:
{
iCurve = AddCurve<VSplinePath>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::CubicBezier:
{
iCurve = AddCurve<VCubicBezier>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::CubicBezierPath:
{
iCurve = AddCurve<VCubicBezierPath>(firstPoint, secondPoint, id, iCurve);
break;
}
case GOType::Unknown:
break;
}
}
RefreshFlippedObjects(firstPoint, secondPoint);
}
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
@ -162,24 +88,3 @@ void VisToolFlippingByLine::SetSecondLinePointId(quint32 value)
{
object2Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
int VisToolFlippingByLine::AddCurve(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;
}

View file

@ -52,9 +52,6 @@ private:
quint32 object2Id;
QGraphicsEllipseItem *point1;
QGraphicsEllipseItem *point2;
template <class Item>
int AddCurve(const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, int i);
};
#endif // VISTOOLFLIPPINGBYLINE_H

View file

@ -35,7 +35,8 @@ HEADERS += \
$$PWD/path/vistoolpointofintersectioncurves.h \
$$PWD/path/vistoolcubicbezier.h \
$$PWD/path/vistoolcubicbezierpath.h \
$$PWD/line/operation/visoperation.h
$$PWD/line/operation/visoperation.h \
$$PWD/line/operation/vistoolflippingbyaxis.h
SOURCES += \
$$PWD/visualization.cpp \
@ -71,4 +72,5 @@ SOURCES += \
$$PWD/path/vistoolpointofintersectioncurves.cpp \
$$PWD/path/vistoolcubicbezier.cpp \
$$PWD/path/vistoolcubicbezierpath.cpp \
$$PWD/line/operation/visoperation.cpp
$$PWD/line/operation/visoperation.cpp \
$$PWD/line/operation/vistoolflippingbyaxis.cpp