Commit successful build.
--HG-- branch : feature
This commit is contained in:
parent
2717382d71
commit
910c40a5b3
|
@ -74,7 +74,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser()
|
||||||
void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
// This check helps to find missed tools in the switch
|
// This check helps to find missed tools in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch.");
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used in switch.");
|
||||||
|
|
||||||
switch (item->type())
|
switch (item->type())
|
||||||
{
|
{
|
||||||
|
@ -177,6 +177,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
||||||
case VToolTrueDarts::Type:
|
case VToolTrueDarts::Type:
|
||||||
ShowOptionsToolTrueDarts(item);
|
ShowOptionsToolTrueDarts(item);
|
||||||
break;
|
break;
|
||||||
|
case VToolRotation::Type:
|
||||||
|
ShowOptionsToolRotation(item);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +194,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// This check helps to find missed tools in the switch
|
// This check helps to find missed tools in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch.");
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used in switch.");
|
||||||
|
|
||||||
switch (currentItem->type())
|
switch (currentItem->type())
|
||||||
{
|
{
|
||||||
|
@ -288,6 +291,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
|
||||||
case VToolTrueDarts::Type:
|
case VToolTrueDarts::Type:
|
||||||
UpdateOptionsToolTrueDarts();
|
UpdateOptionsToolTrueDarts();
|
||||||
break;
|
break;
|
||||||
|
case VToolRotation::Type:
|
||||||
|
UpdateOptionsToolRotation();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +329,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This check helps to find missed tools in the switch
|
// This check helps to find missed tools in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch.");
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used in switch.");
|
||||||
|
|
||||||
switch (currentItem->type())
|
switch (currentItem->type())
|
||||||
{
|
{
|
||||||
|
@ -414,6 +420,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
||||||
case VToolTrueDarts::Type:
|
case VToolTrueDarts::Type:
|
||||||
ChangeDataToolTrueDarts(prop);
|
ChangeDataToolTrueDarts(prop);
|
||||||
break;
|
break;
|
||||||
|
case VToolRotation::Type:
|
||||||
|
ChangeDataToolRotation(prop);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1525,6 +1534,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCurveIntersectAxis(VProperty *pr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolOptionsPropertyBrowser::ChangeDataToolRotation(VProperty *property)
|
||||||
|
{
|
||||||
|
SCASSERT(property != nullptr)
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item)
|
void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
|
@ -1907,6 +1922,12 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCurveIntersectAxis(QGraphicsIte
|
||||||
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
|
AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), AttrAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolOptionsPropertyBrowser::ShowOptionsToolRotation(QGraphicsItem *item)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint()
|
void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint()
|
||||||
{
|
{
|
||||||
|
@ -2365,6 +2386,12 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis()
|
||||||
idToProperty[AttrAngle]->setValue(valueAngle);
|
idToProperty[AttrAngle]->setValue(valueAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolOptionsPropertyBrowser::UpdateOptionsToolRotation()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -144,6 +144,7 @@ private:
|
||||||
void ChangeDataToolTriangle(VPE::VProperty *property);
|
void ChangeDataToolTriangle(VPE::VProperty *property);
|
||||||
void ChangeDataToolLineIntersectAxis(VPE::VProperty *property);
|
void ChangeDataToolLineIntersectAxis(VPE::VProperty *property);
|
||||||
void ChangeDataToolCurveIntersectAxis(VPE::VProperty *property);
|
void ChangeDataToolCurveIntersectAxis(VPE::VProperty *property);
|
||||||
|
void ChangeDataToolRotation(VPE::VProperty *property);
|
||||||
|
|
||||||
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
|
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
|
||||||
void ShowOptionsToolEndLine(QGraphicsItem *item);
|
void ShowOptionsToolEndLine(QGraphicsItem *item);
|
||||||
|
@ -174,6 +175,7 @@ private:
|
||||||
void ShowOptionsToolTriangle(QGraphicsItem *item);
|
void ShowOptionsToolTriangle(QGraphicsItem *item);
|
||||||
void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item);
|
void ShowOptionsToolLineIntersectAxis(QGraphicsItem *item);
|
||||||
void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item);
|
void ShowOptionsToolCurveIntersectAxis(QGraphicsItem *item);
|
||||||
|
void ShowOptionsToolRotation(QGraphicsItem *item);
|
||||||
|
|
||||||
void UpdateOptionsToolSinglePoint();
|
void UpdateOptionsToolSinglePoint();
|
||||||
void UpdateOptionsToolEndLine();
|
void UpdateOptionsToolEndLine();
|
||||||
|
@ -204,6 +206,7 @@ private:
|
||||||
void UpdateOptionsToolTriangle();
|
void UpdateOptionsToolTriangle();
|
||||||
void UpdateOptionsToolLineIntersectAxis();
|
void UpdateOptionsToolLineIntersectAxis();
|
||||||
void UpdateOptionsToolCurveIntersectAxis();
|
void UpdateOptionsToolCurveIntersectAxis();
|
||||||
|
void UpdateOptionsToolRotation();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLOPTIONSPROPERTYBROWSER_H
|
#endif // VTOOLOPTIONSPROPERTYBROWSER_H
|
||||||
|
|
|
@ -208,7 +208,7 @@ void DialogHistory::FillTable()
|
||||||
QString DialogHistory::Record(const VToolRecord &tool)
|
QString DialogHistory::Record(const VToolRecord &tool)
|
||||||
{
|
{
|
||||||
// This check helps to find missed tools in the switch
|
// This check helps to find missed tools in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in history.");
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used in history.");
|
||||||
|
|
||||||
const QDomElement domElem = doc->elementById(tool.getId());
|
const QDomElement domElem = doc->elementById(tool.getId());
|
||||||
if (domElem.isElement() == false)
|
if (domElem.isElement() == false)
|
||||||
|
@ -384,6 +384,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
||||||
case Tool::NodeSpline:
|
case Tool::NodeSpline:
|
||||||
case Tool::NodeSplinePath:
|
case Tool::NodeSplinePath:
|
||||||
case Tool::Group:
|
case Tool::Group:
|
||||||
|
case Tool::Rotation:
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -613,6 +613,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
|
||||||
SCASSERT(scene != nullptr);
|
SCASSERT(scene != nullptr);
|
||||||
|
|
||||||
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
|
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
|
||||||
|
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool, &DialogTool::SelectedObject);
|
||||||
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
|
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
|
||||||
connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot);
|
connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot);
|
||||||
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
|
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
|
||||||
|
@ -1004,12 +1005,22 @@ void MainWindow::ClosedDialogUnionDetails(int result)
|
||||||
void MainWindow::ToolGroup(bool checked)
|
void MainWindow::ToolGroup(bool checked)
|
||||||
{
|
{
|
||||||
ToolSelectGroupObjects();
|
ToolSelectGroupObjects();
|
||||||
currentScene->clearSelection();
|
|
||||||
SetToolButton<DialogGroup>(checked, Tool::Group, ":/cursor/group_plus_cursor.png",
|
SetToolButton<DialogGroup>(checked, Tool::Group, ":/cursor/group_plus_cursor.png",
|
||||||
tr("Select one or more objects, <b>Enter</b> - finish creation"),
|
tr("Select one or more objects, <b>Enter</b> - finish creation"),
|
||||||
&MainWindow::ClosedDialogGroup);
|
&MainWindow::ClosedDialogGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MainWindow::ToolRotation(bool checked)
|
||||||
|
{
|
||||||
|
ToolSelectGroupObjects();
|
||||||
|
SetToolButtonWithApply<DialogRotation>(checked, Tool::Rotation,
|
||||||
|
":/cursor/rotation_cursor.png",
|
||||||
|
tr("Select one or more objects, <b>Enter</b> - confirm selection"),
|
||||||
|
&MainWindow::ClosedDialogWithApply<VToolRotation>,
|
||||||
|
&MainWindow::ApplyDialog<VToolRotation>);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindow::ClosedDialogGroup(int result)
|
void MainWindow::ClosedDialogGroup(int result)
|
||||||
{
|
{
|
||||||
|
@ -1740,6 +1751,7 @@ void MainWindow::InitToolButtons()
|
||||||
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength);
|
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength);
|
||||||
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
|
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
|
||||||
connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup);
|
connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup);
|
||||||
|
connect(ui->toolButtonRotation, &QToolButton::clicked, this, &MainWindow::ToolRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1780,12 +1792,16 @@ void MainWindow::mouseMove(const QPointF &scenePos)
|
||||||
void MainWindow::CancelTool()
|
void MainWindow::CancelTool()
|
||||||
{
|
{
|
||||||
// This check helps to find missed tools in the switch
|
// This check helps to find missed tools in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was handled.");
|
||||||
|
|
||||||
qCDebug(vMainWindow, "Canceling tool.");
|
qCDebug(vMainWindow, "Canceling tool.");
|
||||||
delete dialogTool;
|
delete dialogTool;
|
||||||
dialogTool = nullptr;
|
dialogTool = nullptr;
|
||||||
qCDebug(vMainWindow, "Dialog closed.");
|
qCDebug(vMainWindow, "Dialog closed.");
|
||||||
|
|
||||||
|
currentScene->setFocus(Qt::OtherFocusReason);
|
||||||
|
currentScene->clearSelection();
|
||||||
|
|
||||||
switch ( currentTool )
|
switch ( currentTool )
|
||||||
{
|
{
|
||||||
case Tool::Arrow:
|
case Tool::Arrow:
|
||||||
|
@ -1907,9 +1923,10 @@ void MainWindow::CancelTool()
|
||||||
case Tool::Group:
|
case Tool::Group:
|
||||||
ui->toolButtonGroup->setChecked(false);
|
ui->toolButtonGroup->setChecked(false);
|
||||||
break;
|
break;
|
||||||
|
case Tool::Rotation:
|
||||||
|
ui->toolButtonRotation->setChecked(false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
currentScene->setFocus(Qt::OtherFocusReason);
|
|
||||||
currentScene->clearSelection();
|
|
||||||
|
|
||||||
// Crash: using CRTL+Z while using line tool.
|
// Crash: using CRTL+Z while using line tool.
|
||||||
// related bug report:
|
// related bug report:
|
||||||
|
@ -3110,6 +3127,7 @@ void MainWindow::SetEnableTool(bool enable)
|
||||||
ui->toolButtonArcWithLength->setEnabled(drawTools);
|
ui->toolButtonArcWithLength->setEnabled(drawTools);
|
||||||
ui->toolButtonTrueDarts->setEnabled(drawTools);
|
ui->toolButtonTrueDarts->setEnabled(drawTools);
|
||||||
ui->toolButtonGroup->setEnabled(drawTools);
|
ui->toolButtonGroup->setEnabled(drawTools);
|
||||||
|
ui->toolButtonRotation->setEnabled(drawTools);
|
||||||
|
|
||||||
ui->actionLast_tool->setEnabled(drawTools);
|
ui->actionLast_tool->setEnabled(drawTools);
|
||||||
|
|
||||||
|
@ -3380,7 +3398,7 @@ void MainWindow::CreateMenus()
|
||||||
void MainWindow::LastUsedTool()
|
void MainWindow::LastUsedTool()
|
||||||
{
|
{
|
||||||
// This check helps to find missed tools in the switch
|
// This check helps to find missed tools in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was handled.");
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was handled.");
|
||||||
|
|
||||||
if (currentTool == lastUsedTool)
|
if (currentTool == lastUsedTool)
|
||||||
{
|
{
|
||||||
|
@ -3531,6 +3549,10 @@ void MainWindow::LastUsedTool()
|
||||||
ui->toolButtonGroup->setChecked(true);
|
ui->toolButtonGroup->setChecked(true);
|
||||||
ToolGroup(true);
|
ToolGroup(true);
|
||||||
break;
|
break;
|
||||||
|
case Tool::Rotation:
|
||||||
|
ui->toolButtonRotation->setChecked(true);
|
||||||
|
ToolRotation(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4715,12 +4737,12 @@ void MainWindow::ToolSelectAllDrawObjects() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindow::ToolSelectGroupObjects() const
|
void MainWindow::ToolSelectOperationObjects() const
|
||||||
{
|
{
|
||||||
// Only true for rubber band selection
|
// Only true for rubber band selection
|
||||||
emit EnableLabelSelection(true);
|
emit EnableLabelSelection(true);
|
||||||
emit EnablePointSelection(true);
|
emit EnablePointSelection(true);
|
||||||
emit EnableLineSelection(true);
|
emit EnableLineSelection(false);
|
||||||
emit EnableArcSelection(true);
|
emit EnableArcSelection(true);
|
||||||
emit EnableSplineSelection(true);
|
emit EnableSplineSelection(true);
|
||||||
emit EnableSplinePathSelection(true);
|
emit EnableSplinePathSelection(true);
|
||||||
|
@ -4728,7 +4750,7 @@ void MainWindow::ToolSelectGroupObjects() const
|
||||||
// Hovering
|
// Hovering
|
||||||
emit EnableLabelHover(true);
|
emit EnableLabelHover(true);
|
||||||
emit EnablePointHover(true);
|
emit EnablePointHover(true);
|
||||||
emit EnableLineHover(true);
|
emit EnableLineHover(false);
|
||||||
emit EnableArcHover(true);
|
emit EnableArcHover(true);
|
||||||
emit EnableSplineHover(true);
|
emit EnableSplineHover(true);
|
||||||
emit EnableSplinePathHover(true);
|
emit EnableSplinePathHover(true);
|
||||||
|
@ -4738,6 +4760,17 @@ void MainWindow::ToolSelectGroupObjects() const
|
||||||
ui->view->AllowRubberBand(true);
|
ui->view->AllowRubberBand(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MainWindow::ToolSelectGroupObjects() const
|
||||||
|
{
|
||||||
|
ToolSelectOperationObjects();
|
||||||
|
// Only true for rubber band selection
|
||||||
|
emit EnableLineSelection(true);
|
||||||
|
|
||||||
|
// Hovering
|
||||||
|
emit EnableLineHover(true);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindow::ToolSelectDetail() const
|
void MainWindow::ToolSelectDetail() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,6 +122,7 @@ public slots:
|
||||||
void ToolPointOfIntersection(bool checked);
|
void ToolPointOfIntersection(bool checked);
|
||||||
void ToolUnionDetails(bool checked);
|
void ToolUnionDetails(bool checked);
|
||||||
void ToolGroup(bool checked);
|
void ToolGroup(bool checked);
|
||||||
|
void ToolRotation(bool checked);
|
||||||
void ToolCutArc(bool checked);
|
void ToolCutArc(bool checked);
|
||||||
void ToolLineIntersectAxis(bool checked);
|
void ToolLineIntersectAxis(bool checked);
|
||||||
void ToolCurveIntersectAxis(bool checked);
|
void ToolCurveIntersectAxis(bool checked);
|
||||||
|
@ -372,6 +373,7 @@ private:
|
||||||
void ToolSelectPointArc() const;
|
void ToolSelectPointArc() const;
|
||||||
void ToolSelectCurve() const;
|
void ToolSelectCurve() const;
|
||||||
void ToolSelectAllDrawObjects() const;
|
void ToolSelectAllDrawObjects() const;
|
||||||
|
void ToolSelectOperationObjects() const;
|
||||||
void ToolSelectGroupObjects() const;
|
void ToolSelectGroupObjects() const;
|
||||||
void ToolSelectDetail() const;
|
void ToolSelectDetail() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -983,6 +983,32 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QToolButton" name="toolButtonRotation">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Rotate objects</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="share/resources/toolicon.qrc">
|
||||||
|
<normaloff>:/toolicon/32x32/rotation.png</normaloff>:/toolicon/32x32/rotation.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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_5">
|
<widget class="QWidget" name="page_5">
|
||||||
|
|
|
@ -66,5 +66,7 @@
|
||||||
<file>cursor/cubic_bezier_path_cursor@2x.png</file>
|
<file>cursor/cubic_bezier_path_cursor@2x.png</file>
|
||||||
<file>cursor/group_plus_cursor.png</file>
|
<file>cursor/group_plus_cursor.png</file>
|
||||||
<file>cursor/group_plus_cursor@2x.png</file>
|
<file>cursor/group_plus_cursor@2x.png</file>
|
||||||
|
<file>cursor/rotation_cursor.png</file>
|
||||||
|
<file>cursor/rotation_cursor@2x.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
src/app/valentina/share/resources/cursor/rotation_cursor.png
Normal file
BIN
src/app/valentina/share/resources/cursor/rotation_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 836 B |
BIN
src/app/valentina/share/resources/cursor/rotation_cursor@2x.png
Normal file
BIN
src/app/valentina/share/resources/cursor/rotation_cursor@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -64,5 +64,7 @@
|
||||||
<file>toolicon/32x32/cubic_bezier_path@2x.png</file>
|
<file>toolicon/32x32/cubic_bezier_path@2x.png</file>
|
||||||
<file>toolicon/32x32/group_plus.png</file>
|
<file>toolicon/32x32/group_plus.png</file>
|
||||||
<file>toolicon/32x32/group_plus@2x.png</file>
|
<file>toolicon/32x32/group_plus@2x.png</file>
|
||||||
|
<file>toolicon/32x32/rotation.png</file>
|
||||||
|
<file>toolicon/32x32/rotation@2x.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
src/app/valentina/share/resources/toolicon/32x32/rotation.png
Normal file
BIN
src/app/valentina/share/resources/toolicon/32x32/rotation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
src/app/valentina/share/resources/toolicon/32x32/rotation@2x.png
Normal file
BIN
src/app/valentina/share/resources/toolicon/32x32/rotation@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
82
src/app/valentina/share/resources/toolicon/svg/rotation.svg
Normal file
82
src/app/valentina/share/resources/toolicon/svg/rotation.svg
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="64mm"
|
||||||
|
height="64mm"
|
||||||
|
viewBox="0 0 226.77165 226.77165"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.91 r"
|
||||||
|
sodipodi:docname="rotation.svg">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="2"
|
||||||
|
inkscape:cx="95.256309"
|
||||||
|
inkscape:cy="193.75942"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:window-width="1855"
|
||||||
|
inkscape:window-height="1056"
|
||||||
|
inkscape:window-x="65"
|
||||||
|
inkscape:window-y="24"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<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></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-109.37599,-227.40381)">
|
||||||
|
<g
|
||||||
|
id="g4161"
|
||||||
|
transform="matrix(1.4799279,0,0,1.514144,-50.49258,-240.01162)">
|
||||||
|
<path
|
||||||
|
style="fill:#4c4c4e"
|
||||||
|
d="m 175.63227,452.76646 c -4.46875,-0.93774 -11.21875,-3.08929 -15,-4.78121 -8.24709,-3.69017 -21.35406,-13.37364 -24.40567,-18.03098 -2.17124,-3.31373 -2.15358,-3.39279 1.41601,-6.34044 8.98492,-7.41942 8.5619,-7.37711 15.15272,-1.51551 7.49569,6.66635 18.87856,12.10104 29.12615,13.90613 15.6875,2.76328 32.5699,-2.90492 44.78685,-15.03701 21.30761,-21.15965 21.42043,-54.09472 0.25774,-75.24597 -16.4986,-16.48969 -40.34704,-20.56179 -61.06292,-10.42646 -7.89028,3.86036 -20.27088,15.13215 -20.27088,18.45542 0,1.46429 2.69199,3.44216 8.18114,6.01083 4.49962,2.10564 7.97069,4.45977 7.71347,5.2314 -0.76092,2.28276 -43.5192,27.43921 -44.63742,26.26202 -0.85926,-0.90458 -7.53255,-46.56479 -7.51343,-51.40866 0.004,-1.03123 2.60033,-0.271 7.47059,2.1875 4.1054,2.07239 8.48533,3.76799 9.73318,3.76799 1.26595,0 4.32338,-2.75199 6.91685,-6.22583 8.0603,-10.79646 20.45023,-19.26242 35.88562,-24.52041 9.52071,-3.2432 30.42538,-3.25368 40,-0.0201 24.10475,8.14083 41.33866,25.60172 48.25576,48.8913 3.36888,11.34283 3.081,28.84652 -0.6646,40.40947 -11.1378,34.38337 -46.87719,55.6626 -81.34116,48.4305 z"
|
||||||
|
id="path3349"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
d="m 205.99674,384.45563 a 16.359516,16.624689 0 0 1 -16.33832,16.62467 16.359516,16.624689 0 0 1 -16.38066,-16.58158 16.359516,16.624689 0 0 1 16.29586,-16.66766 16.359516,16.624689 0 0 1 16.4229,16.53839"
|
||||||
|
sodipodi:open="true"
|
||||||
|
sodipodi:end="6.2780017"
|
||||||
|
sodipodi:start="0"
|
||||||
|
sodipodi:ry="16.624689"
|
||||||
|
sodipodi:rx="16.359516"
|
||||||
|
sodipodi:cy="384.45563"
|
||||||
|
sodipodi:cx="189.63722"
|
||||||
|
sodipodi:type="arc"
|
||||||
|
id="path3357"
|
||||||
|
style="opacity:1;fill:#da4d3b;fill-opacity:1;fill-rule:evenodd;stroke:#da4d3b;stroke-width:1.82180572;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4.9000001;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.7 KiB |
|
@ -840,7 +840,7 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do
|
||||||
void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
|
void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
|
||||||
{
|
{
|
||||||
ToolsCommonAttributes(domElement, id);
|
ToolsCommonAttributes(domElement, id);
|
||||||
idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
|
idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
||||||
idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,7 +1279,7 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par
|
||||||
qreal my = 0;
|
qreal my = 0;
|
||||||
|
|
||||||
PointsCommonAttributes(domElement, id, mx, my);
|
PointsCommonAttributes(domElement, id, mx, my);
|
||||||
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
|
const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
||||||
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
||||||
QSharedPointer<VPointF> point;
|
QSharedPointer<VPointF> point;
|
||||||
try
|
try
|
||||||
|
@ -2330,7 +2330,7 @@ void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse
|
||||||
quint32 id = 0;
|
quint32 id = 0;
|
||||||
|
|
||||||
ToolsCommonAttributes(domElement, id);
|
ToolsCommonAttributes(domElement, id);
|
||||||
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
|
const quint32 idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
||||||
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
||||||
VArc *arc = nullptr;
|
VArc *arc = nullptr;
|
||||||
try
|
try
|
||||||
|
@ -3130,7 +3130,7 @@ void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
|
||||||
QRectF VPattern::ActiveDrawBoundingRect() const
|
QRectF VPattern::ActiveDrawBoundingRect() const
|
||||||
{
|
{
|
||||||
// This check helps to find missed tools in the switch
|
// This check helps to find missed tools in the switch
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used.");
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 43, "Not all tools was used.");
|
||||||
|
|
||||||
QRectF rec;
|
QRectF rec;
|
||||||
|
|
||||||
|
@ -3237,6 +3237,9 @@ QRectF VPattern::ActiveDrawBoundingRect() const
|
||||||
case Tool::TrueDarts:
|
case Tool::TrueDarts:
|
||||||
rec = ToolBoundingRect<VToolTrueDarts>(rec, tool.getId());
|
rec = ToolBoundingRect<VToolTrueDarts>(rec, tool.getId());
|
||||||
break;
|
break;
|
||||||
|
case Tool::Rotation:
|
||||||
|
rec = ToolBoundingRect<VToolRotation>(rec, tool.getId());
|
||||||
|
break;
|
||||||
//These tools are not accesseble in Draw mode, but still 'history' contains them.
|
//These tools are not accesseble in Draw mode, but still 'history' contains them.
|
||||||
case Tool::Detail:
|
case Tool::Detail:
|
||||||
case Tool::UnionDetails:
|
case Tool::UnionDetails:
|
||||||
|
|
|
@ -170,7 +170,7 @@ VExceptionToolWasDeleted &VExceptionToolWasDeleted::operator=(const VExceptionTo
|
||||||
* @brief raise method raise for exception
|
* @brief raise method raise for exception
|
||||||
*/
|
*/
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
Q_NORETURN void VExceptionToolWasDeleted::VExceptionToolWasDeleted::raise() const
|
Q_NORETURN void VExceptionToolWasDeleted::raise() const
|
||||||
{
|
{
|
||||||
throw *this;
|
throw *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,8 @@ const QString AttrCCenter = QStringLiteral("cCenter");
|
||||||
const QString AttrTangent = QStringLiteral("tangent");
|
const QString AttrTangent = QStringLiteral("tangent");
|
||||||
const QString AttrCRadius = QStringLiteral("cRadius");
|
const QString AttrCRadius = QStringLiteral("cRadius");
|
||||||
const QString AttrArc = QStringLiteral("arc");
|
const QString AttrArc = QStringLiteral("arc");
|
||||||
|
const QString AttrSuffix = QStringLiteral("suffix");
|
||||||
|
const QString AttrIdObject = QStringLiteral("idObject");
|
||||||
|
|
||||||
const QString TypeLineNone = QStringLiteral("none");
|
const QString TypeLineNone = QStringLiteral("none");
|
||||||
const QString TypeLineLine = QStringLiteral("hair");
|
const QString TypeLineLine = QStringLiteral("hair");
|
||||||
|
|
|
@ -130,6 +130,8 @@ extern const QString AttrCCenter;
|
||||||
extern const QString AttrTangent;
|
extern const QString AttrTangent;
|
||||||
extern const QString AttrCRadius;
|
extern const QString AttrCRadius;
|
||||||
extern const QString AttrArc;
|
extern const QString AttrArc;
|
||||||
|
extern const QString AttrSuffix;
|
||||||
|
extern const QString AttrIdObject;
|
||||||
|
|
||||||
extern const QString TypeLineNone;
|
extern const QString TypeLineNone;
|
||||||
extern const QString TypeLineLine;
|
extern const QString TypeLineLine;
|
||||||
|
|
|
@ -210,7 +210,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief ChangedActivDraw change active pattern peace.
|
* @brief ChangedActivPP change active pattern peace.
|
||||||
* @param newName new pattern peace name.
|
* @param newName new pattern peace name.
|
||||||
*/
|
*/
|
||||||
void ChangedActivPP(const QString &newName);
|
void ChangedActivPP(const QString &newName);
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
#ifndef VGEOMETRYDEF_H
|
#ifndef VGEOMETRYDEF_H
|
||||||
#define VGEOMETRYDEF_H
|
#define VGEOMETRYDEF_H
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
enum class Draw : char { Calculation, Modeling, Layout };
|
enum class Draw : char { Calculation, Modeling, Layout };
|
||||||
enum class GOType : char { Point, Arc, EllipticalArc, Spline, SplinePath, CubicBezier, CubicBezierPath, Unknown };
|
enum class GOType : char { Point, Arc, EllipticalArc, Spline, SplinePath, CubicBezier, CubicBezierPath, Unknown };
|
||||||
enum class SplinePointPosition : char { FirstPoint, LastPoint };
|
enum class SplinePointPosition : char { FirstPoint, LastPoint };
|
||||||
|
|
|
@ -102,6 +102,7 @@ enum class Tool : ToolVisHolderType
|
||||||
TrueDarts,
|
TrueDarts,
|
||||||
UnionDetails,
|
UnionDetails,
|
||||||
Group,
|
Group,
|
||||||
|
Rotation,
|
||||||
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
|
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ enum class Vis : ToolVisHolderType
|
||||||
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
|
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
|
||||||
GraphicsSimpleTextItem,
|
GraphicsSimpleTextItem,
|
||||||
SimplePoint,
|
SimplePoint,
|
||||||
|
SimpleCurve,
|
||||||
Line,
|
Line,
|
||||||
Path,
|
Path,
|
||||||
ToolAlongLine,
|
ToolAlongLine,
|
||||||
|
@ -139,7 +141,8 @@ enum class Vis : ToolVisHolderType
|
||||||
ToolCutSplinePath,
|
ToolCutSplinePath,
|
||||||
ToolLineIntersectAxis,
|
ToolLineIntersectAxis,
|
||||||
ToolCurveIntersectAxis,
|
ToolCurveIntersectAxis,
|
||||||
ToolTrueDarts
|
ToolTrueDarts,
|
||||||
|
ToolRotation
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, LineAngle, CurveAngle, ArcRadius,
|
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, LineAngle, CurveAngle, ArcRadius,
|
||||||
|
|
|
@ -37,7 +37,8 @@ HEADERS += \
|
||||||
$$PWD/tools/dialogpointofintersectioncurves.h \
|
$$PWD/tools/dialogpointofintersectioncurves.h \
|
||||||
$$PWD/tools/dialogcubicbezier.h \
|
$$PWD/tools/dialogcubicbezier.h \
|
||||||
$$PWD/tools/dialogcubicbezierpath.h \
|
$$PWD/tools/dialogcubicbezierpath.h \
|
||||||
$$PWD/tools/dialoggroup.h
|
$$PWD/tools/dialoggroup.h \
|
||||||
|
$$PWD/tools/dialogrotation.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/tools/dialogalongline.cpp \
|
$$PWD/tools/dialogalongline.cpp \
|
||||||
|
@ -74,7 +75,8 @@ SOURCES += \
|
||||||
$$PWD/tools/dialogpointofintersectioncurves.cpp \
|
$$PWD/tools/dialogpointofintersectioncurves.cpp \
|
||||||
$$PWD/tools/dialogcubicbezier.cpp \
|
$$PWD/tools/dialogcubicbezier.cpp \
|
||||||
$$PWD/tools/dialogcubicbezierpath.cpp \
|
$$PWD/tools/dialogcubicbezierpath.cpp \
|
||||||
$$PWD/tools/dialoggroup.cpp
|
$$PWD/tools/dialoggroup.cpp \
|
||||||
|
$$PWD/tools/dialogrotation.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/tools/dialogalongline.ui \
|
$$PWD/tools/dialogalongline.ui \
|
||||||
|
@ -110,4 +112,5 @@ FORMS += \
|
||||||
$$PWD/tools/dialogpointofintersectioncurves.ui \
|
$$PWD/tools/dialogpointofintersectioncurves.ui \
|
||||||
$$PWD/tools/dialogcubicbezier.ui \
|
$$PWD/tools/dialogcubicbezier.ui \
|
||||||
$$PWD/tools/dialogcubicbezierpath.ui \
|
$$PWD/tools/dialogcubicbezierpath.ui \
|
||||||
$$PWD/tools/dialoggroup.ui
|
$$PWD/tools/dialoggroup.ui \
|
||||||
|
$$PWD/tools/dialogrotation.ui
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
#include "dialogs/tools/dialogpointfromarcandtangent.h"
|
#include "dialogs/tools/dialogpointfromarcandtangent.h"
|
||||||
#include "dialogs/tools/dialogtruedarts.h"
|
#include "dialogs/tools/dialogtruedarts.h"
|
||||||
#include "dialogs/tools/dialoggroup.h"
|
#include "dialogs/tools/dialoggroup.h"
|
||||||
|
#include "dialogs/tools/dialogrotation.h"
|
||||||
|
|
||||||
#include "dialogs/support/dialogeditwrongformula.h"
|
#include "dialogs/support/dialogeditwrongformula.h"
|
||||||
#include "dialogs/support/dialogundo.h"
|
#include "dialogs/support/dialogundo.h"
|
||||||
|
|
323
src/libs/vtools/dialogs/tools/dialogrotation.cpp
Normal file
323
src/libs/vtools/dialogs/tools/dialogrotation.cpp
Normal file
|
@ -0,0 +1,323 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogrotation.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 10 4, 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 "dialogrotation.h"
|
||||||
|
#include "ui_dialogrotation.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../ifc/xml/vdomdocument.h"
|
||||||
|
#include "../../visualization/line/vistoolrotation.h"
|
||||||
|
#include "../support/dialogeditwrongformula.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||||
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogRotation),
|
||||||
|
flagAngle(false),
|
||||||
|
timerAngle(nullptr),
|
||||||
|
formulaAngle(),
|
||||||
|
formulaBaseHeightAngle(0),
|
||||||
|
objects(),
|
||||||
|
stage1(true)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
|
||||||
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
|
// ui->lineEditSuffix->setText(/*qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)*/);
|
||||||
|
|
||||||
|
timerAngle = new QTimer(this);
|
||||||
|
connect(timerAngle, &QTimer::timeout, this, &DialogRotation::EvalAngle);
|
||||||
|
|
||||||
|
InitOkCancelApply(ui);
|
||||||
|
|
||||||
|
FillComboBoxPoints(ui->comboBoxOriginPoint);
|
||||||
|
|
||||||
|
// flagName = true;
|
||||||
|
CheckState();
|
||||||
|
|
||||||
|
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogRotation::SuffixChanged);
|
||||||
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogRotation::FXAngle);
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogRotation::AngleChanged);
|
||||||
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogRotation::DeployAngleTextEdit);
|
||||||
|
|
||||||
|
vis = new VisToolRotation(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DialogRotation::~DialogRotation()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
quint32 DialogRotation::GetOrigPointId() const
|
||||||
|
{
|
||||||
|
return getCurrentObjectId(ui->comboBoxOriginPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SetOrigPointId(const quint32 &value)
|
||||||
|
{
|
||||||
|
ChangeCurrentData(ui->comboBoxOriginPoint, value);
|
||||||
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(operation != nullptr);
|
||||||
|
operation->SetOriginPointId(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogRotation::GetAngle() const
|
||||||
|
{
|
||||||
|
return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator());
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SetAngle(const QString &value)
|
||||||
|
{
|
||||||
|
formulaAngle = qApp->TrVars()->FormulaToUser(value);
|
||||||
|
// increase height if needed.
|
||||||
|
if (formulaAngle.length() > 80)
|
||||||
|
{
|
||||||
|
this->DeployAngleTextEdit();
|
||||||
|
}
|
||||||
|
ui->plainTextEditFormula->setPlainText(formulaAngle);
|
||||||
|
|
||||||
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(operation != nullptr);
|
||||||
|
operation->SetAngle(formulaAngle);
|
||||||
|
|
||||||
|
MoveCursorToEnd(ui->plainTextEditFormula);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogRotation::GetSuffix() const
|
||||||
|
{
|
||||||
|
return ui->lineEditSuffix->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SetSuffix(const QString &value)
|
||||||
|
{
|
||||||
|
ui->lineEditSuffix->setText(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<quint32> DialogRotation::GetObjects() const
|
||||||
|
{
|
||||||
|
return objects.toVector();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::ShowDialog(bool click)
|
||||||
|
{
|
||||||
|
if (stage1 && not click)
|
||||||
|
{
|
||||||
|
if (objects.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stage1 = false;
|
||||||
|
|
||||||
|
auto scene = qApp->getCurrentScene();
|
||||||
|
SCASSERT(scene != nullptr);
|
||||||
|
scene->clearSelection();
|
||||||
|
|
||||||
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(operation != nullptr);
|
||||||
|
operation->SetObjects(objects.toVector());
|
||||||
|
operation->VisualMode();
|
||||||
|
|
||||||
|
emit ToolTip("Select origin point");
|
||||||
|
}
|
||||||
|
else if (not stage1 && prepare && click)
|
||||||
|
{
|
||||||
|
/*We will ignore click if pointer is in point circle*/
|
||||||
|
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||||
|
SCASSERT(scene != nullptr);
|
||||||
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetOrigPointId());
|
||||||
|
const QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
|
||||||
|
|
||||||
|
//Radius of point circle, but little bigger. Need handle with hover sizes.
|
||||||
|
const qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
|
||||||
|
if (line.length() <= radius)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(operation != nullptr);
|
||||||
|
|
||||||
|
SetAngle(operation->Angle());//Show in dialog angle that a user choose
|
||||||
|
setModal(true);
|
||||||
|
emit ToolTip("");
|
||||||
|
timerAngle->start();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
|
{
|
||||||
|
if (not stage1 && not prepare)// After first choose we ignore all objects
|
||||||
|
{
|
||||||
|
if (type == SceneObject::Point)
|
||||||
|
{
|
||||||
|
if (SetObject(id, ui->comboBoxOriginPoint, ""))
|
||||||
|
{
|
||||||
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(operation != nullptr);
|
||||||
|
|
||||||
|
connect(operation, &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip);
|
||||||
|
|
||||||
|
operation->SetOriginPointId(id);
|
||||||
|
operation->RefreshGeometry();
|
||||||
|
|
||||||
|
prepare = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool)
|
||||||
|
{
|
||||||
|
if (stage1)
|
||||||
|
{
|
||||||
|
if (selected)
|
||||||
|
{
|
||||||
|
if (not objects.contains(object))
|
||||||
|
{
|
||||||
|
objects.append(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objects.removeOne(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::DeployAngleTextEdit()
|
||||||
|
{
|
||||||
|
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeightAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::AngleChanged()
|
||||||
|
{
|
||||||
|
labelEditFormula = ui->labelEditAngle;
|
||||||
|
labelResultCalculation = ui->labelResultAngle;
|
||||||
|
ValFormulaChanged(flagAngle, ui->plainTextEditFormula, timerAngle, degreeSymbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::FXAngle()
|
||||||
|
{
|
||||||
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||||
|
dialog->setWindowTitle(tr("Edit angle"));
|
||||||
|
dialog->SetFormula(GetAngle());
|
||||||
|
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||||
|
if (dialog->exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
SetAngle(dialog->GetFormula());
|
||||||
|
}
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SuffixChanged()
|
||||||
|
{
|
||||||
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
||||||
|
if (edit)
|
||||||
|
{
|
||||||
|
const QString name = edit->text();
|
||||||
|
// QRegularExpression rx(NameRegExp());
|
||||||
|
if (name.isEmpty()/* || (pointName != name && not data->IsUnique(name)) || not rx.match(name).hasMatch()*/)
|
||||||
|
{
|
||||||
|
flagName = false;
|
||||||
|
ChangeColor(ui->labelSuffix, Qt::red);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flagName = true;
|
||||||
|
ChangeColor(ui->labelSuffix, okColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::CheckState()
|
||||||
|
{
|
||||||
|
SCASSERT(bOk != nullptr);
|
||||||
|
bOk->setEnabled(flagAngle && flagName);
|
||||||
|
SCASSERT(bApply != nullptr);
|
||||||
|
bApply->setEnabled(bOk->isEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::ShowVisualization()
|
||||||
|
{
|
||||||
|
AddVisualization<VisToolRotation>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::SaveData()
|
||||||
|
{
|
||||||
|
formulaAngle = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaAngle.replace("\n", " ");
|
||||||
|
|
||||||
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(operation != nullptr);
|
||||||
|
|
||||||
|
operation->SetObjects(objects.toVector());
|
||||||
|
operation->SetOriginPointId(GetOrigPointId());
|
||||||
|
operation->SetAngle(formulaAngle);
|
||||||
|
operation->RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
ui->plainTextEditFormula->blockSignals(true);
|
||||||
|
DialogTool::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogRotation::EvalAngle()
|
||||||
|
{
|
||||||
|
labelEditFormula = ui->labelEditAngle;
|
||||||
|
Eval(ui->plainTextEditFormula->toPlainText(), flagAngle, ui->labelResultAngle, degreeSymbol, false);
|
||||||
|
}
|
101
src/libs/vtools/dialogs/tools/dialogrotation.h
Normal file
101
src/libs/vtools/dialogs/tools/dialogrotation.h
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogrotation.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 10 4, 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 DIALOGROTATION_H
|
||||||
|
#define DIALOGROTATION_H
|
||||||
|
|
||||||
|
#include "dialogtool.h"
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class DialogRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogRotation : public DialogTool
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
||||||
|
virtual ~DialogRotation();
|
||||||
|
|
||||||
|
quint32 GetOrigPointId() const;
|
||||||
|
void SetOrigPointId(const quint32 &value);
|
||||||
|
|
||||||
|
QString GetAngle() const;
|
||||||
|
void SetAngle(const QString &value);
|
||||||
|
|
||||||
|
QString GetSuffix() const;
|
||||||
|
void SetSuffix(const QString &value);
|
||||||
|
|
||||||
|
QVector<quint32> GetObjects() const;
|
||||||
|
|
||||||
|
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
|
||||||
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
/** @brief DeployAngleTextEdit grow or shrink formula input */
|
||||||
|
void DeployAngleTextEdit();
|
||||||
|
void AngleChanged();
|
||||||
|
void FXAngle();
|
||||||
|
void SuffixChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void CheckState() Q_DECL_OVERRIDE;
|
||||||
|
virtual void ShowVisualization() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
/** @brief SaveData Put dialog data in local variables */
|
||||||
|
virtual void SaveData() Q_DECL_OVERRIDE;
|
||||||
|
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(DialogRotation)
|
||||||
|
Ui::DialogRotation *ui;
|
||||||
|
|
||||||
|
/** @brief flagAngle true if value of angle is correct */
|
||||||
|
bool flagAngle;
|
||||||
|
|
||||||
|
/** @brief timerAngle timer of check formula of angle */
|
||||||
|
QTimer *timerAngle;
|
||||||
|
|
||||||
|
/** @brief angle formula of angle */
|
||||||
|
QString formulaAngle;
|
||||||
|
|
||||||
|
/** @brief formulaBaseHeightAngle base height defined by dialogui */
|
||||||
|
int formulaBaseHeightAngle;
|
||||||
|
|
||||||
|
QList<quint32> objects;
|
||||||
|
|
||||||
|
bool stage1;
|
||||||
|
|
||||||
|
void EvalAngle();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGROTATION_H
|
275
src/libs/vtools/dialogs/tools/dialogrotation.ui
Normal file
275
src/libs/vtools/dialogs/tools/dialogrotation.ui
Normal file
|
@ -0,0 +1,275 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogRotation</class>
|
||||||
|
<widget class="QDialog" name="DialogRotation">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>309</width>
|
||||||
|
<height>189</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Rotation</string>
|
||||||
|
</property>
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../../vmisc/share/resources/icon.qrc">
|
||||||
|
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="plainTextEditFormula">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Calulation</string>
|
||||||
|
</property>
|
||||||
|
<property name="tabChangesFocus">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonGrowLength">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>18</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeIncrement">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Show full calculation in message box</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="go-down">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item alignment="Qt::AlignLeft">
|
||||||
|
<widget class="QLabel" name="labelEditAngle">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="palette">
|
||||||
|
<palette>
|
||||||
|
<active>
|
||||||
|
<colorrole role="WindowText">
|
||||||
|
<brush brushstyle="SolidPattern">
|
||||||
|
<color alpha="255">
|
||||||
|
<red>255</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</brush>
|
||||||
|
</colorrole>
|
||||||
|
</active>
|
||||||
|
<inactive>
|
||||||
|
<colorrole role="WindowText">
|
||||||
|
<brush brushstyle="SolidPattern">
|
||||||
|
<color alpha="255">
|
||||||
|
<red>255</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</brush>
|
||||||
|
</colorrole>
|
||||||
|
</inactive>
|
||||||
|
<disabled>
|
||||||
|
<colorrole role="WindowText">
|
||||||
|
<brush brushstyle="SolidPattern">
|
||||||
|
<color alpha="255">
|
||||||
|
<red>159</red>
|
||||||
|
<green>158</green>
|
||||||
|
<blue>158</blue>
|
||||||
|
</color>
|
||||||
|
</brush>
|
||||||
|
</colorrole>
|
||||||
|
</disabled>
|
||||||
|
</palette>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Angle:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QToolButton" name="toolButtonExprAngle">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Formula wizard</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../vmisc/share/resources/icon.qrc">
|
||||||
|
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QLabel" name="labelResultAngle">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>87</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Value</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">_</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelOriginPoint">
|
||||||
|
<property name="text">
|
||||||
|
<string>Origin Point:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBoxOriginPoint"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="labelSuffix">
|
||||||
|
<property name="text">
|
||||||
|
<string>Suffix:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditSuffix"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../../../vmisc/share/resources/icon.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>DialogRotation</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>DialogRotation</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>
|
|
@ -58,5 +58,6 @@
|
||||||
#include "toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
|
#include "toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
|
||||||
#include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
|
#include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
|
||||||
#include "toolpoint/tooldoublepoint/vtooltruedarts.h"
|
#include "toolpoint/tooldoublepoint/vtooltruedarts.h"
|
||||||
|
#include "operation/vtoolrotation.h"
|
||||||
|
|
||||||
#endif // DRAWTOOLS_H
|
#endif // DRAWTOOLS_H
|
||||||
|
|
934
src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp
Normal file
934
src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp
Normal file
|
@ -0,0 +1,934 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vtoolrotation.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 12 4, 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 "vtoolrotation.h"
|
||||||
|
#include "../../../dialogs/tools/dialogrotation.h"
|
||||||
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vgeometry/varc.h"
|
||||||
|
#include "../vgeometry/vellipticalarc.h"
|
||||||
|
#include "../vgeometry/vspline.h"
|
||||||
|
#include "../vgeometry/vsplinepath.h"
|
||||||
|
#include "../vgeometry/vcubicbezier.h"
|
||||||
|
#include "../vgeometry/vcubicbezierpath.h"
|
||||||
|
#include "../../../visualization/line/vistoolrotation.h"
|
||||||
|
#include "../vwidgets/vsimplepoint.h"
|
||||||
|
#include "../vwidgets/vsimplecurve.h"
|
||||||
|
|
||||||
|
const QString VToolRotation::TagName = QStringLiteral("operation");
|
||||||
|
const QString VToolRotation::TagItem = QStringLiteral("item");
|
||||||
|
const QString VToolRotation::TagSource = QStringLiteral("source");
|
||||||
|
const QString VToolRotation::TagDestination = QStringLiteral("destination");
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
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),
|
||||||
|
QGraphicsItem(parent),
|
||||||
|
origPointId(origPointId),
|
||||||
|
angle(angle),
|
||||||
|
suffix(suffix),
|
||||||
|
source(source),
|
||||||
|
destination(destination),
|
||||||
|
rObjects()
|
||||||
|
{
|
||||||
|
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.");
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolCreation(typeCreation);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VToolRotation::~VToolRotation()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::setDialog()
|
||||||
|
{
|
||||||
|
SCASSERT(dialog != nullptr);
|
||||||
|
DialogRotation *dialogTool = qobject_cast<DialogRotation*>(dialog);
|
||||||
|
SCASSERT(dialogTool != nullptr);
|
||||||
|
dialogTool->SetOrigPointId(origPointId);
|
||||||
|
dialogTool->SetAngle(angle);
|
||||||
|
dialogTool->SetSuffix(suffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VToolRotation *VToolRotation::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
|
VContainer *data)
|
||||||
|
{
|
||||||
|
SCASSERT(dialog != nullptr);
|
||||||
|
DialogRotation *dialogTool = qobject_cast<DialogRotation*>(dialog);
|
||||||
|
SCASSERT(dialogTool != nullptr);
|
||||||
|
const quint32 originPointId = dialogTool->GetOrigPointId();
|
||||||
|
QString angle = dialogTool->GetAngle();
|
||||||
|
const QString suffix = dialogTool->GetSuffix();
|
||||||
|
const QVector<quint32> source = dialogTool->GetObjects();
|
||||||
|
VToolRotation* operation = Create(0, originPointId, angle, suffix, source, QVector<DestinationItem>(),
|
||||||
|
scene, doc, data, Document::FullParse, Source::FromGui);
|
||||||
|
if (operation != nullptr)
|
||||||
|
{
|
||||||
|
operation->dialog = dialogTool;
|
||||||
|
}
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VToolRotation *VToolRotation::Create(const quint32 _id, const quint32 &origin, QString &angle, const QString &suffix,
|
||||||
|
const QVector<quint32> &source,
|
||||||
|
const QVector<DestinationItem> &destination,
|
||||||
|
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||||
|
const Document &parse, const Source &typeCreation)
|
||||||
|
{
|
||||||
|
qreal calcAngle = 0;
|
||||||
|
|
||||||
|
calcAngle = CheckFormula(_id, angle, data);
|
||||||
|
|
||||||
|
const auto originPoint = *data->GeometricObject<VPointF>(origin);
|
||||||
|
const QPointF oPoint = originPoint.toQPointF();
|
||||||
|
|
||||||
|
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.");
|
||||||
|
|
||||||
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
|
{
|
||||||
|
case GOType::Point:
|
||||||
|
dest.append(CreatePoint(id, idObject, oPoint, calcAngle, suffix, data));
|
||||||
|
break;
|
||||||
|
case GOType::Arc:
|
||||||
|
dest.append(CreateArc(id, idObject, oPoint, calcAngle, suffix, data));
|
||||||
|
break;
|
||||||
|
case GOType::EllipticalArc:
|
||||||
|
//dest.append(CreateItem<VEllipticalArc>(id, idObject, oPoint, angle, suffix));
|
||||||
|
break;
|
||||||
|
case GOType::Spline:
|
||||||
|
dest.append(CreateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||||
|
break;
|
||||||
|
case GOType::SplinePath:
|
||||||
|
dest.append(CreateCurveWithSegments<VSplinePath>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||||
|
break;
|
||||||
|
case GOType::CubicBezier:
|
||||||
|
dest.append(CreateCurve<VCubicBezier>(id, idObject, oPoint, calcAngle, suffix, data));
|
||||||
|
break;
|
||||||
|
case GOType::CubicBezierPath:
|
||||||
|
dest.append(CreateCurveWithSegments<VCubicBezierPath>(id, idObject, oPoint, calcAngle, suffix,
|
||||||
|
data));
|
||||||
|
break;
|
||||||
|
case GOType::Unknown:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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.");
|
||||||
|
|
||||||
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
|
{
|
||||||
|
case GOType::Point:
|
||||||
|
UpdatePoint(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id, dest.at(i).mx,
|
||||||
|
dest.at(i).my);
|
||||||
|
break;
|
||||||
|
case GOType::Arc:
|
||||||
|
UpdateArc(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||||
|
break;
|
||||||
|
case GOType::EllipticalArc:
|
||||||
|
//dest.append(UpdateItem<VEllipticalArc>(id, idObject, oPoint, angle, suffix, data));
|
||||||
|
break;
|
||||||
|
case GOType::Spline:
|
||||||
|
UpdateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||||
|
break;
|
||||||
|
case GOType::SplinePath:
|
||||||
|
UpdateCurveWithSegments<VSplinePath>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||||
|
break;
|
||||||
|
case GOType::CubicBezier:
|
||||||
|
UpdateCurve<VCubicBezier>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
|
||||||
|
break;
|
||||||
|
case GOType::CubicBezierPath:
|
||||||
|
UpdateCurveWithSegments<VCubicBezierPath>(id, idObject, oPoint, calcAngle, suffix, data,
|
||||||
|
dest.at(i).id);
|
||||||
|
break;
|
||||||
|
case GOType::Unknown:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parse != Document::FullParse)
|
||||||
|
{
|
||||||
|
doc->UpdateToolData(id, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VDrawTool::AddRecord(id, Tool::Rotation, doc);
|
||||||
|
if (parse == Document::FullParse)
|
||||||
|
{
|
||||||
|
VToolRotation *tool = new VToolRotation(doc, data, id, origin, angle, suffix, source, dest, typeCreation);
|
||||||
|
scene->addItem(tool);
|
||||||
|
InitRotationToolConnections(scene, tool);
|
||||||
|
doc->AddTool(id, tool);
|
||||||
|
doc->IncrementReferens(originPoint.getIdTool());
|
||||||
|
for (int i = 0; i < source.size(); ++i)
|
||||||
|
{
|
||||||
|
doc->IncrementReferens(data->GetGObject(source.at(i))->getIdTool());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < dest.size(); ++i)
|
||||||
|
{
|
||||||
|
doc->IncrementReferens(data->GetGObject(dest.at(i).id)->getIdTool());
|
||||||
|
}
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VToolRotation::getTagName() const
|
||||||
|
{
|
||||||
|
return VToolRotation::TagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::setEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
this->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VToolRotation::Suffix() const
|
||||||
|
{
|
||||||
|
return suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
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::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()
|
||||||
|
{
|
||||||
|
if (vis != nullptr)
|
||||||
|
{
|
||||||
|
VisToolRotation *visual = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
SCASSERT(visual != nullptr);
|
||||||
|
|
||||||
|
visual->SetObjects(source);
|
||||||
|
visual->SetOriginPointId(origPointId);
|
||||||
|
visual->SetAngle(angle);
|
||||||
|
visual->RefreshGeometry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QRectF VToolRotation::boundingRect() const
|
||||||
|
{
|
||||||
|
QRectF recTool;
|
||||||
|
const QList<QGraphicsItem *> items = childItems();
|
||||||
|
foreach (QGraphicsItem *item, items)
|
||||||
|
{
|
||||||
|
recTool = recTool.united(item->boundingRect());
|
||||||
|
recTool = recTool.united(item->childrenBoundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
return recTool;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(obj);
|
||||||
|
SCASSERT(item != nullptr);
|
||||||
|
ChangePosition(item, labelId, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::SaveDialog(QDomElement &domElement)
|
||||||
|
{
|
||||||
|
SCASSERT(dialog != nullptr);
|
||||||
|
DialogRotation *dialogTool = qobject_cast<DialogRotation*>(dialog);
|
||||||
|
SCASSERT(dialogTool != nullptr);
|
||||||
|
|
||||||
|
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId()));
|
||||||
|
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
|
||||||
|
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::ReadToolAttributes(const QDomElement &domElement)
|
||||||
|
{
|
||||||
|
origPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
||||||
|
angle = doc->GetParametrString(domElement, AttrAngle, "0");
|
||||||
|
suffix = doc->GetParametrString(domElement, AttrSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||||
|
{
|
||||||
|
VDrawTool::SaveOptions(tag, obj);
|
||||||
|
|
||||||
|
doc->SetAttribute(tag, AttrCenter, QString().setNum(origPointId));
|
||||||
|
doc->SetAttribute(tag, AttrAngle, angle);
|
||||||
|
doc->SetAttribute(tag, AttrSuffix, suffix);
|
||||||
|
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ContextMenu<DialogRotation>(this, event);
|
||||||
|
}
|
||||||
|
catch(const VExceptionToolWasDeleted &e)
|
||||||
|
{
|
||||||
|
Q_UNUSED(e);
|
||||||
|
return;//Leave this method immediately!!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
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->blockSignals(true);
|
||||||
|
item->setPos(QPointF(mx, my));
|
||||||
|
item->blockSignals(false);
|
||||||
|
item->RefreshLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::UpdateNamePosition(quint32 id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||||
|
// auto moveLabel = new MoveLabel(doc, point->mx(), point->my(), id, scene());
|
||||||
|
// connect(moveLabel, &MoveLabel::ChangePosition, this, &VToolSinglePoint::DoChangePosition);
|
||||||
|
// qApp->getUndoStack()->push(moveLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DestinationItem VToolRotation::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
||||||
|
VPointF rotated = point->Rotate(origin, angle, suffix);
|
||||||
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
DestinationItem item;
|
||||||
|
item.mx = rotated.mx();
|
||||||
|
item.my = rotated.my();
|
||||||
|
item.id = data->AddGObject(new VPointF(rotated));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class Item>
|
||||||
|
DestinationItem VToolRotation::CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data)
|
||||||
|
{
|
||||||
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
||||||
|
Item rotated = i->Rotate(origin, angle, suffix);
|
||||||
|
rotated.setIdObject(idTool);
|
||||||
|
|
||||||
|
DestinationItem item;
|
||||||
|
item.mx = INT_MAX;
|
||||||
|
item.my = INT_MAX;
|
||||||
|
item.id = data->AddGObject(new Item(rotated));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DestinationItem VToolRotation::CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data)
|
||||||
|
{
|
||||||
|
const DestinationItem item = CreateItem<VArc>(idTool, idItem, origin, angle, suffix, data);
|
||||||
|
data->AddArc(data->GeometricObject<VArc>(item.id), item.id);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class Item>
|
||||||
|
DestinationItem VToolRotation::CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data)
|
||||||
|
{
|
||||||
|
const DestinationItem item = CreateItem<Item>(idTool, idItem, origin, angle, suffix, data);
|
||||||
|
data->AddCurve(data->GeometricObject<Item>(item.id), item.id);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class Item>
|
||||||
|
DestinationItem VToolRotation::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin,
|
||||||
|
qreal angle, const QString &suffix, VContainer *data)
|
||||||
|
{
|
||||||
|
const DestinationItem item = CreateItem<Item>(idTool, idItem, origin, angle, suffix, data);
|
||||||
|
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my)
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
|
||||||
|
VPointF rotated = point->Rotate(origin, angle, suffix);
|
||||||
|
rotated.setIdObject(idTool);
|
||||||
|
rotated.setMx(mx);
|
||||||
|
rotated.setMy(my);
|
||||||
|
data->UpdateGObject(id, new VPointF(rotated));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class Item>
|
||||||
|
void VToolRotation::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
|
{
|
||||||
|
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
|
||||||
|
Item rotated = i->Rotate(origin, angle, suffix);
|
||||||
|
rotated.setIdObject(idTool);
|
||||||
|
data->UpdateGObject(id, new Item(rotated));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VToolRotation::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
|
{
|
||||||
|
UpdateItem<VArc>(idTool, idItem, origin, angle, suffix, data, id);
|
||||||
|
data->AddArc(data->GeometricObject<VArc>(id), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class Item>
|
||||||
|
void VToolRotation::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
|
{
|
||||||
|
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
|
||||||
|
data->AddCurve(data->GeometricObject<Item>(id), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class Item>
|
||||||
|
void VToolRotation::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
}
|
175
src/libs/vtools/tools/drawTools/operation/vtoolrotation.h
Normal file
175
src/libs/vtools/tools/drawTools/operation/vtoolrotation.h
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vtoolrotation.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 12 4, 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 VTOOLROTATION_H
|
||||||
|
#define VTOOLROTATION_H
|
||||||
|
|
||||||
|
#include "../vdrawtool.h"
|
||||||
|
|
||||||
|
struct DestinationItem
|
||||||
|
{
|
||||||
|
quint32 id;
|
||||||
|
qreal mx;
|
||||||
|
qreal my;
|
||||||
|
};
|
||||||
|
|
||||||
|
class VAbstractSimple;
|
||||||
|
class VSimpleCurve;
|
||||||
|
|
||||||
|
class VToolRotation : public VDrawTool, public QGraphicsItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
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 = nullptr);
|
||||||
|
virtual ~VToolRotation();
|
||||||
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
|
static VToolRotation* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static VToolRotation* Create(const quint32 _id, const quint32 &origin, QString &angle, const QString &suffix,
|
||||||
|
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
|
||||||
|
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||||
|
const Document &parse, const Source &typeCreation);
|
||||||
|
// cppcheck-suppress duplInheritedMember
|
||||||
|
static const QString TagName;
|
||||||
|
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);
|
||||||
|
|
||||||
|
QString Suffix() const;
|
||||||
|
|
||||||
|
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
|
||||||
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
virtual QRectF boundingRect() const 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 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 angle;
|
||||||
|
QString suffix;
|
||||||
|
|
||||||
|
QVector<quint32> source;
|
||||||
|
QVector<DestinationItem> destination;
|
||||||
|
|
||||||
|
QMap<quint32, VAbstractSimple *> rObjects;
|
||||||
|
|
||||||
|
void UpdateNamePosition(quint32 id);
|
||||||
|
|
||||||
|
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data);
|
||||||
|
|
||||||
|
template <class Item>
|
||||||
|
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data);
|
||||||
|
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data);
|
||||||
|
template <class Item>
|
||||||
|
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data);
|
||||||
|
template <class Item>
|
||||||
|
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data);
|
||||||
|
|
||||||
|
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id, qreal mx, qreal my);
|
||||||
|
template <class Item>
|
||||||
|
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id);
|
||||||
|
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id);
|
||||||
|
template <class Item>
|
||||||
|
static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
const QString &suffix, VContainer *data, quint32 id);
|
||||||
|
template <class Item>
|
||||||
|
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
|
||||||
|
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
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject");
|
|
||||||
const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
|
const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -45,7 +45,6 @@ public:
|
||||||
VAbstractNode(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode,
|
VAbstractNode(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode,
|
||||||
const quint32 &idTool, QObject *parent = nullptr);
|
const quint32 &idTool, QObject *parent = nullptr);
|
||||||
virtual ~VAbstractNode() Q_DECL_OVERRIDE {}
|
virtual ~VAbstractNode() Q_DECL_OVERRIDE {}
|
||||||
static const QString AttrIdObject;
|
|
||||||
static const QString AttrIdTool;
|
static const QString AttrIdTool;
|
||||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||||
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
virtual void incrementReferens() Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -49,7 +49,8 @@ HEADERS += \
|
||||||
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h \
|
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h \
|
||||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h \
|
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h \
|
||||||
$$PWD/drawTools/toolcurve/vtoolcubicbezier.h \
|
$$PWD/drawTools/toolcurve/vtoolcubicbezier.h \
|
||||||
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.h
|
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.h \
|
||||||
|
$$PWD/drawTools/operation/vtoolrotation.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/vtooldetail.cpp \
|
$$PWD/vtooldetail.cpp \
|
||||||
|
@ -96,4 +97,5 @@ SOURCES += \
|
||||||
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp \
|
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp \
|
||||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp \
|
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp \
|
||||||
$$PWD/drawTools/toolcurve/vtoolcubicbezier.cpp \
|
$$PWD/drawTools/toolcurve/vtoolcubicbezier.cpp \
|
||||||
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.cpp
|
$$PWD/drawTools/toolcurve/vtoolcubicbezierpath.cpp \
|
||||||
|
$$PWD/drawTools/operation/vtoolrotation.cpp
|
||||||
|
|
258
src/libs/vtools/visualization/line/vistoolrotation.cpp
Normal file
258
src/libs/vtools/visualization/line/vistoolrotation.cpp
Normal file
|
@ -0,0 +1,258 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vistoolrotation.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 11 4, 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 "vistoolrotation.h"
|
||||||
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vgeometry/varc.h"
|
||||||
|
#include "../vgeometry/vellipticalarc.h"
|
||||||
|
#include "../vgeometry/vspline.h"
|
||||||
|
#include "../vgeometry/vsplinepath.h"
|
||||||
|
#include "../vgeometry/vcubicbezier.h"
|
||||||
|
#include "../vgeometry/vcubicbezierpath.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
: VisLine(data, parent),
|
||||||
|
angle(INT_MIN),
|
||||||
|
objects(),
|
||||||
|
point(nullptr),
|
||||||
|
xAxis(nullptr),
|
||||||
|
supportColor2(Qt::darkGreen),
|
||||||
|
points(),
|
||||||
|
curves()
|
||||||
|
{
|
||||||
|
point = InitPoint(supportColor2, this);
|
||||||
|
xAxis = InitItem<QGraphicsLineItem>(supportColor2, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VisToolRotation::~VisToolRotation()
|
||||||
|
{
|
||||||
|
qDeleteAll(points);
|
||||||
|
qDeleteAll(curves);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
#if defined(Q_CC_GNU)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wswitch-default"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void VisToolRotation::RefreshGeometry()
|
||||||
|
{
|
||||||
|
if (objects.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object1Id != NULL_ID)
|
||||||
|
{
|
||||||
|
const QPointF origin = Visualization::data->GeometricObject<VPointF>(object1Id)->toQPointF();
|
||||||
|
DrawPoint(point, origin, supportColor2);
|
||||||
|
|
||||||
|
QLineF rLine;
|
||||||
|
if (VFuzzyComparePossibleNulls(angle, INT_MIN))
|
||||||
|
{
|
||||||
|
rLine = QLineF(origin, Visualization::scenePos);
|
||||||
|
|
||||||
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||||
|
{
|
||||||
|
rLine.setAngle(CorrectAngle(rLine.angle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
rLine.setP2(Ray(origin, rLine.angle()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rLine = QLineF(origin, Ray(origin, angle));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == Mode::Creation)
|
||||||
|
{
|
||||||
|
DrawLine(this, rLine, supportColor2, Qt::DashLine);
|
||||||
|
DrawLine(xAxis, QLineF(origin, Ray(origin, 0)), supportColor2, Qt::DashLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
Visualization::toolTip = tr("Rotating angle = %1°, <b>Shift</b> - sticking angle, "
|
||||||
|
"<b>Mouse click</b> - finish creation").arg(rLine.angle());
|
||||||
|
|
||||||
|
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 was handled.");
|
||||||
|
|
||||||
|
switch(static_cast<GOType>(obj->getType()))
|
||||||
|
{
|
||||||
|
case GOType::Point:
|
||||||
|
{
|
||||||
|
const QSharedPointer<VPointF> p = Visualization::data->GeometricObject<VPointF>(id);
|
||||||
|
|
||||||
|
++iPoint;
|
||||||
|
QGraphicsEllipseItem *point = GetPoint(iPoint);
|
||||||
|
DrawPoint(point, p->toQPointF(), supportColor);
|
||||||
|
|
||||||
|
++iPoint;
|
||||||
|
point = GetPoint(iPoint);
|
||||||
|
DrawPoint(point, p->Rotate(origin, angle).toQPointF(), supportColor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GOType::Arc:
|
||||||
|
{
|
||||||
|
iCurve = AddCurve<VArc>(origin, id, iCurve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GOType::EllipticalArc:
|
||||||
|
{
|
||||||
|
iCurve = AddCurve<VEllipticalArc>(origin, id, iCurve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GOType::Spline:
|
||||||
|
{
|
||||||
|
iCurve = AddCurve<VSpline>(origin, id, iCurve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GOType::SplinePath:
|
||||||
|
{
|
||||||
|
iCurve = AddCurve<VSplinePath>(origin, id, iCurve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GOType::CubicBezier:
|
||||||
|
{
|
||||||
|
iCurve = AddCurve<VCubicBezier>(origin, id, iCurve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GOType::CubicBezierPath:
|
||||||
|
{
|
||||||
|
iCurve = AddCurve<VCubicBezierPath>(origin, id, iCurve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GOType::Unknown:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(Q_CC_GNU)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VisToolRotation::SetObjects(QVector<quint32> objects)
|
||||||
|
{
|
||||||
|
this->objects = objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VisToolRotation::SetOriginPointId(quint32 value)
|
||||||
|
{
|
||||||
|
object1Id = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VisToolRotation::Angle() const
|
||||||
|
{
|
||||||
|
return QString::number(line().angle());
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (not points.isEmpty() && static_cast<quint32>(points.size() - 1) >= i)
|
||||||
|
{
|
||||||
|
return points.at(static_cast<int>(i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto point = InitPoint(supportColor, this);
|
||||||
|
points.append(point);
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QGraphicsPathItem *VisToolRotation::GetCurve(quint32 i)
|
||||||
|
{
|
||||||
|
if (not curves.isEmpty() && static_cast<quint32>(curves.size() - 1) >= i)
|
||||||
|
{
|
||||||
|
return curves.at(static_cast<int>(i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto curve = InitItem<QGraphicsPathItem>(supportColor, this);
|
||||||
|
curves.append(curve);
|
||||||
|
return curve;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class Item>
|
||||||
|
int VisToolRotation::AddCurve(const QPointF &origin, quint32 id, int i)
|
||||||
|
{
|
||||||
|
const QSharedPointer<Item> curve = Visualization::data->GeometricObject<Item>(id);
|
||||||
|
|
||||||
|
++i;
|
||||||
|
QGraphicsPathItem *path = GetCurve(i);
|
||||||
|
DrawPath(path, curve->GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
|
||||||
|
++i;
|
||||||
|
path = GetCurve(i);
|
||||||
|
const Item rotated = curve->Rotate(origin, angle);
|
||||||
|
DrawPath(path, rotated.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
71
src/libs/vtools/visualization/line/vistoolrotation.h
Normal file
71
src/libs/vtools/visualization/line/vistoolrotation.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vistoolrotation.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 11 4, 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 VISTOOLROTATION_H
|
||||||
|
#define VISTOOLROTATION_H
|
||||||
|
|
||||||
|
#include "visline.h"
|
||||||
|
|
||||||
|
class VisToolRotation : public VisLine
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit VisToolRotation(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||||
|
virtual ~VisToolRotation();
|
||||||
|
|
||||||
|
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;
|
||||||
|
QGraphicsLineItem *xAxis;
|
||||||
|
QColor supportColor2;
|
||||||
|
|
||||||
|
QVector<QGraphicsEllipseItem *> points;
|
||||||
|
QVector<QGraphicsPathItem *> curves;
|
||||||
|
|
||||||
|
QGraphicsEllipseItem * GetPoint(quint32 i);
|
||||||
|
QGraphicsPathItem * GetCurve(quint32 i);
|
||||||
|
|
||||||
|
template <class Item>
|
||||||
|
int AddCurve(const QPointF &origin, quint32 id, int i);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VISTOOLROTATION_H
|
|
@ -32,7 +32,8 @@ HEADERS += \
|
||||||
$$PWD/path/vistoolarcwithlength.h \
|
$$PWD/path/vistoolarcwithlength.h \
|
||||||
$$PWD/path/vistoolpointofintersectioncurves.h \
|
$$PWD/path/vistoolpointofintersectioncurves.h \
|
||||||
$$PWD/path/vistoolcubicbezier.h \
|
$$PWD/path/vistoolcubicbezier.h \
|
||||||
$$PWD/path/vistoolcubicbezierpath.h
|
$$PWD/path/vistoolcubicbezierpath.h \
|
||||||
|
visualization/line/vistoolrotation.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/visualization.cpp \
|
$$PWD/visualization.cpp \
|
||||||
|
@ -65,4 +66,5 @@ SOURCES += \
|
||||||
$$PWD/path/vistoolarcwithlength.cpp \
|
$$PWD/path/vistoolarcwithlength.cpp \
|
||||||
$$PWD/path/vistoolpointofintersectioncurves.cpp \
|
$$PWD/path/vistoolpointofintersectioncurves.cpp \
|
||||||
$$PWD/path/vistoolcubicbezier.cpp \
|
$$PWD/path/vistoolcubicbezier.cpp \
|
||||||
$$PWD/path/vistoolcubicbezierpath.cpp
|
$$PWD/path/vistoolcubicbezierpath.cpp \
|
||||||
|
visualization/line/vistoolrotation.cpp
|
||||||
|
|
|
@ -28,16 +28,32 @@
|
||||||
|
|
||||||
#include "vabstractsimple.h"
|
#include "vabstractsimple.h"
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractSimple::VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor,
|
VAbstractSimple::VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
:QObject(parent), id (id), factor(factor), currentColor(currentColor), enabled(true), patternUnit(patternUnit)
|
: QObject(parent),
|
||||||
|
id (id),
|
||||||
|
factor(factor),
|
||||||
|
currentColor(currentColor),
|
||||||
|
enabled(true),
|
||||||
|
patternUnit(patternUnit),
|
||||||
|
selectionType(SelectionType::ByMouseRelease),
|
||||||
|
type(GOType::Unknown)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractSimple::~VAbstractSimple()
|
VAbstractSimple::~VAbstractSimple()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractSimple::ToolSelectionType(const SelectionType &type)
|
||||||
|
{
|
||||||
|
selectionType = type;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QColor VAbstractSimple::CorrectColor(const QColor &color) const
|
QColor VAbstractSimple::CorrectColor(const QColor &color) const
|
||||||
{
|
{
|
||||||
|
@ -50,3 +66,28 @@ QColor VAbstractSimple::CorrectColor(const QColor &color) const
|
||||||
return Qt::gray;
|
return Qt::gray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// cppcheck-suppress unusedFunction
|
||||||
|
QColor VAbstractSimple::GetCurrentColor() const
|
||||||
|
{
|
||||||
|
return currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractSimple::ContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
emit ShowContextMenu(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
GOType VAbstractSimple::GetType() const
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractSimple::SetType(const GOType &value)
|
||||||
|
{
|
||||||
|
type = value;
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,11 @@
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
#include "../vgeometry/vgeometrydef.h"
|
||||||
|
#include "../ifc/ifcdef.h"
|
||||||
|
|
||||||
|
class QGraphicsSceneContextMenuEvent;
|
||||||
|
class QGraphicsItem;
|
||||||
|
|
||||||
class VAbstractSimple : public QObject
|
class VAbstractSimple : public QObject
|
||||||
{
|
{
|
||||||
|
@ -40,9 +45,22 @@ class VAbstractSimple : public QObject
|
||||||
public:
|
public:
|
||||||
VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor = nullptr,
|
VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor = nullptr,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
virtual ~VAbstractSimple() Q_DECL_OVERRIDE;
|
virtual ~VAbstractSimple();
|
||||||
|
|
||||||
virtual void ChangedActivDraw(const bool &flag)=0;
|
virtual void ToolSelectionType(const SelectionType &type);
|
||||||
|
|
||||||
|
QColor GetCurrentColor() const;
|
||||||
|
|
||||||
|
virtual void SetEnabled(bool enabled) { Q_UNUSED(enabled); }
|
||||||
|
|
||||||
|
GOType GetType() const;
|
||||||
|
void SetType(const GOType &value);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void ShowContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @brief id spline id. */
|
/** @brief id spline id. */
|
||||||
|
@ -58,11 +76,21 @@ protected:
|
||||||
|
|
||||||
Unit patternUnit;
|
Unit patternUnit;
|
||||||
|
|
||||||
|
SelectionType selectionType;
|
||||||
|
|
||||||
|
GOType type;
|
||||||
|
|
||||||
QColor CorrectColor(const QColor &color) const;
|
QColor CorrectColor(const QColor &color) const;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void SetPen(T *item, const QColor &color, qreal width);
|
void SetPen(T *item, const QColor &color, qreal width);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void SimpleChangedActivDraw(T *item, const bool &flag);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void SetSimpleCurrentColor(T *item, const QColor &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractSimple)
|
Q_DISABLE_COPY(VAbstractSimple)
|
||||||
};
|
};
|
||||||
|
@ -81,4 +109,21 @@ void VAbstractSimple::SetPen(T *item, const QColor &color, qreal width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class T>
|
||||||
|
void VAbstractSimple::SimpleChangedActivDraw(T *item, const bool &flag)
|
||||||
|
{
|
||||||
|
enabled = flag;
|
||||||
|
item->setEnabled(enabled);
|
||||||
|
SetPen(item, currentColor, WidthHairLine(patternUnit));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class T>
|
||||||
|
void VAbstractSimple::SetSimpleCurrentColor(T *item, const QColor &value)
|
||||||
|
{
|
||||||
|
currentColor = value;
|
||||||
|
SetPen(item, CorrectColor(currentColor), item->pen().widthF());
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VABSTRACTSIMPLE_H
|
#endif // VABSTRACTSIMPLE_H
|
||||||
|
|
133
src/libs/vwidgets/vsimplecurve.cpp
Normal file
133
src/libs/vwidgets/vsimplecurve.cpp
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vsimplecurve.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 7 5, 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 "vsimplecurve.h"
|
||||||
|
#include "../ifc/ifcdef.h"
|
||||||
|
#include "../vgeometry/vabstractcurve.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
||||||
|
: VAbstractSimple(id, currentColor, patternUnit, factor, parent),
|
||||||
|
QGraphicsPathItem(),
|
||||||
|
m_curve()
|
||||||
|
{
|
||||||
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
|
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||||
|
this->setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VSimpleCurve::~VSimpleCurve()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::SetCurrentColor(const QColor &value)
|
||||||
|
{
|
||||||
|
SetSimpleCurrentColor(this, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::ChangedActivDraw(bool flag)
|
||||||
|
{
|
||||||
|
SimpleChangedActivDraw(this, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
||||||
|
{
|
||||||
|
m_curve = curve;
|
||||||
|
if (not curve.isNull())
|
||||||
|
{
|
||||||
|
setPath(curve->GetPath(PathDirection::Hide));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << tr("VSimpleCurve::RefreshGeometry: pointer to curve is null.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::CurveChoosed()
|
||||||
|
{
|
||||||
|
emit Choosed(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::CurveSelected(bool selected)
|
||||||
|
{
|
||||||
|
emit Selected(selected, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
// Special for not selectable item first need to call standard mousePressEvent then accept event
|
||||||
|
QGraphicsPathItem::mousePressEvent(event);
|
||||||
|
if (selectionType == SelectionType::ByMouseRelease)
|
||||||
|
{
|
||||||
|
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
emit Choosed(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (selectionType == SelectionType::ByMouseRelease)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
emit Choosed(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QGraphicsPathItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
SetPen(this, currentColor, WidthMainLine(patternUnit));
|
||||||
|
QGraphicsPathItem::hoverEnterEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||||
|
QGraphicsPathItem::hoverLeaveEvent(event);
|
||||||
|
}
|
78
src/libs/vwidgets/vsimplecurve.h
Normal file
78
src/libs/vwidgets/vsimplecurve.h
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vsimplecurve.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 7 5, 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 VSIMPLECURVE_H
|
||||||
|
#define VSIMPLECURVE_H
|
||||||
|
|
||||||
|
#include "vabstractsimple.h"
|
||||||
|
|
||||||
|
#include <QGraphicsPathItem>
|
||||||
|
|
||||||
|
class VAbstractCurve;
|
||||||
|
|
||||||
|
class VSimpleCurve : public VAbstractSimple, public QGraphicsPathItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor = nullptr,
|
||||||
|
QObject *parent = nullptr);
|
||||||
|
virtual ~VSimpleCurve();
|
||||||
|
|
||||||
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
|
enum { Type = UserType + static_cast<int>(Vis::SimpleCurve)};
|
||||||
|
|
||||||
|
void SetCurrentColor(const QColor &value);
|
||||||
|
|
||||||
|
void ChangedActivDraw(bool flag);
|
||||||
|
void RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve);
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* @brief Choosed send id when clicked.
|
||||||
|
* @param id point id.
|
||||||
|
*/
|
||||||
|
void Choosed(quint32 id);
|
||||||
|
void Selected(bool selected, quint32 id);
|
||||||
|
void Delete();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void CurveChoosed();
|
||||||
|
void CurveSelected(bool selected);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VSimpleCurve)
|
||||||
|
|
||||||
|
QSharedPointer<VAbstractCurve> m_curve;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VSIMPLECURVE_H
|
|
@ -39,8 +39,7 @@
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
||||||
:VAbstractSimple(id, currentColor, patternUnit, factor, parent), QGraphicsEllipseItem(),
|
:VAbstractSimple(id, currentColor, patternUnit, factor, parent), QGraphicsEllipseItem(),
|
||||||
radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)), namePoint(nullptr), lineName(nullptr),
|
radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)), namePoint(nullptr), lineName(nullptr)
|
||||||
selectionType(SelectionType::ByMouseRelease)
|
|
||||||
{
|
{
|
||||||
namePoint = new VGraphicsSimpleTextItem(this);
|
namePoint = new VGraphicsSimpleTextItem(this);
|
||||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
|
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
|
||||||
|
@ -59,11 +58,15 @@ VSimplePoint::~VSimplePoint()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimplePoint::ChangedActivDraw(const bool &flag)
|
void VSimplePoint::SetCurrentColor(const QColor &value)
|
||||||
{
|
{
|
||||||
enabled = flag;
|
SetSimpleCurrentColor(this, value);
|
||||||
setEnabled(enabled);
|
}
|
||||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VSimplePoint::ChangedActivDraw(bool flag)
|
||||||
|
{
|
||||||
|
SimpleChangedActivDraw(this, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -150,7 +153,7 @@ void VSimplePoint::AllowLabelSelecting(bool enabled)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimplePoint::ToolSelectionType(const SelectionType &type)
|
void VSimplePoint::ToolSelectionType(const SelectionType &type)
|
||||||
{
|
{
|
||||||
selectionType = type;
|
VAbstractSimple::ToolSelectionType(type);
|
||||||
namePoint->LabelSelectionType(type);
|
namePoint->LabelSelectionType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,13 +178,7 @@ void VSimplePoint::PointSelected(bool selected)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimplePoint::ChangedPosition(const QPointF &pos)
|
void VSimplePoint::ChangedPosition(const QPointF &pos)
|
||||||
{
|
{
|
||||||
emit NameChangedPosition(pos);
|
emit NameChangedPosition(pos, id);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VSimplePoint::ContextMenu(QGraphicsSceneContextMenuEvent *event)
|
|
||||||
{
|
|
||||||
emit ShowContextMenu(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -242,17 +239,3 @@ QVariant VSimplePoint::itemChange(QGraphicsItem::GraphicsItemChange change, cons
|
||||||
|
|
||||||
return QGraphicsEllipseItem::itemChange(change, value);
|
return QGraphicsEllipseItem::itemChange(change, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
// cppcheck-suppress unusedFunction
|
|
||||||
QColor VSimplePoint::GetCurrentColor() const
|
|
||||||
{
|
|
||||||
return currentColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VSimplePoint::SetCurrentColor(const QColor &value)
|
|
||||||
{
|
|
||||||
currentColor = value;
|
|
||||||
SetPen(this, CorrectColor(currentColor), pen().widthF());
|
|
||||||
}
|
|
||||||
|
|
|
@ -44,20 +44,18 @@ public:
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
virtual ~VSimplePoint() Q_DECL_OVERRIDE;
|
virtual ~VSimplePoint() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual void ChangedActivDraw(const bool &flag) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Vis::SimplePoint)};
|
enum { Type = UserType + static_cast<int>(Vis::SimplePoint)};
|
||||||
|
|
||||||
|
void ChangedActivDraw(bool flag);
|
||||||
void RefreshLine();
|
void RefreshLine();
|
||||||
void RefreshGeometry(const VPointF &point);
|
void RefreshGeometry(const VPointF &point);
|
||||||
void SetEnabled(bool enabled);
|
virtual void SetEnabled(bool enabled) Q_DECL_OVERRIDE;
|
||||||
void EnableToolMove(bool move);
|
void EnableToolMove(bool move);
|
||||||
void AllowLabelHover(bool enabled);
|
void AllowLabelHover(bool enabled);
|
||||||
void AllowLabelSelecting(bool enabled);
|
void AllowLabelSelecting(bool enabled);
|
||||||
void ToolSelectionType(const SelectionType &type);
|
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
QColor GetCurrentColor() const;
|
|
||||||
void SetCurrentColor(const QColor &value);
|
void SetCurrentColor(const QColor &value);
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
@ -66,16 +64,14 @@ signals:
|
||||||
*/
|
*/
|
||||||
void Choosed(quint32 id);
|
void Choosed(quint32 id);
|
||||||
void Selected(bool selected, quint32 id);
|
void Selected(bool selected, quint32 id);
|
||||||
void ShowContextMenu(QGraphicsSceneContextMenuEvent * event);
|
|
||||||
void Delete();
|
void Delete();
|
||||||
void NameChangedPosition(const QPointF &pos);
|
void NameChangedPosition(const QPointF &pos, quint32 id);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void DeleteFromLabel();
|
void DeleteFromLabel();
|
||||||
void PointChoosed();
|
void PointChoosed();
|
||||||
void PointSelected(bool selected);
|
void PointSelected(bool selected);
|
||||||
void ChangedPosition(const QPointF &pos);
|
void ChangedPosition(const QPointF &pos);
|
||||||
void ContextMenu(QGraphicsSceneContextMenuEvent * event);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||||
|
@ -95,9 +91,6 @@ private:
|
||||||
|
|
||||||
/** @brief lineName line what we see if label moved too away from point. */
|
/** @brief lineName line what we see if label moved too away from point. */
|
||||||
QGraphicsLineItem *lineName;
|
QGraphicsLineItem *lineName;
|
||||||
|
|
||||||
SelectionType selectionType;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VSIMPLEPOINT_H
|
#endif // VSIMPLEPOINT_H
|
||||||
|
|
|
@ -9,7 +9,8 @@ SOURCES += \
|
||||||
$$PWD/vgraphicssimpletextitem.cpp \
|
$$PWD/vgraphicssimpletextitem.cpp \
|
||||||
$$PWD/vsimplepoint.cpp \
|
$$PWD/vsimplepoint.cpp \
|
||||||
$$PWD/vabstractsimple.cpp \
|
$$PWD/vabstractsimple.cpp \
|
||||||
$$PWD/vnobrushscalepathitem.cpp
|
$$PWD/vnobrushscalepathitem.cpp \
|
||||||
|
$$PWD/vsimplecurve.cpp
|
||||||
|
|
||||||
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
||||||
|
@ -22,4 +23,5 @@ HEADERS += \
|
||||||
$$PWD/vgraphicssimpletextitem.h \
|
$$PWD/vgraphicssimpletextitem.h \
|
||||||
$$PWD/vsimplepoint.h \
|
$$PWD/vsimplepoint.h \
|
||||||
$$PWD/vabstractsimple.h \
|
$$PWD/vabstractsimple.h \
|
||||||
$$PWD/vnobrushscalepathitem.h
|
$$PWD/vnobrushscalepathitem.h \
|
||||||
|
$$PWD/vsimplecurve.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user