New tool Flipping by line.
--HG-- branch : feature
This commit is contained in:
parent
fe56607d7d
commit
9bb88afaa5
|
@ -75,7 +75,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser()
|
|||
void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
||||
{
|
||||
// This check helps to find missed tools in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was used in switch.");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46, "Not all tools was used in switch.");
|
||||
|
||||
switch (item->type())
|
||||
{
|
||||
|
@ -185,6 +185,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
|||
case VToolRotation::Type:
|
||||
ShowOptionsToolRotation(item);
|
||||
break;
|
||||
case VToolFlippingByLine::Type:
|
||||
ShowOptionsToolFlippingByLine(item);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -199,7 +202,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
|
|||
}
|
||||
|
||||
// This check helps to find missed tools in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was used in switch.");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46, "Not all tools was used in switch.");
|
||||
|
||||
switch (currentItem->type())
|
||||
{
|
||||
|
@ -299,6 +302,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
|
|||
case VToolRotation::Type:
|
||||
UpdateOptionsToolRotation();
|
||||
break;
|
||||
case VToolFlippingByLine::Type:
|
||||
UpdateOptionsToolFlippingByLine();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -334,7 +340,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
|||
}
|
||||
|
||||
// This check helps to find missed tools in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was used in switch.");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46, "Not all tools was used in switch.");
|
||||
|
||||
switch (currentItem->type())
|
||||
{
|
||||
|
@ -428,6 +434,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
|||
case VToolRotation::Type:
|
||||
ChangeDataToolRotation(prop);
|
||||
break;
|
||||
case VToolFlippingByLine::Type:
|
||||
ChangeDataToolFlippingByLine(prop);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1601,6 +1610,27 @@ void VToolOptionsPropertyBrowser::ChangeDataToolRotation(VProperty *property)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByLine(VProperty *property)
|
||||
{
|
||||
SCASSERT(property != nullptr)
|
||||
|
||||
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
|
||||
const QString id = propertyToId[property];
|
||||
|
||||
VToolFlippingByLine *i = qgraphicsitem_cast<VToolFlippingByLine *>(currentItem);
|
||||
SCASSERT(i != nullptr);
|
||||
switch (PropertiesList().indexOf(id))
|
||||
{
|
||||
case 38: // AttrSuffix
|
||||
SetOperationSuffix<VToolFlippingByLine>(value.toString());
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"Unknown property type. id = "<<id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item)
|
||||
{
|
||||
|
@ -1991,6 +2021,16 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolRotation(QGraphicsItem *item)
|
|||
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ShowOptionsToolFlippingByLine(QGraphicsItem *item)
|
||||
{
|
||||
VToolFlippingByLine *i = qgraphicsitem_cast<VToolFlippingByLine *>(item);
|
||||
i->ShowVisualization(true);
|
||||
formView->setTitle(tr("Tool flipping by line"));
|
||||
|
||||
AddPropertyOperationSuffix(i, tr("Suffix"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint()
|
||||
{
|
||||
|
@ -2451,6 +2491,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolRotation()
|
|||
idToProperty[AttrAngle]->setValue(valueAngle);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByLine()
|
||||
{
|
||||
VToolFlippingByLine *i = qgraphicsitem_cast<VToolFlippingByLine *>(currentItem);
|
||||
idToProperty[AttrSuffix]->setValue(i->Suffix());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
||||
{
|
||||
|
|
|
@ -152,6 +152,7 @@ private:
|
|||
void ChangeDataToolLineIntersectAxis(VPE::VProperty *property);
|
||||
void ChangeDataToolCurveIntersectAxis(VPE::VProperty *property);
|
||||
void ChangeDataToolRotation(VPE::VProperty *property);
|
||||
void ChangeDataToolFlippingByLine(VPE::VProperty *property);
|
||||
|
||||
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
|
||||
void ShowOptionsToolEndLine(QGraphicsItem *item);
|
||||
|
@ -183,6 +184,7 @@ private:
|
|||
void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item);
|
||||
void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item);
|
||||
void ShowOptionsToolRotation(QGraphicsItem *item);
|
||||
void ShowOptionsToolFlippingByLine(QGraphicsItem *item);
|
||||
|
||||
void UpdateOptionsToolSinglePoint();
|
||||
void UpdateOptionsToolEndLine();
|
||||
|
@ -214,6 +216,7 @@ private:
|
|||
void UpdateOptionsToolLineIntersectAxis();
|
||||
void UpdateOptionsToolCurveIntersectAxis();
|
||||
void UpdateOptionsToolRotation();
|
||||
void UpdateOptionsToolFlippingByLine();
|
||||
};
|
||||
|
||||
#endif // VTOOLOPTIONSPROPERTYBROWSER_H
|
||||
|
|
|
@ -207,7 +207,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
QString DialogHistory::Record(const VToolRecord &tool)
|
||||
{
|
||||
// This check helps to find missed tools in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was used in history.");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46, "Not all tools was used in history.");
|
||||
|
||||
const QDomElement domElem = doc->elementById(tool.getId());
|
||||
if (domElem.isElement() == false)
|
||||
|
@ -387,6 +387,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
case Tool::NodeSplinePath:
|
||||
case Tool::Group:
|
||||
case Tool::Rotation:
|
||||
case Tool::FlippingByLine:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1033,6 +1033,17 @@ void MainWindow::ToolRotation(bool checked)
|
|||
&MainWindow::ApplyDialog<VToolRotation>);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::ToolFlippingByLine(bool checked)
|
||||
{
|
||||
ToolSelectOperationObjects();
|
||||
SetToolButtonWithApply<DialogFlippingByLine>(checked, Tool::FlippingByLine,
|
||||
":/cursor/flipping_line_cursor.png",
|
||||
tr("Select one or more objects, <b>Enter</b> - confirm selection"),
|
||||
&MainWindow::ClosedDialogWithApply<VToolFlippingByLine>,
|
||||
&MainWindow::ApplyDialog<VToolFlippingByLine>);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::ClosedDialogGroup(int result)
|
||||
{
|
||||
|
@ -1702,6 +1713,7 @@ void MainWindow::InitToolButtons()
|
|||
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
|
||||
connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup);
|
||||
connect(ui->toolButtonRotation, &QToolButton::clicked, this, &MainWindow::ToolRotation);
|
||||
connect(ui->toolButtonFlippingByLine, &QToolButton::clicked, this, &MainWindow::ToolFlippingByLine);
|
||||
connect(ui->toolButtonMidpoint, &QToolButton::clicked, this, &MainWindow::ToolMidpoint);
|
||||
connect(ui->toolButtonLayoutExportAs, &QToolButton::clicked, this, &MainWindow::ExportLayoutAs);
|
||||
}
|
||||
|
@ -1731,7 +1743,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
void MainWindow::CancelTool()
|
||||
{
|
||||
// This check helps to find missed tools in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was handled.");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46, "Not all tools was handled.");
|
||||
|
||||
qCDebug(vMainWindow, "Canceling tool.");
|
||||
delete dialogTool;
|
||||
|
@ -1871,6 +1883,9 @@ void MainWindow::CancelTool()
|
|||
case Tool::Rotation:
|
||||
ui->toolButtonRotation->setChecked(false);
|
||||
break;
|
||||
case Tool::FlippingByLine:
|
||||
ui->toolButtonFlippingByLine->setChecked(false);
|
||||
break;
|
||||
}
|
||||
|
||||
// Crash: using CRTL+Z while using line tool.
|
||||
|
@ -2952,6 +2967,7 @@ void MainWindow::SetEnableTool(bool enable)
|
|||
ui->toolButtonTrueDarts->setEnabled(drawTools);
|
||||
ui->toolButtonGroup->setEnabled(drawTools);
|
||||
ui->toolButtonRotation->setEnabled(drawTools);
|
||||
ui->toolButtonFlippingByLine->setEnabled(drawTools);
|
||||
ui->toolButtonMidpoint->setEnabled(drawTools);
|
||||
|
||||
ui->actionLast_tool->setEnabled(drawTools);
|
||||
|
@ -3234,7 +3250,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
void MainWindow::LastUsedTool()
|
||||
{
|
||||
// This check helps to find missed tools in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was handled.");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46, "Not all tools was handled.");
|
||||
|
||||
if (currentTool == lastUsedTool)
|
||||
{
|
||||
|
@ -3400,6 +3416,10 @@ void MainWindow::LastUsedTool()
|
|||
ui->toolButtonRotation->setChecked(true);
|
||||
ToolRotation(true);
|
||||
break;
|
||||
case Tool::FlippingByLine:
|
||||
ui->toolButtonFlippingByLine->setChecked(true);
|
||||
ToolFlippingByLine(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ private slots:
|
|||
void ToolUnionDetails(bool checked);
|
||||
void ToolGroup(bool checked);
|
||||
void ToolRotation(bool checked);
|
||||
void ToolFlippingByLine(bool checked);
|
||||
void ToolCutArc(bool checked);
|
||||
void ToolLineIntersectAxis(bool checked);
|
||||
void ToolCurveIntersectAxis(bool checked);
|
||||
|
|
|
@ -48,14 +48,14 @@
|
|||
<string>Tools</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>6</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>117</width>
|
||||
<height>358</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -427,7 +427,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>130</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -536,7 +536,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>130</width>
|
||||
<height>248</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -798,7 +798,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>130</width>
|
||||
<height>248</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -1063,8 +1063,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>104</height>
|
||||
<width>130</width>
|
||||
<height>356</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
|
@ -1156,6 +1156,32 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QToolButton" name="toolButtonFlippingByLine">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Flipping objects by line</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="share/resources/toolicon.qrc">
|
||||
<normaloff>:/toolicon/32x32/flipping_line.png</normaloff>:/toolicon/32x32/flipping_line.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_5">
|
||||
|
@ -1163,7 +1189,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<width>130</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -2402,8 +2428,8 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
|
||||
<include location="share/resources/toolicon.qrc"/>
|
||||
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -70,5 +70,7 @@
|
|||
<file>cursor/rotation_cursor@2x.png</file>
|
||||
<file>cursor/midpoint_cursor.png</file>
|
||||
<file>cursor/midpoint_cursor@2x.png</file>
|
||||
<file>cursor/flipping_line_cursor@2x.png</file>
|
||||
<file>cursor/flipping_line_cursor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 618 B |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -68,5 +68,7 @@
|
|||
<file>toolicon/32x32/rotation@2x.png</file>
|
||||
<file>toolicon/32x32/midpoint.png</file>
|
||||
<file>toolicon/32x32/midpoint@2x.png</file>
|
||||
<file>toolicon/32x32/flipping_line@2x.png</file>
|
||||
<file>toolicon/32x32/flipping_line.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="32"
|
||||
height="32"
|
||||
id="svg2985"
|
||||
inkscape:version="0.91 r"
|
||||
sodipodi:docname="flipping_line.svg"
|
||||
inkscape:export-filename="/home/dismine/CAD/Valentina/src/app/share/resources/icon/32x32/point_of_contact.png"
|
||||
inkscape:export-xdpi="92"
|
||||
inkscape:export-ydpi="92">
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1855"
|
||||
inkscape:window-height="1056"
|
||||
id="namedview12"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.9121197"
|
||||
inkscape:cx="21.55347"
|
||||
inkscape:cy="24.569283"
|
||||
inkscape:window-x="65"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg2985" />
|
||||
<defs
|
||||
id="defs2987" />
|
||||
<metadata
|
||||
id="metadata2990">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.90600002;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 1.5658875,1.7702081 25.903239,1.347147 1.5658875,25.250103 Z"
|
||||
id="path4136"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.5784626;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 29.899487,2.4822417 1.4448327,30.426215"
|
||||
id="path4138"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.56700003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="path2985-2-9-3-5"
|
||||
d="m 30.806658,3.5000351 a 1.7373301,1.7294948 0 0 1 -3.47466,0 1.7373301,1.7294948 0 1 1 3.47466,0 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.56700003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="path2985-2-9-3"
|
||||
d="m 4.568231,29.217478 a 1.7373301,1.7294948 0 0 1 -3.47466,0 1.7373301,1.7294948 0 1 1 3.47466,0 z" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#ff0034;stroke-width:1.85944629;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 30.518196,30.169295 6.5134588,30.577521 30.518196,7.5127354 Z"
|
||||
id="path4136-3"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
</svg>
|
After Width: | Height: | Size: 3.3 KiB |
|
@ -2519,7 +2519,7 @@ void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
|
||||
QVector<quint32> source;
|
||||
QVector<DestinationItem> destination;
|
||||
VToolRotation::ExtractData(this, domElement, source, destination);
|
||||
VAbstractOperation::ExtractData(this, domElement, source, destination);
|
||||
|
||||
VToolRotation::Create(id, center, a, suffix, source, destination, scene, this, data, parse, Source::FromFile);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
|
@ -2544,6 +2544,36 @@ void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
||||
{
|
||||
SCASSERT(scene != nullptr);
|
||||
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
||||
|
||||
try
|
||||
{
|
||||
quint32 id = NULL_ID;
|
||||
|
||||
ToolsCommonAttributes(domElement, id);
|
||||
const quint32 p1 = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
||||
const quint32 p2 = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
||||
const QString suffix = GetParametrString(domElement, AttrSuffix, "");
|
||||
|
||||
QVector<quint32> source;
|
||||
QVector<DestinationItem> destination;
|
||||
VAbstractOperation::ExtractData(this, domElement, source, destination);
|
||||
|
||||
VToolFlippingByLine::Create(id, p1, p2, suffix, source, destination, scene, this, data, parse,
|
||||
Source::FromFile);
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
VExceptionObjectError excep(tr("Error creating or updating operation of flipping by line"), domElement);
|
||||
excep.AddMoreInformation(e.ErrorMessage());
|
||||
throw excep;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VPattern::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
|
||||
{
|
||||
|
@ -2794,13 +2824,17 @@ void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &dom
|
|||
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of operation is empty");
|
||||
|
||||
const QStringList opers = QStringList() << VToolRotation::ToolType; /*0*/
|
||||
const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/
|
||||
<< VToolFlippingByLine::ToolType; /*1*/
|
||||
|
||||
switch (opers.indexOf(type))
|
||||
{
|
||||
case 0: //VToolRotation::ToolType
|
||||
ParseToolRotation(scene, domElement, parse);
|
||||
break;
|
||||
case 1: //VToolFlippingByLine::ToolType
|
||||
ParseToolFlippingByLine(scene, domElement, parse);
|
||||
break;
|
||||
default:
|
||||
VException e(tr("Unknown operation type '%1'.").arg(type));
|
||||
throw e;
|
||||
|
@ -3306,7 +3340,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
QRectF VPattern::ActiveDrawBoundingRect() const
|
||||
{
|
||||
// This check helps to find missed tools in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 45, "Not all tools was used.");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46, "Not all tools was used.");
|
||||
|
||||
QRectF rec;
|
||||
|
||||
|
@ -3418,6 +3452,9 @@ QRectF VPattern::ActiveDrawBoundingRect() const
|
|||
case Tool::Rotation:
|
||||
rec = ToolBoundingRect<VToolRotation>(rec, tool.getId());
|
||||
break;
|
||||
case Tool::FlippingByLine:
|
||||
rec = ToolBoundingRect<VToolFlippingByLine>(rec, tool.getId());
|
||||
break;
|
||||
//These tools are not accesseble in Draw mode, but still 'history' contains them.
|
||||
case Tool::Detail:
|
||||
case Tool::UnionDetails:
|
||||
|
|
|
@ -194,6 +194,7 @@ private:
|
|||
void ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
||||
|
||||
void ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
||||
void ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse);
|
||||
|
||||
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<file>schema/pattern/v0.3.2.xsd</file>
|
||||
<file>schema/pattern/v0.3.3.xsd</file>
|
||||
<file>schema/pattern/v0.3.4.xsd</file>
|
||||
<file>schema/pattern/v0.3.5.xsd</file>
|
||||
<file>schema/standard_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.1.xsd</file>
|
||||
|
|
574
src/libs/ifc/schema/pattern/v0.3.5.xsd
Normal file
574
src/libs/ifc/schema/pattern/v0.3.5.xsd
Normal file
|
@ -0,0 +1,574 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||
<!-- XML Schema Generated from XML Document-->
|
||||
<xs:element name="pattern">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element name="version" type="formatVersion"></xs:element>
|
||||
<xs:element name="unit" type="units"></xs:element>
|
||||
<xs:element name="image" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="extension" type="imageExtension"></xs:attribute>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="heights">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
|
||||
<xs:attribute name="h92" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h98" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h104" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h110" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h116" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h122" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h128" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h134" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h140" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h146" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h152" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h158" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h164" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h170" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h176" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h182" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h188" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="h194" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="sizes">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
|
||||
<xs:attribute name="s22" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s24" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s26" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s28" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s30" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s32" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s34" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s36" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s38" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s40" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s42" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s44" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s46" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s48" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s50" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s52" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s54" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="s56" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="custom" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="defHeight" type="baseHeight"></xs:attribute>
|
||||
<xs:attribute name="defSize" type="baseSize"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="patternName" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="showDate" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="showMeasurements" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="measurements" type="xs:string"></xs:element>
|
||||
<xs:element name="increments" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="description" type="xs:string" use="required"></xs:attribute>
|
||||
<xs:attribute name="name" type="shortName" use="required"></xs:attribute>
|
||||
<xs:attribute name="formula" type="xs:string" use="required"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:unique name="incrementName">
|
||||
<xs:selector xpath="increment"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="x" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="y" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="name" type="shortName"></xs:attribute>
|
||||
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="basePoint" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="pShoulder" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="length" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="angle" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="splinePath" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="spline" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="p1Line1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="p1Line2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="p2Line1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="p2Line2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="radius" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="axisP1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="axisP2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="arc" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="curve" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="curve1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="curve2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="lineColor" type="colors"></xs:attribute>
|
||||
<xs:attribute name="color" type="colors"></xs:attribute>
|
||||
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="crossPoint" type="crossType"></xs:attribute>
|
||||
<xs:attribute name="vCrossPoint" type="crossType"></xs:attribute>
|
||||
<xs:attribute name="hCrossPoint" type="crossType"></xs:attribute>
|
||||
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="name1" type="shortName"></xs:attribute>
|
||||
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my1" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="name2" type="shortName"></xs:attribute>
|
||||
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my2" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="lineColor" type="colors"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="operation" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="source" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="destination" minOccurs="1" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="angle" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="suffix" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string" use="required"></xs:attribute>
|
||||
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="radius" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="color" type="colors"></xs:attribute>
|
||||
<xs:attribute name="length" type="xs:string"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="kAsm2" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="pSpline" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="angle" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="length1" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="length2" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="kAsm1" type="xs:string"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="kCurve" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="kAsm1" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="kAsm2" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="length1" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="length2" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="point3" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="point4" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="color" type="colors"></xs:attribute>
|
||||
<xs:attribute name="duplicate" type="xs:unsignedInt"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="det" minOccurs="2" maxOccurs="2">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="node" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="children" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="data" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="mcp" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="cutNumber" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="userDef" type="xs:string"/>
|
||||
<xs:attribute name="material" type="materialType"/>
|
||||
<xs:attribute name="placement" type="placementType"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="letter" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="fontSize" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="width" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="height" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="rotation" type="xs:double"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
|
||||
<xs:attribute name="fontSize" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="width" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="height" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="rotation" type="xs:double"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="node" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="type" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="supplement" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="width" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="name" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="closed" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="forbidFlipping" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="inLayout" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="groups" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="group" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="object" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="tool" type="xs:unsignedInt"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
|
||||
<xs:attribute name="name" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="visible" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="readOnly" type="xs:boolean"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:simpleType name="shortName">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\"]){1,1}([^*/^+\-=\s()?%:;!.,`'\"]){0,}$"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="units">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="mm"/>
|
||||
<xs:enumeration value="cm"/>
|
||||
<xs:enumeration value="inch"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="measurementsTypes">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="standard"/>
|
||||
<xs:enumeration value="individual"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="formatVersion">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="imageExtension">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="PNG"/>
|
||||
<xs:enumeration value="JPG"/>
|
||||
<xs:enumeration value="BMP"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="colors">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="black"/>
|
||||
<xs:enumeration value="green"/>
|
||||
<xs:enumeration value="blue"/>
|
||||
<xs:enumeration value="darkRed"/>
|
||||
<xs:enumeration value="darkGreen"/>
|
||||
<xs:enumeration value="darkBlue"/>
|
||||
<xs:enumeration value="yellow"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="baseHeight">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="92"/>
|
||||
<xs:enumeration value="98"/>
|
||||
<xs:enumeration value="104"/>
|
||||
<xs:enumeration value="110"/>
|
||||
<xs:enumeration value="116"/>
|
||||
<xs:enumeration value="122"/>
|
||||
<xs:enumeration value="128"/>
|
||||
<xs:enumeration value="134"/>
|
||||
<xs:enumeration value="140"/>
|
||||
<xs:enumeration value="146"/>
|
||||
<xs:enumeration value="152"/>
|
||||
<xs:enumeration value="158"/>
|
||||
<xs:enumeration value="164"/>
|
||||
<xs:enumeration value="170"/>
|
||||
<xs:enumeration value="176"/>
|
||||
<xs:enumeration value="182"/>
|
||||
<xs:enumeration value="188"/>
|
||||
<xs:enumeration value="194"/>
|
||||
<xs:enumeration value="920"/>
|
||||
<xs:enumeration value="980"/>
|
||||
<xs:enumeration value="1040"/>
|
||||
<xs:enumeration value="1100"/>
|
||||
<xs:enumeration value="1160"/>
|
||||
<xs:enumeration value="1220"/>
|
||||
<xs:enumeration value="1280"/>
|
||||
<xs:enumeration value="1340"/>
|
||||
<xs:enumeration value="1400"/>
|
||||
<xs:enumeration value="1460"/>
|
||||
<xs:enumeration value="1520"/>
|
||||
<xs:enumeration value="1580"/>
|
||||
<xs:enumeration value="1640"/>
|
||||
<xs:enumeration value="1700"/>
|
||||
<xs:enumeration value="1760"/>
|
||||
<xs:enumeration value="1820"/>
|
||||
<xs:enumeration value="1880"/>
|
||||
<xs:enumeration value="1940"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="baseSize">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="22"/>
|
||||
<xs:enumeration value="24"/>
|
||||
<xs:enumeration value="26"/>
|
||||
<xs:enumeration value="28"/>
|
||||
<xs:enumeration value="30"/>
|
||||
<xs:enumeration value="32"/>
|
||||
<xs:enumeration value="34"/>
|
||||
<xs:enumeration value="36"/>
|
||||
<xs:enumeration value="38"/>
|
||||
<xs:enumeration value="40"/>
|
||||
<xs:enumeration value="42"/>
|
||||
<xs:enumeration value="44"/>
|
||||
<xs:enumeration value="46"/>
|
||||
<xs:enumeration value="48"/>
|
||||
<xs:enumeration value="50"/>
|
||||
<xs:enumeration value="52"/>
|
||||
<xs:enumeration value="54"/>
|
||||
<xs:enumeration value="56"/>
|
||||
<xs:enumeration value="220"/>
|
||||
<xs:enumeration value="240"/>
|
||||
<xs:enumeration value="260"/>
|
||||
<xs:enumeration value="280"/>
|
||||
<xs:enumeration value="300"/>
|
||||
<xs:enumeration value="320"/>
|
||||
<xs:enumeration value="340"/>
|
||||
<xs:enumeration value="360"/>
|
||||
<xs:enumeration value="380"/>
|
||||
<xs:enumeration value="400"/>
|
||||
<xs:enumeration value="420"/>
|
||||
<xs:enumeration value="440"/>
|
||||
<xs:enumeration value="460"/>
|
||||
<xs:enumeration value="480"/>
|
||||
<xs:enumeration value="500"/>
|
||||
<xs:enumeration value="520"/>
|
||||
<xs:enumeration value="540"/>
|
||||
<xs:enumeration value="560"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="crossType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="1"/>
|
||||
<xs:enumeration value="2"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="materialType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="0"/><!--Fabric-->
|
||||
<xs:enumeration value="1"/><!--Lining-->
|
||||
<xs:enumeration value="2"/><!--Interfacing-->
|
||||
<xs:enumeration value="3"/><!--Interlining-->
|
||||
<xs:enumeration value="4"/><!--UserDefined-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="placementType">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:enumeration value="0"/><!--No placement-->
|
||||
<xs:enumeration value="1"/><!--Cut on Fold-->
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
|
@ -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) == 45);
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
|
||||
|
||||
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) == 45);
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
|
||||
|
||||
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) == 45);
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
|
||||
|
||||
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) == 45);
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 46);
|
||||
|
||||
QStringList expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagOperation);
|
||||
|
|
|
@ -58,8 +58,8 @@ class QDomElement;
|
|||
*/
|
||||
|
||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.4");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.4.xsd");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.5");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.5.xsd");
|
||||
|
||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -167,6 +167,8 @@ QString VPatternConverter::XSDSchema(int ver) const
|
|||
case (0x000303):
|
||||
return QStringLiteral("://schema/pattern/v0.3.3.xsd");
|
||||
case (0x000304):
|
||||
return QStringLiteral("://schema/pattern/v0.3.4.xsd");
|
||||
case (0x000305):
|
||||
return CurrentSchema;
|
||||
default:
|
||||
InvalidVersion(ver);
|
||||
|
@ -250,6 +252,10 @@ void VPatternConverter::ApplyPatches()
|
|||
ValidateXML(XSDSchema(0x000304), fileName);
|
||||
V_FALLTHROUGH
|
||||
case (0x000304):
|
||||
ToV0_3_5();
|
||||
ValidateXML(XSDSchema(0x000305), fileName);
|
||||
V_FALLTHROUGH
|
||||
case (0x000305):
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -410,6 +416,13 @@ void VPatternConverter::ToV0_3_4()
|
|||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ToV0_3_5()
|
||||
{
|
||||
SetVersion(QStringLiteral("0.3.5"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::TagUnitToV0_2_0()
|
||||
{
|
||||
|
|
|
@ -55,10 +55,10 @@ public:
|
|||
// GCC 4.6 doesn't allow constexpr and const together
|
||||
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406
|
||||
static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
|
||||
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 4);
|
||||
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 5);
|
||||
#else
|
||||
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 4);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 5);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -93,6 +93,7 @@ private:
|
|||
void ToV0_3_2();
|
||||
void ToV0_3_3();
|
||||
void ToV0_3_4();
|
||||
void ToV0_3_5();
|
||||
|
||||
void TagUnitToV0_2_0();
|
||||
void TagIncrementToV0_2_0();
|
||||
|
|
|
@ -109,6 +109,7 @@ enum class Tool : ToolVisHolderType
|
|||
UnionDetails,
|
||||
Group,
|
||||
Rotation,
|
||||
FlippingByLine,
|
||||
Midpoint,
|
||||
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
|
||||
};
|
||||
|
@ -121,6 +122,7 @@ enum class Vis : ToolVisHolderType
|
|||
SimpleCurve,
|
||||
Line,
|
||||
Path,
|
||||
Operation,
|
||||
ToolAlongLine,
|
||||
ToolArc,
|
||||
ToolArcWithLength,
|
||||
|
@ -149,7 +151,8 @@ enum class Vis : ToolVisHolderType
|
|||
ToolLineIntersectAxis,
|
||||
ToolCurveIntersectAxis,
|
||||
ToolTrueDarts,
|
||||
ToolRotation
|
||||
ToolRotation,
|
||||
ToolFlippingByLine
|
||||
};
|
||||
|
||||
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, LineAngle, CurveAngle, ArcRadius,
|
||||
|
|
|
@ -38,7 +38,8 @@ HEADERS += \
|
|||
$$PWD/tools/dialogcubicbezier.h \
|
||||
$$PWD/tools/dialogcubicbezierpath.h \
|
||||
$$PWD/tools/dialoggroup.h \
|
||||
$$PWD/tools/dialogrotation.h
|
||||
$$PWD/tools/dialogrotation.h \
|
||||
$$PWD/tools/dialogflippingbyline.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
|
@ -77,7 +78,8 @@ SOURCES += \
|
|||
$$PWD/tools/dialogcubicbezier.cpp \
|
||||
$$PWD/tools/dialogcubicbezierpath.cpp \
|
||||
$$PWD/tools/dialoggroup.cpp \
|
||||
$$PWD/tools/dialogrotation.cpp
|
||||
$$PWD/tools/dialogrotation.cpp \
|
||||
$$PWD/tools/dialogflippingbyline.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/tools/dialogalongline.ui \
|
||||
|
@ -114,4 +116,5 @@ FORMS += \
|
|||
$$PWD/tools/dialogcubicbezier.ui \
|
||||
$$PWD/tools/dialogcubicbezierpath.ui \
|
||||
$$PWD/tools/dialoggroup.ui \
|
||||
$$PWD/tools/dialogrotation.ui
|
||||
$$PWD/tools/dialogrotation.ui \
|
||||
$$PWD/tools/dialogflippingbyline.ui
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "tools/dialogtruedarts.h"
|
||||
#include "tools/dialoggroup.h"
|
||||
#include "tools/dialogrotation.h"
|
||||
#include "tools/dialogflippingbyline.h"
|
||||
|
||||
#include "support/dialogeditwrongformula.h"
|
||||
#include "support/dialogundo.h"
|
||||
|
|
349
src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp
Normal file
349
src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp
Normal file
|
@ -0,0 +1,349 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogflippingbyline.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "dialogflippingbyline.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QComboBox>
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPointF>
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
#include <QSharedPointer>
|
||||
#include <QStringList>
|
||||
#include <QToolButton>
|
||||
#include <Qt>
|
||||
#include <new>
|
||||
|
||||
#include "../../visualization/visualization.h"
|
||||
#include "../../visualization/line/operation/vistoolflippingbyline.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "ui_dialogflippingbyline.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
: DialogTool(data, toolId, parent),
|
||||
ui(new Ui::DialogFlippingByLine),
|
||||
objects(),
|
||||
stage1(true),
|
||||
m_suffix()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
|
||||
|
||||
InitOkCancelApply(ui);
|
||||
|
||||
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
|
||||
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
|
||||
|
||||
flagName = true;
|
||||
CheckState();
|
||||
|
||||
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByLine::SuffixChanged);
|
||||
connect(ui->comboBoxFirstLinePoint,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogFlippingByLine::PointChanged);
|
||||
|
||||
vis = new VisToolFlippingByLine(data);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogFlippingByLine::~DialogFlippingByLine()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogFlippingByLine::GetFirstLinePointId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxFirstLinePoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::SetFirstLinePointId(quint32 value)
|
||||
{
|
||||
ChangeCurrentData(ui->comboBoxFirstLinePoint, value);
|
||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||
SCASSERT(operation != nullptr);
|
||||
operation->SetFirstLinePointId(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogFlippingByLine::GetSecondLinePointId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxSecondLinePoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::SetSecondLinePointId(quint32 value)
|
||||
{
|
||||
ChangeCurrentData(ui->comboBoxSecondLinePoint, value);
|
||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||
SCASSERT(operation != nullptr);
|
||||
operation->SetSecondLinePointId(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogFlippingByLine::GetSuffix() const
|
||||
{
|
||||
return m_suffix;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::SetSuffix(const QString &value)
|
||||
{
|
||||
m_suffix = value;
|
||||
ui->lineEditSuffix->setText(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<quint32> DialogFlippingByLine::GetObjects() const
|
||||
{
|
||||
return objects.toVector();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::ShowDialog(bool click)
|
||||
{
|
||||
if (stage1 && not click)
|
||||
{
|
||||
if (objects.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
stage1 = false;
|
||||
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr);
|
||||
scene->clearSelection();
|
||||
|
||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||
SCASSERT(operation != nullptr);
|
||||
operation->SetObjects(objects.toVector());
|
||||
operation->VisualMode();
|
||||
|
||||
scene->ToggleArcSelection(false);
|
||||
scene->ToggleSplineSelection(false);
|
||||
scene->ToggleSplinePathSelection(false);
|
||||
|
||||
scene->ToggleArcHover(false);
|
||||
scene->ToggleSplineHover(false);
|
||||
scene->ToggleSplinePathHover(false);
|
||||
|
||||
emit ToolTip("Select first line point");
|
||||
}
|
||||
else if (not stage1 && prepare && click)
|
||||
{
|
||||
setModal(true);
|
||||
emit ToolTip("");
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
|
||||
{
|
||||
if (not stage1 && not prepare)// After first choose we ignore all objects
|
||||
{
|
||||
if (type == SceneObject::Point)
|
||||
{
|
||||
if (objects.contains(id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (number)
|
||||
{
|
||||
case 0:
|
||||
if (SetObject(id, ui->comboBoxFirstLinePoint, tr("Select second line point")))
|
||||
{
|
||||
number++;
|
||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||
SCASSERT(operation != nullptr);
|
||||
operation->SetFirstLinePointId(id);
|
||||
operation->RefreshGeometry();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxSecondLinePoint, ""))
|
||||
{
|
||||
if (flagError)
|
||||
{
|
||||
number = 0;
|
||||
prepare = true;
|
||||
|
||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||
SCASSERT(operation != nullptr);
|
||||
operation->SetSecondLinePointId(id);
|
||||
operation->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::SelectedObject(bool selected, quint32 object, quint32 tool)
|
||||
{
|
||||
Q_UNUSED(tool)
|
||||
if (stage1)
|
||||
{
|
||||
if (selected)
|
||||
{
|
||||
if (not objects.contains(object))
|
||||
{
|
||||
objects.append(object);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
objects.removeOne(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::SuffixChanged()
|
||||
{
|
||||
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
||||
if (edit)
|
||||
{
|
||||
const QString suffix = edit->text();
|
||||
if (suffix.isEmpty())
|
||||
{
|
||||
flagName = false;
|
||||
ChangeColor(ui->labelSuffix, Qt::red);
|
||||
CheckState();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_suffix != suffix)
|
||||
{
|
||||
QRegularExpression rx(NameRegExp());
|
||||
const QStringList uniqueNames = data->AllUniqueNames();
|
||||
for (int i=0; i < uniqueNames.size(); ++i)
|
||||
{
|
||||
const QString name = uniqueNames.at(i) + suffix;
|
||||
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
||||
{
|
||||
flagName = false;
|
||||
ChangeColor(ui->labelSuffix, Qt::red);
|
||||
CheckState();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flagName = true;
|
||||
ChangeColor(ui->labelSuffix, okColor);
|
||||
}
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::CheckState()
|
||||
{
|
||||
SCASSERT(bOk != nullptr);
|
||||
bOk->setEnabled(flagError && flagName);
|
||||
SCASSERT(bApply != nullptr);
|
||||
bApply->setEnabled(bOk->isEnabled());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::ShowVisualization()
|
||||
{
|
||||
AddVisualization<VisToolFlippingByLine>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::SaveData()
|
||||
{
|
||||
m_suffix = ui->lineEditSuffix->text();
|
||||
|
||||
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||
SCASSERT(operation != nullptr);
|
||||
|
||||
operation->SetObjects(objects.toVector());
|
||||
operation->SetFirstLinePointId(GetFirstLinePointId());
|
||||
operation->SetSecondLinePointId(GetSecondLinePointId());
|
||||
operation->RefreshGeometry();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogFlippingByLine::PointChanged()
|
||||
{
|
||||
QColor color = okColor;
|
||||
flagError = true;
|
||||
ChangeColor(ui->labelFirstLinePoint, color);
|
||||
ChangeColor(ui->labelSecondLinePoint, color);
|
||||
|
||||
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) == getCurrentObjectId(ui->comboBoxSecondLinePoint))
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
ChangeColor(ui->labelFirstLinePoint, color);
|
||||
ChangeColor(ui->labelSecondLinePoint, color);
|
||||
}
|
||||
else if (objects.contains(getCurrentObjectId(ui->comboBoxFirstLinePoint)))
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
ChangeColor(ui->labelFirstLinePoint, color);
|
||||
}
|
||||
else if (objects.contains(getCurrentObjectId(ui->comboBoxSecondLinePoint)))
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
ChangeColor(ui->labelSecondLinePoint, color);
|
||||
}
|
||||
|
||||
CheckState();
|
||||
}
|
102
src/libs/vtools/dialogs/tools/dialogflippingbyline.h
Normal file
102
src/libs/vtools/dialogs/tools/dialogflippingbyline.h
Normal file
|
@ -0,0 +1,102 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogflippingbyline.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef DIALOGFLIPPINGBYLINE_H
|
||||
#define DIALOGFLIPPINGBYLINE_H
|
||||
|
||||
#include "dialogtool.h"
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QList>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
class QWidget;
|
||||
class VContainer;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DialogFlippingByLine;
|
||||
}
|
||||
|
||||
class DialogFlippingByLine : public DialogTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogFlippingByLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
||||
virtual ~DialogFlippingByLine();
|
||||
|
||||
quint32 GetFirstLinePointId() const;
|
||||
void SetFirstLinePointId(quint32 value);
|
||||
|
||||
quint32 GetSecondLinePointId() const;
|
||||
void SetSecondLinePointId(quint32 value);
|
||||
|
||||
QString GetSuffix() const;
|
||||
void SetSuffix(const QString &value);
|
||||
|
||||
QVector<quint32> GetObjects() const;
|
||||
|
||||
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
|
||||
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
|
||||
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void SuffixChanged();
|
||||
|
||||
protected:
|
||||
virtual void CheckState() Q_DECL_OVERRIDE;
|
||||
virtual void ShowVisualization() Q_DECL_OVERRIDE;
|
||||
|
||||
/** @brief SaveData Put dialog data in local variables */
|
||||
virtual void SaveData() Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void PointChanged();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogFlippingByLine)
|
||||
|
||||
Ui::DialogFlippingByLine *ui;
|
||||
|
||||
QList<quint32> objects;
|
||||
|
||||
bool stage1;
|
||||
|
||||
QString m_suffix;
|
||||
};
|
||||
|
||||
#endif // DIALOGFLIPPINGBYLINE_H
|
98
src/libs/vtools/dialogs/tools/dialogflippingbyline.ui
Normal file
98
src/libs/vtools/dialogs/tools/dialogflippingbyline.ui
Normal file
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogFlippingByLine</class>
|
||||
<widget class="QDialog" name="DialogFlippingByLine">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>285</width>
|
||||
<height>146</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelFirstLinePoint">
|
||||
<property name="text">
|
||||
<string>First line point:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBoxFirstLinePoint"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelSuffix">
|
||||
<property name="text">
|
||||
<string>Suffix:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEditSuffix"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelSecondLinePoint">
|
||||
<property name="text">
|
||||
<string>Second line point:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBoxSecondLinePoint"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogFlippingByLine</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DialogFlippingByLine</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -48,7 +48,7 @@
|
|||
#include <new>
|
||||
|
||||
#include "../../visualization/visualization.h"
|
||||
#include "../../visualization/line/vistoolrotation.h"
|
||||
#include "../../visualization/line/operation/vistoolrotation.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
|
|
|
@ -59,5 +59,6 @@
|
|||
#include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
|
||||
#include "toolpoint/tooldoublepoint/vtooltruedarts.h"
|
||||
#include "operation/vtoolrotation.h"
|
||||
#include "operation/flipping/vtoolflippingbyline.h"
|
||||
|
||||
#endif // DRAWTOOLS_H
|
||||
|
|
|
@ -0,0 +1,438 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vtoolflippingbyline.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <qiterator.h>
|
||||
#include <QColor>
|
||||
#include <QDomNode>
|
||||
#include <QDomNodeList>
|
||||
#include <QMapIterator>
|
||||
#include <QPoint>
|
||||
#include <QSharedPointer>
|
||||
#include <QStaticStringData>
|
||||
#include <QStringData>
|
||||
#include <QStringDataPtr>
|
||||
#include <QUndoStack>
|
||||
#include <new>
|
||||
|
||||
#include "../../../../dialogs/tools/dialogtool.h"
|
||||
#include "../../../../dialogs/tools/dialogflippingbyline.h"
|
||||
#include "../../../../undocommands/label/rotationmovelabel.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"
|
||||
#include "../vmisc/diagnostic.h"
|
||||
#include "../vmisc/logging.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vformula.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../vwidgets/vabstractsimple.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../../../vabstracttool.h"
|
||||
#include "../../../vdatatool.h"
|
||||
#include "../../vdrawtool.h"
|
||||
|
||||
class QDomElement;
|
||||
class QGraphicsSceneContextMenuEvent;
|
||||
class QPainter;
|
||||
class QStyleOptionGraphicsItem;
|
||||
class QWidget;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
const QString VToolFlippingByLine::ToolType = QStringLiteral("flippingByLine");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByLine::~VToolFlippingByLine()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::setDialog()
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogFlippingByLine *dialogTool = qobject_cast<DialogFlippingByLine*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
dialogTool->SetFirstLinePointId(m_firstLinePointId);
|
||||
dialogTool->SetSecondLinePointId(m_secondLinePointId);
|
||||
dialogTool->SetSuffix(suffix);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByLine *VToolFlippingByLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data)
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogFlippingByLine *dialogTool = qobject_cast<DialogFlippingByLine*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
const quint32 firstLinePointId = dialogTool->GetFirstLinePointId();
|
||||
const quint32 secondLinePointId = dialogTool->GetSecondLinePointId();
|
||||
const QString suffix = dialogTool->GetSuffix();
|
||||
const QVector<quint32> source = dialogTool->GetObjects();
|
||||
VToolFlippingByLine* operation = Create(0, firstLinePointId, secondLinePointId, suffix, source,
|
||||
QVector<DestinationItem>(), scene, doc, data, Document::FullParse,
|
||||
Source::FromGui);
|
||||
if (operation != nullptr)
|
||||
{
|
||||
operation->dialog = dialogTool;
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByLine *VToolFlippingByLine::Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
|
||||
const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation)
|
||||
{
|
||||
const auto firstPoint = *data->GeometricObject<VPointF>(firstLinePointId);
|
||||
const QPointF fPoint = firstPoint;
|
||||
|
||||
const auto secondPoint = *data->GeometricObject<VPointF>(secondLinePointId);
|
||||
const QPointF sPoint = secondPoint;
|
||||
|
||||
QVector<DestinationItem> dest = destination;
|
||||
|
||||
quint32 id = _id;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
VDrawTool::AddRecord(id, Tool::FlippingByLine, doc);
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
VToolFlippingByLine *tool = new VToolFlippingByLine(doc, data, id, firstLinePointId, secondLinePointId, suffix,
|
||||
source, dest, typeCreation);
|
||||
scene->addItem(tool);
|
||||
InitOperationToolConnections(scene, tool);
|
||||
doc->AddTool(id, tool);
|
||||
doc->IncrementReferens(firstPoint.getIdTool());
|
||||
doc->IncrementReferens(secondPoint.getIdTool());
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
{
|
||||
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
||||
}
|
||||
return tool;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::ShowVisualization(bool show)
|
||||
{
|
||||
ShowToolVisualization<VisToolFlippingByLine>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolFlippingByLine *visual = qobject_cast<VisToolFlippingByLine *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->SetObjects(source);
|
||||
visual->SetFirstLinePointId(m_firstLinePointId);
|
||||
visual->SetSecondLinePointId(m_secondLinePointId);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogFlippingByLine *dialogTool = qobject_cast<DialogFlippingByLine*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
|
||||
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId()));
|
||||
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId()));
|
||||
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::ReadToolAttributes(const QDomElement &domElement)
|
||||
{
|
||||
m_firstLinePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
||||
m_secondLinePointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
||||
suffix = doc->GetParametrString(domElement, AttrSuffix);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VDrawTool::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrP1Line, QString().setNum(m_firstLinePointId));
|
||||
doc->SetAttribute(tag, AttrP2Line, QString().setNum(m_secondLinePointId));
|
||||
doc->SetAttribute(tag, AttrSuffix, suffix);
|
||||
|
||||
SaveSourceDestination(tag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolFlippingByLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogFlippingByLine>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolFlippingByLine::VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
|
||||
quint32 secondLinePointId, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
: VAbstractOperation(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);
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VTOOLFLIPPINGBYLINE_H
|
||||
#define VTOOLFLIPPINGBYLINE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../vabstractoperation.h"
|
||||
|
||||
class VToolFlippingByLine : public VAbstractOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~VToolFlippingByLine();
|
||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static VToolFlippingByLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolFlippingByLine* Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId,
|
||||
const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
|
||||
static const QString ToolType;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::FlippingByLine)};
|
||||
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolFlippingByLine)
|
||||
|
||||
quint32 m_firstLinePointId;
|
||||
quint32 m_secondLinePointId;
|
||||
|
||||
VToolFlippingByLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstLinePointId,
|
||||
quint32 secondLinePointId, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
|
||||
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
|
610
src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp
Normal file
610
src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp
Normal file
|
@ -0,0 +1,610 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vabstractoperation.h"
|
||||
#include "../../../undocommands/label/rotationmovelabel.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
const QString VAbstractOperation::TagItem = QStringLiteral("item");
|
||||
const QString VAbstractOperation::TagSource = QStringLiteral("source");
|
||||
const QString VAbstractOperation::TagDestination = QStringLiteral("destination");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractOperation::~VAbstractOperation()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractOperation::getTagName() const
|
||||
{
|
||||
return VAbstractPattern::TagOperation;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::SetEnabled(bool enabled)
|
||||
{
|
||||
this->setEnabled(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractOperation::Suffix() const
|
||||
{
|
||||
return suffix;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::SetSuffix(const QString &suffix)
|
||||
{
|
||||
// Don't know if need check name here.
|
||||
this->suffix = suffix;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::GroupVisibility(quint32 object, bool visible)
|
||||
{
|
||||
if (operatedObjects.contains(object))
|
||||
{
|
||||
VAbstractSimple *obj = operatedObjects.value(object);
|
||||
if (obj->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
||||
SCASSERT(item != nullptr);
|
||||
item->setVisible(visible);
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(obj);
|
||||
SCASSERT(item != nullptr);
|
||||
item->setVisible(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
|
||||
QVector<DestinationItem> &destination)
|
||||
{
|
||||
SCASSERT(doc != nullptr)
|
||||
const QDomNodeList nodeList = domElement.childNodes();
|
||||
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||
{
|
||||
const QDomElement dataElement = nodeList.at(i).toElement();
|
||||
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
|
||||
{
|
||||
source.clear();
|
||||
const QDomNodeList srcList = dataElement.childNodes();
|
||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||
{
|
||||
const QDomElement element = srcList.at(j).toElement();
|
||||
if (not element.isNull())
|
||||
{
|
||||
source.append(doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
|
||||
{
|
||||
destination.clear();
|
||||
const QDomNodeList srcList = dataElement.childNodes();
|
||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||
{
|
||||
const QDomElement element = srcList.at(j).toElement();
|
||||
if (not element.isNull())
|
||||
{
|
||||
DestinationItem d;
|
||||
d.id = doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
|
||||
d.mx = qApp->toPixel(doc->GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
|
||||
d.my = qApp->toPixel(doc->GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
|
||||
destination.append(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::FullUpdateFromFile()
|
||||
{
|
||||
ReadAttributes();
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
|
||||
}
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowHover(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowSelecting(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowPointHover(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowPointSelecting(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowPointLabelHover(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->AllowLabelHover(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowPointLabelSelecting(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->AllowLabelSelecting(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowSplineHover(bool enabled)
|
||||
{
|
||||
AllowCurveHover(enabled, GOType::Spline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowSplineSelecting(bool enabled)
|
||||
{
|
||||
AllowCurveSelecting(enabled, GOType::Spline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowSplinePathHover(bool enabled)
|
||||
{
|
||||
AllowCurveHover(enabled, GOType::SplinePath);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowSplinePathSelecting(bool enabled)
|
||||
{
|
||||
AllowCurveSelecting(enabled, GOType::SplinePath);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowArcHover(bool enabled)
|
||||
{
|
||||
AllowCurveHover(enabled, GOType::Arc);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowArcSelecting(bool enabled)
|
||||
{
|
||||
AllowCurveSelecting(enabled, GOType::Arc);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
enabled = !CorrectDisable(disable, namePP);
|
||||
SetEnabled(enabled);
|
||||
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
i.value()->SetEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::ObjectSelected(bool selected, quint32 objId)
|
||||
{
|
||||
emit ChangedToolSelection(selected, objId, id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::DeleteFromLabel()
|
||||
{
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::LabelChangePosition(const QPointF &pos, quint32 labelId)
|
||||
{
|
||||
if (operatedObjects.contains(labelId))
|
||||
{
|
||||
VAbstractSimple *obj = operatedObjects.value(labelId);
|
||||
if (obj->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
||||
SCASSERT(item != nullptr);
|
||||
ChangePosition(item, labelId, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractOperation::VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
QGraphicsItem *parent)
|
||||
: VDrawTool(doc, data, id),
|
||||
QGraphicsLineItem(parent),
|
||||
suffix(suffix),
|
||||
source(source),
|
||||
destination(destination),
|
||||
operatedObjects()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AddToFile()
|
||||
{
|
||||
QDomElement domElement = doc->createElement(getTagName());
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOptions(domElement, obj);
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOptions(domElement, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Can't find tool with id = %u", id);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::UpdateNamePosition(quint32 id)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
auto moveLabel = new RotationMoveLabel(this->id, doc, point->mx(), point->my(), id);
|
||||
connect(moveLabel, &RotationMoveLabel::ChangePosition, this, &VAbstractOperation::DoChangePosition);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
|
||||
{
|
||||
doc->RemoveAllChildren(tag);
|
||||
|
||||
QDomElement tagObjects = doc->createElement(TagSource);
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
{
|
||||
QDomElement item = doc->createElement(TagItem);
|
||||
doc->SetAttribute(item, AttrIdObject, source.at(i));
|
||||
tagObjects.appendChild(item);
|
||||
}
|
||||
tag.appendChild(tagObjects);
|
||||
|
||||
tagObjects = doc->createElement(TagDestination);
|
||||
for (int i = 0; i < destination.size(); ++i)
|
||||
{
|
||||
QDomElement item = doc->createElement(TagItem);
|
||||
doc->SetAttribute(item, AttrIdObject, destination.at(i).id);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(destination.at(i).mx, INT_MAX) &&
|
||||
not VFuzzyComparePossibleNulls(destination.at(i).my, INT_MAX))
|
||||
{
|
||||
doc->SetAttribute(item, AttrMx, qApp->fromPixel(destination.at(i).mx));
|
||||
doc->SetAttribute(item, AttrMy, qApp->fromPixel(destination.at(i).my));
|
||||
}
|
||||
|
||||
tagObjects.appendChild(item);
|
||||
}
|
||||
tag.appendChild(tagObjects);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSimpleCurve *VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveType)
|
||||
{
|
||||
VSimpleCurve *curve = new VSimpleCurve(id, QColor(baseColor), *data->GetPatternUnit(), &factor);
|
||||
curve->setParentItem(this);
|
||||
curve->SetType(curveType);
|
||||
connect(curve, &VSimpleCurve::Selected, this, &VAbstractOperation::ObjectSelected);
|
||||
connect(curve, &VSimpleCurve::ShowContextMenu, [this](QGraphicsSceneContextMenuEvent * event)
|
||||
{
|
||||
contextMenuEvent(event);
|
||||
});
|
||||
connect(curve, &VSimpleCurve::Delete, this, &VAbstractOperation::DeleteFromLabel);
|
||||
curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
|
||||
operatedObjects.insert(id, curve);
|
||||
return curve;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::DoChangePosition(quint32 id, qreal mx, qreal my)
|
||||
{
|
||||
if (operatedObjects.contains(id))
|
||||
{
|
||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
point->setMx(mx);
|
||||
point->setMy(my);
|
||||
VAbstractTool::data.UpdateGObject(id, point);
|
||||
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(operatedObjects.value(id));
|
||||
SCASSERT(item != nullptr);
|
||||
|
||||
item->RefreshGeometry(*point);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowCurveHover(bool enabled, GOType type)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() != GOType::Point)
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
if (item->GetType() == type)
|
||||
{
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::AllowCurveSelecting(bool enabled, GOType type)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() != GOType::Point)
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
if (item->GetType() == type)
|
||||
{
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos)
|
||||
{
|
||||
const QPointF p = pos - item->pos();
|
||||
DoChangePosition(id, p.x(), p.y());
|
||||
UpdateNamePosition(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::InitOperatedObjects()
|
||||
{
|
||||
for (int i = 0; i < destination.size(); ++i)
|
||||
{
|
||||
const DestinationItem object = destination.at(i);
|
||||
const QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(object.id);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
{
|
||||
VSimplePoint *point = new VSimplePoint(object.id, QColor(baseColor),
|
||||
*VAbstractTool::data.GetPatternUnit(), &factor);
|
||||
point->setParentItem(this);
|
||||
point->SetType(GOType::Point);
|
||||
connect(point, &VSimplePoint::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Point);
|
||||
});
|
||||
connect(point, &VSimplePoint::Selected, this, &VAbstractOperation::ObjectSelected);
|
||||
connect(point, &VSimplePoint::ShowContextMenu, [this](QGraphicsSceneContextMenuEvent * event)
|
||||
{
|
||||
contextMenuEvent(event);
|
||||
});
|
||||
connect(point, &VSimplePoint::Delete, this, &VAbstractOperation::DeleteFromLabel);
|
||||
connect(point, &VSimplePoint::NameChangedPosition, this, &VAbstractOperation::LabelChangePosition);
|
||||
point->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(object.id));
|
||||
operatedObjects.insert(object.id, point);
|
||||
break;
|
||||
}
|
||||
case GOType::Arc:
|
||||
case GOType::EllipticalArc:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::Arc);
|
||||
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Arc);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case GOType::Spline:
|
||||
case GOType::CubicBezier:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::Spline);
|
||||
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Spline);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case GOType::SplinePath:
|
||||
case GOType::CubicBezierPath:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::SplinePath);
|
||||
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::SplinePath);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
}
|
||||
}
|
203
src/libs/vtools/tools/drawTools/operation/vabstractoperation.h
Normal file
203
src/libs/vtools/tools/drawTools/operation/vabstractoperation.h
Normal file
|
@ -0,0 +1,203 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VABSTRACTOPERATION_H
|
||||
#define VABSTRACTOPERATION_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QMap>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QGraphicsLineItem>
|
||||
|
||||
#include "../vdrawtool.h"
|
||||
#include "../vwidgets/vsimplecurve.h"
|
||||
#include "../vwidgets/vsimplepoint.h"
|
||||
|
||||
struct DestinationItem
|
||||
{
|
||||
quint32 id;
|
||||
qreal mx;
|
||||
qreal my;
|
||||
};
|
||||
|
||||
class VAbstractSimple;
|
||||
class VAbstractPattern;
|
||||
class QDomElement;
|
||||
class QPainter;
|
||||
class QPointF;
|
||||
class QStyleOptionGraphicsItem;
|
||||
class QWidget;
|
||||
class VContainer;
|
||||
|
||||
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
|
||||
// QGraphicsItem itself produce case where clicking on empty space produce call to QGraphicsItem.
|
||||
// And i don't know how to fix it.
|
||||
class VAbstractOperation : public VDrawTool, public QGraphicsLineItem
|
||||
{
|
||||
Q_OBJECT
|
||||
// Fix warning "Class implements the interface QGraphicsItem but does not list it
|
||||
// in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!"
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
virtual ~VAbstractOperation();
|
||||
|
||||
static const QString TagItem;
|
||||
static const QString TagSource;
|
||||
static const QString TagDestination;
|
||||
|
||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
QString Suffix() const;
|
||||
void SetSuffix(const QString &suffix);
|
||||
|
||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
||||
|
||||
static void ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
|
||||
QVector<DestinationItem> &destination);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
||||
|
||||
void AllowPointHover(bool enabled);
|
||||
void AllowPointSelecting(bool enabled);
|
||||
|
||||
void AllowPointLabelHover(bool enabled);
|
||||
void AllowPointLabelSelecting(bool enabled);
|
||||
|
||||
void AllowSplineHover(bool enabled);
|
||||
void AllowSplineSelecting(bool enabled);
|
||||
|
||||
void AllowSplinePathHover(bool enabled);
|
||||
void AllowSplinePathSelecting(bool enabled);
|
||||
|
||||
void AllowArcHover(bool enabled);
|
||||
void AllowArcSelecting(bool enabled);
|
||||
|
||||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||
void ObjectSelected(bool selected, quint32 objId);
|
||||
void DeleteFromLabel();
|
||||
void LabelChangePosition(const QPointF &pos, quint32 labelId);
|
||||
protected:
|
||||
QString suffix;
|
||||
|
||||
QVector<quint32> source;
|
||||
QVector<DestinationItem> destination;
|
||||
|
||||
QMap<quint32, VAbstractSimple *> operatedObjects;
|
||||
|
||||
VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
|
||||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
|
||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
|
||||
|
||||
void UpdateNamePosition(quint32 id);
|
||||
void SaveSourceDestination(QDomElement &tag);
|
||||
|
||||
template <typename T>
|
||||
void ShowToolVisualization(bool show);
|
||||
|
||||
VSimpleCurve *InitCurve(quint32 id, VContainer *data, GOType curveType);
|
||||
|
||||
template <typename T>
|
||||
static void InitOperationToolConnections(VMainGraphicsScene *scene, T *tool);
|
||||
|
||||
void InitOperatedObjects();
|
||||
protected slots:
|
||||
void DoChangePosition(quint32 id, qreal mx, qreal my);
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractOperation)
|
||||
|
||||
void AllowCurveHover(bool enabled, GOType type);
|
||||
void AllowCurveSelecting(bool enabled, GOType type);
|
||||
|
||||
void ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VAbstractOperation::ShowToolVisualization(bool show)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
AddVisualization<T>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (T *visual = qobject_cast<T *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete vis;
|
||||
vis = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VAbstractOperation::InitOperationToolConnections(VMainGraphicsScene *scene, T *tool)
|
||||
{
|
||||
SCASSERT(scene != nullptr);
|
||||
SCASSERT(tool != nullptr);
|
||||
|
||||
InitDrawToolConnections(scene, tool);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemHover, tool, &T::AllowPointHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemSelection, tool, &T::AllowPointSelecting);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemHover, tool, &T::AllowPointLabelHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, tool, &T::AllowPointLabelSelecting);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemHover, tool, &T::AllowSplineHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemSelection, tool, &T::AllowSplineSelecting);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemHover, tool, &T::AllowSplinePathHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemSelection, tool, &T::AllowSplinePathSelecting);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemHover, tool, &T::AllowArcHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowArcSelecting);
|
||||
}
|
||||
|
||||
#endif // VABSTRACTOPERATION_H
|
|
@ -44,8 +44,7 @@
|
|||
|
||||
#include "../../../dialogs/tools/dialogtool.h"
|
||||
#include "../../../dialogs/tools/dialogrotation.h"
|
||||
#include "../../../undocommands/label/rotationmovelabel.h"
|
||||
#include "../../../visualization/line/vistoolrotation.h"
|
||||
#include "../../../visualization/line/operation/vistoolrotation.h"
|
||||
#include "../../../visualization/visualization.h"
|
||||
#include "../vgeometry/vabstractcurve.h"
|
||||
#include "../vgeometry/varc.h"
|
||||
|
@ -66,8 +65,6 @@
|
|||
#include "../ifc/exception/vexception.h"
|
||||
#include "../vwidgets/vabstractsimple.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../vwidgets/vsimplecurve.h"
|
||||
#include "../vwidgets/vsimplepoint.h"
|
||||
#include "../../vabstracttool.h"
|
||||
#include "../../vdatatool.h"
|
||||
#include "../vdrawtool.h"
|
||||
|
@ -79,90 +76,18 @@ class QStyleOptionGraphicsItem;
|
|||
class QWidget;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
const QString VToolRotation::ToolType = QStringLiteral("rotation");
|
||||
const QString VToolRotation::TagItem = QStringLiteral("item");
|
||||
const QString VToolRotation::TagSource = QStringLiteral("source");
|
||||
const QString VToolRotation::TagDestination = QStringLiteral("destination");
|
||||
const QString VToolRotation::ToolType = QStringLiteral("rotation");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolRotation::VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
|
||||
const QString &angle, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
: VDrawTool(doc, data, id),
|
||||
QGraphicsLineItem(parent),
|
||||
: VAbstractOperation(doc, data, id, suffix, source, destination, parent),
|
||||
origPointId(origPointId),
|
||||
formulaAngle(angle),
|
||||
suffix(suffix),
|
||||
source(source),
|
||||
destination(destination),
|
||||
rObjects()
|
||||
formulaAngle(angle)
|
||||
{
|
||||
for (int i = 0; i < destination.size(); ++i)
|
||||
{
|
||||
const DestinationItem object = destination.at(i);
|
||||
const QSharedPointer<VGObject> obj = data->GetGObject(object.id);
|
||||
|
||||
// This check helps to find missed objects in the switch
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 7, "Not all objects were handled.");
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
switch(static_cast<GOType>(obj->getType()))
|
||||
{
|
||||
case GOType::Point:
|
||||
{
|
||||
VSimplePoint *point = new VSimplePoint(object.id, QColor(baseColor), *data->GetPatternUnit(), &factor);
|
||||
point->setParentItem(this);
|
||||
point->SetType(GOType::Point);
|
||||
connect(point, &VSimplePoint::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Point);
|
||||
});
|
||||
connect(point, &VSimplePoint::Selected, this, &VToolRotation::ObjectSelected);
|
||||
connect(point, &VSimplePoint::ShowContextMenu, this, &VToolRotation::contextMenuEvent);
|
||||
connect(point, &VSimplePoint::Delete, this, &VToolRotation::DeleteFromLabel);
|
||||
connect(point, &VSimplePoint::NameChangedPosition, this, &VToolRotation::LabelChangePosition);
|
||||
point->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(object.id));
|
||||
rObjects.insert(object.id, point);
|
||||
break;
|
||||
}
|
||||
case GOType::Arc:
|
||||
case GOType::EllipticalArc:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, data, GOType::Arc);
|
||||
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Arc);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case GOType::Spline:
|
||||
case GOType::CubicBezier:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, data, GOType::Spline);
|
||||
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Spline);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case GOType::SplinePath:
|
||||
case GOType::CubicBezierPath:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, data, GOType::SplinePath);
|
||||
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::SplinePath);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case GOType::Unknown:
|
||||
break;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
}
|
||||
|
||||
InitOperatedObjects();
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
|
@ -317,7 +242,7 @@ QT_WARNING_POP
|
|||
{
|
||||
VToolRotation *tool = new VToolRotation(doc, data, id, origin, angle, suffix, source, dest, typeCreation);
|
||||
scene->addItem(tool);
|
||||
InitRotationToolConnections(scene, tool);
|
||||
InitOperationToolConnections(scene, tool);
|
||||
doc->AddTool(id, tool);
|
||||
doc->IncrementReferens(originPoint.getIdTool());
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
|
@ -329,61 +254,6 @@ QT_WARNING_POP
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
|
||||
QVector<DestinationItem> &destination)
|
||||
{
|
||||
SCASSERT(doc != nullptr)
|
||||
const QDomNodeList nodeList = domElement.childNodes();
|
||||
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||
{
|
||||
const QDomElement dataElement = nodeList.at(i).toElement();
|
||||
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
|
||||
{
|
||||
source.clear();
|
||||
const QDomNodeList srcList = dataElement.childNodes();
|
||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||
{
|
||||
const QDomElement element = srcList.at(j).toElement();
|
||||
if (not element.isNull())
|
||||
{
|
||||
source.append(doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
|
||||
{
|
||||
destination.clear();
|
||||
const QDomNodeList srcList = dataElement.childNodes();
|
||||
for (qint32 j = 0; j < srcList.size(); ++j)
|
||||
{
|
||||
const QDomElement element = srcList.at(j).toElement();
|
||||
if (not element.isNull())
|
||||
{
|
||||
DestinationItem d;
|
||||
d.id = doc->GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
|
||||
d.mx = qApp->toPixel(doc->GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
|
||||
d.my = qApp->toPixel(doc->GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
|
||||
destination.append(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolRotation::getTagName() const
|
||||
{
|
||||
return VAbstractPattern::TagOperation;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::SetEnabled(bool enabled)
|
||||
{
|
||||
this->setEnabled(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolRotation::GetFormulaAngle() const
|
||||
{
|
||||
|
@ -406,263 +276,12 @@ void VToolRotation::SetFormulaAngle(const VFormula &value)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolRotation::Suffix() const
|
||||
{
|
||||
return suffix;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::SetSuffix(const QString &suffix)
|
||||
{
|
||||
// Don't know if need check name here.
|
||||
this->suffix = suffix;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::GroupVisibility(quint32 object, bool visible)
|
||||
{
|
||||
if (rObjects.contains(object))
|
||||
{
|
||||
VAbstractSimple *obj = rObjects.value(object);
|
||||
if (obj->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
||||
SCASSERT(item != nullptr);
|
||||
item->setVisible(visible);
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(obj);
|
||||
SCASSERT(item != nullptr);
|
||||
item->setVisible(visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::ShowVisualization(bool show)
|
||||
{
|
||||
ShowToolVisualization<VisToolRotation>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::FullUpdateFromFile()
|
||||
{
|
||||
ReadAttributes();
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
|
||||
}
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowHover(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowSelecting(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowPointHover(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowPointSelecting(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowPointLabelHover(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->AllowLabelHover(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowPointLabelSelecting(bool enabled)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
item->AllowLabelSelecting(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowSplineHover(bool enabled)
|
||||
{
|
||||
AllowCurveHover(enabled, GOType::Spline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowSplineSelecting(bool enabled)
|
||||
{
|
||||
AllowCurveSelecting(enabled, GOType::Spline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowSplinePathHover(bool enabled)
|
||||
{
|
||||
AllowCurveHover(enabled, GOType::SplinePath);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowSplinePathSelecting(bool enabled)
|
||||
{
|
||||
AllowCurveSelecting(enabled, GOType::SplinePath);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowArcHover(bool enabled)
|
||||
{
|
||||
AllowCurveHover(enabled, GOType::Arc);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowArcSelecting(bool enabled)
|
||||
{
|
||||
AllowCurveSelecting(enabled, GOType::Arc);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AddToFile()
|
||||
{
|
||||
QDomElement domElement = doc->createElement(getTagName());
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOptions(domElement, obj);
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOptions(domElement, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Can't find tool with id = %u", id);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::SetVisualization()
|
||||
{
|
||||
|
@ -678,63 +297,6 @@ void VToolRotation::SetVisualization()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
enabled = !CorrectDisable(disable, namePP);
|
||||
SetEnabled(enabled);
|
||||
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
i.value()->SetEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::ObjectSelected(bool selected, quint32 objId)
|
||||
{
|
||||
emit ChangedToolSelection(selected, objId, id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::DeleteFromLabel()
|
||||
{
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::LabelChangePosition(const QPointF &pos, quint32 labelId)
|
||||
{
|
||||
if (rObjects.contains(labelId))
|
||||
{
|
||||
VAbstractSimple *obj = rObjects.value(labelId);
|
||||
if (obj->GetType() == GOType::Point)
|
||||
{
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(obj);
|
||||
SCASSERT(item != nullptr);
|
||||
ChangePosition(item, labelId, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
|
@ -765,33 +327,7 @@ void VToolRotation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
doc->SetAttribute(tag, AttrAngle, formulaAngle);
|
||||
doc->SetAttribute(tag, AttrSuffix, suffix);
|
||||
|
||||
doc->RemoveAllChildren(tag);
|
||||
|
||||
QDomElement tagObjects = doc->createElement(TagSource);
|
||||
for (int i = 0; i < source.size(); ++i)
|
||||
{
|
||||
QDomElement item = doc->createElement(TagItem);
|
||||
doc->SetAttribute(item, AttrIdObject, source.at(i));
|
||||
tagObjects.appendChild(item);
|
||||
}
|
||||
tag.appendChild(tagObjects);
|
||||
|
||||
tagObjects = doc->createElement(TagDestination);
|
||||
for (int i = 0; i < destination.size(); ++i)
|
||||
{
|
||||
QDomElement item = doc->createElement(TagItem);
|
||||
doc->SetAttribute(item, AttrIdObject, destination.at(i).id);
|
||||
|
||||
if (not VFuzzyComparePossibleNulls(destination.at(i).mx, INT_MAX) &&
|
||||
not VFuzzyComparePossibleNulls(destination.at(i).my, INT_MAX))
|
||||
{
|
||||
doc->SetAttribute(item, AttrMx, qApp->fromPixel(destination.at(i).mx));
|
||||
doc->SetAttribute(item, AttrMy, qApp->fromPixel(destination.at(i).my));
|
||||
}
|
||||
|
||||
tagObjects.appendChild(item);
|
||||
}
|
||||
tag.appendChild(tagObjects);
|
||||
SaveSourceDestination(tag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -808,32 +344,6 @@ void VToolRotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::DoChangePosition(quint32 id, qreal mx, qreal my)
|
||||
{
|
||||
if (rObjects.contains(id))
|
||||
{
|
||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
point->setMx(mx);
|
||||
point->setMy(my);
|
||||
VAbstractTool::data.UpdateGObject(id, point);
|
||||
|
||||
VSimplePoint *item = qobject_cast<VSimplePoint *>(rObjects.value(id));
|
||||
SCASSERT(item != nullptr);
|
||||
|
||||
item->RefreshGeometry(*point);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::UpdateNamePosition(quint32 id)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
auto moveLabel = new RotationMoveLabel(this->id, doc, point->mx(), point->my(), id);
|
||||
connect(moveLabel, &RotationMoveLabel::ChangePosition, this, &VToolRotation::DoChangePosition);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||
const QString &suffix, VContainer *data)
|
||||
|
@ -942,121 +452,3 @@ void VToolRotation::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, cons
|
|||
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
|
||||
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VToolRotation::ShowToolVisualization(bool show)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
AddVisualization<T>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (T *visual = qobject_cast<T *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete vis;
|
||||
vis = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos)
|
||||
{
|
||||
const QPointF p = pos - item->pos();
|
||||
DoChangePosition(id, p.x(), p.y());
|
||||
UpdateNamePosition(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSimpleCurve *VToolRotation::InitCurve(quint32 id, VContainer *data, GOType curveType)
|
||||
{
|
||||
VSimpleCurve *curve = new VSimpleCurve(id, QColor(baseColor), *data->GetPatternUnit(), &factor);
|
||||
curve->setParentItem(this);
|
||||
curve->SetType(curveType);
|
||||
connect(curve, &VSimpleCurve::Selected, this, &VToolRotation::ObjectSelected);
|
||||
connect(curve, &VSimpleCurve::ShowContextMenu, this, &VToolRotation::contextMenuEvent);
|
||||
connect(curve, &VSimpleCurve::Delete, this, &VToolRotation::DeleteFromLabel);
|
||||
curve->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(id));
|
||||
rObjects.insert(id, curve);
|
||||
return curve;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowCurveHover(bool enabled, GOType type)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() != GOType::Point)
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
if (item->GetType() == type)
|
||||
{
|
||||
item->setAcceptHoverEvents(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AllowCurveSelecting(bool enabled, GOType type)
|
||||
{
|
||||
QMapIterator<quint32, VAbstractSimple *> i(rObjects);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value()->GetType() != GOType::Point)
|
||||
{
|
||||
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
|
||||
SCASSERT(item != nullptr);
|
||||
if (item->GetType() == type)
|
||||
{
|
||||
item->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolRotation::AddSourceObject(VAbstractPattern *doc, QDomElement &domElement, quint32 objId)
|
||||
{
|
||||
QDomElement obj = doc->createElement(TagItem);
|
||||
doc->SetAttribute(obj, AttrIdObject, objId);
|
||||
domElement.appendChild(obj);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VToolRotation::InitRotationToolConnections(VMainGraphicsScene *scene, T *tool)
|
||||
{
|
||||
SCASSERT(scene != nullptr);
|
||||
SCASSERT(tool != nullptr);
|
||||
|
||||
InitDrawToolConnections(scene, tool);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemHover, tool, &T::AllowPointHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemSelection, tool, &T::AllowPointSelecting);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemHover, tool, &T::AllowPointLabelHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, tool, &T::AllowPointLabelSelecting);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemHover, tool, &T::AllowSplineHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemSelection, tool, &T::AllowSplineSelecting);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemHover, tool, &T::AllowSplinePathHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemSelection, tool, &T::AllowSplinePathSelecting);
|
||||
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemHover, tool, &T::AllowArcHover);
|
||||
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowArcSelecting);
|
||||
}
|
||||
|
|
|
@ -30,18 +30,14 @@
|
|||
#define VTOOLROTATION_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QDomElement>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QMap>
|
||||
#include <QMetaObject>
|
||||
#include <QObject>
|
||||
#include <QPointF>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../vdrawtool.h"
|
||||
#include "vabstractoperation.h"
|
||||
#include "../vgeometry/vgeometrydef.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
|
@ -49,35 +45,16 @@
|
|||
class DialogTool;
|
||||
class QDomElement;
|
||||
class QGraphicsSceneContextMenuEvent;
|
||||
class QPainter;
|
||||
class QPointF;
|
||||
class QStyleOptionGraphicsItem;
|
||||
class QWidget;
|
||||
class VContainer;
|
||||
class VGObject;
|
||||
class VMainGraphicsScene;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct DestinationItem
|
||||
{
|
||||
quint32 id;
|
||||
qreal mx;
|
||||
qreal my;
|
||||
};
|
||||
|
||||
class VAbstractSimple;
|
||||
class VFormula;
|
||||
class VSimpleCurve;
|
||||
|
||||
// FIXME. I don't know how to use QGraphicsItem properly, so just took first available finished class.
|
||||
// QGraphicsItem itself produce case where clicking on empty space produce call to QGraphicsItem.
|
||||
// And i don't know how to fix it.
|
||||
class VToolRotation : public VDrawTool, public QGraphicsLineItem
|
||||
class VToolRotation : public VAbstractOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
// Fix warning "Class implements the interface QGraphicsItem but does not list it
|
||||
// in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!"
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
virtual ~VToolRotation();
|
||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
|
@ -87,85 +64,34 @@ public:
|
|||
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static void ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector<quint32> &source,
|
||||
QVector<DestinationItem> &destination);
|
||||
|
||||
static const QString ToolType;
|
||||
static const QString TagItem;
|
||||
static const QString TagSource;
|
||||
static const QString TagDestination;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::Rotation)};
|
||||
virtual QString getTagName() const Q_DECL_OVERRIDE;
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
VFormula GetFormulaAngle() const;
|
||||
void SetFormulaAngle(const VFormula &value);
|
||||
|
||||
QString Suffix() const;
|
||||
void SetSuffix(const QString &suffix);
|
||||
|
||||
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
|
||||
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
|
||||
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
|
||||
|
||||
void AllowPointHover(bool enabled);
|
||||
void AllowPointSelecting(bool enabled);
|
||||
|
||||
void AllowPointLabelHover(bool enabled);
|
||||
void AllowPointLabelSelecting(bool enabled);
|
||||
|
||||
void AllowSplineHover(bool enabled);
|
||||
void AllowSplineSelecting(bool enabled);
|
||||
|
||||
void AllowSplinePathHover(bool enabled);
|
||||
void AllowSplinePathSelecting(bool enabled);
|
||||
|
||||
void AllowArcHover(bool enabled);
|
||||
void AllowArcSelecting(bool enabled);
|
||||
|
||||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||
void ObjectSelected(bool selected, quint32 objId);
|
||||
void DeleteFromLabel();
|
||||
void LabelChangePosition(const QPointF &pos, quint32 labelId);
|
||||
|
||||
protected:
|
||||
virtual void AddToFile() Q_DECL_OVERRIDE;
|
||||
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void DoChangePosition(quint32 id, qreal mx, qreal my);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolRotation)
|
||||
quint32 origPointId;
|
||||
QString formulaAngle;
|
||||
QString suffix;
|
||||
|
||||
QVector<quint32> source;
|
||||
QVector<DestinationItem> destination;
|
||||
|
||||
QMap<quint32, VAbstractSimple *> rObjects;
|
||||
|
||||
VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 origPointId,
|
||||
const QString &formulaAngle, const QString &suffix, const QVector<quint32> &source,
|
||||
const QVector<DestinationItem> &destination, const Source &typeCreation,
|
||||
QGraphicsItem *parent = nullptr);
|
||||
|
||||
void UpdateNamePosition(quint32 id);
|
||||
|
||||
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
|
||||
const QString &suffix, VContainer *data);
|
||||
|
||||
|
@ -178,8 +104,8 @@ private:
|
|||
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
|
||||
const QString &suffix, VContainer *data);
|
||||
template <class Item>
|
||||
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
|
||||
const QString &suffix, VContainer *data);
|
||||
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin,
|
||||
qreal formulaAngle, const QString &suffix, VContainer *data);
|
||||
|
||||
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
|
||||
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my);
|
||||
|
@ -194,21 +120,6 @@ private:
|
|||
template <class Item>
|
||||
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
|
||||
const QString &suffix, VContainer *data, quint32 id);
|
||||
|
||||
template <typename T>
|
||||
void ShowToolVisualization(bool show);
|
||||
|
||||
void ChangePosition(QGraphicsItem *item, quint32 id, const QPointF &pos);
|
||||
|
||||
VSimpleCurve *InitCurve(quint32 id, VContainer *data, GOType curveType);
|
||||
|
||||
template <typename T>
|
||||
static void InitRotationToolConnections(VMainGraphicsScene *scene, T *tool);
|
||||
|
||||
void AllowCurveHover(bool enabled, GOType type);
|
||||
void AllowCurveSelecting(bool enabled, GOType type);
|
||||
|
||||
static void AddSourceObject(VAbstractPattern *doc, QDomElement &domElement, quint32 objId);
|
||||
};
|
||||
|
||||
#endif // VTOOLROTATION_H
|
||||
|
|
|
@ -51,7 +51,9 @@ HEADERS += \
|
|||
$$PWD/drawTools/toolcurve/vtoolcubicbezier.h \
|
||||
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.h \
|
||||
$$PWD/drawTools/operation/vtoolrotation.h \
|
||||
$$PWD/vtextgraphicsitem.h
|
||||
$$PWD/vtextgraphicsitem.h \
|
||||
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.h \
|
||||
$$PWD/drawTools/operation/vabstractoperation.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vtooldetail.cpp \
|
||||
|
@ -100,4 +102,6 @@ SOURCES += \
|
|||
$$PWD/drawTools/toolcurve/vtoolcubicbezier.cpp \
|
||||
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.cpp \
|
||||
$$PWD/drawTools/operation/vtoolrotation.cpp \
|
||||
$$PWD/vtextgraphicsitem.cpp
|
||||
$$PWD/vtextgraphicsitem.cpp \
|
||||
$$PWD/drawTools/operation/flipping/vtoolflippingbyline.cpp \
|
||||
$$PWD/drawTools/operation/vabstractoperation.cpp
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "visoperation.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisOperation::VisOperation(const VContainer *data, QGraphicsItem *parent)
|
||||
: VisLine(data, parent),
|
||||
objects(),
|
||||
supportColor2(Qt::darkGreen),
|
||||
points(),
|
||||
curves()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisOperation::~VisOperation()
|
||||
{
|
||||
qDeleteAll(points);
|
||||
qDeleteAll(curves);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisOperation::SetObjects(QVector<quint32> objects)
|
||||
{
|
||||
this->objects = objects;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisOperation::VisualMode(const quint32 &pointId)
|
||||
{
|
||||
Q_UNUSED(pointId);
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr);
|
||||
|
||||
Visualization::scenePos = scene->getScenePos();
|
||||
RefreshGeometry();
|
||||
|
||||
AddOnScene();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *VisOperation::GetPoint(quint32 i, const QColor &color)
|
||||
{
|
||||
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
||||
{
|
||||
return points.at(static_cast<int>(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto point = InitPoint(color, this);
|
||||
points.append(point);
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsPathItem *VisOperation::GetCurve(quint32 i, const QColor &color)
|
||||
{
|
||||
if (not curves.isEmpty() && static_cast<quint32>(curves.size() - 1) >= i)
|
||||
{
|
||||
return curves.at(static_cast<int>(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto curve = InitItem<QGraphicsPathItem>(color, this);
|
||||
curves.append(curve);
|
||||
return curve;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
62
src/libs/vtools/visualization/line/operation/visoperation.h
Normal file
62
src/libs/vtools/visualization/line/operation/visoperation.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VISOPERATION_H
|
||||
#define VISOPERATION_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../visline.h"
|
||||
|
||||
class VisOperation : public VisLine
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||
virtual ~VisOperation();
|
||||
|
||||
void SetObjects(QVector<quint32> objects);
|
||||
|
||||
virtual void VisualMode(const quint32 &pointId = NULL_ID) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolRotation)};
|
||||
protected:
|
||||
QVector<quint32> objects;
|
||||
QColor supportColor2;
|
||||
|
||||
QVector<QGraphicsEllipseItem *> points;
|
||||
QVector<QGraphicsPathItem *> curves;
|
||||
|
||||
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color);
|
||||
QGraphicsPathItem * GetCurve(quint32 i, const QColor &color);
|
||||
private:
|
||||
Q_DISABLE_COPY(VisOperation)
|
||||
};
|
||||
|
||||
#endif // VISOPERATION_H
|
|
@ -0,0 +1,185 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vistoolflippingbyline.h"
|
||||
#include "../vgeometry/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)
|
||||
: VisOperation(data, parent),
|
||||
object2Id(NULL_ID),
|
||||
point1(nullptr),
|
||||
point2(nullptr)
|
||||
{
|
||||
point1 = InitPoint(supportColor2, this);
|
||||
point2 = InitPoint(supportColor2, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolFlippingByLine::~VisToolFlippingByLine()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
void VisToolFlippingByLine::RefreshGeometry()
|
||||
{
|
||||
if (objects.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QPointF firstPoint;
|
||||
QPointF secondPoint;
|
||||
|
||||
if (object1Id != NULL_ID)
|
||||
{
|
||||
firstPoint = *Visualization::data->GeometricObject<VPointF>(object1Id);
|
||||
DrawPoint(point1, firstPoint, supportColor2);
|
||||
|
||||
if (object2Id == NULL_ID)
|
||||
{
|
||||
secondPoint = Visualization::scenePos;
|
||||
}
|
||||
else
|
||||
{
|
||||
secondPoint = *Visualization::data->GeometricObject<VPointF>(object2Id);
|
||||
DrawPoint(point2, secondPoint, supportColor2);
|
||||
}
|
||||
|
||||
DrawLine(this, QLineF(firstPoint, secondPoint), supportColor2, Qt::DashLine);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
|
||||
{
|
||||
object1Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 9, 2016
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2016 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VISTOOLFLIPPINGBYLINE_H
|
||||
#define VISTOOLFLIPPINGBYLINE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "visoperation.h"
|
||||
|
||||
class VisToolFlippingByLine : public VisOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||
virtual ~VisToolFlippingByLine();
|
||||
|
||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||
|
||||
void SetFirstLinePointId(quint32 value);
|
||||
void SetSecondLinePointId(quint32 value);
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByLine)};
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolFlippingByLine)
|
||||
quint32 object2Id;
|
||||
QGraphicsEllipseItem *point1;
|
||||
QGraphicsEllipseItem *point2;
|
||||
|
||||
template <class Item>
|
||||
int AddCurve(const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, int i);
|
||||
};
|
||||
|
||||
#endif // VISTOOLFLIPPINGBYLINE_H
|
|
@ -53,22 +53,17 @@
|
|||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../visualization.h"
|
||||
#include "visline.h"
|
||||
#include "visoperation.h"
|
||||
|
||||
class QPointF;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
|
||||
: VisLine(data, parent),
|
||||
: VisOperation(data, parent),
|
||||
angle(INT_MIN),
|
||||
objects(),
|
||||
point(nullptr),
|
||||
angleArc(nullptr),
|
||||
xAxis(nullptr),
|
||||
supportColor2(Qt::darkGreen),
|
||||
points(),
|
||||
curves()
|
||||
xAxis(nullptr)
|
||||
{
|
||||
point = InitPoint(supportColor2, this);
|
||||
angleArc = InitItem<QGraphicsPathItem>(supportColor2, this);
|
||||
|
@ -78,8 +73,6 @@ VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolRotation::~VisToolRotation()
|
||||
{
|
||||
qDeleteAll(points);
|
||||
qDeleteAll(curves);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -198,12 +191,6 @@ void VisToolRotation::RefreshGeometry()
|
|||
|
||||
QT_WARNING_POP
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolRotation::SetObjects(QVector<quint32> objects)
|
||||
{
|
||||
this->objects = objects;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolRotation::SetOriginPointId(quint32 value)
|
||||
{
|
||||
|
@ -222,51 +209,6 @@ void VisToolRotation::SetAngle(const QString &expression)
|
|||
angle = FindVal(expression, Visualization::data->PlainVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolRotation::VisualMode(const quint32 &pointId)
|
||||
{
|
||||
Q_UNUSED(pointId);
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr);
|
||||
|
||||
Visualization::scenePos = scene->getScenePos();
|
||||
RefreshGeometry();
|
||||
|
||||
AddOnScene();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsEllipseItem *VisToolRotation::GetPoint(quint32 i, const QColor &color)
|
||||
{
|
||||
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
||||
{
|
||||
return points.at(static_cast<int>(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto point = InitPoint(color, this);
|
||||
points.append(point);
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsPathItem *VisToolRotation::GetCurve(quint32 i, const QColor &color)
|
||||
{
|
||||
if (not curves.isEmpty() && static_cast<quint32>(curves.size() - 1) >= i)
|
||||
{
|
||||
return curves.at(static_cast<int>(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto curve = InitItem<QGraphicsPathItem>(color, this);
|
||||
curves.append(curve);
|
||||
return curve;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class Item>
|
||||
int VisToolRotation::AddCurve(qreal angle, const QPointF &origin, quint32 id, int i)
|
|
@ -41,12 +41,12 @@
|
|||
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "visline.h"
|
||||
#include "visoperation.h"
|
||||
|
||||
class QPointF;
|
||||
class VContainer;
|
||||
|
||||
class VisToolRotation : public VisLine
|
||||
class VisToolRotation : public VisOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -55,30 +55,19 @@ public:
|
|||
|
||||
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
|
||||
|
||||
void SetObjects(QVector<quint32> objects);
|
||||
void SetOriginPointId(quint32 value);
|
||||
|
||||
QString Angle() const;
|
||||
void SetAngle(const QString &expression);
|
||||
|
||||
virtual void VisualMode(const quint32 &pointId = NULL_ID) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolRotation)};
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolRotation)
|
||||
qreal angle;
|
||||
QVector<quint32> objects;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsPathItem *angleArc;
|
||||
QGraphicsLineItem *xAxis;
|
||||
QColor supportColor2;
|
||||
|
||||
QVector<QGraphicsEllipseItem *> points;
|
||||
QVector<QGraphicsPathItem *> curves;
|
||||
|
||||
QGraphicsEllipseItem * GetPoint(quint32 i, const QColor &color);
|
||||
QGraphicsPathItem * GetCurve(quint32 i, const QColor &color);
|
||||
|
||||
template <class Item>
|
||||
int AddCurve(qreal angle, const QPointF &origin, quint32 id, int i);
|
|
@ -22,6 +22,8 @@ HEADERS += \
|
|||
$$PWD/line/vistoolpointofintersectioncircles.h \
|
||||
$$PWD/line/vistoolpointfromcircleandtangent.h \
|
||||
$$PWD/line/vistoolpointfromarcandtangent.h \
|
||||
$$PWD/line/operation/vistoolrotation.h \
|
||||
$$PWD/line/operation/vistoolflippingbyline.h \
|
||||
$$PWD/path/vispath.h \
|
||||
$$PWD/path/vistoolarc.h \
|
||||
$$PWD/path/vistoolcutarc.h \
|
||||
|
@ -33,7 +35,7 @@ HEADERS += \
|
|||
$$PWD/path/vistoolpointofintersectioncurves.h \
|
||||
$$PWD/path/vistoolcubicbezier.h \
|
||||
$$PWD/path/vistoolcubicbezierpath.h \
|
||||
visualization/line/vistoolrotation.h
|
||||
$$PWD/line/operation/visoperation.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/visualization.cpp \
|
||||
|
@ -56,6 +58,8 @@ SOURCES += \
|
|||
$$PWD/line/vistoolpointofintersectioncircles.cpp \
|
||||
$$PWD/line/vistoolpointfromcircleandtangent.cpp \
|
||||
$$PWD/line/vistoolpointfromarcandtangent.cpp \
|
||||
$$PWD/line/operation/vistoolrotation.cpp \
|
||||
$$PWD/line/operation/vistoolflippingbyline.cpp \
|
||||
$$PWD/path/vispath.cpp \
|
||||
$$PWD/path/vistoolarc.cpp \
|
||||
$$PWD/path/vistoolcutarc.cpp \
|
||||
|
@ -67,4 +71,4 @@ SOURCES += \
|
|||
$$PWD/path/vistoolpointofintersectioncurves.cpp \
|
||||
$$PWD/path/vistoolcubicbezier.cpp \
|
||||
$$PWD/path/vistoolcubicbezierpath.cpp \
|
||||
visualization/line/vistoolrotation.cpp
|
||||
$$PWD/line/operation/visoperation.cpp
|
||||
|
|
Loading…
Reference in New Issue
Block a user