Merge with feature
--HG-- branch : develop
This commit is contained in:
commit
fab3c53a26
|
@ -32,6 +32,7 @@
|
|||
#include "../../libs/vwidgets/vmaingraphicsview.h"
|
||||
#include "../../libs/vwidgets/vgraphicssimpletextitem.h"
|
||||
#include "../../libs/vwidgets/vcontrolpointspline.h"
|
||||
#include "../../libs/vwidgets/vsimplepoint.h"
|
||||
#include "../../libs/vpropertyexplorer/vproperties.h"
|
||||
#include "vformulaproperty.h"
|
||||
#include "../../libs/vpatterndb/vformula.h"
|
||||
|
@ -161,6 +162,13 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
|||
case VToolPointFromArcAndTangent::Type:
|
||||
ShowOptionsToolPointFromArcAndTangent(item);
|
||||
break;
|
||||
case VSimplePoint::Type:
|
||||
currentItem = item->parentItem();
|
||||
ShowItemOptions(currentItem);
|
||||
break;
|
||||
case VToolTrueDarts::Type:
|
||||
ShowOptionsToolTrueDarts(item);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -257,6 +265,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
|
|||
case VToolPointFromArcAndTangent::Type:
|
||||
UpdateOptionsToolPointFromArcAndTangent();
|
||||
break;
|
||||
case VToolTrueDarts::Type:
|
||||
UpdateOptionsToolTrueDarts();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -368,6 +379,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
|||
case VToolPointFromArcAndTangent::Type:
|
||||
ChangeDataToolPointFromArcAndTangent(prop);
|
||||
break;
|
||||
case VToolTrueDarts::Type:
|
||||
ChangeDataToolTrueDarts(prop);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -433,6 +447,25 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &p
|
|||
AddProperty(itemName, VAbstractTool::AttrName);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName)
|
||||
{
|
||||
VProperty* itemName = new VProperty(propertyName);
|
||||
itemName->setValue(i->nameP1());
|
||||
AddProperty(itemName, VAbstractTool::AttrName1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::AddPropertyPointName2(Tool *i, const QString &propertyName)
|
||||
{
|
||||
VProperty* itemName = new VProperty(propertyName);
|
||||
itemName->setValue(i->nameP2());
|
||||
AddProperty(itemName, VAbstractTool::AttrName2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &propertyName)
|
||||
|
@ -502,6 +535,59 @@ void VToolOptionsPropertyBrowser::SetPointName(const QString &name)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::SetPointName1(const QString &name)
|
||||
{
|
||||
if (Tool *i = qgraphicsitem_cast<Tool *>(currentItem))
|
||||
{
|
||||
if (name == i->nameP1())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QRegularExpression rx(NameRegExp());
|
||||
if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.match(name).hasMatch() == false)
|
||||
{
|
||||
idToProperty[VAbstractTool::AttrName1]->setValue(i->nameP1());
|
||||
}
|
||||
else
|
||||
{
|
||||
i->setNameP1(name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't cast item";
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::SetPointName2(const QString &name)
|
||||
{
|
||||
if (Tool *i = qgraphicsitem_cast<Tool *>(currentItem))
|
||||
{
|
||||
if (name == i->nameP2())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QRegularExpression rx(NameRegExp());
|
||||
if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.match(name).hasMatch() == false)
|
||||
{
|
||||
idToProperty[VAbstractTool::AttrName2]->setValue(i->nameP2());
|
||||
}
|
||||
else
|
||||
{
|
||||
i->setNameP2(name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't cast item";
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
|
@ -719,6 +805,30 @@ void VToolOptionsPropertyBrowser::ChangeDataToolBisector(VProperty *property)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ChangeDataToolTrueDarts(VProperty *property)
|
||||
{
|
||||
SCASSERT(property != nullptr)
|
||||
|
||||
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
|
||||
const QString id = propertyToId[property];
|
||||
|
||||
VToolTrueDarts *i = qgraphicsitem_cast<VToolTrueDarts *>(currentItem);
|
||||
SCASSERT(i != nullptr);
|
||||
switch (PropertiesList().indexOf(id))
|
||||
{
|
||||
case 32: // VAbstractTool::AttrName1
|
||||
SetPointName1<VToolTrueDarts>(value.toString());
|
||||
break;
|
||||
case 33: // VAbstractTool::AttrName2
|
||||
SetPointName2<VToolTrueDarts>(value.toString());
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"Unknown property type. id = "<<id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ChangeDataToolCutArc(VProperty *property)
|
||||
{
|
||||
|
@ -1304,6 +1414,17 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item)
|
|||
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ShowOptionsToolTrueDarts(QGraphicsItem *item)
|
||||
{
|
||||
VToolTrueDarts *i = qgraphicsitem_cast<VToolTrueDarts *>(item);
|
||||
i->ShowVisualization(true);
|
||||
formView->setTitle(tr("True darts"));
|
||||
|
||||
AddPropertyPointName1(i, tr("Point 1 label"));
|
||||
AddPropertyPointName2(i, tr("Point 2 label"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item)
|
||||
{
|
||||
|
@ -1666,6 +1787,15 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::UpdateOptionsToolTrueDarts()
|
||||
{
|
||||
VToolTrueDarts *i = qgraphicsitem_cast<VToolTrueDarts *>(currentItem);
|
||||
|
||||
idToProperty[VAbstractTool::AttrName1]->setValue(i->nameP1());
|
||||
idToProperty[VAbstractTool::AttrName2]->setValue(i->nameP2());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc()
|
||||
{
|
||||
|
@ -1975,6 +2105,8 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
|||
<< VAbstractTool::AttrCrossPoint /* 28 */
|
||||
<< VAbstractTool::AttrC1Radius /* 29 */
|
||||
<< VAbstractTool::AttrC2Radius /* 30 */
|
||||
<< VAbstractTool::AttrCRadius; /* 31 */
|
||||
<< VAbstractTool::AttrCRadius /* 31 */
|
||||
<< VAbstractTool::AttrName1 /* 32 */
|
||||
<< VAbstractTool::AttrName2; /* 33 */
|
||||
return attr;
|
||||
}
|
||||
|
|
|
@ -68,12 +68,24 @@ private:
|
|||
template<class Tool>
|
||||
void SetPointName(const QString &name);
|
||||
|
||||
template<class Tool>
|
||||
void SetPointName1(const QString &name);
|
||||
|
||||
template<class Tool>
|
||||
void SetPointName2(const QString &name);
|
||||
|
||||
template<class Tool>
|
||||
void SetCrossCirclesPoint(const QVariant value);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyPointName(Tool *i, const QString &propertyName);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyPointName1(Tool *i, const QString &propertyName);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyPointName2(Tool *i, const QString &propertyName);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyCrossPoint(Tool *i, const QString &propertyName);
|
||||
|
||||
|
@ -94,6 +106,7 @@ private:
|
|||
void ChangeDataToolArc(VPE::VProperty *property);
|
||||
void ChangeDataToolArcWithLength(VPE::VProperty *property);
|
||||
void ChangeDataToolBisector(VPE::VProperty *property);
|
||||
void ChangeDataToolTrueDarts(VPE::VProperty *property);
|
||||
void ChangeDataToolCutArc(VPE::VProperty *property);
|
||||
void ChangeDataToolCutSpline(VPE::VProperty *property);
|
||||
void ChangeDataToolCutSplinePath(VPE::VProperty *property);
|
||||
|
@ -120,6 +133,7 @@ private:
|
|||
void ShowOptionsToolArc(QGraphicsItem *item);
|
||||
void ShowOptionsToolArcWithLength(QGraphicsItem *item);
|
||||
void ShowOptionsToolBisector(QGraphicsItem *item);
|
||||
void ShowOptionsToolTrueDarts(QGraphicsItem *item);
|
||||
void ShowOptionsToolCutArc(QGraphicsItem *item);
|
||||
void ShowOptionsToolCutSpline(QGraphicsItem *item);
|
||||
void ShowOptionsToolCutSplinePath(QGraphicsItem *item);
|
||||
|
@ -146,6 +160,7 @@ private:
|
|||
void UpdateOptionsToolArc();
|
||||
void UpdateOptionsToolArcWithLength();
|
||||
void UpdateOptionsToolBisector();
|
||||
void UpdateOptionsToolTrueDarts();
|
||||
void UpdateOptionsToolCutArc();
|
||||
void UpdateOptionsToolCutSpline();
|
||||
void UpdateOptionsToolCutSplinePath();
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
#include "../../libs/vgeometry/vsplinepath.h"
|
||||
#include "../../libs/vgeometry/vpointf.h"
|
||||
#include "../../libs/vtools/tools/vabstracttool.h"
|
||||
#include "../../libs/vtools/tools/drawTools/vtoolcutspline.h"
|
||||
#include "../../libs/vtools/tools/drawTools/vtoolcutsplinepath.h"
|
||||
#include "../../libs/vtools/tools/drawTools/vtoolcutarc.h"
|
||||
#include "../../libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h"
|
||||
#include "../../libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h"
|
||||
#include "../../libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -407,6 +407,13 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
{
|
||||
return QString(tr("%1 - point from arc and tangent")).arg(PointName(tool.getId()));
|
||||
}
|
||||
case Tool::TrueDarts:
|
||||
{
|
||||
return QString(tr("Correction the dart %1_%2_%3"))
|
||||
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrDartP1)))
|
||||
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrDartP2)))
|
||||
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrDartP2)));
|
||||
}
|
||||
//Because "history" not only show history of pattern, but help restore current data for each pattern's
|
||||
//piece, we need add record about details and nodes, but don't show them.
|
||||
case Tool::Detail:
|
||||
|
|
|
@ -178,7 +178,7 @@ void MainWindow::AddPP(const QString &PPName, const QString &path)
|
|||
sceneDraw->addItem(spoint);
|
||||
ui->view->itemClicked(spoint);
|
||||
|
||||
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(spoint, &VToolSinglePoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(sceneDraw, &VMainGraphicsScene::DisableItem, spoint, &VToolBasePoint::Disable);
|
||||
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolBasePoint::SetFactor);
|
||||
connect(sceneDraw, &VMainGraphicsScene::EnableToolMove, spoint, &VToolBasePoint::EnableToolMove);
|
||||
|
@ -309,7 +309,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
|
|||
ui->view->setCursor(cur);
|
||||
ui->view->setShowToolOptions(false);
|
||||
helpLabel->setText(toolTip);
|
||||
dialogTool = new Dialog(pattern, 0, this);
|
||||
dialogTool = new Dialog(pattern, NULL_ID, this);
|
||||
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
|
||||
SCASSERT(scene != nullptr);
|
||||
|
@ -745,6 +745,16 @@ void MainWindow::ToolArcWithLength(bool checked)
|
|||
&MainWindow::ApplyDialog<VToolArcWithLength>);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::ToolTrueDarts(bool checked)
|
||||
{
|
||||
SetToolButtonWithApply<DialogTrueDarts>(checked, Tool::TrueDarts,
|
||||
"://cursor/true_darts_cursor.png",
|
||||
tr("Select the first base line point"),
|
||||
&MainWindow::ClosedDialogWithApply<VToolTrueDarts>,
|
||||
&MainWindow::ApplyDialog<VToolTrueDarts>);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief About show widows about.
|
||||
|
@ -1048,6 +1058,7 @@ void MainWindow::InitToolButtons()
|
|||
&MainWindow::ToolPointFromCircleAndTangent);
|
||||
connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent);
|
||||
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength);
|
||||
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1176,6 +1187,9 @@ void MainWindow::CancelTool()
|
|||
case Tool::PointFromArcAndTangent:
|
||||
ui->toolButtonPointFromArcAndTangent->setChecked(false);
|
||||
break;
|
||||
case Tool::TrueDarts:
|
||||
ui->toolButtonTrueDarts->setChecked(false);
|
||||
break;
|
||||
case Tool::NodePoint:
|
||||
case Tool::NodeArc:
|
||||
case Tool::NodeSpline:
|
||||
|
@ -2206,6 +2220,7 @@ void MainWindow::SetEnableTool(bool enable)
|
|||
ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools);
|
||||
ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools);
|
||||
ui->toolButtonArcWithLength->setEnabled(drawTools);
|
||||
ui->toolButtonTrueDarts->setEnabled(drawTools);
|
||||
|
||||
ui->actionLast_tool->setEnabled(drawTools);
|
||||
|
||||
|
@ -2584,6 +2599,10 @@ void MainWindow::LastUsedTool()
|
|||
ui->toolButtonArcWithLength->setChecked(true);
|
||||
ToolArcWithLength(true);
|
||||
break;
|
||||
case Tool::TrueDarts:
|
||||
ui->toolButtonTrueDarts->setChecked(true);
|
||||
ToolTrueDarts(true);
|
||||
break;
|
||||
case Tool::NodePoint:
|
||||
case Tool::NodeArc:
|
||||
case Tool::NodeSpline:
|
||||
|
|
|
@ -121,6 +121,7 @@ public slots:
|
|||
void ToolPointFromCircleAndTangent(bool checked);
|
||||
void ToolPointFromArcAndTangent(bool checked);
|
||||
void ToolArcWithLength(bool checked);
|
||||
void ToolTrueDarts(bool checked);
|
||||
|
||||
void ClosedDialogDetail(int result);
|
||||
void ClosedDialogUnionDetails(int result);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<string>Tools</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>5</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
|
@ -56,7 +56,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>130</width>
|
||||
<height>272</height>
|
||||
<height>318</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -342,6 +342,29 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QToolButton" name="toolButtonTrueDarts">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="share/resources/icon.qrc">
|
||||
<normaloff>:/toolicon/32x32/true_darts.png</normaloff>:/toolicon/32x32/true_darts.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
|
|
|
@ -29,5 +29,6 @@
|
|||
<file>cursor/point_from_circle_and_tangent_cursor.png</file>
|
||||
<file>cursor/point_from_arc_and_tangent_cursor.png</file>
|
||||
<file>cursor/arc_with_length_cursor.png</file>
|
||||
<file>cursor/true_darts_cursor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
src/app/share/resources/cursor/true_darts_cursor.png
Normal file
BIN
src/app/share/resources/cursor/true_darts_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -45,5 +45,6 @@
|
|||
<file>icon/16x16/toolsectionpoint.png</file>
|
||||
<file>icon/16x16/toolsectiondetail.png</file>
|
||||
<file>icon/16x16/toolsectionlayout.png</file>
|
||||
<file>toolicon/32x32/true_darts.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
src/app/share/resources/toolicon/32x32/true_darts.png
Normal file
BIN
src/app/share/resources/toolicon/32x32/true_darts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 797 B |
101
src/app/share/resources/toolicon/svg/true_darts.svg
Normal file
101
src/app/share/resources/toolicon/svg/true_darts.svg
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="32"
|
||||
height="32"
|
||||
id="svg3837"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="true_darts.svg">
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1855"
|
||||
inkscape:window-height="1056"
|
||||
id="namedview12"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.921875"
|
||||
inkscape:cx="51.692473"
|
||||
inkscape:cy="-106.62764"
|
||||
inkscape:window-x="65"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg3837" />
|
||||
<defs
|
||||
id="defs3839" />
|
||||
<metadata
|
||||
id="metadata3842">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#370000;stroke-width:1.56700003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:0.93950177;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="path2985-2"
|
||||
d="m 21.179013,29.435997 a 1.7373301,1.7294948 0 0 1 -3.47466,0 1.7373301,1.7294948 0 1 1 3.47466,0 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.02699999999999991;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="path3009"
|
||||
d="M 14.375231,4.3244216 1.6038115,8.9917748"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#370000;stroke-width:1.57200003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:0.93950177;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="path2985-2-9"
|
||||
d="m 30.989681,2.8929613 a 1.8239208,1.9086996 0 0 1 -3.647841,0 1.8239208,1.9086996 0 1 1 3.647841,0 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;stroke:#370000;stroke-width:1.56599998;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:0.93950177;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="path2985-2-9-1"
|
||||
d="m 4.2694493,8.6961601 a 1.6940329,1.7299054 0 0 1 -3.38806468,0 1.6940329,1.7299054 0 1 1 3.38806468,0 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.02699995;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="path3009-1"
|
||||
d="M 14.317913,4.3781875 19.309206,30.130286"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.02699995;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="path3009-5"
|
||||
d="M 18.521303,3.6324247 19.377002,30.26588"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.02699995;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="path3009-9"
|
||||
d="M 31.131472,2.1408998 18.495646,3.6896088"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#f73208;fill-opacity:1;stroke:#f73208;stroke-width:1.56599998;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="path2985-2-9-1-5"
|
||||
d="m 15.185559,4.4745762 a 1.694033,1.7299055 0 0 1 -3.388066,0 1.694033,1.7299055 0 1 1 3.388066,0 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#f73208;fill-opacity:1;stroke:#f73208;stroke-width:1.56599998;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="path2985-2-9-1-5-5"
|
||||
d="m 20.609287,3.6610169 a 1.694033,1.7299055 0 0 1 -3.388066,0 1.694033,1.7299055 0 1 1 3.388066,0 z" />
|
||||
</svg>
|
After Width: | Height: | Size: 4.5 KiB |
|
@ -293,7 +293,7 @@ quint32 VPattern::SPointActiveDraw()
|
|||
const QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
if (domElement.tagName() == VToolPoint::TagName &&
|
||||
if (domElement.tagName() == VToolSinglePoint::TagName &&
|
||||
domElement.attribute(AttrType, "") == VToolBasePoint::ToolType)
|
||||
{
|
||||
return GetParametrId(domElement);
|
||||
|
@ -677,7 +677,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
<< VToolPointOfIntersectionArcs::ToolType
|
||||
<< VToolPointOfIntersectionCircles::ToolType
|
||||
<< VToolPointFromCircleAndTangent::ToolType
|
||||
<< VToolPointFromArcAndTangent::ToolType;
|
||||
<< VToolPointFromArcAndTangent::ToolType
|
||||
<< VToolTrueDarts::ToolType;
|
||||
switch (points.indexOf(type))
|
||||
{
|
||||
case 0: //VToolBasePoint::ToolType
|
||||
|
@ -1267,6 +1268,40 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
throw excep;
|
||||
}
|
||||
break;
|
||||
case 21: //VToolTrueDarts::ToolType
|
||||
try
|
||||
{
|
||||
ToolsCommonAttributes(domElement, id);
|
||||
|
||||
const quint32 p1Id = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, NULL_ID_STR);
|
||||
const quint32 p2Id = GetParametrUInt(domElement, VAbstractTool::AttrPoint2, NULL_ID_STR);
|
||||
|
||||
const quint32 baseLineP1Id = GetParametrUInt(domElement, VAbstractTool::AttrBaseLineP1, NULL_ID_STR);
|
||||
const quint32 baseLineP2Id = GetParametrUInt(domElement, VAbstractTool::AttrBaseLineP2, NULL_ID_STR);
|
||||
const quint32 dartP1Id = GetParametrUInt(domElement, VAbstractTool::AttrDartP1, NULL_ID_STR);
|
||||
const quint32 dartP2Id = GetParametrUInt(domElement, VAbstractTool::AttrDartP2, NULL_ID_STR);
|
||||
const quint32 dartP3Id = GetParametrUInt(domElement, VAbstractTool::AttrDartP3, NULL_ID_STR);
|
||||
|
||||
const QString name1 = GetParametrString(domElement, VAbstractTool::AttrName1, "A");
|
||||
const qreal mx1 = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx1, "10.0"));
|
||||
const qreal my1 = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy1, "15.0"));
|
||||
|
||||
const QString name2 = GetParametrString(domElement, VAbstractTool::AttrName2, "A");
|
||||
const qreal mx2 = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx2, "10.0"));
|
||||
const qreal my2 = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy2, "15.0"));
|
||||
|
||||
VToolTrueDarts::Create(id, p1Id, p2Id,
|
||||
baseLineP1Id, baseLineP2Id, dartP1Id, dartP2Id, dartP3Id,
|
||||
name1, mx1, my1, name2, mx2, my2,
|
||||
scene, this, data, parse, Source::FromFile);
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
VExceptionObjectError excep(tr("Error creating or updating true darts"), domElement);
|
||||
excep.AddMoreInformation(e.ErrorMessage());
|
||||
throw excep;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Illegal point type in VDomDocument::ParsePointElement().";
|
||||
break;
|
||||
|
|
|
@ -133,6 +133,19 @@
|
|||
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="name1" type="shortName"></xs:attribute>
|
||||
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my1" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="name2" type="shortName"></xs:attribute>
|
||||
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my2" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
||||
|
|
|
@ -45,7 +45,8 @@ enum class Source : char { FromGui, FromFile, FromTool };
|
|||
enum class Tool : unsigned char
|
||||
{
|
||||
Arrow,
|
||||
Point,
|
||||
SinglePoint,
|
||||
DoublePoint,
|
||||
LinePoint,
|
||||
AbstractSpline,
|
||||
Cut,
|
||||
|
@ -79,14 +80,16 @@ enum class Tool : unsigned char
|
|||
PointOfIntersection,
|
||||
PointFromCircleAndTangent,
|
||||
PointFromArcAndTangent,
|
||||
UnionDetails // 35
|
||||
TrueDarts,
|
||||
UnionDetails // 37
|
||||
};
|
||||
|
||||
enum class Vis : unsigned char
|
||||
{
|
||||
ControlPointSpline = 36, // increase this value if need more positions in Tool enum
|
||||
ControlPointSpline = 38, // increase this value if need more positions in Tool enum
|
||||
GraphicsSimpleTextItem,
|
||||
SimpleSplinePath,
|
||||
SimplePoint,
|
||||
Line,
|
||||
Path,
|
||||
ToolAlongLine,
|
||||
|
@ -112,7 +115,8 @@ enum class Vis : unsigned char
|
|||
ToolSplinePath,
|
||||
ToolCutSplinePath,
|
||||
ToolLineIntersectAxis,
|
||||
ToolCurveIntersectAxis
|
||||
ToolCurveIntersectAxis,
|
||||
ToolTrueDarts
|
||||
};
|
||||
|
||||
enum class VarType : char { Measurement, Increment, LineLength, SplineLength, ArcLength, ArcRadius, LineAngle, ArcAngle,
|
||||
|
|
|
@ -95,6 +95,15 @@ const QSharedPointer<VGObject> VContainer::GetGObject(quint32 id)const
|
|||
return GetObject(d->gObjects, id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const QSharedPointer<VGObject> VContainer::GetFakeGObject(quint32 id) const
|
||||
{
|
||||
VGObject *obj = new VGObject();
|
||||
obj->setId(id);
|
||||
QSharedPointer<VGObject> pointer(obj);
|
||||
return pointer;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetObject return object from container
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
template <typename T>
|
||||
const QSharedPointer<T> GeometricObject(const quint32 &id) const;
|
||||
const QSharedPointer<VGObject> GetGObject(quint32 id) const;
|
||||
const QSharedPointer<VGObject> GetFakeGObject(quint32 id) const;
|
||||
const VDetail GetDetail(quint32 id) const;
|
||||
qreal GetTableValue(const QString& name, MeasurementsType patternType) const;
|
||||
template <typename T>
|
||||
|
|
|
@ -32,7 +32,8 @@ HEADERS += \
|
|||
$$PWD/tools/dialogtriangle.h \
|
||||
$$PWD/tools/dialoguniondetails.h \
|
||||
$$PWD/support/dialogeditwrongformula.h \
|
||||
$$PWD/support/dialogundo.h
|
||||
$$PWD/support/dialogundo.h \
|
||||
$$PWD/tools/dialogtruedarts.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/tools/dialogalongline.cpp \
|
||||
|
@ -64,7 +65,8 @@ SOURCES += \
|
|||
$$PWD/tools/dialogtriangle.cpp \
|
||||
$$PWD/tools/dialoguniondetails.cpp \
|
||||
$$PWD/support/dialogeditwrongformula.cpp \
|
||||
$$PWD/support/dialogundo.cpp
|
||||
$$PWD/support/dialogundo.cpp \
|
||||
$$PWD/tools/dialogtruedarts.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/tools/dialogalongline.ui \
|
||||
|
@ -95,4 +97,5 @@ FORMS += \
|
|||
$$PWD/tools/dialogtriangle.ui \
|
||||
$$PWD/tools/dialoguniondetails.ui \
|
||||
$$PWD/support/dialogeditwrongformula.ui \
|
||||
$$PWD/support/dialogundo.ui
|
||||
$$PWD/support/dialogundo.ui \
|
||||
$$PWD/tools/dialogtruedarts.ui
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "dialogs/tools/dialogpointofintersectioncircles.h"
|
||||
#include "dialogs/tools/dialogpointfromcircleandtangent.h"
|
||||
#include "dialogs/tools/dialogpointfromarcandtangent.h"
|
||||
#include "dialogs/tools/dialogtruedarts.h"
|
||||
|
||||
#include "dialogs/support/dialogeditwrongformula.h"
|
||||
#include "dialogs/support/dialogundo.h"
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0)
|
||||
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0),
|
||||
ch1(NULL_ID), ch2(NULL_ID)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
InitFormulaUI(ui);
|
||||
|
@ -56,7 +57,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
|
|||
flagFormula = false;
|
||||
CheckState();
|
||||
|
||||
FillComboBoxArcs(ui->comboBoxArc);
|
||||
FillComboBoxArcs(ui->comboBoxArc, FillComboBox::NoChildren, ch1, ch2);
|
||||
FillComboBoxLineColors(ui->comboBoxColor);
|
||||
|
||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutArc::FXLength);
|
||||
|
@ -157,7 +158,7 @@ void DialogCutArc::closeEvent(QCloseEvent *event)
|
|||
*/
|
||||
void DialogCutArc::setArcId(const quint32 &value)
|
||||
{
|
||||
setCurrentArcId(ui->comboBoxArc, value, ComboBoxCutArc::CutArc);
|
||||
setCurrentArcId(ui->comboBoxArc, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis);
|
||||
SCASSERT(path != nullptr);
|
||||
|
@ -176,6 +177,14 @@ void DialogCutArc::SetColor(const QString &value)
|
|||
ChangeCurrentData(ui->comboBoxColor, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutArc::SetChildrenId(const quint32 &ch1, const quint32 &ch2)
|
||||
{
|
||||
this->ch1 = ch1;
|
||||
this->ch2 = ch2;
|
||||
FillComboBoxArcs(ui->comboBoxArc, FillComboBox::NoChildren, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetFormula set string with formula length
|
||||
|
|
|
@ -57,6 +57,8 @@ public:
|
|||
|
||||
QString GetColor() const;
|
||||
void SetColor(const QString &value);
|
||||
|
||||
void SetChildrenId(const quint32 &ch1, const quint32 &ch2);
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||
/**
|
||||
|
@ -85,6 +87,9 @@ private:
|
|||
|
||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||
int formulaBaseHeight;
|
||||
|
||||
quint32 ch1;
|
||||
quint32 ch2;
|
||||
};
|
||||
|
||||
#endif // DIALOGCUTARC_H
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0),
|
||||
ch1(NULL_ID), ch2(NULL_ID)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
InitFormulaUI(ui);
|
||||
|
@ -55,7 +56,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
|
|||
flagFormula = false;
|
||||
CheckState();
|
||||
|
||||
FillComboBoxSplines(ui->comboBoxSpline);
|
||||
FillComboBoxSplines(ui->comboBoxSpline, FillComboBox::NoChildren, ch1, ch2);
|
||||
FillComboBoxLineColors(ui->comboBoxColor);
|
||||
|
||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::FXLength);
|
||||
|
@ -114,7 +115,7 @@ void DialogCutSpline::SetFormula(const QString &value)
|
|||
*/
|
||||
void DialogCutSpline::setSplineId(const quint32 &value)
|
||||
{
|
||||
setCurrentSplineId(ui->comboBoxSpline, value, ComboBoxCutSpline::CutSpline);
|
||||
setCurrentSplineId(ui->comboBoxSpline, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
|
||||
SCASSERT(path != nullptr);
|
||||
|
@ -133,6 +134,14 @@ void DialogCutSpline::SetColor(const QString &value)
|
|||
ChangeCurrentData(ui->comboBoxColor, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSpline::SetChildrenId(const quint32 &ch1, const quint32 &ch2)
|
||||
{
|
||||
this->ch1 = ch1;
|
||||
this->ch2 = ch2;
|
||||
FillComboBoxSplines(ui->comboBoxSpline, FillComboBox::NoChildren, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
|
||||
QString GetColor() const;
|
||||
void SetColor(const QString &value);
|
||||
|
||||
void SetChildrenId(const quint32 &ch1, const quint32 &ch2);
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||
/**
|
||||
|
@ -81,6 +83,9 @@ private:
|
|||
|
||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||
int formulaBaseHeight;
|
||||
|
||||
quint32 ch1;
|
||||
quint32 ch2;
|
||||
};
|
||||
|
||||
#endif // DIALOGCUTSPLINE_H
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0),
|
||||
ch1(NULL_ID), ch2(NULL_ID)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
InitFormulaUI(ui);
|
||||
|
@ -55,7 +56,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
|
|||
flagFormula = false;
|
||||
CheckState();
|
||||
|
||||
FillComboBoxSplinesPath(ui->comboBoxSplinePath);
|
||||
FillComboBoxSplinesPath(ui->comboBoxSplinePath, FillComboBox::NoChildren, ch1, ch2);
|
||||
FillComboBoxLineColors(ui->comboBoxColor);
|
||||
|
||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSplinePath::FXLength);
|
||||
|
@ -114,7 +115,7 @@ void DialogCutSplinePath::SetFormula(const QString &value)
|
|||
*/
|
||||
void DialogCutSplinePath::setSplinePathId(const quint32 &value)
|
||||
{
|
||||
setCurrentSplinePathId(ui->comboBoxSplinePath, value, ComboBoxCutSpline::CutSpline);
|
||||
setCurrentSplinePathId(ui->comboBoxSplinePath, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis);
|
||||
SCASSERT(path != nullptr);
|
||||
|
@ -133,6 +134,14 @@ void DialogCutSplinePath::SetColor(const QString &value)
|
|||
ChangeCurrentData(ui->comboBoxColor, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSplinePath::SetChildrenId(const quint32 &ch1, const quint32 &ch2)
|
||||
{
|
||||
this->ch1 = ch1;
|
||||
this->ch2 = ch2;
|
||||
FillComboBoxSplinesPath(ui->comboBoxSplinePath, FillComboBox::NoChildren, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
|
||||
QString GetColor() const;
|
||||
void SetColor(const QString &value);
|
||||
|
||||
void SetChildrenId(const quint32 &ch1, const quint32 &ch2);
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||
/**
|
||||
|
@ -81,6 +83,9 @@ private:
|
|||
|
||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||
int formulaBaseHeight;
|
||||
|
||||
quint32 ch1;
|
||||
quint32 ch2;
|
||||
};
|
||||
|
||||
#endif // DIALOGCUTSPLINEPATH_H
|
||||
|
|
|
@ -115,146 +115,28 @@ void DialogTool::showEvent(QShowEvent *event)
|
|||
* @brief FillComboBoxPoints fill comboBox list of points
|
||||
* @param box comboBox
|
||||
*/
|
||||
void DialogTool::FillComboBoxPoints(QComboBox *box) const
|
||||
void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
||||
QMap<QString, quint32> list;
|
||||
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != toolId)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(i.key());
|
||||
list[point->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
FillList(box, list);
|
||||
FillCombo<VPointF>(box, GOType::Point, rule, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const
|
||||
void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (cut == ComboBoxCutArc::CutArc)
|
||||
{
|
||||
if (i.key() != toolId + 1 && i.key() != toolId + 2)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
|
||||
list[arc->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i.key() != toolId)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
|
||||
list[arc->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FillList(box, list);
|
||||
FillCombo<VArc>(box, GOType::Arc, rule, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FillComboBoxSplines fill comboBox list of splines
|
||||
* @param box comboBox
|
||||
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
||||
*/
|
||||
void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) const
|
||||
void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (cut == ComboBoxCutSpline::CutSpline)
|
||||
{
|
||||
if (i.key() != toolId + 1 && i.key() != toolId + 2)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(i.key());
|
||||
list[spl->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i.key() != toolId)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(i.key());
|
||||
list[spl->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FillList(box, list);
|
||||
FillCombo<VSpline>(box, GOType::Spline, rule, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FillComboBoxSplinesPath
|
||||
* @param box comboBox
|
||||
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
||||
*/
|
||||
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, ComboBoxCutSpline cut) const
|
||||
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule, const quint32 &ch1,
|
||||
const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
||||
QMap<QString, quint32> list;
|
||||
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (cut == ComboBoxCutSpline::CutSpline)
|
||||
{
|
||||
if (i.key() != toolId + 1 && i.key() != toolId + 2)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(i.key());
|
||||
list[splPath->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i.key() != toolId)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(i.key());
|
||||
list[splPath->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FillList(box, list);
|
||||
FillCombo<VSplinePath>(box, GOType::SplinePath, rule, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -505,13 +387,14 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const
|
||||
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillComboBox rule,
|
||||
const quint32 &ch1, const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
|
||||
box->blockSignals(true);
|
||||
|
||||
FillComboBoxPoints(box);
|
||||
FillComboBoxPoints(box, rule, ch1, ch2);
|
||||
ChangeCurrentData(box, value);
|
||||
|
||||
box->blockSignals(false);
|
||||
|
@ -520,28 +403,24 @@ void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setCurrentSplineId set current spline id in combobox
|
||||
* @param box combobox
|
||||
* @param value spline id
|
||||
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
||||
*/
|
||||
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
|
||||
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, FillComboBox rule,
|
||||
const quint32 &ch1, const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
FillComboBoxSplines(box, cut);
|
||||
FillComboBoxSplines(box, rule, ch1, ch2);
|
||||
ChangeCurrentData(box, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setCurrentArcId
|
||||
* @param box combobox
|
||||
* @param value arc id
|
||||
* @param cut if set to ComboMode::CutArc don't show id+1 and id+2
|
||||
*/
|
||||
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxCutArc cut) const
|
||||
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillComboBox rule,
|
||||
const quint32 &ch1, const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
FillComboBoxArcs(box, cut);
|
||||
FillComboBoxArcs(box, rule, ch1, ch2);
|
||||
ChangeCurrentData(box, value);
|
||||
}
|
||||
|
||||
|
@ -552,10 +431,11 @@ void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxC
|
|||
* @param value splinePath id
|
||||
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
|
||||
*/
|
||||
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
|
||||
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, FillComboBox rule,
|
||||
const quint32 &ch1, const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
FillComboBoxSplinesPath(box, cut);
|
||||
FillComboBoxSplinesPath(box, rule, ch1, ch2);
|
||||
ChangeCurrentData(box, value);
|
||||
}
|
||||
|
||||
|
@ -922,3 +802,46 @@ void DialogTool::SetAssociatedTool(VAbstractTool *tool)
|
|||
this->associatedTool=tool;
|
||||
SetToolId(tool->getId());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename GObject>
|
||||
void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, const quint32 &ch1,
|
||||
const quint32 &ch2) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
box->blockSignals(true);
|
||||
|
||||
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (rule == FillComboBox::NoChildren)
|
||||
{
|
||||
if (i.key() != toolId && i.key() != ch1 && i.key() != ch2)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
|
||||
list[arc->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i.key() != toolId)
|
||||
{
|
||||
QSharedPointer<VGObject> obj = i.value();
|
||||
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
|
||||
{
|
||||
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
|
||||
list[arc->name()] = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FillList(box, list);
|
||||
|
||||
box->blockSignals(false);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ class VContainer;
|
|||
class QPlainTextEdit;
|
||||
class VAbstractTool;
|
||||
|
||||
enum class ComboBoxCutSpline : char { CutSpline, NoCutSpline };
|
||||
enum class ComboBoxCutArc : char { CutArc, NoCutArc};
|
||||
enum class FillComboBox : char { Whole, NoChildren};
|
||||
|
||||
/**
|
||||
* @brief The DialogTool class parent for all dialog of tools.
|
||||
|
@ -185,11 +184,14 @@ protected:
|
|||
virtual void closeEvent ( QCloseEvent * event );
|
||||
virtual void showEvent( QShowEvent *event );
|
||||
|
||||
void FillComboBoxPoints(QComboBox *box)const;
|
||||
void FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const;
|
||||
void FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
|
||||
void FillComboBoxSplinesPath(QComboBox *box,
|
||||
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
|
||||
void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
||||
void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
||||
void FillComboBoxSplines(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
||||
void FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
||||
void FillComboBoxCurves(QComboBox *box)const;
|
||||
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
|
||||
void FillComboBoxLineColors(QComboBox *box)const;
|
||||
|
@ -202,13 +204,19 @@ protected:
|
|||
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
|
||||
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
|
||||
bool checkZero = true);
|
||||
void setCurrentPointId(QComboBox *box, const quint32 &value) const;
|
||||
|
||||
void setCurrentPointId(QComboBox *box, const quint32 &value,
|
||||
FillComboBox rule = FillComboBox::NoChildren,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
||||
void setCurrentSplineId(QComboBox *box, const quint32 &value,
|
||||
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
|
||||
FillComboBox rule = FillComboBox::NoChildren,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
||||
void setCurrentArcId(QComboBox *box, const quint32 &value,
|
||||
ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc) const;
|
||||
FillComboBox rule = FillComboBox::NoChildren,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
||||
void setCurrentSplinePathId(QComboBox *box, const quint32 &value,
|
||||
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
|
||||
FillComboBox rule = FillComboBox::NoChildren,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
||||
void setCurrentCurveId(QComboBox *box, const quint32 &value) const;
|
||||
|
||||
quint32 getCurrentObjectId(QComboBox *box) const;
|
||||
|
@ -309,6 +317,10 @@ protected:
|
|||
bool eventFilter(QObject *object, QEvent *event);
|
||||
private:
|
||||
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
||||
|
||||
template <typename GObject>
|
||||
void FillCombo(QComboBox *box, GOType gType, FillComboBox rule = FillComboBox::Whole,
|
||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
422
src/libs/vtools/dialogs/tools/dialogtruedarts.cpp
Normal file
422
src/libs/vtools/dialogs/tools/dialogtruedarts.cpp
Normal file
|
@ -0,0 +1,422 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogtruedarts.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "dialogtruedarts.h"
|
||||
#include "ui_dialogtruedarts.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../../visualization/vistooltruedarts.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogTrueDarts::DialogTrueDarts(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogTrueDarts), d1PointName(), d2PointName(), ch1(NULL_ID),
|
||||
ch2(NULL_ID), flagName1(true), flagName2(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
const QString name1 = qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel);
|
||||
const QString name2 = qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel, name1);
|
||||
ui->lineEditFirstNewDartPoint->setText(name1);
|
||||
ui->lineEditSecondNewDartPoint->setText(name2);
|
||||
|
||||
InitOkCancelApply(ui);
|
||||
CheckState();
|
||||
|
||||
FillComboBoxs(ch1, ch2);
|
||||
|
||||
connect(ui->lineEditFirstNewDartPoint, &QLineEdit::textChanged, this, &DialogTrueDarts::NameDartPoint1Changed);
|
||||
connect(ui->lineEditSecondNewDartPoint, &QLineEdit::textChanged, this, &DialogTrueDarts::NameDartPoint2Changed);
|
||||
connect(ui->comboBoxFirstBasePoint,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogTrueDarts::PointNameChanged);
|
||||
connect(ui->comboBoxSecondBasePoint,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogTrueDarts::PointNameChanged);
|
||||
connect(ui->comboBoxFirstDartPoint,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogTrueDarts::PointNameChanged);
|
||||
connect(ui->comboBoxSecondDartPoint,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogTrueDarts::PointNameChanged);
|
||||
connect(ui->comboBoxThirdDartPoint,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogTrueDarts::PointNameChanged);
|
||||
|
||||
vis = new VisToolTrueDarts(data);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogTrueDarts::~DialogTrueDarts()
|
||||
{
|
||||
DeleteVisualization<VisToolTrueDarts>();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogTrueDarts::GetFirstNewDartPointName()
|
||||
{
|
||||
return d1PointName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogTrueDarts::GetSecondNewDartPointName()
|
||||
{
|
||||
return d2PointName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SetNewDartPointNames(const QString &firstPoint, const QString &secondPoint)
|
||||
{
|
||||
ui->lineEditFirstNewDartPoint->blockSignals(true);
|
||||
ui->lineEditSecondNewDartPoint->blockSignals(true);
|
||||
|
||||
d1PointName = firstPoint;
|
||||
ui->lineEditFirstNewDartPoint->setText(d1PointName);
|
||||
|
||||
d2PointName = secondPoint;
|
||||
ui->lineEditSecondNewDartPoint->setText(d2PointName);
|
||||
|
||||
ui->lineEditSecondNewDartPoint->blockSignals(false);
|
||||
ui->lineEditFirstNewDartPoint->blockSignals(false);
|
||||
|
||||
CheckName(ui->lineEditFirstNewDartPoint, ui->labelFirstNewDartPoint, d1PointName, d2PointName,
|
||||
ui->lineEditSecondNewDartPoint, flagName1);
|
||||
CheckName(ui->lineEditSecondNewDartPoint, ui->labelSecondNewDartPoint, d1PointName, d2PointName,
|
||||
ui->lineEditFirstNewDartPoint, flagName2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogTrueDarts::GetFirstBasePointId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxFirstBasePoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SetFirstBasePointId(const quint32 &value)
|
||||
{
|
||||
setCurrentPointId(ui->comboBoxFirstBasePoint, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolTrueDarts *points = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(points != nullptr);
|
||||
points->setPoint1Id(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogTrueDarts::GetSecondBasePointId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxSecondBasePoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SetSecondBasePointId(const quint32 &value)
|
||||
{
|
||||
setCurrentPointId(ui->comboBoxSecondBasePoint, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolTrueDarts *points = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(points != nullptr);
|
||||
points->setPoint2Id(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogTrueDarts::GetFirstDartPointId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxFirstDartPoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SetFirstDartPointId(const quint32 &value)
|
||||
{
|
||||
setCurrentPointId(ui->comboBoxFirstDartPoint, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolTrueDarts *points = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(points != nullptr);
|
||||
points->setD1PointId(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogTrueDarts::GetSecondDartPointId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxSecondDartPoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SetSecondDartPointId(const quint32 &value)
|
||||
{
|
||||
setCurrentPointId(ui->comboBoxSecondDartPoint, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolTrueDarts *points = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(points != nullptr);
|
||||
points->setD2PointId(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogTrueDarts::GetThirdDartPointId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxThirdDartPoint);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SetThirdDartPointId(const quint32 &value)
|
||||
{
|
||||
setCurrentPointId(ui->comboBoxThirdDartPoint, value, FillComboBox::NoChildren, ch1, ch2);
|
||||
|
||||
VisToolTrueDarts *points = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(points != nullptr);
|
||||
points->setD3PointId(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SetChildrenId(const quint32 &ch1, const quint32 &ch2)
|
||||
{
|
||||
this->ch1 = ch1;
|
||||
this->ch2 = ch2;
|
||||
FillComboBoxs(ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type)
|
||||
{
|
||||
if (prepare == false)// After first choose we ignore all objects
|
||||
{
|
||||
if (type == SceneObject::Point)
|
||||
{
|
||||
VisToolTrueDarts *points = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(points != nullptr);
|
||||
|
||||
switch (number)
|
||||
{
|
||||
case 0:
|
||||
if (SetObject(id, ui->comboBoxFirstBasePoint, tr("Select the second base point")))
|
||||
{
|
||||
number++;
|
||||
points->VisualMode(id);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (getCurrentObjectId(ui->comboBoxFirstBasePoint) != id)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point")))
|
||||
{
|
||||
number++;
|
||||
points->setPoint2Id(id);
|
||||
points->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
|
||||
set.insert(id);
|
||||
|
||||
if (set.size() == 3)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point")))
|
||||
{
|
||||
number++;
|
||||
points->setD1PointId(id);
|
||||
points->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
|
||||
set.insert(id);
|
||||
|
||||
if (set.size() == 4)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point")))
|
||||
{
|
||||
number++;
|
||||
points->setD2PointId(id);
|
||||
points->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint));
|
||||
set.insert(id);
|
||||
|
||||
if (set.size() == 5)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxThirdDartPoint, ""))
|
||||
{
|
||||
points->setD3PointId(id);
|
||||
points->RefreshGeometry();
|
||||
prepare = true;
|
||||
this->setModal(true);
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::PointNameChanged()
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstBasePoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondBasePoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstDartPoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxThirdDartPoint));
|
||||
|
||||
QColor color = okColor;
|
||||
if (set.size() != 5)
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
flagError = true;
|
||||
color = okColor;
|
||||
}
|
||||
ChangeColor(ui->labelFirstBasePoint, color);
|
||||
ChangeColor(ui->labelSecondBasePoint, color);
|
||||
ChangeColor(ui->labelFirstDartPoint, color);
|
||||
ChangeColor(ui->labelSecondDartPoint, color);
|
||||
ChangeColor(ui->labelThirdDartPoint, color);
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::NameDartPoint1Changed()
|
||||
{
|
||||
NameChanged(ui->labelFirstNewDartPoint, d1PointName, d2PointName, ui->lineEditSecondNewDartPoint, flagName1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::NameDartPoint2Changed()
|
||||
{
|
||||
NameChanged(ui->labelSecondNewDartPoint, d1PointName, d2PointName, ui->lineEditFirstNewDartPoint, flagName2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::ShowVisualization()
|
||||
{
|
||||
AddVisualization<VisToolTrueDarts>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::SaveData()
|
||||
{
|
||||
d1PointName = ui->lineEditFirstNewDartPoint->text();
|
||||
d2PointName = ui->lineEditSecondNewDartPoint->text();
|
||||
|
||||
VisToolTrueDarts *points = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(points != nullptr);
|
||||
|
||||
points->setPoint1Id(GetFirstBasePointId());
|
||||
points->setPoint2Id(GetSecondBasePointId());
|
||||
points->setD1PointId(GetFirstDartPointId());
|
||||
points->setD2PointId(GetSecondDartPointId());
|
||||
points->setD3PointId(GetThirdDartPointId());
|
||||
points->RefreshGeometry();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::CheckState()
|
||||
{
|
||||
SCASSERT(bOk != nullptr);
|
||||
bOk->setEnabled(flagName1 && flagName2 && flagError);
|
||||
// In case dialog hasn't apply button
|
||||
if ( bApply != nullptr)
|
||||
{
|
||||
bApply->setEnabled(bOk->isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::NameChanged(QLabel *labelEditNamePoint, const QString &pointD1Name, const QString &pointD2Name,
|
||||
QLineEdit* secondPointName, bool &flagName)
|
||||
{
|
||||
SCASSERT(labelEditNamePoint != nullptr);
|
||||
SCASSERT(secondPointName != nullptr);
|
||||
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
||||
if (edit)
|
||||
{
|
||||
CheckName(edit, labelEditNamePoint, pointD1Name, pointD2Name, secondPointName, flagName);
|
||||
}
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::FillComboBoxs(const quint32 &ch1, const quint32 &ch2)
|
||||
{
|
||||
FillComboBoxPoints(ui->comboBoxFirstBasePoint, FillComboBox::NoChildren, ch1, ch2);
|
||||
FillComboBoxPoints(ui->comboBoxSecondBasePoint, FillComboBox::NoChildren, ch1, ch2);
|
||||
FillComboBoxPoints(ui->comboBoxFirstDartPoint, FillComboBox::NoChildren, ch1, ch2);
|
||||
FillComboBoxPoints(ui->comboBoxSecondDartPoint, FillComboBox::NoChildren, ch1, ch2);
|
||||
FillComboBoxPoints(ui->comboBoxThirdDartPoint, FillComboBox::NoChildren, ch1, ch2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTrueDarts::CheckName(QLineEdit *edit, QLabel *labelEditNamePoint, const QString &pointD1Name,
|
||||
const QString &pointD2Name, QLineEdit *secondPointName, bool &flagName)
|
||||
{
|
||||
SCASSERT(labelEditNamePoint != nullptr);
|
||||
SCASSERT(secondPointName != nullptr);
|
||||
SCASSERT(edit != nullptr);
|
||||
|
||||
const QString name = edit->text();
|
||||
const QString secondName = secondPointName->text();
|
||||
QRegularExpression rx(NameRegExp());
|
||||
if (name.isEmpty()
|
||||
|| secondName == name
|
||||
|| (pointD1Name != name && pointD2Name != name && data->IsUnique(name) == false)
|
||||
|| rx.match(name).hasMatch() == false)
|
||||
{
|
||||
flagName = false;
|
||||
ChangeColor(labelEditNamePoint, Qt::red);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagName = true;
|
||||
ChangeColor(labelEditNamePoint, okColor);
|
||||
}
|
||||
}
|
102
src/libs/vtools/dialogs/tools/dialogtruedarts.h
Normal file
102
src/libs/vtools/dialogs/tools/dialogtruedarts.h
Normal file
|
@ -0,0 +1,102 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogtruedarts.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 12 6, 2015
|
||||
**
|
||||
** @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) 2015 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 DIALOGTRUEDARTS_H
|
||||
#define DIALOGTRUEDARTS_H
|
||||
|
||||
#include "dialogtool.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DialogTrueDarts;
|
||||
}
|
||||
|
||||
class DialogTrueDarts : public DialogTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DialogTrueDarts(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
||||
~DialogTrueDarts();
|
||||
|
||||
QString GetFirstNewDartPointName();
|
||||
QString GetSecondNewDartPointName();
|
||||
void SetNewDartPointNames(const QString &firstPoint, const QString &secondPoint);
|
||||
|
||||
quint32 GetFirstBasePointId() const;
|
||||
void SetFirstBasePointId(const quint32 &value);
|
||||
|
||||
quint32 GetSecondBasePointId() const;
|
||||
void SetSecondBasePointId(const quint32 &value);
|
||||
|
||||
quint32 GetFirstDartPointId() const;
|
||||
void SetFirstDartPointId(const quint32 &value);
|
||||
|
||||
quint32 GetSecondDartPointId() const;
|
||||
void SetSecondDartPointId(const quint32 &value);
|
||||
|
||||
quint32 GetThirdDartPointId() const;
|
||||
void SetThirdDartPointId(const quint32 &value);
|
||||
|
||||
void SetChildrenId(const quint32 &ch1, const quint32 &ch2);
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||
virtual void PointNameChanged();
|
||||
void NameDartPoint1Changed();
|
||||
void NameDartPoint2Changed();
|
||||
protected:
|
||||
virtual void ShowVisualization();
|
||||
/**
|
||||
* @brief SaveData Put dialog data in local variables
|
||||
*/
|
||||
virtual void SaveData();
|
||||
virtual void CheckState();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogTrueDarts)
|
||||
Ui::DialogTrueDarts *ui;
|
||||
|
||||
QString d1PointName;
|
||||
QString d2PointName;
|
||||
|
||||
quint32 ch1;
|
||||
quint32 ch2;
|
||||
|
||||
bool flagName1;
|
||||
bool flagName2;
|
||||
|
||||
void NameChanged(QLabel *labelEditNamePoint, const QString &pointD1Name, const QString &pointD2Name,
|
||||
QLineEdit *secondPointName, bool &flagName);
|
||||
|
||||
void FillComboBoxs(const quint32 &ch1, const quint32 &ch2);
|
||||
|
||||
void CheckName(QLineEdit* edit, QLabel *labelEditNamePoint, const QString &pointD1Name, const QString &pointD2Name,
|
||||
QLineEdit *secondPointName, bool &flagName);
|
||||
};
|
||||
|
||||
#endif // DIALOGTRUEDARTS_H
|
202
src/libs/vtools/dialogs/tools/dialogtruedarts.ui
Normal file
202
src/libs/vtools/dialogs/tools/dialogtruedarts.ui
Normal file
|
@ -0,0 +1,202 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogTrueDarts</class>
|
||||
<widget class="QDialog" name="DialogTrueDarts">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>333</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>True darts</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../../app/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelFirstBasePoint">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First base point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBoxFirstBasePoint">
|
||||
<property name="toolTip">
|
||||
<string>First point of angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelSecondBasePoint">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Second base point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBoxSecondBasePoint">
|
||||
<property name="toolTip">
|
||||
<string>Second point of angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelFirstDartPoint">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First dart point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBoxFirstDartPoint">
|
||||
<property name="toolTip">
|
||||
<string>Third point of angle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelSecondDartPoint">
|
||||
<property name="text">
|
||||
<string>Second dart point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBoxSecondDartPoint">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show line from second point to this point</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>14</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelThirdDartPoint">
|
||||
<property name="text">
|
||||
<string>Third dart point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="comboBoxThirdDartPoint"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelFirstNewDartPoint">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First new dart point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="lineEditFirstNewDartPoint"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="labelSecondNewDartPoint">
|
||||
<property name="text">
|
||||
<string>Second new dart point</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="lineEditSecondNewDartPoint"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../../app/share/resources/icon.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogTrueDarts</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>DialogTrueDarts</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>
|
|
@ -54,5 +54,6 @@
|
|||
#include "toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h"
|
||||
#include "toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
|
||||
#include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
|
||||
#include "toolpoint/tooldoublepoint/vtooltruedarts.h"
|
||||
|
||||
#endif // DRAWTOOLS_H
|
||||
|
|
|
@ -0,0 +1,308 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtooldoublepoint.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 20 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "vtooldoublepoint.h"
|
||||
#include "../vwidgets/vsimplepoint.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../../../../undocommands/movedoublelabel.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id,
|
||||
QGraphicsItem *parent)
|
||||
:VAbstractPoint(doc, data, id), QGraphicsPathItem(parent), firstPoint(nullptr), secondPoint(nullptr), p1id(p1id),
|
||||
p2id(p2id)
|
||||
{
|
||||
firstPoint = new VSimplePoint(p1id, QColor(baseColor), *data->GetPatternUnit(), &factor);
|
||||
firstPoint->setParentItem(this);
|
||||
connect(firstPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point1Choosed);
|
||||
connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
|
||||
connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
|
||||
connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label1ChangePosition);
|
||||
firstPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
||||
|
||||
secondPoint = new VSimplePoint(p2id, QColor(baseColor), *data->GetPatternUnit(), &factor);
|
||||
secondPoint->setParentItem(this);
|
||||
connect(secondPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point2Choosed);
|
||||
connect(secondPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
|
||||
connect(secondPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
|
||||
connect(secondPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label2ChangePosition);
|
||||
secondPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolDoublePoint::~VToolDoublePoint()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
/* From question on StackOverflow
|
||||
* https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected
|
||||
*
|
||||
* There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way
|
||||
* I can think of is derive your own items from the build-in ones and override the paint() function:*/
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
QGraphicsPathItem::paint(painter, &myOption, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolDoublePoint::nameP1() const
|
||||
{
|
||||
return PointName(p1id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::setNameP1(const QString &name)
|
||||
{
|
||||
SetPointName(p1id, name);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolDoublePoint::nameP2() const
|
||||
{
|
||||
return PointName(p2id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::setNameP2(const QString &name)
|
||||
{
|
||||
SetPointName(p2id, name);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::SetEnabled(bool enabled)
|
||||
{
|
||||
SetToolEnabled(this, enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
|
||||
{
|
||||
ChangePosition(firstPoint, p1id, pos);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Label2ChangePosition(const QPointF &pos)
|
||||
{
|
||||
ChangePosition(secondPoint, p2id, pos);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
firstPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
||||
secondPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
enabled = !CorrectDisable(disable, namePP);
|
||||
this->SetEnabled(enabled);
|
||||
firstPoint->setEnabled(enabled);
|
||||
secondPoint->setEnabled(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::EnableToolMove(bool move)
|
||||
{
|
||||
firstPoint->EnableToolMove(move);
|
||||
secondPoint->EnableToolMove(move);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Point1Choosed()
|
||||
{
|
||||
emit ChoosedTool(p1id, SceneObject::Point);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::Point2Choosed()
|
||||
{
|
||||
emit ChoosedTool(p2id, SceneObject::Point);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::FullUpdateFromFile()
|
||||
{
|
||||
ReadAttributes();
|
||||
firstPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
|
||||
secondPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::UpdateNamePosition(quint32 id)
|
||||
{
|
||||
if (id == p1id)
|
||||
{
|
||||
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
|
||||
|
||||
MoveDoubleLabel *moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, this->id,
|
||||
this->scene());
|
||||
connect(moveLabel, &MoveDoubleLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
else if (id == p2id)
|
||||
{
|
||||
VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
|
||||
|
||||
MoveDoubleLabel *moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, this->id,
|
||||
this->scene());
|
||||
connect(moveLabel, &MoveDoubleLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::RefreshLine(quint32 id)
|
||||
{
|
||||
if (id == p1id)
|
||||
{
|
||||
firstPoint->RefreshLine();
|
||||
}
|
||||
else if (id == p2id)
|
||||
{
|
||||
secondPoint->RefreshLine();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief itemChange hadle item change.
|
||||
* @param change change.
|
||||
* @param value value.
|
||||
* @return value.
|
||||
*/
|
||||
QVariant VToolDoublePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == QGraphicsItem::ItemSelectedChange)
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
// do stuff if selected
|
||||
this->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
// do stuff if not selected
|
||||
}
|
||||
}
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief keyReleaseEvent handle key release events.
|
||||
* @param event key release event.
|
||||
*/
|
||||
void VToolDoublePoint::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
DeleteTool();
|
||||
return; //Leave this method immediately after call!!!
|
||||
default:
|
||||
break;
|
||||
}
|
||||
QGraphicsPathItem::keyReleaseEvent ( event );
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VDrawTool::SaveOptions(tag, obj);
|
||||
|
||||
if (obj->id() == p1id)
|
||||
{
|
||||
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
||||
SCASSERT(point.isNull() == false);
|
||||
|
||||
doc->SetAttribute(tag, AttrName1, point->name());
|
||||
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my()));
|
||||
}
|
||||
else if (obj->id() == p2id)
|
||||
{
|
||||
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
||||
SCASSERT(point.isNull() == false);
|
||||
|
||||
doc->SetAttribute(tag, AttrName2, point->name());
|
||||
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my()));
|
||||
}
|
||||
else
|
||||
{
|
||||
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
|
||||
VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
|
||||
|
||||
doc->SetAttribute(tag, AttrPoint1, p1id);
|
||||
doc->SetAttribute(tag, AttrName1, p1->name());
|
||||
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(p1->mx()));
|
||||
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(p1->my()));
|
||||
|
||||
doc->SetAttribute(tag, AttrPoint2, p2id);
|
||||
doc->SetAttribute(tag, AttrName2, p2->name());
|
||||
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(p2->mx()));
|
||||
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(p2->my()));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::AddToFile()
|
||||
{
|
||||
QDomElement domElement = doc->createElement(getTagName());
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOptions(domElement, obj);
|
||||
AddToCalculation(domElement);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolDoublePoint::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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtooldoublepoint.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 20 6, 2015
|
||||
**
|
||||
** @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) 2015 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 VTOOLDOUBLEPOINT_H
|
||||
#define VTOOLDOUBLEPOINT_H
|
||||
|
||||
#include "../vabstractpoint.h"
|
||||
|
||||
#include <QGraphicsPathItem>
|
||||
|
||||
class VPointF;
|
||||
class VGraphicsSimpleTextItem;
|
||||
class VSimplePoint;
|
||||
|
||||
class VToolDoublePoint: public VAbstractPoint, public QGraphicsPathItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
virtual ~VToolDoublePoint();
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::DoublePoint)};
|
||||
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||
|
||||
QString nameP1() const;
|
||||
void setNameP1(const QString &name);
|
||||
|
||||
QString nameP2() const;
|
||||
void setNameP2(const QString &name);
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
public slots:
|
||||
void Label1ChangePosition(const QPointF &pos);
|
||||
void Label2ChangePosition(const QPointF &pos);
|
||||
virtual void SetFactor(qreal factor);
|
||||
virtual void Disable(bool disable, const QString &namePP);
|
||||
virtual void EnableToolMove(bool move);
|
||||
void Point1Choosed();
|
||||
void Point2Choosed();
|
||||
virtual void FullUpdateFromFile();
|
||||
|
||||
protected:
|
||||
VSimplePoint *firstPoint;
|
||||
VSimplePoint *secondPoint;
|
||||
|
||||
quint32 p1id;
|
||||
quint32 p2id;
|
||||
|
||||
virtual void UpdateNamePosition(quint32 id);
|
||||
virtual void RefreshLine(quint32 id);
|
||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||
virtual void keyReleaseEvent(QKeyEvent * event);
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void AddToFile();
|
||||
virtual void RefreshDataInFile();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolDoublePoint)
|
||||
};
|
||||
|
||||
#endif // VTOOLDOUBLEPOINT_H
|
|
@ -0,0 +1,362 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtooltruedarts.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 23 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "vtooltruedarts.h"
|
||||
#include "../../../../dialogs/tools/dialogtruedarts.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../../../../visualization/vistooltruedarts.h"
|
||||
|
||||
const QString VToolTrueDarts::ToolType = QStringLiteral("trueDarts");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolTrueDarts::VToolTrueDarts(VAbstractPattern *doc,
|
||||
VContainer *data,
|
||||
const quint32 &id,
|
||||
const quint32 &p1id,
|
||||
const quint32 &p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolDoublePoint(doc, data, id, p1id, p2id, parent),
|
||||
baseLineP1Id (baseLineP1Id),
|
||||
baseLineP2Id(baseLineP2Id),
|
||||
dartP1Id(dartP1Id),
|
||||
dartP2Id(dartP2Id),
|
||||
dartP3Id(dartP3Id)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::FindPoint(const QPointF &baseLineP1, const QPointF &baseLineP2, const QPointF &dartP1,
|
||||
const QPointF &dartP2, const QPointF &dartP3, QPointF &p1, QPointF &p2)
|
||||
{
|
||||
const QLineF d2d1(dartP2, dartP1);
|
||||
const QLineF d2d3(dartP2, dartP3);
|
||||
|
||||
const qreal degrees = d2d3.angleTo(d2d1);
|
||||
|
||||
QLineF d2blP2(dartP2, baseLineP2);
|
||||
d2blP2.setAngle(d2d3.angle()+degrees);
|
||||
const QPointF bP2Temp = d2blP2.p2();
|
||||
|
||||
const QLineF bP1bP2Temp(baseLineP1, bP2Temp);
|
||||
|
||||
const QLineF::IntersectType res = bP1bP2Temp.intersect(d2d1, &p1);
|
||||
|
||||
if (res == QLineF::NoIntersection)
|
||||
{
|
||||
p1 = QPointF(0, 0);
|
||||
p2 = QPointF(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
QLineF d2p1(dartP2, p1);
|
||||
d2p1.setAngle(d2p1.angle()-degrees);
|
||||
p2 = d2p1.p2();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::setDialog()
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogTrueDarts *dialogTool = qobject_cast<DialogTrueDarts*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
|
||||
const QSharedPointer<VPointF> p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id);
|
||||
const QSharedPointer<VPointF> p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id);
|
||||
|
||||
dialogTool->SetChildrenId(p1id, p2id);
|
||||
dialogTool->SetNewDartPointNames(p1->name(), p2->name());
|
||||
dialogTool->SetFirstBasePointId(baseLineP1Id);
|
||||
dialogTool->SetSecondBasePointId(baseLineP2Id);
|
||||
dialogTool->SetFirstDartPointId(dartP1Id);
|
||||
dialogTool->SetSecondDartPointId(dartP2Id);
|
||||
dialogTool->SetThirdDartPointId(dartP3Id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolTrueDarts *VToolTrueDarts::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data)
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogTrueDarts *dialogTool = qobject_cast<DialogTrueDarts*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
|
||||
const QString point1Name = dialogTool->GetFirstNewDartPointName();
|
||||
const QString point2Name = dialogTool->GetSecondNewDartPointName();
|
||||
const quint32 baseLineP1Id = dialogTool->GetFirstBasePointId();
|
||||
const quint32 baseLineP2Id = dialogTool->GetSecondBasePointId();
|
||||
const quint32 dartP1Id = dialogTool->GetFirstDartPointId();
|
||||
const quint32 dartP2Id = dialogTool->GetSecondDartPointId();
|
||||
const quint32 dartP3Id = dialogTool->GetThirdDartPointId();
|
||||
|
||||
VToolTrueDarts *point = nullptr;
|
||||
point=Create(0, 0, 0, baseLineP1Id, baseLineP2Id, dartP1Id, dartP2Id, dartP3Id, point1Name, 5, 10, point2Name, 5,
|
||||
10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->dialog = dialogTool;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolTrueDarts *VToolTrueDarts::Create(quint32 _id,
|
||||
const quint32 &_p1id, const quint32 &_p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const QString &point1Name, const qreal &mx1, const qreal &my1,
|
||||
const QString &point2Name, const qreal &mx2, const qreal &my2,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation)
|
||||
{
|
||||
const QSharedPointer<VPointF> baseLineP1 = data->GeometricObject<VPointF>(baseLineP1Id);
|
||||
const QSharedPointer<VPointF> baseLineP2 = data->GeometricObject<VPointF>(baseLineP2Id);
|
||||
const QSharedPointer<VPointF> dartP1 = data->GeometricObject<VPointF>(dartP1Id);
|
||||
const QSharedPointer<VPointF> dartP2 = data->GeometricObject<VPointF>(dartP2Id);
|
||||
const QSharedPointer<VPointF> dartP3 = data->GeometricObject<VPointF>(dartP3Id);
|
||||
|
||||
QPointF fPoint1;
|
||||
QPointF fPoint2;
|
||||
VToolTrueDarts::FindPoint(baseLineP1->toQPointF(), baseLineP2->toQPointF(),
|
||||
dartP1->toQPointF(), dartP2->toQPointF(), dartP3->toQPointF(), fPoint1, fPoint2);
|
||||
quint32 id = _id;
|
||||
quint32 p1id = _p1id;
|
||||
quint32 p2id = _p2id;
|
||||
if (typeCreation == Source::FromGui)
|
||||
{
|
||||
id = data->getNextId();//Just reserve id for tool
|
||||
p1id = data->AddGObject(new VPointF(fPoint1, point1Name, mx1, my1));
|
||||
p2id = data->AddGObject(new VPointF(fPoint2, point2Name, mx2, my2));
|
||||
}
|
||||
else
|
||||
{
|
||||
data->UpdateGObject(p1id, new VPointF(fPoint1, point1Name, mx1, my1));
|
||||
data->UpdateGObject(p2id, new VPointF(fPoint2, point2Name, mx2, my2));
|
||||
if (parse != Document::FullParse)
|
||||
{
|
||||
doc->UpdateToolData(id, data);
|
||||
}
|
||||
}
|
||||
VDrawTool::AddRecord(id, Tool::TrueDarts, doc);
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
VToolTrueDarts *points = new VToolTrueDarts(doc, data, id, p1id, p2id, baseLineP1Id, baseLineP2Id,
|
||||
dartP1Id, dartP2Id, dartP3Id, typeCreation);
|
||||
scene->addItem(points);
|
||||
connect(points, &VToolDoublePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, points, &VToolTrueDarts::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, points, &VToolTrueDarts::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, points, &VToolTrueDarts::EnableToolMove);
|
||||
doc->AddTool(id, points);
|
||||
doc->IncrementReferens(baseLineP1Id);
|
||||
doc->IncrementReferens(baseLineP2Id);
|
||||
doc->IncrementReferens(dartP1Id);
|
||||
doc->IncrementReferens(dartP2Id);
|
||||
doc->IncrementReferens(dartP3Id);
|
||||
return points;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::ShowVisualization(bool show)
|
||||
{
|
||||
ShowToolVisualization<VisToolTrueDarts>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolTrueDarts::GetBaseLineP1Id() const
|
||||
{
|
||||
return baseLineP1Id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SetBaseLineP1Id(const quint32 &value)
|
||||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
baseLineP1Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolTrueDarts::GetBaseLineP2Id() const
|
||||
{
|
||||
return baseLineP2Id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SetBaseLineP2Id(const quint32 &value)
|
||||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
baseLineP2Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolTrueDarts::GetDartP1Id() const
|
||||
{
|
||||
return dartP1Id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SetDartP1Id(const quint32 &value)
|
||||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
dartP1Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolTrueDarts::GetDartP2Id() const
|
||||
{
|
||||
return dartP2Id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SetDartP2Id(const quint32 &value)
|
||||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
dartP2Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolTrueDarts::GetDartP3Id() const
|
||||
{
|
||||
return dartP3Id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SetDartP3Id(const quint32 &value)
|
||||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
dartP3Id = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetFakeGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
ContextMenu<DialogTrueDarts>(this, event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::RemoveReferens()
|
||||
{
|
||||
doc->DecrementReferens(baseLineP1Id);
|
||||
doc->DecrementReferens(baseLineP2Id);
|
||||
doc->DecrementReferens(dartP1Id);
|
||||
doc->DecrementReferens(dartP2Id);
|
||||
doc->DecrementReferens(dartP3Id);
|
||||
VToolDoublePoint::RemoveReferens();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogTrueDarts *dialogTool = qobject_cast<DialogTrueDarts*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
|
||||
doc->SetAttribute(domElement, AttrName1, dialogTool->GetFirstNewDartPointName());
|
||||
doc->SetAttribute(domElement, AttrName2, dialogTool->GetSecondNewDartPointName());
|
||||
doc->SetAttribute(domElement, AttrBaseLineP1, QString().setNum(dialogTool->GetFirstBasePointId()));
|
||||
doc->SetAttribute(domElement, AttrBaseLineP2, QString().setNum(dialogTool->GetSecondBasePointId()));
|
||||
doc->SetAttribute(domElement, AttrDartP1, QString().setNum(dialogTool->GetFirstDartPointId()));
|
||||
doc->SetAttribute(domElement, AttrDartP2, QString().setNum(dialogTool->GetSecondDartPointId()));
|
||||
doc->SetAttribute(domElement, AttrDartP3, QString().setNum(dialogTool->GetThirdDartPointId()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolDoublePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrBaseLineP1, baseLineP1Id);
|
||||
doc->SetAttribute(tag, AttrBaseLineP2, baseLineP2Id);
|
||||
doc->SetAttribute(tag, AttrDartP1, dartP1Id);
|
||||
doc->SetAttribute(tag, AttrDartP2, dartP2Id);
|
||||
doc->SetAttribute(tag, AttrDartP3, dartP3Id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::ReadToolAttributes(const QDomElement &domElement)
|
||||
{
|
||||
baseLineP1Id = doc->GetParametrUInt(domElement, AttrBaseLineP1, NULL_ID_STR);
|
||||
baseLineP2Id = doc->GetParametrUInt(domElement, AttrBaseLineP2, NULL_ID_STR);
|
||||
dartP1Id = doc->GetParametrUInt(domElement, AttrDartP1, NULL_ID_STR);
|
||||
dartP2Id = doc->GetParametrUInt(domElement, AttrDartP2, NULL_ID_STR);
|
||||
dartP3Id = doc->GetParametrUInt(domElement, AttrDartP3, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolTrueDarts *visual = qobject_cast<VisToolTrueDarts *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(baseLineP1Id);
|
||||
visual->setPoint2Id(baseLineP2Id);
|
||||
visual->setD1PointId(dartP1Id);
|
||||
visual->setD2PointId(dartP2Id);
|
||||
visual->setD3PointId(dartP3Id);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtooltruedarts.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 23 6, 2015
|
||||
**
|
||||
** @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) 2015 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 VTOOLTRUEDARTS_H
|
||||
#define VTOOLTRUEDARTS_H
|
||||
|
||||
#include "vtooldoublepoint.h"
|
||||
|
||||
class VToolTrueDarts : public VToolDoublePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolTrueDarts(VAbstractPattern *doc,
|
||||
VContainer *data,
|
||||
const quint32 &id,
|
||||
const quint32 &p1id,
|
||||
const quint32 &p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
|
||||
static void FindPoint(const QPointF &baseLineP1, const QPointF &baseLineP2, const QPointF &dartP1,
|
||||
const QPointF &dartP2, const QPointF &dartP3, QPointF &p1, QPointF &p2);
|
||||
virtual void setDialog();
|
||||
static VToolTrueDarts* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolTrueDarts* Create(quint32 _id,
|
||||
const quint32 &_p1id, const quint32 &_p2id,
|
||||
const quint32 &baseLineP1Id,
|
||||
const quint32 &baseLineP2Id,
|
||||
const quint32 &dartP1Id,
|
||||
const quint32 &dartP2Id,
|
||||
const quint32 &dartP3Id,
|
||||
const QString &point1Name, const qreal &mx1, const qreal &my1,
|
||||
const QString &point2Name, const qreal &mx2, const qreal &my2,
|
||||
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
||||
const Document &parse, const Source &typeCreation);
|
||||
static const QString ToolType;
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::TrueDarts)};
|
||||
|
||||
virtual void ShowVisualization(bool show);
|
||||
|
||||
quint32 GetBaseLineP1Id() const;
|
||||
void SetBaseLineP1Id(const quint32 &value);
|
||||
|
||||
quint32 GetBaseLineP2Id() const;
|
||||
void SetBaseLineP2Id(const quint32 &value);
|
||||
|
||||
quint32 GetDartP1Id() const;
|
||||
void SetDartP1Id(const quint32 &value);
|
||||
|
||||
quint32 GetDartP2Id() const;
|
||||
void SetDartP2Id(const quint32 &value);
|
||||
|
||||
quint32 GetDartP3Id() const;
|
||||
void SetDartP3Id(const quint32 &value);
|
||||
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void RemoveReferens();
|
||||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolTrueDarts)
|
||||
quint32 baseLineP1Id;
|
||||
quint32 baseLineP2Id;
|
||||
quint32 dartP1Id;
|
||||
quint32 dartP2Id;
|
||||
quint32 dartP3Id;
|
||||
};
|
||||
|
||||
#endif // VTOOLTRUEDARTS_H
|
|
@ -34,7 +34,7 @@
|
|||
VToolCut::VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, const QString &color,
|
||||
QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr),
|
||||
:VToolSinglePoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr),
|
||||
curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id), detailsMode(false)
|
||||
{
|
||||
Q_ASSERT_X(curveCutId > 0, Q_FUNC_INFO, "curveCutId <= 0");
|
||||
|
@ -72,7 +72,7 @@ void VToolCut::HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirecti
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
VToolPoint::Disable(disable, namePP);
|
||||
VToolSinglePoint::Disable(disable, namePP);
|
||||
firstCurve->ChangedActivDraw(enabled);
|
||||
secondCurve->ChangedActivDraw(enabled);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ void VToolCut::RefreshGeometry()
|
|||
{
|
||||
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
|
||||
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -172,7 +172,7 @@ void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrColor, lineColor);
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#ifndef VTOOLCUT_H
|
||||
#define VTOOLCUT_H
|
||||
|
||||
#include "../vtoolpoint.h"
|
||||
#include "../vtoolsinglepoint.h"
|
||||
#include "../vwidgets/vsimplecurve.h"
|
||||
#include "../../../toolcurve/vabstractspline.h"
|
||||
|
||||
class VFormula;
|
||||
|
||||
class VToolCut : public VToolPoint
|
||||
class VToolCut : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -70,6 +70,7 @@ void VToolCutArc::setDialog()
|
|||
DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
dialogTool->SetChildrenId(curve1id, curve2id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setArcId(curveCutId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
|
@ -165,7 +166,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
|
|||
{
|
||||
VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, color, typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutArc::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutArc::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutArc::EnableToolMove);
|
||||
|
|
|
@ -69,6 +69,7 @@ void VToolCutSpline::setDialog()
|
|||
DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
dialogTool->SetChildrenId(curve1id, curve2id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setSplineId(curveCutId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
|
@ -173,7 +174,7 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa
|
|||
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, color,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSpline::EnableToolMove);
|
||||
|
|
|
@ -72,6 +72,7 @@ void VToolCutSplinePath::setDialog()
|
|||
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
dialogTool->SetChildrenId(curve1id, curve2id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setSplinePathId(curveCutId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
|
@ -217,7 +218,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
|
|||
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id,
|
||||
splPath2id, color, typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSplinePath::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSplinePath::EnableToolMove);
|
||||
|
|
|
@ -201,7 +201,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
|
|||
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId,
|
||||
secondPointId, thirdPointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolBisector::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolBisector::EnableToolMove);
|
||||
|
|
|
@ -129,7 +129,7 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons
|
|||
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
|
||||
basePointId, curveId, typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCurveIntersectAxis::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCurveIntersectAxis::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCurveIntersectAxis::EnableToolMove);
|
||||
|
|
|
@ -166,7 +166,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
|
|||
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle,
|
||||
basePointId, typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolEndLine::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolEndLine::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolEndLine::EnableToolMove);
|
||||
|
|
|
@ -158,7 +158,7 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co
|
|||
VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolHeight::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolHeight::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolHeight::EnableToolMove);
|
||||
|
|
|
@ -140,7 +140,7 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const
|
|||
basePointId, firstPointId, secondPointId,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersectAxis::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersectAxis::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersectAxis::EnableToolMove);
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||
const QString &lineColor, const QString &formula, const quint32 &basePointId,
|
||||
const qreal &angle, QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), formulaLength(formula), angle(angle), basePointId(basePointId),
|
||||
:VToolSinglePoint(doc, data, id, parent), formulaLength(formula), angle(angle), basePointId(basePointId),
|
||||
mainLine(nullptr)
|
||||
{
|
||||
this->typeLine = typeLine;
|
||||
|
@ -74,7 +74,7 @@ void VToolLinePoint::RefreshGeometry()
|
|||
mainLine->setPen(QPen(CorrectColor(QColor(lineColor)),
|
||||
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||
LineStyleToPenStyle(typeLine)));
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
QPointF point = VDrawTool::data.GeometricObject<VPointF>(id)->toQPointF();
|
||||
QPointF basePoint = VDrawTool::data.GeometricObject<VPointF>(basePointId)->toQPointF();
|
||||
mainLine->setLine(QLineF(basePoint - point, QPointF()));
|
||||
|
@ -92,7 +92,7 @@ void VToolLinePoint::RemoveReferens()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLinePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrTypeLine, typeLine);
|
||||
doc->SetAttribute(tag, AttrLineColor, lineColor);
|
||||
|
@ -112,7 +112,7 @@ void VToolLinePoint::SetFactor(qreal factor)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLinePoint::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
VToolPoint::Disable(disable, namePP);
|
||||
VToolSinglePoint::Disable(disable, namePP);
|
||||
mainLine->setPen(QPen(CorrectColor(lineColor),
|
||||
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||
LineStyleToPenStyle(typeLine)));
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#ifndef VTOOLLINEPOINT_H
|
||||
#define VTOOLLINEPOINT_H
|
||||
|
||||
#include "../vtoolpoint.h"
|
||||
#include "../vtoolsinglepoint.h"
|
||||
#include "../vpatterndb/vformula.h"
|
||||
|
||||
/**
|
||||
* @brief The VToolLinePoint class parent for all tools what create point with line.
|
||||
*/
|
||||
class VToolLinePoint : public VToolPoint
|
||||
class VToolLinePoint : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -49,7 +49,7 @@ const QString VToolBasePoint::ToolType = QStringLiteral("single");
|
|||
*/
|
||||
VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
const QString &namePP, const QString &mPath, QGraphicsItem * parent )
|
||||
:VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
|
||||
:VToolSinglePoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
|
||||
{
|
||||
baseColor = Qt::red;
|
||||
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||
|
@ -202,7 +202,7 @@ void VToolBasePoint::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBasePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
VToolPoint::hoverEnterEvent(event);
|
||||
VToolSinglePoint::hoverEnterEvent(event);
|
||||
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ void VToolBasePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBasePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
VToolPoint::hoverLeaveEvent(event);
|
||||
VToolSinglePoint::hoverLeaveEvent(event);
|
||||
|
||||
if (flags() & QGraphicsItem::ItemIsMovable)
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
|
||||
}
|
||||
}
|
||||
VToolPoint::mousePressEvent(event);
|
||||
VToolSinglePoint::mousePressEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -246,7 +246,7 @@ void VToolBasePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
RestoreOverrideCursor(cursorArrowCloseHand);
|
||||
}
|
||||
}
|
||||
VToolPoint::mouseReleaseEvent(event);
|
||||
VToolSinglePoint::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -263,7 +263,7 @@ void VToolBasePoint::SetColorLabel(const Qt::GlobalColor &color)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBasePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
|
||||
SCASSERT(point.isNull() == false);
|
||||
|
@ -329,5 +329,5 @@ void VToolBasePoint::SetFactor(qreal factor)
|
|||
void VToolBasePoint::EnableToolMove(bool move)
|
||||
{
|
||||
this->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||
VToolPoint::EnableToolMove(move);
|
||||
VToolSinglePoint::EnableToolMove(move);
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#ifndef VTOOLBASEPOINT_H
|
||||
#define VTOOLBASEPOINT_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
/**
|
||||
* @brief The VToolBasePoint class tool for creation pattern base point. Obly base point can move. All object
|
||||
* pattern peace depend on base point.
|
||||
*/
|
||||
class VToolBasePoint : public VToolPoint
|
||||
class VToolBasePoint : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -50,7 +50,7 @@ VToolLineIntersect::VToolLineIntersect(VAbstractPattern *doc, VContainer *data,
|
|||
const quint32 &p1Line1, const quint32 &p2Line1, const quint32 &p1Line2,
|
||||
const quint32 &p2Line2, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
|
||||
:VToolSinglePoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
|
||||
p2Line2(p2Line2)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
|
@ -232,7 +232,7 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrP1Line1, p1Line1);
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
#ifndef VTOOLLINEINTERSECT_H
|
||||
#define VTOOLLINEINTERSECT_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
/**
|
||||
* @brief The VToolLineIntersect class help find point intersection lines.
|
||||
*/
|
||||
class VToolLineIntersect:public VToolPoint
|
||||
class VToolLineIntersect:public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -39,7 +39,7 @@ VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(VAbstractPattern *doc,
|
|||
quint32 arcId, quint32 tangentPointId,
|
||||
CrossCirclesPoint crossPoint, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), arcId(arcId), tangentPointId(tangentPointId), crossPoint(crossPoint)
|
||||
:VToolSinglePoint(doc, data, id, parent), arcId(arcId), tangentPointId(tangentPointId), crossPoint(crossPoint)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromArcAndTangent::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrArc, arcId);
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#ifndef VTOOLPOINTFROMARCANDTANGENT_H
|
||||
#define VTOOLPOINTFROMARCANDTANGENT_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
class VToolPointFromArcAndTangent : public VToolPoint
|
||||
class VToolPointFromArcAndTangent : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -41,7 +41,7 @@ VToolPointFromCircleAndTangent::VToolPointFromCircleAndTangent(VAbstractPattern
|
|||
quint32 circleCenterId, const QString &circleRadius,
|
||||
quint32 tangentPointId, CrossCirclesPoint crossPoint,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), circleCenterId(circleCenterId), tangentPointId(tangentPointId),
|
||||
:VToolSinglePoint(doc, data, id, parent), circleCenterId(circleCenterId), tangentPointId(tangentPointId),
|
||||
circleRadius(circleRadius), crossPoint(crossPoint)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
|
@ -272,7 +272,7 @@ void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromCircleAndTangent::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrCCenter, circleCenterId);
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#ifndef VTOOLPOINTFROMCIRCLEANDTANGENT_H
|
||||
#define VTOOLPOINTFROMCIRCLEANDTANGENT_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
class VFormula;
|
||||
|
||||
class VToolPointFromCircleAndTangent : public VToolPoint
|
||||
class VToolPointFromCircleAndTangent : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -54,7 +54,7 @@ VToolPointOfContact::VToolPointOfContact(VAbstractPattern *doc, VContainer *data
|
|||
const QString &radius, const quint32 ¢er,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
: VToolPoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId),
|
||||
: VToolSinglePoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId),
|
||||
secondPointId(secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
|
@ -285,7 +285,7 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfContact::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrRadius, arcRadius);
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
#ifndef VTOOLPOINTOFCONTACT_H
|
||||
#define VTOOLPOINTOFCONTACT_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
class VFormula;
|
||||
|
||||
/**
|
||||
* @brief The VToolPointOfContact class tool for creation point intersection line and arc.
|
||||
*/
|
||||
class VToolPointOfContact : public VToolPoint
|
||||
class VToolPointOfContact : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -47,7 +47,7 @@ const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfInters
|
|||
VToolPointOfIntersection::VToolPointOfIntersection(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
||||
const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId)
|
||||
:VToolSinglePoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersection::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
#ifndef VTOOLPOINTOFINTERSECTION_H
|
||||
#define VTOOLPOINTOFINTERSECTION_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
/**
|
||||
* @brief The VToolPointOfIntersection class tool for creation point intersection two lines.
|
||||
*/
|
||||
class VToolPointOfIntersection : public VToolPoint
|
||||
class VToolPointOfIntersection : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -39,7 +39,7 @@ VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VAbstractPattern *doc
|
|||
const quint32 &firstArcId, const quint32 &secondArcId,
|
||||
CrossCirclesPoint pType, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
|
||||
:VToolSinglePoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrFirstArc, firstArcId);
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#ifndef VTOOLPOINTOFINTERSECTIONARCS_H
|
||||
#define VTOOLPOINTOFINTERSECTIONARCS_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
class VArc;
|
||||
|
||||
class VToolPointOfIntersectionArcs : public VToolPoint
|
||||
class VToolPointOfIntersectionArcs : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(VAbstractPatter
|
|||
const QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), firstCircleCenterId(firstCircleCenterId),
|
||||
:VToolSinglePoint(doc, data, id, parent), firstCircleCenterId(firstCircleCenterId),
|
||||
secondCircleCenterId(secondCircleCenterId), firstCircleRadius(firstCircleRadius),
|
||||
secondCircleRadius(secondCircleRadius), crossPoint(crossPoint)
|
||||
{
|
||||
|
@ -308,7 +308,7 @@ void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrC1Center, firstCircleCenterId);
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#ifndef VTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||
#define VTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
class VFormula;
|
||||
|
||||
class VToolPointOfIntersectionCircles : public VToolPoint
|
||||
class VToolPointOfIntersectionCircles : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtoolpoint.cpp
|
||||
** @file vtoolsinglepoint.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
|
@ -26,7 +26,7 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
#include "../vmisc/logging.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vwidgets/vgraphicssimpletextitem.h"
|
||||
|
@ -34,29 +34,26 @@
|
|||
|
||||
#include <QKeyEvent>
|
||||
|
||||
Q_LOGGING_CATEGORY(vToolPoint, "v.toolPoint")
|
||||
|
||||
const QString VToolPoint::TagName = QStringLiteral("point");
|
||||
Q_LOGGING_CATEGORY(vToolSinglePoint, "v.toolSinglePoint")
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VToolPoint constructor.
|
||||
* @brief VToolSinglePoint constructor.
|
||||
* @param doc dom document container.
|
||||
* @param data container with variables.
|
||||
* @param id object id in container.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolPoint::VToolPoint(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
|
||||
:VDrawTool(doc, data, id), QGraphicsEllipseItem(parent), radius(DefPointRadius), namePoint(nullptr),
|
||||
lineName(nullptr)
|
||||
VToolSinglePoint::VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
|
||||
:VAbstractPoint(doc, data, id), QGraphicsEllipseItem(parent), radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)),
|
||||
namePoint(nullptr), lineName(nullptr)
|
||||
{
|
||||
radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm);
|
||||
namePoint = new VGraphicsSimpleTextItem(this);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::contextMenuEvent);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolPoint::DeleteFromLabel);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VToolPoint::PointChoosed);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolSinglePoint::contextMenuEvent);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolSinglePoint::DeleteFromLabel);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VToolSinglePoint::PointChoosed);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition);
|
||||
lineName = new QGraphicsLineItem(this);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition);
|
||||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||
|
@ -65,11 +62,11 @@ VToolPoint::VToolPoint(VAbstractPattern *doc, VContainer *data, quint32 id, QGra
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPoint::~VToolPoint()
|
||||
VToolSinglePoint::~VToolSinglePoint()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void VToolSinglePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
/* From question on StackOverflow
|
||||
* https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected
|
||||
|
@ -82,33 +79,21 @@ void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolPoint::name() const
|
||||
QString VToolSinglePoint::name() const
|
||||
{
|
||||
try
|
||||
{
|
||||
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
qCDebug(vToolPoint, "Error! Couldn't get point name. %s %s", e.ErrorMessage().toUtf8().constData(),
|
||||
e.DetailedInformation().toUtf8().constData());
|
||||
return QString("");// Return empty string for property browser
|
||||
}
|
||||
return PointName(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::setName(const QString &name)
|
||||
void VToolSinglePoint::setName(const QString &name)
|
||||
{
|
||||
// Don't know if need check name here.
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
obj->setName(name);
|
||||
SaveOption(obj);
|
||||
SetPointName(id, name);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolPoint::getTagName() const
|
||||
void VToolSinglePoint::SetEnabled(bool enabled)
|
||||
{
|
||||
return VToolPoint::TagName;
|
||||
SetToolEnabled(this, enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -116,15 +101,9 @@ QString VToolPoint::getTagName() const
|
|||
* @brief NameChangePosition handle change posion point label.
|
||||
* @param pos new position.
|
||||
*/
|
||||
void VToolPoint::NameChangePosition(const QPointF &pos)
|
||||
void VToolSinglePoint::NameChangePosition(const QPointF &pos)
|
||||
{
|
||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
QPointF p = pos - this->pos();
|
||||
point->setMx(p.x());
|
||||
point->setMy(p.y());
|
||||
RefreshLine();
|
||||
UpdateNamePosition(point->mx(), point->my());
|
||||
VAbstractTool::data.UpdateGObject(id, point);
|
||||
ChangePosition(this, id, pos);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -133,57 +112,41 @@ void VToolPoint::NameChangePosition(const QPointF &pos)
|
|||
* @param mx label bias x axis.
|
||||
* @param my label bias y axis.
|
||||
*/
|
||||
void VToolPoint::UpdateNamePosition(qreal mx, qreal my)
|
||||
void VToolSinglePoint::UpdateNamePosition(quint32 id)
|
||||
{
|
||||
MoveLabel *moveLabel = new MoveLabel(doc, mx, my, id, this->scene());
|
||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
MoveLabel *moveLabel = new MoveLabel(doc, point->mx(), point->my(), id, this->scene());
|
||||
connect(moveLabel, &MoveLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveLabel);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ShowTool highlight tool.
|
||||
* @param id object id in container.
|
||||
* @param enable enable or disable highlight.
|
||||
*/
|
||||
void VToolPoint::ShowTool(quint32 id, bool enable)
|
||||
{
|
||||
ShowItem(this, id, enable);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief SetFactor set current scale factor of scene.
|
||||
* @param factor scene scale factor.
|
||||
*/
|
||||
void VToolPoint::SetFactor(qreal factor)
|
||||
void VToolSinglePoint::SetFactor(qreal factor)
|
||||
{
|
||||
VDrawTool::SetFactor(factor);
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::Disable(bool disable, const QString &namePP)
|
||||
void VToolSinglePoint::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
enabled = !CorrectDisable(disable, namePP);
|
||||
this->setEnabled(enabled);
|
||||
this->SetEnabled(enabled);
|
||||
namePoint->setEnabled(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::DeleteFromLabel()
|
||||
{
|
||||
DeleteTool(); //Leave this method immediately after call!!!
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::EnableToolMove(bool move)
|
||||
void VToolSinglePoint::EnableToolMove(bool move)
|
||||
{
|
||||
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::PointChoosed()
|
||||
void VToolSinglePoint::PointChoosed()
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Point);
|
||||
}
|
||||
|
@ -192,7 +155,7 @@ void VToolPoint::PointChoosed()
|
|||
/**
|
||||
* @brief FullUpdateFromFile update tool data form file.
|
||||
*/
|
||||
void VToolPoint::FullUpdateFromFile()
|
||||
void VToolSinglePoint::FullUpdateFromFile()
|
||||
{
|
||||
ReadAttributes();
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
|
@ -204,7 +167,7 @@ void VToolPoint::FullUpdateFromFile()
|
|||
* @brief mouseReleaseEvent handle mouse release events.
|
||||
* @param event mouse release event.
|
||||
*/
|
||||
void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
|
@ -218,7 +181,7 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
* @brief hoverEnterEvent handle hover enter events.
|
||||
* @param event hover enter event.
|
||||
*/
|
||||
void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(CorrectColor(baseColor),
|
||||
|
@ -231,7 +194,7 @@ void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||
* @brief hoverLeaveEvent handle hover leave events.
|
||||
* @param event hover leave event.
|
||||
*/
|
||||
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
this->setPen(QPen(CorrectColor(baseColor),
|
||||
|
@ -244,7 +207,7 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
* @brief RefreshPointGeometry refresh point on scene.
|
||||
* @param point point.
|
||||
*/
|
||||
void VToolPoint::RefreshPointGeometry(const VPointF &point)
|
||||
void VToolSinglePoint::RefreshPointGeometry(const VPointF &point)
|
||||
{
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
this->setPen(QPen(CorrectColor(baseColor),
|
||||
|
@ -261,7 +224,7 @@ void VToolPoint::RefreshPointGeometry(const VPointF &point)
|
|||
namePoint->setText(point.name());
|
||||
namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||
namePoint->blockSignals(false);
|
||||
RefreshLine();
|
||||
RefreshLine(id);
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
}
|
||||
|
||||
|
@ -269,16 +232,18 @@ void VToolPoint::RefreshPointGeometry(const VPointF &point)
|
|||
/**
|
||||
* @brief RefreshLine refresh line to label on scene.
|
||||
*/
|
||||
void VToolPoint::RefreshLine()
|
||||
void VToolSinglePoint::RefreshLine(quint32 id)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
|
||||
QRectF nRec = namePoint->sceneBoundingRect();
|
||||
nRec.translate(- scenePos());
|
||||
if (this->rect().intersects(nRec) == false)
|
||||
{
|
||||
QRectF nameRec = namePoint->sceneBoundingRect();
|
||||
const QRectF nameRec = namePoint->sceneBoundingRect();
|
||||
QPointF p1, p2;
|
||||
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
|
||||
QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||
const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||
lineName->setPen(QPen(CorrectColor(Qt::black),
|
||||
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||
|
@ -305,7 +270,7 @@ void VToolPoint::RefreshLine()
|
|||
* @param value value.
|
||||
* @return value.
|
||||
*/
|
||||
QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == QGraphicsItem::ItemSelectedChange)
|
||||
{
|
||||
|
@ -328,7 +293,7 @@ QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const
|
|||
* @brief keyReleaseEvent handle key release events.
|
||||
* @param event key release event.
|
||||
*/
|
||||
void VToolPoint::keyReleaseEvent(QKeyEvent *event)
|
||||
void VToolSinglePoint::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key())
|
||||
{
|
||||
|
@ -342,13 +307,13 @@ void VToolPoint::keyReleaseEvent(QKeyEvent *event)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
void VToolSinglePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VDrawTool::SaveOptions(tag, obj);
|
||||
|
||||
|
@ -359,17 +324,3 @@ void VToolPoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
|
||||
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPoint::setEnabled(bool enabled)
|
||||
{
|
||||
QGraphicsEllipseItem::setEnabled(enabled);
|
||||
if (enabled)
|
||||
{
|
||||
setPen(QPen(QColor(baseColor), qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||
}
|
||||
else
|
||||
{
|
||||
setPen(QPen(Qt::gray, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtoolpoint.h
|
||||
** @file vtoolsinglepoint.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
|
@ -26,37 +26,38 @@
|
|||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VTOOLPOINT_H
|
||||
#define VTOOLPOINT_H
|
||||
#ifndef VTOOLSINGLEPOINT_H
|
||||
#define VTOOLSINGLEPOINT_H
|
||||
|
||||
#include "../../vdrawtool.h"
|
||||
#include "../vabstractpoint.h"
|
||||
#include <QGraphicsEllipseItem>
|
||||
|
||||
class VPointF;
|
||||
class VGraphicsSimpleTextItem;
|
||||
|
||||
/**
|
||||
* @brief The VToolPoint class parent for all tools what create points.
|
||||
* @brief The VToolSinglePoint class parent for all tools what create points.
|
||||
*/
|
||||
class VToolPoint: public VDrawTool, public QGraphicsEllipseItem
|
||||
class VToolSinglePoint: public VAbstractPoint, public QGraphicsEllipseItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolPoint(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
|
||||
virtual ~VToolPoint();
|
||||
VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
|
||||
virtual ~VToolSinglePoint();
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::SinglePoint)};
|
||||
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
virtual QString getTagName() const;
|
||||
static const QString TagName;
|
||||
|
||||
void setEnabled(bool enabled);
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
public slots:
|
||||
void NameChangePosition(const QPointF &pos);
|
||||
virtual void ShowTool(quint32 id, bool enable);
|
||||
virtual void SetFactor(qreal factor);
|
||||
virtual void Disable(bool disable, const QString &namePP);
|
||||
void DeleteFromLabel();
|
||||
virtual void EnableToolMove(bool move);
|
||||
void PointChoosed();
|
||||
virtual void FullUpdateFromFile();
|
||||
|
@ -70,43 +71,18 @@ protected:
|
|||
/** @brief lineName line what we see if label moved too away from point. */
|
||||
QGraphicsLineItem *lineName;
|
||||
|
||||
virtual void UpdateNamePosition(qreal mx, qreal my);
|
||||
virtual void UpdateNamePosition(quint32 id);
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void RefreshPointGeometry(const VPointF &point);
|
||||
void RefreshLine();
|
||||
virtual void RefreshLine(quint32 id);
|
||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||
virtual void keyReleaseEvent(QKeyEvent * event);
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
|
||||
template <typename T>
|
||||
void 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;
|
||||
}
|
||||
}
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolPoint)
|
||||
Q_DISABLE_COPY(VToolSinglePoint)
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINT_H
|
||||
#endif // VTOOLSINGLEPOINT_H
|
|
@ -50,7 +50,7 @@ const QString VToolTriangle::ToolType = QStringLiteral("triangle");
|
|||
VToolTriangle::VToolTriangle(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
|
||||
const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
|
||||
:VToolSinglePoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
|
||||
secondPointId(secondPointId)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
|
@ -249,7 +249,7 @@ void VToolTriangle::SaveDialog(QDomElement &domElement)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTriangle::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrAxisP1, axisP1Id);
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#ifndef VTOOLTRIANGLE_H
|
||||
#define VTOOLTRIANGLE_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "vtoolsinglepoint.h"
|
||||
|
||||
/**
|
||||
* @brief The VToolTriangle class for tool that find point intersection two foots right triangle
|
||||
* (triangle with 90 degree).
|
||||
*/
|
||||
class VToolTriangle : public VToolPoint
|
||||
class VToolTriangle : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
88
src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.cpp
Normal file
88
src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.cpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractpoint.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 19 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "vabstractpoint.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
const QString VAbstractPoint::TagName = QStringLiteral("point");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractPoint::VAbstractPoint(VAbstractPattern *doc, VContainer *data, quint32 id)
|
||||
:VDrawTool(doc, data, id)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractPoint::~VAbstractPoint()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractPoint::getTagName() const
|
||||
{
|
||||
return VAbstractPoint::TagName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ShowTool highlight tool.
|
||||
* @param id object id in container.
|
||||
* @param enable enable or disable highlight.
|
||||
*/
|
||||
void VAbstractPoint::ShowTool(quint32 id, bool enable)
|
||||
{
|
||||
ShowItem(this, id, enable);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPoint::DeleteFromLabel()
|
||||
{
|
||||
DeleteTool(); //Leave this method immediately after call!!!
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractPoint::PointName(quint32 id) const
|
||||
{
|
||||
try
|
||||
{
|
||||
return VAbstractTool::data.GeometricObject<VPointF>(id)->name();
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
qCDebug(vTool, "Error! Couldn't get point name. %s %s", e.ErrorMessage().toUtf8().constData(),
|
||||
e.DetailedInformation().toUtf8().constData());
|
||||
return QString("");// Return empty string for property browser
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPoint::SetPointName(quint32 id, const QString &name)
|
||||
{
|
||||
// Don't know if need check name here.
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
obj->setName(name);
|
||||
SaveOption(obj);
|
||||
}
|
124
src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h
Normal file
124
src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h
Normal file
|
@ -0,0 +1,124 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractpoint.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 19 6, 2015
|
||||
**
|
||||
** @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) 2015 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 VABSTRACTPOINT_H
|
||||
#define VABSTRACTPOINT_H
|
||||
|
||||
#include "../vdrawtool.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
class VAbstractPoint: public VDrawTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VAbstractPoint(VAbstractPattern *doc, VContainer *data, quint32 id);
|
||||
virtual ~VAbstractPoint();
|
||||
|
||||
virtual QString getTagName() const;
|
||||
static const QString TagName;
|
||||
|
||||
template <typename T>
|
||||
void ShowToolVisualization(bool show);
|
||||
|
||||
public slots:
|
||||
virtual void ShowTool(quint32 id, bool enable);
|
||||
void DeleteFromLabel();
|
||||
|
||||
protected:
|
||||
QString PointName(quint32 id) const;
|
||||
void SetPointName(quint32 id, const QString &name);
|
||||
|
||||
template <typename T>
|
||||
void ChangePosition(T *item, quint32 id, const QPointF &pos);
|
||||
|
||||
virtual void UpdateNamePosition(quint32 id)=0;
|
||||
virtual void RefreshLine(quint32 id)=0;
|
||||
|
||||
template <typename T>
|
||||
void SetToolEnabled(T *item, bool enabled);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractPoint)
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VAbstractPoint::ShowToolVisualization(bool show)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
AddVisualization<T>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (T *visual = qobject_cast<T *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete vis;
|
||||
vis = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VAbstractPoint::SetToolEnabled(T *item, bool enabled)
|
||||
{
|
||||
item->setEnabled(enabled);
|
||||
if (enabled)
|
||||
{
|
||||
item->setPen(QPen(QColor(baseColor),
|
||||
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setPen(QPen(Qt::gray, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void VAbstractPoint::ChangePosition(T *item, quint32 id, const QPointF &pos)
|
||||
{
|
||||
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
const QPointF p = pos - item->pos();
|
||||
point->setMx(p.x());
|
||||
point->setMy(p.y());
|
||||
VAbstractTool::data.UpdateGObject(id, point);
|
||||
RefreshLine(id);
|
||||
UpdateNamePosition(id);
|
||||
}
|
||||
|
||||
#endif // VABSTRACTPOINT_H
|
|
@ -104,6 +104,16 @@ protected:
|
|||
void ReadAttributes();
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement)=0;
|
||||
|
||||
template <typename Dialog, typename Tool>
|
||||
void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove = true);
|
||||
|
||||
template <typename Item>
|
||||
void ShowItem(Item *item, quint32 id, bool enable);
|
||||
private:
|
||||
Q_DISABLE_COPY(VDrawTool)
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename Dialog, typename Tool>
|
||||
/**
|
||||
* @brief ContextMenu show context menu for tool.
|
||||
|
@ -111,7 +121,7 @@ protected:
|
|||
* @param event context menu event.
|
||||
* @param showRemove true - tool have option delete.
|
||||
*/
|
||||
void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove = true)
|
||||
void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove)
|
||||
{
|
||||
SCASSERT(tool != nullptr);
|
||||
SCASSERT(event != nullptr);
|
||||
|
@ -156,6 +166,8 @@ protected:
|
|||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename Item>
|
||||
/**
|
||||
* @brief ShowItem highlight tool.
|
||||
|
@ -163,7 +175,7 @@ protected:
|
|||
* @param id object id in container.
|
||||
* @param enable enable or disable highlight.
|
||||
*/
|
||||
void ShowItem(Item *item, quint32 id, bool enable)
|
||||
void VDrawTool::ShowItem(Item *item, quint32 id, bool enable)
|
||||
{
|
||||
SCASSERT(item != nullptr);
|
||||
if (id == item->id)
|
||||
|
@ -171,8 +183,5 @@ protected:
|
|||
ShowVisualization(enable);
|
||||
}
|
||||
}
|
||||
private:
|
||||
Q_DISABLE_COPY(VDrawTool)
|
||||
};
|
||||
|
||||
#endif // VDRAWTOOL_H
|
||||
|
|
|
@ -13,7 +13,7 @@ HEADERS += \
|
|||
$$PWD/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpoint.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h \
|
||||
|
@ -43,7 +43,10 @@ HEADERS += \
|
|||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h \
|
||||
$$PWD/drawTools/toolcurve/vtoolarcwithlength.h
|
||||
$$PWD/drawTools/toolcurve/vtoolarcwithlength.h \
|
||||
$$PWD/drawTools/toolpoint/vabstractpoint.h \
|
||||
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h \
|
||||
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vtooldetail.cpp \
|
||||
|
@ -56,7 +59,7 @@ SOURCES += \
|
|||
$$PWD/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpoint.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp \
|
||||
|
@ -84,4 +87,7 @@ SOURCES += \
|
|||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp \
|
||||
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp \
|
||||
$$PWD/drawTools/toolcurve/vtoolarcwithlength.cpp
|
||||
$$PWD/drawTools/toolcurve/vtoolarcwithlength.cpp \
|
||||
$$PWD/drawTools/toolpoint/vabstractpoint.cpp \
|
||||
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp \
|
||||
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp
|
||||
|
|
|
@ -44,6 +44,17 @@ const QString VAbstractTool::AttrType = QStringLiteral("type");
|
|||
const QString VAbstractTool::AttrMx = QStringLiteral("mx");
|
||||
const QString VAbstractTool::AttrMy = QStringLiteral("my");
|
||||
const QString VAbstractTool::AttrName = QStringLiteral("name");
|
||||
const QString VAbstractTool::AttrMx1 = QStringLiteral("mx1");
|
||||
const QString VAbstractTool::AttrMy1 = QStringLiteral("my1");
|
||||
const QString VAbstractTool::AttrName1 = QStringLiteral("name1");
|
||||
const QString VAbstractTool::AttrMx2 = QStringLiteral("mx2");
|
||||
const QString VAbstractTool::AttrMy2 = QStringLiteral("my2");
|
||||
const QString VAbstractTool::AttrName2 = QStringLiteral("name2");
|
||||
const QString VAbstractTool::AttrBaseLineP1 = QStringLiteral("baseLineP1");
|
||||
const QString VAbstractTool::AttrBaseLineP2 = QStringLiteral("baseLineP2");
|
||||
const QString VAbstractTool::AttrDartP1 = QStringLiteral("dartP1");
|
||||
const QString VAbstractTool::AttrDartP2 = QStringLiteral("dartP2");
|
||||
const QString VAbstractTool::AttrDartP3 = QStringLiteral("dartP3");
|
||||
const QString VAbstractTool::AttrX = QStringLiteral("x");
|
||||
const QString VAbstractTool::AttrY = QStringLiteral("y");
|
||||
const QString VAbstractTool::AttrTypeLine = QStringLiteral("typeLine");
|
||||
|
@ -65,6 +76,7 @@ const QString VAbstractTool::AttrP1Line2 = QStringLiteral("p1Line2");
|
|||
const QString VAbstractTool::AttrP2Line2 = QStringLiteral("p2Line2");
|
||||
const QString VAbstractTool::AttrPShoulder = QStringLiteral("pShoulder");
|
||||
const QString VAbstractTool::AttrPoint1 = QStringLiteral("point1");
|
||||
const QString VAbstractTool::AttrPoint2 = QStringLiteral("point2");
|
||||
const QString VAbstractTool::AttrPoint4 = QStringLiteral("point4");
|
||||
const QString VAbstractTool::AttrKAsm1 = QStringLiteral("kAsm1");
|
||||
const QString VAbstractTool::AttrKAsm2 = QStringLiteral("kAsm2");
|
||||
|
|
|
@ -58,6 +58,17 @@ public:
|
|||
static const QString AttrMx;
|
||||
static const QString AttrMy;
|
||||
static const QString AttrName;
|
||||
static const QString AttrMx1;
|
||||
static const QString AttrMy1;
|
||||
static const QString AttrName1;
|
||||
static const QString AttrMx2;
|
||||
static const QString AttrMy2;
|
||||
static const QString AttrName2;
|
||||
static const QString AttrBaseLineP1;
|
||||
static const QString AttrBaseLineP2;
|
||||
static const QString AttrDartP1;
|
||||
static const QString AttrDartP2;
|
||||
static const QString AttrDartP3;
|
||||
static const QString AttrX;
|
||||
static const QString AttrY;
|
||||
static const QString AttrTypeLine;
|
||||
|
@ -79,6 +90,7 @@ public:
|
|||
static const QString AttrP2Line2;
|
||||
static const QString AttrPShoulder;
|
||||
static const QString AttrPoint1;
|
||||
static const QString AttrPoint2;
|
||||
static const QString AttrPoint4;
|
||||
static const QString AttrKAsm1;
|
||||
static const QString AttrKAsm2;
|
||||
|
|
190
src/libs/vtools/undocommands/movedoublelabel.cpp
Normal file
190
src/libs/vtools/undocommands/movedoublelabel.cpp
Normal file
|
@ -0,0 +1,190 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file movedoublelabel.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 24 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "movedoublelabel.h"
|
||||
#include "../tools/vabstracttool.h"
|
||||
#include "../../vwidgets/vmaingraphicsview.h"
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QDomElement>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, DoublePoint type,
|
||||
const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent)
|
||||
: VUndoCommand(QDomElement(), doc, parent),
|
||||
oldMx(0.0), oldMy(0.0),
|
||||
newMx(x), newMy(y),
|
||||
scene(scene), type(type)
|
||||
{
|
||||
if (type == DoublePoint::FirstPoint)
|
||||
{
|
||||
setText(tr("move the first dart label"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setText(tr("move the second dart label"));
|
||||
}
|
||||
nodeId = id;
|
||||
qCDebug(vUndo, "Point id %u", nodeId);
|
||||
|
||||
if (type == DoublePoint::FirstPoint)
|
||||
{
|
||||
qCDebug(vUndo, "Label new Mx1 %f", newMx);
|
||||
qCDebug(vUndo, "Label new My1 %f", newMy);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Label new Mx2 %f", newMx);
|
||||
qCDebug(vUndo, "Label new My2 %f", newMy);
|
||||
}
|
||||
|
||||
SCASSERT(scene != nullptr);
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
if (type == DoublePoint::FirstPoint)
|
||||
{
|
||||
oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx1, "0.0"));
|
||||
oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMy1, "0.0"));
|
||||
}
|
||||
else
|
||||
{
|
||||
oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx2, "0.0"));
|
||||
oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMy2, "0.0"));
|
||||
}
|
||||
|
||||
if (type == DoublePoint::FirstPoint)
|
||||
{
|
||||
qCDebug(vUndo, "Label old Mx1 %f", oldMx);
|
||||
qCDebug(vUndo, "Label old My1 %f", oldMy);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Label old Mx2 %f", oldMx);
|
||||
qCDebug(vUndo, "Label old My2 %f", oldMy);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find point with id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveDoubleLabel::~MoveDoubleLabel()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MoveDoubleLabel::undo()
|
||||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
Do(oldMx, oldMy);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MoveDoubleLabel::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
Do(newMx, newMy);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool MoveDoubleLabel::mergeWith(const QUndoCommand *command)
|
||||
{
|
||||
const MoveDoubleLabel *moveCommand = static_cast<const MoveDoubleLabel *>(command);
|
||||
SCASSERT(moveCommand != nullptr);
|
||||
|
||||
if (moveCommand->getPointId() != nodeId || moveCommand->getPointType() != type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
newMx = moveCommand->getNewMx();
|
||||
newMy = moveCommand->getNewMy();
|
||||
|
||||
if (type == DoublePoint::FirstPoint)
|
||||
{
|
||||
qCDebug(vUndo, "Label new Mx1 %f", newMx);
|
||||
qCDebug(vUndo, "Label new My1 %f", newMy);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Label new Mx2 %f", newMx);
|
||||
qCDebug(vUndo, "Label new My2 %f", newMy);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int MoveDoubleLabel::id() const
|
||||
{
|
||||
return static_cast<int>(UndoCommand::MoveDoubleLabel);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MoveDoubleLabel::Do(double mx, double my)
|
||||
{
|
||||
if (type == DoublePoint::FirstPoint)
|
||||
{
|
||||
qCDebug(vUndo, "New mx1 %f", mx);
|
||||
qCDebug(vUndo, "New my1 %f", my);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "New mx2 %f", mx);
|
||||
qCDebug(vUndo, "New my2 %f", my);
|
||||
}
|
||||
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
if (type == DoublePoint::FirstPoint)
|
||||
{
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMx1, QString().setNum(qApp->fromPixel(mx)));
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMy1, QString().setNum(qApp->fromPixel(my)));
|
||||
}
|
||||
else
|
||||
{
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMx2, QString().setNum(qApp->fromPixel(mx)));
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMy2, QString().setNum(qApp->fromPixel(my)));
|
||||
}
|
||||
|
||||
emit NeedLiteParsing(Document::LitePPParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vUndo, "Can't find point with id = %u.", nodeId);
|
||||
return;
|
||||
}
|
||||
}
|
88
src/libs/vtools/undocommands/movedoublelabel.h
Normal file
88
src/libs/vtools/undocommands/movedoublelabel.h
Normal file
|
@ -0,0 +1,88 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file movedoublelabel.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 24 6, 2015
|
||||
**
|
||||
** @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) 2015 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 MOVEDOUBLELABEL_H
|
||||
#define MOVEDOUBLELABEL_H
|
||||
|
||||
#include "vundocommand.h"
|
||||
|
||||
class QGraphicsScene;
|
||||
|
||||
enum class DoublePoint: char { FirstPoint, SecondPoint };
|
||||
|
||||
class MoveDoubleLabel : public VUndoCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MoveDoubleLabel(VAbstractPattern *doc, const double &x, const double &y, DoublePoint type,
|
||||
const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent = 0);
|
||||
virtual ~MoveDoubleLabel();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
virtual bool mergeWith(const QUndoCommand *command);
|
||||
virtual int id() const;
|
||||
quint32 getPointId() const;
|
||||
double getNewMx() const;
|
||||
double getNewMy() const;
|
||||
DoublePoint getPointType() const;
|
||||
void Do(double mx, double my);
|
||||
private:
|
||||
Q_DISABLE_COPY(MoveDoubleLabel)
|
||||
double oldMx;
|
||||
double oldMy;
|
||||
double newMx;
|
||||
double newMy;
|
||||
QGraphicsScene *scene;
|
||||
DoublePoint type;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline quint32 MoveDoubleLabel::getPointId() const
|
||||
{
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline DoublePoint MoveDoubleLabel::getPointType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline double MoveDoubleLabel::getNewMx() const
|
||||
{
|
||||
return newMx;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline double MoveDoubleLabel::getNewMy() const
|
||||
{
|
||||
return newMy;
|
||||
}
|
||||
|
||||
#endif // MOVEDOUBLELABEL_H
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "movesplinepath.h"
|
||||
#include <QDomElement>
|
||||
#include "../tools/drawTools/vtoolsplinepath.h"
|
||||
#include "../tools/drawTools/toolcurve/vtoolsplinepath.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MoveSplinePath::MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath,
|
||||
|
|
|
@ -18,8 +18,8 @@ HEADERS += \
|
|||
$$PWD/deletedetail.h \
|
||||
$$PWD/vundocommand.h \
|
||||
$$PWD/renamepp.h \
|
||||
$$PWD/movelabel.h
|
||||
|
||||
$$PWD/movelabel.h \
|
||||
$$PWD/movedoublelabel.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/addtocalc.cpp \
|
||||
|
@ -38,5 +38,5 @@ SOURCES += \
|
|||
$$PWD/deletedetail.cpp \
|
||||
$$PWD/vundocommand.cpp \
|
||||
$$PWD/renamepp.cpp \
|
||||
$$PWD/movelabel.cpp
|
||||
|
||||
$$PWD/movelabel.cpp \
|
||||
$$PWD/movedoublelabel.cpp
|
||||
|
|
|
@ -48,7 +48,8 @@ enum class UndoCommand: char { AddPatternPiece,
|
|||
DeleteTool,
|
||||
DeletePatternPiece,
|
||||
RenamePP,
|
||||
MoveLabel
|
||||
MoveLabel,
|
||||
MoveDoubleLabel
|
||||
};
|
||||
|
||||
class VPattern;
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolbisector.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/vtoolbisector.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolcurveintersectaxis.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/vtoolcurveintersectaxis.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolheight.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/vtoolheight.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoollineintersectaxis.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/vtoollineintersectaxis.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolnormal.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/vtoolnormal.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolpointfromarcandtangent.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/vtoolpointfromarcandtangent.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../../vgeometry/varc.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vgeometry/varc.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolpointfromcircleandtangent.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/vtoolpointfromcircleandtangent.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolpointofcontact.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/vtoolpointofcontact.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolpointofintersectionarcs.h"
|
||||
#include "../../vgeometry/varc.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/vtoolpointofintersectionarcs.h"
|
||||
#include "../vgeometry/varc.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolpointofintersectioncircles.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/vtoolpointofintersectioncircles.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vistoolshoulderpoint.h"
|
||||
#include "../tools/drawTools/vtoolshoulderpoint.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "vistooltriangle.h"
|
||||
#include "../../vgeometry/vpointf.h"
|
||||
#include "../../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/vtooltriangle.h"
|
||||
#include "../tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h"
|
||||
#include <QtCore/qmath.h>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
159
src/libs/vtools/visualization/vistooltruedarts.cpp
Normal file
159
src/libs/vtools/visualization/vistooltruedarts.cpp
Normal file
|
@ -0,0 +1,159 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vistooltruedarts.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 23 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "vistooltruedarts.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolTrueDarts::VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent)
|
||||
:VisLine(data, parent),
|
||||
baseLineP2Id(NULL_ID),
|
||||
dartP1Id(NULL_ID),
|
||||
dartP2Id(NULL_ID),
|
||||
dartP3Id(NULL_ID),
|
||||
point1(nullptr),
|
||||
point2(nullptr),
|
||||
baseLineP1(nullptr),
|
||||
baseLineP2(nullptr),
|
||||
dartP1(nullptr),
|
||||
dartP2(nullptr),
|
||||
dartP3(nullptr),
|
||||
lineblP1P1(nullptr),
|
||||
lineblP2P2(nullptr),
|
||||
p1d2(nullptr),
|
||||
d2p2(nullptr)
|
||||
{
|
||||
baseLineP1 = InitPoint(supportColor, this);
|
||||
baseLineP2 = InitPoint(supportColor, this);
|
||||
dartP1 = InitPoint(supportColor, this);
|
||||
dartP2 = InitPoint(supportColor, this);
|
||||
dartP3 = InitPoint(supportColor, this);
|
||||
|
||||
lineblP1P1 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
lineblP2P2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
p1d2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
d2p2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
||||
|
||||
point1 = InitPoint(mainColor, this);
|
||||
point2 = InitPoint(mainColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolTrueDarts::~VisToolTrueDarts()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTrueDarts::RefreshGeometry()
|
||||
{
|
||||
if (point1Id > NULL_ID)
|
||||
{
|
||||
const QSharedPointer<VPointF> blP1 = Visualization::data->GeometricObject<VPointF>(point1Id);
|
||||
DrawPoint(baseLineP1, blP1->toQPointF(), supportColor);
|
||||
|
||||
if (baseLineP2Id <= NULL_ID)
|
||||
{
|
||||
DrawLine(this, QLineF(blP1->toQPointF(), Visualization::scenePos), supportColor, Qt::DashLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QSharedPointer<VPointF> blP2 = Visualization::data->GeometricObject<VPointF>(baseLineP2Id);
|
||||
DrawPoint(baseLineP2, blP2->toQPointF(), supportColor);
|
||||
DrawLine(this, QLineF(blP1->toQPointF(), blP2->toQPointF()), supportColor, Qt::DashLine);
|
||||
|
||||
if (dartP1Id > NULL_ID)
|
||||
{
|
||||
const QSharedPointer<VPointF> d1 = Visualization::data->GeometricObject<VPointF>(dartP1Id);
|
||||
DrawPoint(dartP1, d1->toQPointF(), supportColor);
|
||||
|
||||
if (dartP2Id <= NULL_ID)
|
||||
{
|
||||
DrawLine(p1d2, QLineF(d1->toQPointF(), Visualization::scenePos), supportColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QSharedPointer<VPointF> d2 = Visualization::data->GeometricObject<VPointF>(dartP2Id);
|
||||
DrawPoint(dartP2, d2->toQPointF(), supportColor);
|
||||
DrawLine(p1d2, QLineF(d1->toQPointF(), d2->toQPointF()), supportColor);
|
||||
|
||||
if (dartP3Id <= NULL_ID)
|
||||
{
|
||||
DrawLine(d2p2, QLineF(d2->toQPointF(), Visualization::scenePos), supportColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QSharedPointer<VPointF> d3 = Visualization::data->GeometricObject<VPointF>(dartP3Id);
|
||||
DrawPoint(dartP3, d3->toQPointF(), supportColor);
|
||||
DrawLine(d2p2, QLineF(d2->toQPointF(), d3->toQPointF()), supportColor);
|
||||
|
||||
QPointF p1;
|
||||
QPointF p2;
|
||||
VToolTrueDarts::FindPoint(blP1->toQPointF(),
|
||||
blP2->toQPointF(),
|
||||
d1->toQPointF(),
|
||||
d2->toQPointF(),
|
||||
d3->toQPointF(), p1, p2);
|
||||
|
||||
DrawLine(lineblP1P1, QLineF(blP1->toQPointF(), p1), supportColor);
|
||||
DrawLine(lineblP2P2, QLineF(blP2->toQPointF(), p2), supportColor);
|
||||
DrawLine(p1d2, QLineF(p1, d2->toQPointF()), supportColor);
|
||||
DrawLine(d2p2, QLineF(d2->toQPointF(), p2), supportColor);
|
||||
|
||||
DrawPoint(point1, p1, mainColor);
|
||||
DrawPoint(point2, p2, mainColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTrueDarts::setPoint2Id(const quint32 &value)
|
||||
{
|
||||
baseLineP2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTrueDarts::setD1PointId(const quint32 &value)
|
||||
{
|
||||
dartP1Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTrueDarts::setD2PointId(const quint32 &value)
|
||||
{
|
||||
dartP2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolTrueDarts::setD3PointId(const quint32 &value)
|
||||
{
|
||||
dartP3Id = value;
|
||||
}
|
71
src/libs/vtools/visualization/vistooltruedarts.h
Normal file
71
src/libs/vtools/visualization/vistooltruedarts.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vistooltruedarts.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 23 6, 2015
|
||||
**
|
||||
** @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) 2015 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 VISTOOLTRUEDARTS_H
|
||||
#define VISTOOLTRUEDARTS_H
|
||||
|
||||
#include "visline.h"
|
||||
|
||||
class VisToolTrueDarts :public VisLine
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent = 0);
|
||||
virtual ~VisToolTrueDarts();
|
||||
|
||||
virtual void RefreshGeometry();
|
||||
|
||||
void setPoint2Id(const quint32 &value);
|
||||
void setD1PointId(const quint32 &value);
|
||||
void setD2PointId(const quint32 &value);
|
||||
void setD3PointId(const quint32 &value);
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolTrueDarts)};
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolTrueDarts)
|
||||
quint32 baseLineP2Id;
|
||||
quint32 dartP1Id;
|
||||
quint32 dartP2Id;
|
||||
quint32 dartP3Id;
|
||||
|
||||
QGraphicsEllipseItem *point1;
|
||||
QGraphicsEllipseItem *point2;
|
||||
QGraphicsEllipseItem *baseLineP1;
|
||||
QGraphicsEllipseItem *baseLineP2;
|
||||
QGraphicsEllipseItem *dartP1;
|
||||
QGraphicsEllipseItem *dartP2;
|
||||
QGraphicsEllipseItem *dartP3;
|
||||
|
||||
QGraphicsLineItem *lineblP1P1;
|
||||
QGraphicsLineItem *lineblP2P2;
|
||||
QGraphicsLineItem *p1d2;
|
||||
QGraphicsLineItem *d2p2;
|
||||
};
|
||||
|
||||
#endif // VISTOOLTRUEDARTS_H
|
|
@ -28,7 +28,8 @@ HEADERS += \
|
|||
$$PWD/vistoolpointofintersectioncircles.h \
|
||||
$$PWD/vistoolpointfromcircleandtangent.h \
|
||||
$$PWD/vistoolpointfromarcandtangent.h \
|
||||
$$PWD/vistoolarcwithlength.h
|
||||
$$PWD/vistoolarcwithlength.h \
|
||||
visualization/vistooltruedarts.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/visline.cpp \
|
||||
|
@ -57,4 +58,5 @@ SOURCES += \
|
|||
$$PWD/vistoolpointofintersectioncircles.cpp \
|
||||
$$PWD/vistoolpointfromcircleandtangent.cpp \
|
||||
$$PWD/vistoolpointfromarcandtangent.cpp \
|
||||
$$PWD/vistoolarcwithlength.cpp
|
||||
$$PWD/vistoolarcwithlength.cpp \
|
||||
visualization/vistooltruedarts.cpp
|
||||
|
|
52
src/libs/vwidgets/vabstractsimple.cpp
Normal file
52
src/libs/vwidgets/vabstractsimple.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractsimple.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 20 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "vabstractsimple.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractSimple::VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor,
|
||||
QObject *parent)
|
||||
:QObject(parent), id (id), factor(factor), currentColor(currentColor), enabled(true), patternUnit(patternUnit)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractSimple::~VAbstractSimple()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QColor VAbstractSimple::CorrectColor(const QColor &color) const
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Qt::gray;
|
||||
}
|
||||
}
|
82
src/libs/vwidgets/vabstractsimple.h
Normal file
82
src/libs/vwidgets/vabstractsimple.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractsimple.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 20 6, 2015
|
||||
**
|
||||
** @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) 2015 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 VABSTRACTSIMPLE_H
|
||||
#define VABSTRACTSIMPLE_H
|
||||
|
||||
#include <QObject>
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
class VAbstractSimple : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VAbstractSimple(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor = nullptr,
|
||||
QObject *parent = 0);
|
||||
virtual ~VAbstractSimple();
|
||||
|
||||
virtual void ChangedActivDraw(const bool &flag)=0;
|
||||
|
||||
protected:
|
||||
/** @brief id spline id. */
|
||||
quint32 id;
|
||||
|
||||
/** @brief factor scale factor. */
|
||||
qreal *factor;
|
||||
|
||||
/** @brief currentColor current color. */
|
||||
QColor currentColor;
|
||||
|
||||
bool enabled;
|
||||
|
||||
Unit patternUnit;
|
||||
|
||||
QColor CorrectColor(const QColor &color) const;
|
||||
|
||||
template <class T>
|
||||
void SetPen(T *item, const QColor &color, qreal width);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractSimple)
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
void VAbstractSimple::SetPen(T *item, const QColor &color, qreal width)
|
||||
{
|
||||
if (factor == nullptr)
|
||||
{
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit)));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit)/ *factor));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // VABSTRACTSIMPLE_H
|
|
@ -39,19 +39,11 @@
|
|||
* @param currentColor current color.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VSimpleCurve::VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint pointPosition, Unit patternUnit,
|
||||
VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, SimpleCurvePoint pointPosition, Unit patternUnit,
|
||||
qreal *factor, QObject *parent)
|
||||
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor),
|
||||
curvePosition(pointPosition), enabled(true), patternUnit(patternUnit)
|
||||
:VAbstractSimple(id, currentColor, patternUnit, factor, parent), QGraphicsPathItem(), curvePosition(pointPosition)
|
||||
{
|
||||
if (factor == nullptr)
|
||||
{
|
||||
setPen(QPen(currentColor, ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||
}
|
||||
else
|
||||
{
|
||||
setPen(QPen(currentColor, ToPixel(WidthHairLine(patternUnit), patternUnit)/ *factor));
|
||||
}
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
@ -61,7 +53,7 @@ void VSimpleCurve::ChangedActivDraw(const bool &flag)
|
|||
{
|
||||
enabled = flag;
|
||||
setEnabled(enabled);
|
||||
setPen(QPen(CorrectColor(currentColor), ToPixel(WidthHairLine(patternUnit), patternUnit)/ *factor));
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -93,20 +85,13 @@ void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief hoverMoveEvent handle hover move events.
|
||||
* @brief hoverEnterEvent handle hover enter events.
|
||||
* @param event hover move event.
|
||||
*/
|
||||
void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||
void VSimpleCurve::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
if (factor == nullptr)
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthMainLine(patternUnit), patternUnit)));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthMainLine(patternUnit), patternUnit)/ *factor));
|
||||
}
|
||||
SetPen(this, currentColor, WidthMainLine(patternUnit));
|
||||
emit HoverPath(id, curvePosition, PathDirection::Show);
|
||||
}
|
||||
|
||||
|
@ -118,16 +103,14 @@ void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|||
void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
if (factor == nullptr)
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthHairLine(patternUnit), patternUnit)/ *factor));
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
emit HoverPath(id, curvePosition, PathDirection::Hide);
|
||||
}
|
||||
|
||||
emit HoverPath(id, curvePosition, PathDirection::Hide);
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -141,24 +124,5 @@ QColor VSimpleCurve::GetCurrentColor() const
|
|||
void VSimpleCurve::SetCurrentColor(const QColor &value)
|
||||
{
|
||||
currentColor = value;
|
||||
setPen(QPen(CorrectColor(currentColor), pen().widthF()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QColor VSimpleCurve::CorrectColor(const QColor &color) const
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Qt::gray;
|
||||
}
|
||||
SetPen(this, CorrectColor(currentColor), pen().widthF());
|
||||
}
|
||||
|
|
|
@ -31,20 +31,20 @@
|
|||
|
||||
#include <QGraphicsPathItem>
|
||||
#include "../vgeometry/vabstractcurve.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "vabstractsimple.h"
|
||||
|
||||
enum class SimpleCurvePoint : char { FirstPoint, ForthPoint };
|
||||
|
||||
/**
|
||||
* @brief The VSimpleSpline class for simple spline. This object used when we cut spline and want show peaces.
|
||||
*/
|
||||
class VSimpleCurve : public QObject, public QGraphicsPathItem
|
||||
class VSimpleCurve : public VAbstractSimple, public QGraphicsPathItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint curvePosition, Unit patternUnit,
|
||||
VSimpleCurve(quint32 id, const QColor ¤tColor, SimpleCurvePoint curvePosition, Unit patternUnit,
|
||||
qreal *factor = nullptr, QObject *parent = 0);
|
||||
void ChangedActivDraw(const bool &flag);
|
||||
virtual void ChangedActivDraw(const bool &flag);
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
|
@ -63,26 +63,15 @@ signals:
|
|||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
private:
|
||||
Q_DISABLE_COPY(VSimpleCurve)
|
||||
/** @brief id spline id. */
|
||||
quint32 id;
|
||||
|
||||
/** @brief factor scale factor. */
|
||||
qreal *factor;
|
||||
|
||||
/** @brief currentColor current color. */
|
||||
QColor currentColor;
|
||||
|
||||
SimpleCurvePoint curvePosition;
|
||||
|
||||
bool enabled;
|
||||
|
||||
Unit patternUnit;
|
||||
|
||||
QColor CorrectColor(const QColor &color) const;
|
||||
};
|
||||
|
||||
#endif // VSIMPLECURVE_H
|
||||
|
|
210
src/libs/vwidgets/vsimplepoint.cpp
Normal file
210
src/libs/vwidgets/vsimplepoint.cpp
Normal file
|
@ -0,0 +1,210 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vsimplepoint.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 20 6, 2015
|
||||
**
|
||||
** @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) 2015 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 "vsimplepoint.h"
|
||||
#include "vgraphicssimpletextitem.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../vgeometry/vgobject.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
||||
:VAbstractSimple(id, currentColor, patternUnit, factor, parent), QGraphicsEllipseItem(),
|
||||
radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)), namePoint(nullptr), lineName(nullptr)
|
||||
{
|
||||
namePoint = new VGraphicsSimpleTextItem(this);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VSimplePoint::DeleteFromLabel);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VSimplePoint::PointChoosed);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VSimplePoint::ChangedPosition);
|
||||
lineName = new QGraphicsLineItem(this);
|
||||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||
this->setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSimplePoint::~VSimplePoint()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::ChangedActivDraw(const bool &flag)
|
||||
{
|
||||
enabled = flag;
|
||||
setEnabled(enabled);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
/* From question on StackOverflow
|
||||
* https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected
|
||||
*
|
||||
* There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way
|
||||
* I can think of is derive your own items from the build-in ones and override the paint() function:*/
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
QGraphicsEllipseItem::paint(painter, &myOption, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::RefreshLine()
|
||||
{
|
||||
QRectF nRec = namePoint->sceneBoundingRect();
|
||||
nRec.translate(- scenePos());
|
||||
if (this->rect().intersects(nRec) == false)
|
||||
{
|
||||
const QRectF nameRec = namePoint->sceneBoundingRect();
|
||||
QPointF p1, p2;
|
||||
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
|
||||
const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||
SetPen(lineName, QColor(Qt::black), WidthHairLine(patternUnit));
|
||||
|
||||
if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm))
|
||||
{
|
||||
lineName->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
lineName->setVisible(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lineName->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::RefreshGeometry(const VPointF &point)
|
||||
{
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||
rec.translate(-rec.center().x(), -rec.center().y());
|
||||
this->setRect(rec);
|
||||
this->setPos(point.toQPointF());
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
namePoint->blockSignals(true);
|
||||
QFont font = namePoint->font();
|
||||
if (factor == nullptr)
|
||||
{
|
||||
font.setPointSize(static_cast<qint32>(namePoint->FontSize()));
|
||||
}
|
||||
else
|
||||
{
|
||||
font.setPointSize(static_cast<qint32>(namePoint->FontSize()/ *factor));
|
||||
}
|
||||
namePoint->setFont(font);
|
||||
namePoint->setText(point.name());
|
||||
namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||
namePoint->blockSignals(false);
|
||||
RefreshLine();
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::SetEnabled(bool enabled)
|
||||
{
|
||||
namePoint->setEnabled(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::EnableToolMove(bool move)
|
||||
{
|
||||
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::DeleteFromLabel()
|
||||
{
|
||||
emit Delete();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::PointChoosed()
|
||||
{
|
||||
emit Choosed(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::ChangedPosition(const QPointF &pos)
|
||||
{
|
||||
emit NameChangedPosition(pos);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::ContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
emit ShowContextMenu(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit Choosed(id);
|
||||
}
|
||||
QGraphicsEllipseItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
SetPen(this, currentColor, WidthMainLine(patternUnit));
|
||||
QGraphicsEllipseItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
QColor VSimplePoint::GetCurrentColor() const
|
||||
{
|
||||
return currentColor;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimplePoint::SetCurrentColor(const QColor &value)
|
||||
{
|
||||
currentColor = value;
|
||||
SetPen(this, CorrectColor(currentColor), pen().widthF());
|
||||
}
|
95
src/libs/vwidgets/vsimplepoint.h
Normal file
95
src/libs/vwidgets/vsimplepoint.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vsimplepoint.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 20 6, 2015
|
||||
**
|
||||
** @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) 2015 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 VSIMPLEPOINT_H
|
||||
#define VSIMPLEPOINT_H
|
||||
|
||||
#include <QGraphicsEllipseItem>
|
||||
|
||||
#include "vabstractsimple.h"
|
||||
|
||||
class VPointF;
|
||||
class VGraphicsSimpleTextItem;
|
||||
|
||||
class VSimplePoint : public VAbstractSimple, public QGraphicsEllipseItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor = nullptr,
|
||||
QObject *parent = nullptr);
|
||||
virtual ~VSimplePoint();
|
||||
|
||||
virtual void ChangedActivDraw(const bool &flag);
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::SimplePoint)};
|
||||
|
||||
void RefreshLine();
|
||||
void RefreshGeometry(const VPointF &point);
|
||||
void SetEnabled(bool enabled);
|
||||
void EnableToolMove(bool move);
|
||||
|
||||
QColor GetCurrentColor() const;
|
||||
void SetCurrentColor(const QColor &value);
|
||||
signals:
|
||||
/**
|
||||
* @brief Choosed send id when clicked.
|
||||
* @param id point id.
|
||||
*/
|
||||
void Choosed(quint32 id);
|
||||
void ShowContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||
void Delete();
|
||||
void NameChangedPosition(const QPointF &pos);
|
||||
|
||||
public slots:
|
||||
void DeleteFromLabel();
|
||||
void PointChoosed();
|
||||
void ChangedPosition(const QPointF &pos);
|
||||
void ContextMenu(QGraphicsSceneContextMenuEvent * event);
|
||||
|
||||
protected:
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VSimplePoint)
|
||||
|
||||
/** @brief radius radius circle. */
|
||||
qreal radius;
|
||||
|
||||
/** @brief namePoint point label. */
|
||||
VGraphicsSimpleTextItem *namePoint;
|
||||
|
||||
/** @brief lineName line what we see if label moved too away from point. */
|
||||
QGraphicsLineItem *lineName;
|
||||
|
||||
};
|
||||
|
||||
#endif // VSIMPLEPOINT_H
|
|
@ -10,7 +10,9 @@ SOURCES += \
|
|||
$$PWD/vsimplecurve.cpp \
|
||||
$$PWD/vwidgetpopup.cpp \
|
||||
$$PWD/vcontrolpointspline.cpp \
|
||||
$$PWD/vgraphicssimpletextitem.cpp
|
||||
$$PWD/vgraphicssimpletextitem.cpp \
|
||||
$$PWD/vsimplepoint.cpp \
|
||||
$$PWD/vabstractsimple.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/stable.h \
|
||||
|
@ -21,4 +23,6 @@ HEADERS += \
|
|||
$$PWD/vsimplecurve.h \
|
||||
$$PWD/vwidgetpopup.h \
|
||||
$$PWD/vcontrolpointspline.h \
|
||||
$$PWD/vgraphicssimpletextitem.h
|
||||
$$PWD/vgraphicssimpletextitem.h \
|
||||
$$PWD/vsimplepoint.h \
|
||||
$$PWD/vabstractsimple.h
|
||||
|
|
Loading…
Reference in New Issue
Block a user