Resolved issue #301. True darts.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-06-24 17:30:07 +03:00
parent 0c947f5f50
commit b866e7b91e
39 changed files with 2189 additions and 90 deletions

View File

@ -32,6 +32,7 @@
#include "../../libs/vwidgets/vmaingraphicsview.h" #include "../../libs/vwidgets/vmaingraphicsview.h"
#include "../../libs/vwidgets/vgraphicssimpletextitem.h" #include "../../libs/vwidgets/vgraphicssimpletextitem.h"
#include "../../libs/vwidgets/vcontrolpointspline.h" #include "../../libs/vwidgets/vcontrolpointspline.h"
#include "../../libs/vwidgets/vsimplepoint.h"
#include "../../libs/vpropertyexplorer/vproperties.h" #include "../../libs/vpropertyexplorer/vproperties.h"
#include "vformulaproperty.h" #include "vformulaproperty.h"
#include "../../libs/vpatterndb/vformula.h" #include "../../libs/vpatterndb/vformula.h"
@ -161,6 +162,13 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolPointFromArcAndTangent::Type: case VToolPointFromArcAndTangent::Type:
ShowOptionsToolPointFromArcAndTangent(item); ShowOptionsToolPointFromArcAndTangent(item);
break; break;
case VSimplePoint::Type:
currentItem = item->parentItem();
ShowItemOptions(currentItem);
break;
case VToolTrueDarts::Type:
ShowOptionsToolTrueDarts(item);
break;
default: default:
break; break;
} }
@ -257,6 +265,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolPointFromArcAndTangent::Type: case VToolPointFromArcAndTangent::Type:
UpdateOptionsToolPointFromArcAndTangent(); UpdateOptionsToolPointFromArcAndTangent();
break; break;
case VToolTrueDarts::Type:
UpdateOptionsToolTrueDarts();
break;
default: default:
break; break;
} }
@ -368,6 +379,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolPointFromArcAndTangent::Type: case VToolPointFromArcAndTangent::Type:
ChangeDataToolPointFromArcAndTangent(prop); ChangeDataToolPointFromArcAndTangent(prop);
break; break;
case VToolTrueDarts::Type:
ChangeDataToolTrueDarts(prop);
break;
default: default:
break; break;
} }
@ -433,6 +447,25 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &p
AddProperty(itemName, VAbstractTool::AttrName); 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> template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &propertyName) 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> 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) void VToolOptionsPropertyBrowser::ChangeDataToolCutArc(VProperty *property)
{ {
@ -1304,6 +1414,17 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item)
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength); 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) 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() void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc()
{ {
@ -1975,6 +2105,8 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
<< VAbstractTool::AttrCrossPoint /* 28 */ << VAbstractTool::AttrCrossPoint /* 28 */
<< VAbstractTool::AttrC1Radius /* 29 */ << VAbstractTool::AttrC1Radius /* 29 */
<< VAbstractTool::AttrC2Radius /* 30 */ << VAbstractTool::AttrC2Radius /* 30 */
<< VAbstractTool::AttrCRadius; /* 31 */ << VAbstractTool::AttrCRadius /* 31 */
<< VAbstractTool::AttrName1 /* 32 */
<< VAbstractTool::AttrName2; /* 33 */
return attr; return attr;
} }

View File

@ -68,12 +68,24 @@ private:
template<class Tool> template<class Tool>
void SetPointName(const QString &name); void SetPointName(const QString &name);
template<class Tool>
void SetPointName1(const QString &name);
template<class Tool>
void SetPointName2(const QString &name);
template<class Tool> template<class Tool>
void SetCrossCirclesPoint(const QVariant value); void SetCrossCirclesPoint(const QVariant value);
template<class Tool> template<class Tool>
void AddPropertyPointName(Tool *i, const QString &propertyName); 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> template<class Tool>
void AddPropertyCrossPoint(Tool *i, const QString &propertyName); void AddPropertyCrossPoint(Tool *i, const QString &propertyName);
@ -94,6 +106,7 @@ private:
void ChangeDataToolArc(VPE::VProperty *property); void ChangeDataToolArc(VPE::VProperty *property);
void ChangeDataToolArcWithLength(VPE::VProperty *property); void ChangeDataToolArcWithLength(VPE::VProperty *property);
void ChangeDataToolBisector(VPE::VProperty *property); void ChangeDataToolBisector(VPE::VProperty *property);
void ChangeDataToolTrueDarts(VPE::VProperty *property);
void ChangeDataToolCutArc(VPE::VProperty *property); void ChangeDataToolCutArc(VPE::VProperty *property);
void ChangeDataToolCutSpline(VPE::VProperty *property); void ChangeDataToolCutSpline(VPE::VProperty *property);
void ChangeDataToolCutSplinePath(VPE::VProperty *property); void ChangeDataToolCutSplinePath(VPE::VProperty *property);
@ -120,6 +133,7 @@ private:
void ShowOptionsToolArc(QGraphicsItem *item); void ShowOptionsToolArc(QGraphicsItem *item);
void ShowOptionsToolArcWithLength(QGraphicsItem *item); void ShowOptionsToolArcWithLength(QGraphicsItem *item);
void ShowOptionsToolBisector(QGraphicsItem *item); void ShowOptionsToolBisector(QGraphicsItem *item);
void ShowOptionsToolTrueDarts(QGraphicsItem *item);
void ShowOptionsToolCutArc(QGraphicsItem *item); void ShowOptionsToolCutArc(QGraphicsItem *item);
void ShowOptionsToolCutSpline(QGraphicsItem *item); void ShowOptionsToolCutSpline(QGraphicsItem *item);
void ShowOptionsToolCutSplinePath(QGraphicsItem *item); void ShowOptionsToolCutSplinePath(QGraphicsItem *item);
@ -146,6 +160,7 @@ private:
void UpdateOptionsToolArc(); void UpdateOptionsToolArc();
void UpdateOptionsToolArcWithLength(); void UpdateOptionsToolArcWithLength();
void UpdateOptionsToolBisector(); void UpdateOptionsToolBisector();
void UpdateOptionsToolTrueDarts();
void UpdateOptionsToolCutArc(); void UpdateOptionsToolCutArc();
void UpdateOptionsToolCutSpline(); void UpdateOptionsToolCutSpline();
void UpdateOptionsToolCutSplinePath(); void UpdateOptionsToolCutSplinePath();

View File

@ -407,6 +407,13 @@ QString DialogHistory::Record(const VToolRecord &tool)
{ {
return QString(tr("%1 - point from arc and tangent")).arg(PointName(tool.getId())); 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 //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. //piece, we need add record about details and nodes, but don't show them.
case Tool::Detail: case Tool::Detail:

View File

@ -309,7 +309,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
ui->view->setCursor(cur); ui->view->setCursor(cur);
ui->view->setShowToolOptions(false); ui->view->setShowToolOptions(false);
helpLabel->setText(toolTip); helpLabel->setText(toolTip);
dialogTool = new Dialog(pattern, 0, this); dialogTool = new Dialog(pattern, NULL_ID, this);
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene); VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
SCASSERT(scene != nullptr); SCASSERT(scene != nullptr);
@ -745,6 +745,16 @@ void MainWindow::ToolArcWithLength(bool checked)
&MainWindow::ApplyDialog<VToolArcWithLength>); &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. * @brief About show widows about.
@ -1048,6 +1058,7 @@ void MainWindow::InitToolButtons()
&MainWindow::ToolPointFromCircleAndTangent); &MainWindow::ToolPointFromCircleAndTangent);
connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent); connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent);
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength); 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: case Tool::PointFromArcAndTangent:
ui->toolButtonPointFromArcAndTangent->setChecked(false); ui->toolButtonPointFromArcAndTangent->setChecked(false);
break; break;
case Tool::TrueDarts:
ui->toolButtonTrueDarts->setChecked(false);
break;
case Tool::NodePoint: case Tool::NodePoint:
case Tool::NodeArc: case Tool::NodeArc:
case Tool::NodeSpline: case Tool::NodeSpline:
@ -2206,6 +2220,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools); ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools);
ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools); ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools);
ui->toolButtonArcWithLength->setEnabled(drawTools); ui->toolButtonArcWithLength->setEnabled(drawTools);
ui->toolButtonTrueDarts->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools);
@ -2584,6 +2599,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonArcWithLength->setChecked(true); ui->toolButtonArcWithLength->setChecked(true);
ToolArcWithLength(true); ToolArcWithLength(true);
break; break;
case Tool::TrueDarts:
ui->toolButtonTrueDarts->setChecked(true);
ToolTrueDarts(true);
break;
case Tool::NodePoint: case Tool::NodePoint:
case Tool::NodeArc: case Tool::NodeArc:
case Tool::NodeSpline: case Tool::NodeSpline:

View File

@ -121,6 +121,7 @@ public slots:
void ToolPointFromCircleAndTangent(bool checked); void ToolPointFromCircleAndTangent(bool checked);
void ToolPointFromArcAndTangent(bool checked); void ToolPointFromArcAndTangent(bool checked);
void ToolArcWithLength(bool checked); void ToolArcWithLength(bool checked);
void ToolTrueDarts(bool checked);
void ClosedDialogDetail(int result); void ClosedDialogDetail(int result);
void ClosedDialogUnionDetails(int result); void ClosedDialogUnionDetails(int result);

View File

@ -48,7 +48,7 @@
<string>Tools</string> <string>Tools</string>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>5</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<property name="geometry"> <property name="geometry">
@ -56,7 +56,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>130</width> <width>130</width>
<height>272</height> <height>318</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -342,6 +342,29 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<widget class="QWidget" name="page_2"> <widget class="QWidget" name="page_2">

View File

@ -29,5 +29,6 @@
<file>cursor/point_from_circle_and_tangent_cursor.png</file> <file>cursor/point_from_circle_and_tangent_cursor.png</file>
<file>cursor/point_from_arc_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/arc_with_length_cursor.png</file>
<file>cursor/true_darts_cursor.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -45,5 +45,6 @@
<file>icon/16x16/toolsectionpoint.png</file> <file>icon/16x16/toolsectionpoint.png</file>
<file>icon/16x16/toolsectiondetail.png</file> <file>icon/16x16/toolsectiondetail.png</file>
<file>icon/16x16/toolsectionlayout.png</file> <file>icon/16x16/toolsectionlayout.png</file>
<file>toolicon/32x32/true_darts.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

View 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

View File

@ -677,7 +677,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
<< VToolPointOfIntersectionArcs::ToolType << VToolPointOfIntersectionArcs::ToolType
<< VToolPointOfIntersectionCircles::ToolType << VToolPointOfIntersectionCircles::ToolType
<< VToolPointFromCircleAndTangent::ToolType << VToolPointFromCircleAndTangent::ToolType
<< VToolPointFromArcAndTangent::ToolType; << VToolPointFromArcAndTangent::ToolType
<< VToolTrueDarts::ToolType;
switch (points.indexOf(type)) switch (points.indexOf(type))
{ {
case 0: //VToolBasePoint::ToolType case 0: //VToolBasePoint::ToolType
@ -1267,6 +1268,40 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
throw excep; throw excep;
} }
break; 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: default:
qDebug() << "Illegal point type in VDomDocument::ParsePointElement()."; qDebug() << "Illegal point type in VDomDocument::ParsePointElement().";
break; break;

View File

@ -133,6 +133,19 @@
<xs:attribute name="cRadius" type="xs:string"></xs:attribute> <xs:attribute name="cRadius" type="xs:string"></xs:attribute>
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="cCenter" 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:complexType>
</xs:element> </xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded"> <xs:element name="line" minOccurs="0" maxOccurs="unbounded">

View File

@ -80,12 +80,13 @@ enum class Tool : unsigned char
PointOfIntersection, PointOfIntersection,
PointFromCircleAndTangent, PointFromCircleAndTangent,
PointFromArcAndTangent, PointFromArcAndTangent,
UnionDetails // 36 TrueDarts,
UnionDetails // 37
}; };
enum class Vis : unsigned char enum class Vis : unsigned char
{ {
ControlPointSpline = 37, // increase this value if need more positions in Tool enum ControlPointSpline = 38, // increase this value if need more positions in Tool enum
GraphicsSimpleTextItem, GraphicsSimpleTextItem,
SimpleSplinePath, SimpleSplinePath,
SimplePoint, SimplePoint,
@ -114,7 +115,8 @@ enum class Vis : unsigned char
ToolSplinePath, ToolSplinePath,
ToolCutSplinePath, ToolCutSplinePath,
ToolLineIntersectAxis, ToolLineIntersectAxis,
ToolCurveIntersectAxis ToolCurveIntersectAxis,
ToolTrueDarts
}; };
enum class VarType : char { Measurement, Increment, LineLength, SplineLength, ArcLength, ArcRadius, LineAngle, ArcAngle, enum class VarType : char { Measurement, Increment, LineLength, SplineLength, ArcLength, ArcRadius, LineAngle, ArcAngle,

View File

@ -32,7 +32,8 @@ HEADERS += \
$$PWD/tools/dialogtriangle.h \ $$PWD/tools/dialogtriangle.h \
$$PWD/tools/dialoguniondetails.h \ $$PWD/tools/dialoguniondetails.h \
$$PWD/support/dialogeditwrongformula.h \ $$PWD/support/dialogeditwrongformula.h \
$$PWD/support/dialogundo.h $$PWD/support/dialogundo.h \
$$PWD/tools/dialogtruedarts.h
SOURCES += \ SOURCES += \
$$PWD/tools/dialogalongline.cpp \ $$PWD/tools/dialogalongline.cpp \
@ -64,7 +65,8 @@ SOURCES += \
$$PWD/tools/dialogtriangle.cpp \ $$PWD/tools/dialogtriangle.cpp \
$$PWD/tools/dialoguniondetails.cpp \ $$PWD/tools/dialoguniondetails.cpp \
$$PWD/support/dialogeditwrongformula.cpp \ $$PWD/support/dialogeditwrongformula.cpp \
$$PWD/support/dialogundo.cpp $$PWD/support/dialogundo.cpp \
$$PWD/tools/dialogtruedarts.cpp
FORMS += \ FORMS += \
$$PWD/tools/dialogalongline.ui \ $$PWD/tools/dialogalongline.ui \
@ -95,4 +97,5 @@ FORMS += \
$$PWD/tools/dialogtriangle.ui \ $$PWD/tools/dialogtriangle.ui \
$$PWD/tools/dialoguniondetails.ui \ $$PWD/tools/dialoguniondetails.ui \
$$PWD/support/dialogeditwrongformula.ui \ $$PWD/support/dialogeditwrongformula.ui \
$$PWD/support/dialogundo.ui $$PWD/support/dialogundo.ui \
$$PWD/tools/dialogtruedarts.ui

View File

@ -56,6 +56,7 @@
#include "dialogs/tools/dialogpointofintersectioncircles.h" #include "dialogs/tools/dialogpointofintersectioncircles.h"
#include "dialogs/tools/dialogpointfromcircleandtangent.h" #include "dialogs/tools/dialogpointfromcircleandtangent.h"
#include "dialogs/tools/dialogpointfromarcandtangent.h" #include "dialogs/tools/dialogpointfromarcandtangent.h"
#include "dialogs/tools/dialogtruedarts.h"
#include "dialogs/support/dialogeditwrongformula.h" #include "dialogs/support/dialogeditwrongformula.h"
#include "dialogs/support/dialogundo.h" #include "dialogs/support/dialogundo.h"

View File

@ -115,27 +115,28 @@ void DialogTool::showEvent(QShowEvent *event)
* @brief FillComboBoxPoints fill comboBox list of points * @brief FillComboBoxPoints fill comboBox list of points
* @param box comboBox * @param box comboBox
*/ */
void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule) const void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
{ {
FillCombo<VPointF>(box, GOType::Point, rule); FillCombo<VPointF>(box, GOType::Point, rule, ch1, ch2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule) const void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
{ {
FillCombo<VArc>(box, GOType::Arc, rule); FillCombo<VArc>(box, GOType::Arc, rule, ch1, ch2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule) const void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
{ {
FillCombo<VSpline>(box, GOType::Spline, rule); FillCombo<VSpline>(box, GOType::Spline, rule, ch1, ch2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule) const void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule, const quint32 &ch1,
const quint32 &ch2) const
{ {
FillCombo<VSplinePath>(box, GOType::SplinePath, rule); FillCombo<VSplinePath>(box, GOType::SplinePath, rule, ch1, ch2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -386,13 +387,14 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillComboBox rule) const void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillComboBox rule,
const quint32 &ch1, const quint32 &ch2) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
box->blockSignals(true); box->blockSignals(true);
FillComboBoxPoints(box, rule); FillComboBoxPoints(box, rule, ch1, ch2);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
box->blockSignals(false); box->blockSignals(false);
@ -402,10 +404,11 @@ void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillCom
/** /**
* @brief setCurrentSplineId set current spline id in combobox * @brief setCurrentSplineId set current spline id in combobox
*/ */
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, FillComboBox rule) const void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, FillComboBox rule,
const quint32 &ch1, const quint32 &ch2) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxSplines(box, rule); FillComboBoxSplines(box, rule, ch1, ch2);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
@ -413,10 +416,11 @@ void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, FillCo
/** /**
* @brief setCurrentArcId * @brief setCurrentArcId
*/ */
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillComboBox rule) const void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillComboBox rule,
const quint32 &ch1, const quint32 &ch2) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxArcs(box, rule); FillComboBoxArcs(box, rule, ch1, ch2);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
@ -427,10 +431,11 @@ void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillCombo
* @param value splinePath id * @param value splinePath id
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/ */
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, FillComboBox rule) const void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, FillComboBox rule,
const quint32 &ch1, const quint32 &ch2) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxSplinesPath(box, rule); FillComboBoxSplinesPath(box, rule, ch1, ch2);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
@ -800,9 +805,12 @@ void DialogTool::SetAssociatedTool(VAbstractTool *tool)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename GObject> template <typename GObject>
void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule) const void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, const quint32 &ch1,
const quint32 &ch2) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
box->blockSignals(true);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects(); const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i; QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list; QMap<QString, quint32> list;
@ -810,7 +818,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule) cons
{ {
if (rule == FillComboBox::NoChildren) if (rule == FillComboBox::NoChildren)
{ {
if (i.key() != toolId + 1 && i.key() != toolId + 2) if (i.key() != toolId && i.key() != ch1 && i.key() != ch2)
{ {
QSharedPointer<VGObject> obj = i.value(); QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation) if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
@ -834,4 +842,6 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule) cons
} }
} }
FillList(box, list); FillList(box, list);
box->blockSignals(false);
} }

View File

@ -184,10 +184,14 @@ protected:
virtual void closeEvent ( QCloseEvent * event ); virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event ); virtual void showEvent( QShowEvent *event );
void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const; void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const; const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
void FillComboBoxSplines(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const; void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
void FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const; 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 FillComboBoxCurves(QComboBox *box)const;
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const; void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
void FillComboBoxLineColors(QComboBox *box)const; void FillComboBoxLineColors(QComboBox *box)const;
@ -202,13 +206,17 @@ protected:
bool checkZero = true); bool checkZero = true);
void setCurrentPointId(QComboBox *box, const quint32 &value, void setCurrentPointId(QComboBox *box, const quint32 &value,
FillComboBox rule = FillComboBox::NoChildren) const; FillComboBox rule = FillComboBox::NoChildren,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
void setCurrentSplineId(QComboBox *box, const quint32 &value, void setCurrentSplineId(QComboBox *box, const quint32 &value,
FillComboBox rule = FillComboBox::NoChildren) const; FillComboBox rule = FillComboBox::NoChildren,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
void setCurrentArcId(QComboBox *box, const quint32 &value, void setCurrentArcId(QComboBox *box, const quint32 &value,
FillComboBox rule = FillComboBox::NoChildren) const; FillComboBox rule = FillComboBox::NoChildren,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
void setCurrentSplinePathId(QComboBox *box, const quint32 &value, void setCurrentSplinePathId(QComboBox *box, const quint32 &value,
FillComboBox rule = FillComboBox::NoChildren) const; FillComboBox rule = FillComboBox::NoChildren,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
void setCurrentCurveId(QComboBox *box, const quint32 &value) const; void setCurrentCurveId(QComboBox *box, const quint32 &value) const;
quint32 getCurrentObjectId(QComboBox *box) const; quint32 getCurrentObjectId(QComboBox *box) const;
@ -311,7 +319,8 @@ private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const; void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
template <typename GObject> template <typename GObject>
void FillCombo(QComboBox *box, GOType gType, FillComboBox rule = FillComboBox::Whole) const; void FillCombo(QComboBox *box, GOType gType, FillComboBox rule = FillComboBox::Whole,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View 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);
}
}

View 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

View 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>

View File

@ -54,5 +54,6 @@
#include "toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" #include "toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h"
#include "toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" #include "toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
#include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" #include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
#include "toolpoint/tooldoublepoint/vtooltruedarts.h"
#endif // DRAWTOOLS_H #endif // DRAWTOOLS_H

View File

@ -29,7 +29,7 @@
#include "vtooldoublepoint.h" #include "vtooldoublepoint.h"
#include "../vwidgets/vsimplepoint.h" #include "../vwidgets/vsimplepoint.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../../../../undocommands/movelabel.h" #include "../../../../undocommands/movedoublelabel.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id, VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id,
@ -43,13 +43,15 @@ VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quin
connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent); connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel); connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label1ChangePosition); connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label1ChangePosition);
firstPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
secondPoint = new VSimplePoint(p2id, QColor(baseColor), *data->GetPatternUnit(), &factor); secondPoint = new VSimplePoint(p2id, QColor(baseColor), *data->GetPatternUnit(), &factor);
secondPoint->setParentItem(this); secondPoint->setParentItem(this);
connect(secondPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point2Choosed); connect(secondPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point2Choosed);
connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent); connect(secondPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel); connect(secondPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label2ChangePosition); connect(secondPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label2ChangePosition);
secondPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -102,13 +104,13 @@ void VToolDoublePoint::SetEnabled(bool enabled)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::Label1ChangePosition(const QPointF &pos) void VToolDoublePoint::Label1ChangePosition(const QPointF &pos)
{ {
ChangePosition(this, p1id, pos); ChangePosition(firstPoint, p1id, pos);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::Label2ChangePosition(const QPointF &pos) void VToolDoublePoint::Label2ChangePosition(const QPointF &pos)
{ {
ChangePosition(this, p2id, pos); ChangePosition(secondPoint, p2id, pos);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -157,28 +159,39 @@ void VToolDoublePoint::FullUpdateFromFile()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::UpdateNamePosition() void VToolDoublePoint::UpdateNamePosition(quint32 id)
{ {
qApp->getUndoStack()->beginMacro("move labels"); if (id == p1id)
{
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data(); MoveDoubleLabel *moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, this->id,
MoveLabel *moveLabel1 = new MoveLabel(doc, p1->mx(), p1->my(), p1id, this->scene()); this->scene());
connect(moveLabel1, &MoveLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); connect(moveLabel, &MoveDoubleLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveLabel1); qApp->getUndoStack()->push(moveLabel);
}
else if (id == p2id)
{
VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data(); MoveDoubleLabel *moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, this->id,
MoveLabel *moveLabel2 = new MoveLabel(doc, p2->mx(), p2->my(), p2id, this->scene()); this->scene());
connect(moveLabel2, &MoveLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); connect(moveLabel, &MoveDoubleLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveLabel2); qApp->getUndoStack()->push(moveLabel);
}
qApp->getUndoStack()->endMacro();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::RefreshLine() void VToolDoublePoint::RefreshLine(quint32 id)
{ {
firstPoint->RefreshLine(); if (id == p1id)
secondPoint->RefreshLine(); {
firstPoint->RefreshLine();
}
else if (id == p2id)
{
secondPoint->RefreshLine();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -243,12 +256,6 @@ void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
doc->SetAttribute(tag, AttrName1, point->name()); doc->SetAttribute(tag, AttrName1, point->name());
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(point->my()));
VPointF *p = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
doc->SetAttribute(tag, AttrName2, p->name());
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(p->mx()));
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(p->my()));
} }
else if (obj->id() == p2id) else if (obj->id() == p2id)
{ {
@ -258,22 +265,18 @@ void VToolDoublePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &o
doc->SetAttribute(tag, AttrName2, point->name()); doc->SetAttribute(tag, AttrName2, point->name());
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(point->my()));
VPointF *p = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
doc->SetAttribute(tag, AttrName1, p->name());
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(p->mx()));
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(p->my()));
} }
else else
{ {
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data(); VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
VPointF *p2 = 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, AttrName1, p1->name());
doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(p1->mx())); doc->SetAttribute(tag, AttrMx1, qApp->fromPixel(p1->mx()));
doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(p1->my())); doc->SetAttribute(tag, AttrMy1, qApp->fromPixel(p1->my()));
doc->SetAttribute(tag, AttrPoint2, p2id);
doc->SetAttribute(tag, AttrName2, p2->name()); doc->SetAttribute(tag, AttrName2, p2->name());
doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(p2->mx())); doc->SetAttribute(tag, AttrMx2, qApp->fromPixel(p2->mx()));
doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(p2->my())); doc->SetAttribute(tag, AttrMy2, qApp->fromPixel(p2->my()));

View File

@ -75,8 +75,8 @@ protected:
quint32 p1id; quint32 p1id;
quint32 p2id; quint32 p2id;
virtual void UpdateNamePosition(); virtual void UpdateNamePosition(quint32 id);
virtual void RefreshLine(); virtual void RefreshLine(quint32 id);
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event); virtual void keyReleaseEvent(QKeyEvent * event);
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );

View File

@ -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();
}
}

View File

@ -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

View File

@ -112,7 +112,7 @@ void VToolSinglePoint::NameChangePosition(const QPointF &pos)
* @param mx label bias x axis. * @param mx label bias x axis.
* @param my label bias y axis. * @param my label bias y axis.
*/ */
void VToolSinglePoint::UpdateNamePosition() void VToolSinglePoint::UpdateNamePosition(quint32 id)
{ {
VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id)); VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject<VPointF>(id));
MoveLabel *moveLabel = new MoveLabel(doc, point->mx(), point->my(), id, this->scene()); MoveLabel *moveLabel = new MoveLabel(doc, point->mx(), point->my(), id, this->scene());
@ -224,7 +224,7 @@ void VToolSinglePoint::RefreshPointGeometry(const VPointF &point)
namePoint->setText(point.name()); namePoint->setText(point.name());
namePoint->setPos(QPointF(point.mx(), point.my())); namePoint->setPos(QPointF(point.mx(), point.my()));
namePoint->blockSignals(false); namePoint->blockSignals(false);
RefreshLine(); RefreshLine(id);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
} }
@ -232,8 +232,10 @@ void VToolSinglePoint::RefreshPointGeometry(const VPointF &point)
/** /**
* @brief RefreshLine refresh line to label on scene. * @brief RefreshLine refresh line to label on scene.
*/ */
void VToolSinglePoint::RefreshLine() void VToolSinglePoint::RefreshLine(quint32 id)
{ {
Q_UNUSED(id)
QRectF nRec = namePoint->sceneBoundingRect(); QRectF nRec = namePoint->sceneBoundingRect();
nRec.translate(- scenePos()); nRec.translate(- scenePos());
if (this->rect().intersects(nRec) == false) if (this->rect().intersects(nRec) == false)

View File

@ -71,12 +71,12 @@ protected:
/** @brief lineName line what we see if label moved too away from point. */ /** @brief lineName line what we see if label moved too away from point. */
QGraphicsLineItem *lineName; QGraphicsLineItem *lineName;
virtual void UpdateNamePosition(); virtual void UpdateNamePosition(quint32 id);
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RefreshPointGeometry(const VPointF &point); virtual void RefreshPointGeometry(const VPointF &point);
virtual void RefreshLine(); virtual void RefreshLine(quint32 id);
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event); virtual void keyReleaseEvent(QKeyEvent * event);
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );

View File

@ -56,8 +56,8 @@ protected:
template <typename T> template <typename T>
void ChangePosition(T *item, quint32 id, const QPointF &pos); void ChangePosition(T *item, quint32 id, const QPointF &pos);
virtual void UpdateNamePosition()=0; virtual void UpdateNamePosition(quint32 id)=0;
virtual void RefreshLine()=0; virtual void RefreshLine(quint32 id)=0;
template <typename T> template <typename T>
void SetToolEnabled(T *item, bool enabled); void SetToolEnabled(T *item, bool enabled);
@ -116,9 +116,9 @@ void VAbstractPoint::ChangePosition(T *item, quint32 id, const QPointF &pos)
const QPointF p = pos - item->pos(); const QPointF p = pos - item->pos();
point->setMx(p.x()); point->setMx(p.x());
point->setMy(p.y()); point->setMy(p.y());
RefreshLine();
VAbstractTool::data.UpdateGObject(id, point); VAbstractTool::data.UpdateGObject(id, point);
UpdateNamePosition(); RefreshLine(id);
UpdateNamePosition(id);
} }
#endif // VABSTRACTPOINT_H #endif // VABSTRACTPOINT_H

View File

@ -45,7 +45,8 @@ HEADERS += \
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.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/vabstractpoint.h \
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h $$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h \
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h
SOURCES += \ SOURCES += \
$$PWD/vtooldetail.cpp \ $$PWD/vtooldetail.cpp \
@ -88,4 +89,5 @@ SOURCES += \
$$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.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/vabstractpoint.cpp \
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp $$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp \
$$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp

View File

@ -50,6 +50,11 @@ const QString VAbstractTool::AttrName1 = QStringLiteral("name1");
const QString VAbstractTool::AttrMx2 = QStringLiteral("mx2"); const QString VAbstractTool::AttrMx2 = QStringLiteral("mx2");
const QString VAbstractTool::AttrMy2 = QStringLiteral("my2"); const QString VAbstractTool::AttrMy2 = QStringLiteral("my2");
const QString VAbstractTool::AttrName2 = QStringLiteral("name2"); 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::AttrX = QStringLiteral("x");
const QString VAbstractTool::AttrY = QStringLiteral("y"); const QString VAbstractTool::AttrY = QStringLiteral("y");
const QString VAbstractTool::AttrTypeLine = QStringLiteral("typeLine"); const QString VAbstractTool::AttrTypeLine = QStringLiteral("typeLine");
@ -71,6 +76,7 @@ const QString VAbstractTool::AttrP1Line2 = QStringLiteral("p1Line2");
const QString VAbstractTool::AttrP2Line2 = QStringLiteral("p2Line2"); const QString VAbstractTool::AttrP2Line2 = QStringLiteral("p2Line2");
const QString VAbstractTool::AttrPShoulder = QStringLiteral("pShoulder"); const QString VAbstractTool::AttrPShoulder = QStringLiteral("pShoulder");
const QString VAbstractTool::AttrPoint1 = QStringLiteral("point1"); const QString VAbstractTool::AttrPoint1 = QStringLiteral("point1");
const QString VAbstractTool::AttrPoint2 = QStringLiteral("point2");
const QString VAbstractTool::AttrPoint4 = QStringLiteral("point4"); const QString VAbstractTool::AttrPoint4 = QStringLiteral("point4");
const QString VAbstractTool::AttrKAsm1 = QStringLiteral("kAsm1"); const QString VAbstractTool::AttrKAsm1 = QStringLiteral("kAsm1");
const QString VAbstractTool::AttrKAsm2 = QStringLiteral("kAsm2"); const QString VAbstractTool::AttrKAsm2 = QStringLiteral("kAsm2");

View File

@ -64,6 +64,11 @@ public:
static const QString AttrMx2; static const QString AttrMx2;
static const QString AttrMy2; static const QString AttrMy2;
static const QString AttrName2; 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 AttrX;
static const QString AttrY; static const QString AttrY;
static const QString AttrTypeLine; static const QString AttrTypeLine;
@ -85,6 +90,7 @@ public:
static const QString AttrP2Line2; static const QString AttrP2Line2;
static const QString AttrPShoulder; static const QString AttrPShoulder;
static const QString AttrPoint1; static const QString AttrPoint1;
static const QString AttrPoint2;
static const QString AttrPoint4; static const QString AttrPoint4;
static const QString AttrKAsm1; static const QString AttrKAsm1;
static const QString AttrKAsm2; static const QString AttrKAsm2;

View 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;
}
}

View 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

View File

@ -18,7 +18,8 @@ HEADERS += \
$$PWD/deletedetail.h \ $$PWD/deletedetail.h \
$$PWD/vundocommand.h \ $$PWD/vundocommand.h \
$$PWD/renamepp.h \ $$PWD/renamepp.h \
$$PWD/movelabel.h $$PWD/movelabel.h \
$$PWD/movedoublelabel.h
SOURCES += \ SOURCES += \
$$PWD/addtocalc.cpp \ $$PWD/addtocalc.cpp \
@ -37,4 +38,5 @@ SOURCES += \
$$PWD/deletedetail.cpp \ $$PWD/deletedetail.cpp \
$$PWD/vundocommand.cpp \ $$PWD/vundocommand.cpp \
$$PWD/renamepp.cpp \ $$PWD/renamepp.cpp \
$$PWD/movelabel.cpp $$PWD/movelabel.cpp \
$$PWD/movedoublelabel.cpp

View File

@ -48,7 +48,8 @@ enum class UndoCommand: char { AddPatternPiece,
DeleteTool, DeleteTool,
DeletePatternPiece, DeletePatternPiece,
RenamePP, RenamePP,
MoveLabel MoveLabel,
MoveDoubleLabel
}; };
class VPattern; class VPattern;

View 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;
}

View 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

View File

@ -28,7 +28,8 @@ HEADERS += \
$$PWD/vistoolpointofintersectioncircles.h \ $$PWD/vistoolpointofintersectioncircles.h \
$$PWD/vistoolpointfromcircleandtangent.h \ $$PWD/vistoolpointfromcircleandtangent.h \
$$PWD/vistoolpointfromarcandtangent.h \ $$PWD/vistoolpointfromarcandtangent.h \
$$PWD/vistoolarcwithlength.h $$PWD/vistoolarcwithlength.h \
visualization/vistooltruedarts.h
SOURCES += \ SOURCES += \
$$PWD/visline.cpp \ $$PWD/visline.cpp \
@ -57,4 +58,5 @@ SOURCES += \
$$PWD/vistoolpointofintersectioncircles.cpp \ $$PWD/vistoolpointofintersectioncircles.cpp \
$$PWD/vistoolpointfromcircleandtangent.cpp \ $$PWD/vistoolpointfromcircleandtangent.cpp \
$$PWD/vistoolpointfromarcandtangent.cpp \ $$PWD/vistoolpointfromarcandtangent.cpp \
$$PWD/vistoolarcwithlength.cpp $$PWD/vistoolarcwithlength.cpp \
visualization/vistooltruedarts.cpp