From ea0000fea6a1a2cf61dc350771ce256068d33b7e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 24 Jan 2016 18:15:08 +0200 Subject: [PATCH] First successful build. Tool working was not tested! --HG-- branch : feature --- .../core/vtooloptionspropertybrowser.cpp | 169 ++++++-- .../core/vtooloptionspropertybrowser.h | 18 + src/app/valentina/mainwindow.cpp | 19 + src/app/valentina/mainwindow.h | 1 + src/app/valentina/mainwindow.ui | 40 +- .../valentina/share/resources/toolicon.qrc | 56 +-- src/app/valentina/xml/vpattern.cpp | 37 +- src/app/valentina/xml/vpattern.h | 4 +- src/libs/ifc/ifcdef.cpp | 4 + src/libs/ifc/ifcdef.h | 4 + src/libs/ifc/schema/pattern/v0.2.5.xsd | 12 +- src/libs/ifc/xml/vabstractpattern.h | 6 +- src/libs/vgeometry/vabstractcurve.cpp | 29 +- src/libs/vgeometry/vabstractcurve.h | 2 + src/libs/vmisc/def.h | 2 + src/libs/vtools/dialogs/dialogs.pri | 9 +- src/libs/vtools/dialogs/tooldialogs.h | 1 + .../vtools/dialogs/tools/dialogalongline.cpp | 10 +- src/libs/vtools/dialogs/tools/dialogarc.cpp | 4 +- .../dialogs/tools/dialogarcwithlength.cpp | 4 +- .../vtools/dialogs/tools/dialogbisector.cpp | 16 +- .../tools/dialogcurveintersectaxis.cpp | 4 +- .../vtools/dialogs/tools/dialogcutarc.cpp | 4 +- .../vtools/dialogs/tools/dialogcutspline.cpp | 4 +- .../dialogs/tools/dialogcutsplinepath.cpp | 4 +- .../vtools/dialogs/tools/dialogendline.cpp | 4 +- .../vtools/dialogs/tools/dialogheight.cpp | 4 +- src/libs/vtools/dialogs/tools/dialogline.cpp | 4 +- .../dialogs/tools/dialoglineintersect.cpp | 4 +- .../dialogs/tools/dialoglineintersectaxis.cpp | 4 +- .../vtools/dialogs/tools/dialognormal.cpp | 10 +- .../tools/dialogpointfromarcandtangent.cpp | 6 +- .../tools/dialogpointfromcircleandtangent.cpp | 12 +- .../dialogs/tools/dialogpointofcontact.cpp | 4 +- .../tools/dialogpointofintersection.cpp | 6 +- .../tools/dialogpointofintersectionarcs.cpp | 2 +- .../dialogpointofintersectioncircles.cpp | 12 +- .../tools/dialogpointofintersectioncurves.cpp | 204 +++++++++ .../tools/dialogpointofintersectioncurves.h | 77 ++++ .../tools/dialogpointofintersectioncurves.ui | 162 ++++++++ .../dialogs/tools/dialogshoulderpoint.cpp | 4 +- .../vtools/dialogs/tools/dialogspline.cpp | 10 +- src/libs/vtools/dialogs/tools/dialogtool.cpp | 47 +-- src/libs/vtools/dialogs/tools/dialogtool.h | 38 +- .../vtools/dialogs/tools/dialogtriangle.cpp | 10 +- .../vtools/dialogs/tools/dialogtruedarts.cpp | 10 +- src/libs/vtools/tools/drawTools/drawtools.h | 1 + .../tools/drawTools/toolcurve/vtoolarc.cpp | 2 +- .../toolcurve/vtoolarcwithlength.cpp | 2 +- .../tools/drawTools/toolcurve/vtoolspline.cpp | 4 +- .../tooldoublepoint/vtooltruedarts.cpp | 4 +- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 2 +- .../toolcut/vtoolcutspline.cpp | 2 +- .../toolcut/vtoolcutsplinepath.cpp | 2 +- .../toollinepoint/vtoolalongline.cpp | 4 +- .../toollinepoint/vtoolbisector.cpp | 6 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 2 +- .../toollinepoint/vtoolendline.cpp | 2 +- .../toollinepoint/vtoolheight.cpp | 2 +- .../toollinepoint/vtoollineintersectaxis.cpp | 2 +- .../toollinepoint/vtoolnormal.cpp | 4 +- .../toollinepoint/vtoolshoulderpoint.cpp | 2 +- .../toolsinglepoint/vtoollineintersect.cpp | 2 +- .../vtoolpointfromarcandtangent.cpp | 2 +- .../vtoolpointfromcircleandtangent.cpp | 4 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 2 +- .../vtoolpointofintersection.cpp | 2 +- .../vtoolpointofintersectioncircles.cpp | 4 +- .../vtoolpointofintersectioncurves.cpp | 388 ++++++++++++++++++ .../vtoolpointofintersectioncurves.h | 87 ++++ .../toolsinglepoint/vtooltriangle.cpp | 4 +- src/libs/vtools/tools/drawTools/vtoolline.cpp | 2 +- src/libs/vtools/tools/tools.pri | 6 +- .../vtools/visualization/vistoolalongline.cpp | 14 +- .../vtools/visualization/vistoolalongline.h | 4 +- src/libs/vtools/visualization/vistoolarc.cpp | 4 +- .../visualization/vistoolarcwithlength.cpp | 4 +- .../vtools/visualization/vistoolbisector.cpp | 22 +- .../vtools/visualization/vistoolbisector.h | 8 +- .../vistoolcurveintersectaxis.cpp | 4 +- .../vtools/visualization/vistoolcutarc.cpp | 4 +- .../vtools/visualization/vistoolcutspline.cpp | 4 +- .../visualization/vistoolcutsplinepath.cpp | 4 +- .../vtools/visualization/vistoolendline.cpp | 2 +- .../vtools/visualization/vistoolheight.cpp | 4 +- src/libs/vtools/visualization/vistoolline.cpp | 2 +- .../visualization/vistoollineintersect.cpp | 4 +- .../vistoollineintersectaxis.cpp | 4 +- .../vtools/visualization/vistoolnormal.cpp | 14 +- src/libs/vtools/visualization/vistoolnormal.h | 4 +- .../vistoolpointfromarcandtangent.cpp | 4 +- .../vistoolpointfromcircleandtangent.cpp | 14 +- .../vistoolpointfromcircleandtangent.h | 4 +- .../visualization/vistoolpointofcontact.cpp | 4 +- .../vistoolpointofintersection.cpp | 4 +- .../vistoolpointofintersectioncircles.cpp | 16 +- .../vistoolpointofintersectioncircles.h | 4 +- .../vistoolpointofintersectioncurves.cpp | 94 +++++ .../vistoolpointofintersectioncurves.h | 62 +++ .../visualization/vistoolshoulderpoint.cpp | 4 +- .../vtools/visualization/vistoolspline.cpp | 14 +- src/libs/vtools/visualization/vistoolspline.h | 4 +- .../vtools/visualization/vistooltriangle.cpp | 14 +- .../vtools/visualization/vistooltriangle.h | 4 +- .../vtools/visualization/vistooltruedarts.cpp | 6 +- .../vtools/visualization/vistooltruedarts.h | 2 +- .../vtools/visualization/visualization.cpp | 8 +- src/libs/vtools/visualization/visualization.h | 4 +- .../vtools/visualization/visualization.pri | 6 +- 109 files changed, 1688 insertions(+), 333 deletions(-) create mode 100644 src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp create mode 100644 src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h create mode 100644 src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui create mode 100644 src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp create mode 100644 src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h create mode 100644 src/libs/vtools/visualization/vistoolpointofintersectioncurves.cpp create mode 100644 src/libs/vtools/visualization/vistoolpointofintersectioncurves.h diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 04b8d253e..c865db382 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -126,6 +126,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) case VToolPointOfIntersectionCircles::Type: ShowOptionsToolPointOfIntersectionCircles(item); break; + case VToolPointOfIntersectionCurves::Type: + ShowOptionsToolPointOfIntersectionCurves(item); + break; case VToolShoulderPoint::Type: ShowOptionsToolShoulderPoint(item); break; @@ -231,6 +234,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions() case VToolPointOfIntersectionCircles::Type: UpdateOptionsToolPointOfIntersectionCircles(); break; + case VToolPointOfIntersectionCurves::Type: + UpdateOptionsToolPointOfIntersectionCurves(); + break; case VToolShoulderPoint::Type: UpdateOptionsToolShoulderPoint(); break; @@ -351,6 +357,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) case VToolPointOfIntersectionCircles::Type: ChangeDataToolPointOfIntersectionCircles(prop); break; + case VToolPointOfIntersectionCurves::Type: + ChangeDataToolPointOfIntersectionCurves(prop); + break; case VToolShoulderPoint::Type: ChangeDataToolShoulderPoint(prop); break; @@ -471,10 +480,30 @@ void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString & { VEnumProperty* itemProperty = new VEnumProperty(propertyName); itemProperty->setLiterals(QStringList()<< tr("First point") << tr("Second point")); - itemProperty->setValue(static_cast(i->GetCrossCirclesPoint())-1); + itemProperty->setValue(static_cast(i->GetCrossCirclesPoint())); AddProperty(itemProperty, AttrCrossPoint); } +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyVCrossPoint(Tool *i, const QString &propertyName) +{ + auto itemProperty = new VEnumProperty(propertyName); + itemProperty->setLiterals(QStringList()<< tr("Highest point") << tr("Lowest point")); + itemProperty->setValue(static_cast(i->GetVCrossPoint())); + AddProperty(itemProperty, AttrVCrossPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyHCrossPoint(Tool *i, const QString &propertyName) +{ + auto itemProperty = new VEnumProperty(propertyName); + itemProperty->setLiterals(QStringList()<< tr("Leftmost point") << tr("Rightmost point")); + itemProperty->setValue(static_cast(i->GetHCrossPoint())); + AddProperty(itemProperty, AttrHCrossPoint); +} + //--------------------------------------------------------------------------------------------------------------------- template void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName, @@ -588,32 +617,65 @@ void VToolOptionsPropertyBrowser::SetPointName2(const QString &name) } } +//--------------------------------------------------------------------------------------------------------------------- +template +Type VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) +{ + bool ok = false; + const int val = value.toInt(&ok); + + auto cross = static_cast(1); + if (ok) + { + switch(val) + { + case 1: + case 2: + cross = static_cast(val); + break; + default: + break; + } + } + + return cross; +} + //--------------------------------------------------------------------------------------------------------------------- template void VToolOptionsPropertyBrowser::SetCrossCirclesPoint(const QVariant &value) { if (Tool *i = qgraphicsitem_cast(currentItem)) { - bool ok = false; - const int val = value.toInt(&ok); + i->SetCrossCirclesPoint(GetCrossPoint(value)); + } + else + { + qWarning()<<"Can't cast item"; + } +} - CrossCirclesPoint cross = CrossCirclesPoint::FirstPoint; - if (ok) - { - switch(val) - { - case 0: - cross = CrossCirclesPoint::FirstPoint; - break; - case 1: - cross = CrossCirclesPoint::SecondPoint; - break; - default: - cross = CrossCirclesPoint::FirstPoint; - break; - } - } - i->SetCrossCirclesPoint(cross); +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::SetVCrossCurvesPoint(const QVariant &value) +{ + if (auto i = qgraphicsitem_cast(currentItem)) + { + i->SetVCrossPoint(GetCrossPoint(value)); + } + else + { + qWarning()<<"Can't cast item"; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(const QVariant &value) +{ + if (auto i = qgraphicsitem_cast(currentItem)) + { + i->SetHCrossPoint(GetCrossPoint(value)); } else { @@ -1111,6 +1173,39 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionCircles(VProp } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionCurves(VProperty *property) +{ + SCASSERT(property != nullptr) + + const QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + auto i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // AttrName + SetPointName(value.toString()); + break; + case 34: // AttrVCrossPoint + { + const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole); + SetVCrossCurvesPoint(value); + break; + } + case 35: // AttrHCrossPoint + { + const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole); + SetHCrossCurvesPoint(value); + break; + } + default: + qWarning()<<"Unknown property type. id = "<(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool to make point from intersection two curves")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyVCrossPoint(i, tr("Vertical correction")); + AddPropertyHCrossPoint(i, tr("Horizontal correction")); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolPointFromCircleAndTangent(QGraphicsItem *item) { @@ -1930,7 +2037,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs() VToolPointOfIntersectionArcs *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); } //--------------------------------------------------------------------------------------------------------------------- @@ -1939,7 +2046,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCircles() VToolPointOfIntersectionCircles *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); QVariant c1Radius; c1Radius.setValue(i->GetFirstCircleRadius()); @@ -1950,13 +2057,23 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCircles() idToProperty[AttrC2Radius]->setValue(c2Radius); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCurves() +{ + auto i = qgraphicsitem_cast(currentItem); + + idToProperty[AttrName]->setValue(i->name()); + idToProperty[AttrVCrossPoint]->setValue(static_cast(i->GetVCrossPoint())); + idToProperty[AttrHCrossPoint]->setValue(static_cast(i->GetHCrossPoint())); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromCircleAndTangent() { VToolPointFromCircleAndTangent *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); QVariant cRadius; cRadius.setValue(i->GetCircleRadius()); @@ -1969,7 +2086,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromArcAndTangent() VToolPointFromArcAndTangent *i = qgraphicsitem_cast(currentItem); idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())); } //--------------------------------------------------------------------------------------------------------------------- @@ -2104,6 +2221,8 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const << AttrC2Radius /* 30 */ << AttrCRadius /* 31 */ << AttrName1 /* 32 */ - << AttrName2; /* 33 */ + << AttrName2 /* 33 */ + << AttrVCrossPoint /* 34 */ + << AttrHCrossPoint; /* 35 */ return attr; } diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.h b/src/app/valentina/core/vtooloptionspropertybrowser.h index 211522e3d..6dabcd7e8 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.h +++ b/src/app/valentina/core/vtooloptionspropertybrowser.h @@ -74,9 +74,18 @@ private: template void SetPointName2(const QString &name); + template + Type GetCrossPoint(const QVariant &value); + template void SetCrossCirclesPoint(const QVariant &value); + template + void SetVCrossCurvesPoint(const QVariant &value); + + template + void SetHCrossCurvesPoint(const QVariant &value); + template void AddPropertyPointName(Tool *i, const QString &propertyName); @@ -89,6 +98,12 @@ private: template void AddPropertyCrossPoint(Tool *i, const QString &propertyName); + template + void AddPropertyVCrossPoint(Tool *i, const QString &propertyName); + + template + void AddPropertyHCrossPoint(Tool *i, const QString &propertyName); + template void AddPropertyLineType(Tool *i, const QString &propertyName, const QMap &styles); @@ -118,6 +133,7 @@ private: void ChangeDataToolPointOfIntersection(VPE::VProperty *property); void ChangeDataToolPointOfIntersectionArcs(VPE::VProperty *property); void ChangeDataToolPointOfIntersectionCircles(VPE::VProperty *property); + void ChangeDataToolPointOfIntersectionCurves(VPE::VProperty *property); void ChangeDataToolPointFromCircleAndTangent(VPE::VProperty *property); void ChangeDataToolPointFromArcAndTangent(VPE::VProperty *property); void ChangeDataToolShoulderPoint(VPE::VProperty *property); @@ -145,6 +161,7 @@ private: void ShowOptionsToolPointOfIntersection(QGraphicsItem *item); void ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item); void ShowOptionsToolPointOfIntersectionCircles(QGraphicsItem *item); + void ShowOptionsToolPointOfIntersectionCurves(QGraphicsItem *item); void ShowOptionsToolPointFromCircleAndTangent(QGraphicsItem *item); void ShowOptionsToolPointFromArcAndTangent(QGraphicsItem *item); void ShowOptionsToolShoulderPoint(QGraphicsItem *item); @@ -172,6 +189,7 @@ private: void UpdateOptionsToolPointOfIntersection(); void UpdateOptionsToolPointOfIntersectionArcs(); void UpdateOptionsToolPointOfIntersectionCircles(); + void UpdateOptionsToolPointOfIntersectionCurves(); void UpdateOptionsToolPointFromCircleAndTangent(); void UpdateOptionsToolPointFromArcAndTangent(); void UpdateOptionsToolShoulderPoint(); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 1e4a56c72..1498f2826 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -995,6 +995,16 @@ void MainWindow::ToolPointOfIntersectionCircles(bool checked) &MainWindow::ApplyDialog); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolPointOfIntersectionCurves(bool checked) +{ + SetToolButtonWithApply(checked, Tool::PointOfIntersectionCurves, + "://cursor/intersection_curves_cursor.png", + tr("Select first curve"), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointFromCircleAndTangent(bool checked) { @@ -1585,6 +1595,7 @@ void MainWindow::InitToolButtons() &MainWindow::ToolPointOfIntersectionArcs); connect(ui->toolButtonPointOfIntersectionCircles, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersectionCircles); + connect(ui->toolButtonIntersectionCurves, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersectionCurves); connect(ui->toolButtonPointFromCircleAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromCircleAndTangent); connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent); @@ -1714,6 +1725,9 @@ void MainWindow::CancelTool() case Tool::PointOfIntersectionCircles: ui->toolButtonPointOfIntersectionCircles->setChecked(false); break; + case Tool::PointOfIntersectionCurves: + ui->toolButtonIntersectionCurves->setChecked(false); + break; case Tool::PointFromCircleAndTangent: ui->toolButtonPointFromCircleAndTangent->setChecked(false); break; @@ -2892,6 +2906,7 @@ void MainWindow::SetEnableTool(bool enable) ui->toolButtonCurveIntersectAxis->setEnabled(drawTools); ui->toolButtonArcIntersectAxis->setEnabled(drawTools); ui->toolButtonPointOfIntersectionArcs->setEnabled(drawTools); + ui->toolButtonIntersectionCurves->setEnabled(drawTools); ui->toolButtonPointOfIntersectionCircles->setEnabled(drawTools); ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools); ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools); @@ -3272,6 +3287,10 @@ void MainWindow::LastUsedTool() ui->toolButtonPointOfIntersectionCircles->setChecked(true); ToolPointOfIntersectionCircles(true); break; + case Tool::PointOfIntersectionCurves: + ui->toolButtonIntersectionCurves->setChecked(true); + ToolPointOfIntersectionCurves(true); + break; case Tool::PointFromCircleAndTangent: ui->toolButtonPointFromCircleAndTangent->setChecked(true); ToolPointFromCircleAndTangent(true); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 34eea7aa2..a77d9ce62 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -125,6 +125,7 @@ public slots: void ToolArcIntersectAxis(bool checked); void ToolPointOfIntersectionArcs(bool checked); void ToolPointOfIntersectionCircles(bool checked); + void ToolPointOfIntersectionCurves(bool checked); void ToolPointFromCircleAndTangent(bool checked); void ToolPointFromArcAndTangent(bool checked); void ToolArcWithLength(bool checked); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 60cc169c3..6477697ae 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -48,7 +48,7 @@ Tools - 0 + 2 @@ -375,7 +375,7 @@ 0 0 - 100 + 130 58 @@ -461,7 +461,7 @@ 0 0 - 100 + 130 156 @@ -618,6 +618,32 @@ + + + + false + + + Point intersection curves + + + ... + + + + :/toolicon/32x32/intersection_curves.png:/toolicon/32x32/intersection_curves.png + + + + 32 + 32 + + + + true + + + @@ -625,7 +651,7 @@ 0 0 - 100 + 130 196 @@ -867,7 +893,7 @@ 0 0 - 100 + 130 58 @@ -953,8 +979,8 @@ 0 0 - 98 - 58 + 130 + 386 diff --git a/src/app/valentina/share/resources/toolicon.qrc b/src/app/valentina/share/resources/toolicon.qrc index 7b378f67d..ad4724430 100644 --- a/src/app/valentina/share/resources/toolicon.qrc +++ b/src/app/valentina/share/resources/toolicon.qrc @@ -1,60 +1,62 @@ toolicon/32x32/along_line.png - toolicon/32x32/along_line@2x.png + toolicon/32x32/along_line@2x.png toolicon/32x32/arc.png - toolicon/32x32/arc@2x.png + toolicon/32x32/arc@2x.png toolicon/32x32/arc_cut.png - toolicon/32x32/arc_cut@2x.png + toolicon/32x32/arc_cut@2x.png toolicon/32x32/arc_intersect_axis.png - toolicon/32x32/arc_intersect_axis@2x.png + toolicon/32x32/arc_intersect_axis@2x.png toolicon/32x32/bisector.png - toolicon/32x32/bisector@2x.png + toolicon/32x32/bisector@2x.png toolicon/32x32/curve_intersect_axis.png - toolicon/32x32/curve_intersect_axis@2x.png + toolicon/32x32/curve_intersect_axis@2x.png toolicon/32x32/height.png - toolicon/32x32/height@2x.png + toolicon/32x32/height@2x.png toolicon/32x32/intersect.png - toolicon/32x32/intersect@2x.png + toolicon/32x32/intersect@2x.png toolicon/32x32/line.png - toolicon/32x32/line@2x.png + toolicon/32x32/line@2x.png toolicon/32x32/line_intersect_axis.png - toolicon/32x32/line_intersect_axis@2x.png + toolicon/32x32/line_intersect_axis@2x.png toolicon/32x32/normal.png - toolicon/32x32/normal@2x.png + toolicon/32x32/normal@2x.png toolicon/32x32/point_from_arc_and_tangent.png - toolicon/32x32/point_from_arc_and_tangent@2x.png + toolicon/32x32/point_from_arc_and_tangent@2x.png toolicon/32x32/point_from_circle_and_tangent.png - toolicon/32x32/point_from_circle_and_tangent@2x.png + toolicon/32x32/point_from_circle_and_tangent@2x.png toolicon/32x32/point_of_contact.png - toolicon/32x32/point_of_contact@2x.png + toolicon/32x32/point_of_contact@2x.png toolicon/32x32/point_of_intersection.png - toolicon/32x32/point_of_intersection@2x.png + toolicon/32x32/point_of_intersection@2x.png toolicon/32x32/point_of_intersection_arcs.png - toolicon/32x32/point_of_intersection_arcs@2x.png + toolicon/32x32/point_of_intersection_arcs@2x.png toolicon/32x32/point_of_intersection_circles.png - toolicon/32x32/point_of_intersection_circles@2x.png + toolicon/32x32/point_of_intersection_circles@2x.png toolicon/32x32/segment.png - toolicon/32x32/segment@2x.png + toolicon/32x32/segment@2x.png toolicon/32x32/shoulder.png - toolicon/32x32/shoulder@2x.png + toolicon/32x32/shoulder@2x.png toolicon/32x32/spline.png - toolicon/32x32/spline@2x.png + toolicon/32x32/spline@2x.png toolicon/32x32/spline_cut_point.png - toolicon/32x32/spline_cut_point@2x.png + toolicon/32x32/spline_cut_point@2x.png toolicon/32x32/splinePath.png - toolicon/32x32/splinePath@2x.png + toolicon/32x32/splinePath@2x.png toolicon/32x32/splinePath_cut_point.png - toolicon/32x32/splinePath_cut_point@2x.png + toolicon/32x32/splinePath_cut_point@2x.png toolicon/32x32/triangle.png - toolicon/32x32/triangle@2x.png + toolicon/32x32/triangle@2x.png toolicon/32x32/union.png - toolicon/32x32/union@2x.png + toolicon/32x32/union@2x.png toolicon/32x32/new_detail.png - toolicon/32x32/new_detail@2x.png + toolicon/32x32/new_detail@2x.png toolicon/32x32/arc_with_length.png - toolicon/32x32/arc_with_length@2x.png + toolicon/32x32/arc_with_length@2x.png toolicon/32x32/true_darts.png toolicon/32x32/true_darts@2x.png + toolicon/32x32/intersection_curves.png + toolicon/32x32/intersection_curves@2x.png diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 49b4f7656..65380a32c 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -714,7 +714,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem << VToolPointOfIntersectionCircles::ToolType /*18*/ << VToolPointFromCircleAndTangent::ToolType /*19*/ << VToolPointFromArcAndTangent::ToolType /*20*/ - << VToolTrueDarts::ToolType; /*21*/ + << VToolTrueDarts::ToolType /*21*/ + << VToolPointOfIntersectionCurves::ToolType; /*22*/ switch (points.indexOf(type)) { case 0: //VToolBasePoint::ToolType @@ -783,6 +784,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 21: //VToolTrueDarts::ToolType ParseToolTrueDarts(scene, domElement, parse); break; + case 22: //VToolPointOfIntersectionCurves::ToolType + ParseToolPointOfIntersectionCurves(scene, domElement, parse); + break; default: VException e(tr("Unknown point type '%1'.").arg(type)); throw e; @@ -1690,6 +1694,37 @@ void VPattern::ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QD } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDomElement &domElement, + const Document &parse) +{ + SCASSERT(scene != nullptr); + Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); + + try + { + quint32 id = 0; + QString name; + qreal mx = 0; + qreal my = 0; + + PointsCommonAttributes(domElement, id, name, mx, my); + const auto curve1Id = GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR); + const auto curve2Id = GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR); + const auto vCrossPoint = static_cast(GetParametrUInt(domElement, AttrVCrossPoint, "1")); + const auto hCrossPoint = static_cast(GetParametrUInt(domElement, AttrHCrossPoint, "1")); + + VToolPointOfIntersectionCurves::Create(id, name, curve1Id, curve2Id, vCrossPoint, hCrossPoint, mx, my, + scene, this, data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point of intersection curves"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPattern::ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse) diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index bd71a8190..108fd5e46 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -159,8 +159,8 @@ private: void ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseToolPointOfIntersectionArcs(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse); - void ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QDomElement &domElement, - const Document &parse); + void ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); + void ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse); void ParseToolPointFromArcAndTangent(VMainGraphicsScene *scene, const QDomElement &domElement, diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index fda9f7e77..58566ee35 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -107,11 +107,15 @@ const QString AttrPSpline = QStringLiteral("pSpline"); const QString AttrAxisP1 = QStringLiteral("axisP1"); const QString AttrAxisP2 = QStringLiteral("axisP2"); const QString AttrCurve = QStringLiteral("curve"); +const QString AttrCurve1 = QStringLiteral("curve1"); +const QString AttrCurve2 = QStringLiteral("curve2"); const QString AttrLineColor = QStringLiteral("lineColor"); const QString AttrColor = QStringLiteral("color"); const QString AttrFirstArc = QStringLiteral("firstArc"); const QString AttrSecondArc = QStringLiteral("secondArc"); const QString AttrCrossPoint = QStringLiteral("crossPoint"); +const QString AttrVCrossPoint = QStringLiteral("vCrossPoint"); +const QString AttrHCrossPoint = QStringLiteral("hCrossPoint"); const QString AttrC1Center = QStringLiteral("c1Center"); const QString AttrC2Center = QStringLiteral("c2Center"); const QString AttrC1Radius = QStringLiteral("c1Radius"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 7d6793598..f630b509d 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -109,11 +109,15 @@ extern const QString AttrPSpline; extern const QString AttrAxisP1; extern const QString AttrAxisP2; extern const QString AttrCurve; +extern const QString AttrCurve1; +extern const QString AttrCurve2; extern const QString AttrLineColor; extern const QString AttrColor; extern const QString AttrFirstArc; extern const QString AttrSecondArc; extern const QString AttrCrossPoint; +extern const QString AttrVCrossPoint; +extern const QString AttrHCrossPoint; extern const QString AttrC1Center; extern const QString AttrC2Center; extern const QString AttrC1Radius; diff --git a/src/libs/ifc/schema/pattern/v0.2.5.xsd b/src/libs/ifc/schema/pattern/v0.2.5.xsd index 76d366e5f..8e938b7ee 100644 --- a/src/libs/ifc/schema/pattern/v0.2.5.xsd +++ b/src/libs/ifc/schema/pattern/v0.2.5.xsd @@ -120,11 +120,15 @@ + + - + + + @@ -421,4 +425,10 @@ + + + + + + diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 30acc67c5..caad6afcd 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -35,9 +35,13 @@ #include enum class Document : char { LiteParse, LitePPParse, FullParse }; -enum class CrossCirclesPoint : char {FirstPoint = 1, SecondPoint = 2}; enum class LabelType : char {NewPatternPiece, NewLabel}; +// Don't touch values!!!. Same values stored in xml. +enum class CrossCirclesPoint : char {FirstPoint = 1, SecondPoint = 2}; +enum class VCrossCurvesPoint : char {HighestPoint = 1, LowestPoint = 2}; +enum class HCrossCurvesPoint : char {LeftPoint = 1, RightPoint = 2}; + class VDataTool; class VContainer; diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index 8a4cd9468..704de469b 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -155,18 +155,7 @@ QPainterPath VAbstractCurve::GetPath(PathDirection direction) const */ QVector VAbstractCurve::IntersectLine(const QLineF &line) const { - QVector points = this->GetPoints(); - QVector intersections; - for ( qint32 i = 0; i < points.count()-1; ++i ) - { - QPointF crosPoint; - QLineF::IntersectType type = line.intersect(QLineF ( points.at(i), points.at(i+1)), &crosPoint); - if ( type == QLineF::BoundedIntersection ) - { - intersections.append(crosPoint); - } - } - return intersections; + return CurveIntersectLine(this->GetPoints(), line); } //--------------------------------------------------------------------------------------------------------------------- @@ -176,6 +165,22 @@ bool VAbstractCurve::IsIntersectLine(const QLineF &line) const return not points.isEmpty(); } +//--------------------------------------------------------------------------------------------------------------------- +QVector VAbstractCurve::CurveIntersectLine(const QVector &points, const QLineF &line) +{ + QVector intersections; + for ( auto i = 0; i < points.count()-1; ++i ) + { + QPointF crosPoint; + const auto type = line.intersect(QLineF(points.at(i), points.at(i+1)), &crosPoint); + if ( type == QLineF::BoundedIntersection ) + { + intersections.append(crosPoint); + } + } + return intersections; +} + //--------------------------------------------------------------------------------------------------------------------- QPainterPath VAbstractCurve::ShowDirection(const QVector &points) const { diff --git a/src/libs/vgeometry/vabstractcurve.h b/src/libs/vgeometry/vabstractcurve.h index ea44f5f7b..adeee8942 100644 --- a/src/libs/vgeometry/vabstractcurve.h +++ b/src/libs/vgeometry/vabstractcurve.h @@ -56,6 +56,8 @@ public: virtual qreal GetStartAngle () const=0; virtual qreal GetEndAngle () const=0; + + static QVector CurveIntersectLine(const QVector &points, const QLineF &line); protected: QPainterPath ShowDirection(const QVector &points) const; private: diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index d99a40f0b..9dabf32c7 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -91,6 +91,7 @@ enum class Tool : ToolVisHolderType LineIntersectAxis, PointOfIntersectionArcs, PointOfIntersectionCircles, + PointOfIntersectionCurves, CurveIntersectAxis, PointOfIntersection, PointFromCircleAndTangent, @@ -121,6 +122,7 @@ enum class Vis : ToolVisHolderType ToolPointOfIntersection, ToolPointOfIntersectionArcs, ToolPointOfIntersectionCircles, + ToolPointOfIntersectionCurves, ToolPointFromCircleAndTangent, ToolPointFromArcAndTangent, ToolShoulderPoint, diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index 97b92e0d5..4116ae451 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -33,7 +33,8 @@ HEADERS += \ $$PWD/tools/dialoguniondetails.h \ $$PWD/support/dialogeditwrongformula.h \ $$PWD/support/dialogundo.h \ - $$PWD/tools/dialogtruedarts.h + $$PWD/tools/dialogtruedarts.h \ + $$PWD/tools/dialogpointofintersectioncurves.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -66,7 +67,8 @@ SOURCES += \ $$PWD/tools/dialoguniondetails.cpp \ $$PWD/support/dialogeditwrongformula.cpp \ $$PWD/support/dialogundo.cpp \ - $$PWD/tools/dialogtruedarts.cpp + $$PWD/tools/dialogtruedarts.cpp \ + $$PWD/tools/dialogpointofintersectioncurves.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -98,4 +100,5 @@ FORMS += \ $$PWD/tools/dialoguniondetails.ui \ $$PWD/support/dialogeditwrongformula.ui \ $$PWD/support/dialogundo.ui \ - $$PWD/tools/dialogtruedarts.ui + $$PWD/tools/dialogtruedarts.ui \ + $$PWD/tools/dialogpointofintersectioncurves.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index c87b33155..9a8c4fa68 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -54,6 +54,7 @@ #include "dialogs/tools/dialogcurveintersectaxis.h" #include "dialogs/tools/dialogpointofintersectionarcs.h" #include "dialogs/tools/dialogpointofintersectioncircles.h" +#include "dialogs/tools/dialogpointofintersectioncurves.h" #include "dialogs/tools/dialogpointfromcircleandtangent.h" #include "dialogs/tools/dialogpointfromarcandtangent.h" #include "dialogs/tools/dialogtruedarts.h" diff --git a/src/libs/vtools/dialogs/tools/dialogalongline.cpp b/src/libs/vtools/dialogs/tools/dialogalongline.cpp index a78a27a58..6d7484818 100644 --- a/src/libs/vtools/dialogs/tools/dialogalongline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogalongline.cpp @@ -171,7 +171,7 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) { if (flagError) { - line->setPoint2Id(id); + line->setObject2Id(id); line->RefreshGeometry(); prepare = true; this->setModal(true); @@ -201,8 +201,8 @@ void DialogAlongLine::SaveData() VisToolAlongLine *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetFirstPointId()); - line->setPoint2Id(GetSecondPointId()); + line->setObject1Id(GetFirstPointId()); + line->setObject2Id(GetSecondPointId()); line->setLength(formula); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); @@ -226,7 +226,7 @@ void DialogAlongLine::SetSecondPointId(const quint32 &value) VisToolAlongLine *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint2Id(value); + line->setObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -240,7 +240,7 @@ void DialogAlongLine::SetFirstPointId(const quint32 &value) VisToolAlongLine *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogarc.cpp b/src/libs/vtools/dialogs/tools/dialogarc.cpp index c3b38859f..58a520b8b 100644 --- a/src/libs/vtools/dialogs/tools/dialogarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarc.cpp @@ -125,7 +125,7 @@ DialogArc::~DialogArc() void DialogArc::SetCenter(const quint32 &value) { ChangeCurrentData(ui->comboBoxBasePoint, value); - vis->setPoint1Id(value); + vis->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -248,7 +248,7 @@ void DialogArc::SaveData() VisToolArc *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(GetCenter()); + path->setObject1Id(GetCenter()); path->setRadius(radius); path->setF1(f1); path->setF2(f2); diff --git a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp index e79923182..cd8cd700e 100644 --- a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp @@ -104,7 +104,7 @@ quint32 DialogArcWithLength::GetCenter() const void DialogArcWithLength::SetCenter(const quint32 &value) { ChangeCurrentData(ui->comboBoxCenter, value); - vis->setPoint1Id(value); + vis->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -325,7 +325,7 @@ void DialogArcWithLength::SaveData() VisToolArcWithLength *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(GetCenter()); + path->setObject1Id(GetCenter()); path->setRadius(radius); path->setF1(f1); path->setLength(length); diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.cpp b/src/libs/vtools/dialogs/tools/dialogbisector.cpp index 245322ff2..515443f58 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.cpp +++ b/src/libs/vtools/dialogs/tools/dialogbisector.cpp @@ -176,7 +176,7 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) { number++; - line->setPoint2Id(id); + line->setObject2Id(id); line->RefreshGeometry(); } } @@ -192,7 +192,7 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxThirdPoint, "")) { - line->setPoint3Id(id); + line->setObject3Id(id); line->RefreshGeometry(); prepare = true; this->setModal(true); @@ -263,7 +263,7 @@ void DialogBisector::SetFirstPointId(const quint32 &value) VisToolBisector *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -277,7 +277,7 @@ void DialogBisector::SetSecondPointId(const quint32 &value) VisToolBisector *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint2Id(value); + line->setObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -291,7 +291,7 @@ void DialogBisector::SetThirdPointId(const quint32 &value) VisToolBisector *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint3Id(value); + line->setObject3Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -317,9 +317,9 @@ void DialogBisector::SaveData() VisToolBisector *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetFirstPointId()); - line->setPoint2Id(GetSecondPointId()); - line->setPoint3Id(GetThirdPointId()); + line->setObject1Id(GetFirstPointId()); + line->setObject2Id(GetSecondPointId()); + line->setObject3Id(GetThirdPointId()); line->setLength(formula); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index 2fd9aaec4..f0d690266 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -155,7 +155,7 @@ void DialogCurveIntersectAxis::setCurveId(const quint32 &value) VisToolCurveIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -288,7 +288,7 @@ void DialogCurveIntersectAxis::SaveData() VisToolCurveIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(getCurveId()); + line->setObject1Id(getCurveId()); line->setAxisPointId(GetBasePointId()); line->SetAngle(formulaAngle); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index 6afba27f1..59274be51 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -145,7 +145,7 @@ void DialogCutArc::SaveData() VisToolCutArc *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(getArcId()); + path->setObject1Id(getArcId()); path->setLength(formula); path->RefreshGeometry(); } @@ -168,7 +168,7 @@ void DialogCutArc::setArcId(const quint32 &value) VisToolCutArc *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(value); + path->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index 85bf03225..7e13d2a08 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -124,7 +124,7 @@ void DialogCutSpline::setSplineId(const quint32 &value) VisToolCutSpline *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(value); + path->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -180,7 +180,7 @@ void DialogCutSpline::SaveData() VisToolCutSpline *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(getSplineId()); + path->setObject1Id(getSplineId()); path->setLength(formula); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index 7e2e2a737..abb2abaf9 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -124,7 +124,7 @@ void DialogCutSplinePath::setSplinePathId(const quint32 &value) VisToolCutSplinePath *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(value); + path->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -180,7 +180,7 @@ void DialogCutSplinePath::SaveData() VisToolCutSplinePath *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(getSplinePathId()); + path->setObject1Id(getSplinePathId()); path->setLength(formula); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index 479701454..668fc5a92 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -253,7 +253,7 @@ void DialogEndLine::SetBasePointId(const quint32 &value) VisToolEndLine *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -324,7 +324,7 @@ void DialogEndLine::SaveData() VisToolEndLine *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetBasePointId()); + line->setObject1Id(GetBasePointId()); line->setLength(formulaLength); line->SetAngle(formulaAngle); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); diff --git a/src/libs/vtools/dialogs/tools/dialogheight.cpp b/src/libs/vtools/dialogs/tools/dialogheight.cpp index 56475eb4c..f90b44d92 100644 --- a/src/libs/vtools/dialogs/tools/dialogheight.cpp +++ b/src/libs/vtools/dialogs/tools/dialogheight.cpp @@ -112,7 +112,7 @@ void DialogHeight::SetBasePointId(const quint32 &value) VisToolHeight *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -224,7 +224,7 @@ void DialogHeight::SaveData() VisToolHeight *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetBasePointId()); + line->setObject1Id(GetBasePointId()); line->setLineP1Id(GetP1LineId()); line->setLineP2Id(GetP2LineId()); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); diff --git a/src/libs/vtools/dialogs/tools/dialogline.cpp b/src/libs/vtools/dialogs/tools/dialogline.cpp index 04545ebf2..8c7cf6737 100644 --- a/src/libs/vtools/dialogs/tools/dialogline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogline.cpp @@ -120,7 +120,7 @@ void DialogLine::SetFirstPoint(const quint32 &value) VisToolLine *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -154,7 +154,7 @@ void DialogLine::SaveData() VisToolLine *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetFirstPoint()); + line->setObject1Id(GetFirstPoint()); line->setPoint2Id(GetSecondPoint()); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp index cd67c5760..6896c5acf 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp @@ -179,7 +179,7 @@ void DialogLineIntersect::SaveData() VisToolLineIntersect *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetP1Line1()); + line->setObject1Id(GetP1Line1()); line->setLine1P2Id(GetP2Line1()); line->setLine2P1Id(GetP1Line2()); line->setLine2P2Id(GetP2Line2()); @@ -333,7 +333,7 @@ void DialogLineIntersect::SetP1Line1(const quint32 &value) VisToolLineIntersect *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp index 98662d6a7..95600550e 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp @@ -164,7 +164,7 @@ void DialogLineIntersectAxis::SetFirstPointId(const quint32 &value) VisToolLineIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -356,7 +356,7 @@ void DialogLineIntersectAxis::SaveData() VisToolLineIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetFirstPointId()); + line->setObject1Id(GetFirstPointId()); line->setPoint2Id(GetSecondPointId()); line->setAxisPointId(GetBasePointId()); line->SetAngle(formulaAngle); diff --git a/src/libs/vtools/dialogs/tools/dialognormal.cpp b/src/libs/vtools/dialogs/tools/dialognormal.cpp index 1c6940534..ad4de0ce6 100644 --- a/src/libs/vtools/dialogs/tools/dialognormal.cpp +++ b/src/libs/vtools/dialogs/tools/dialognormal.cpp @@ -165,7 +165,7 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxSecondPoint, "")) { - line->setPoint2Id(id); + line->setObject2Id(id); line->RefreshGeometry(); prepare = true; this->setModal(true); @@ -191,8 +191,8 @@ void DialogNormal::SaveData() VisToolNormal *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetFirstPointId()); - line->setPoint2Id(GetSecondPointId()); + line->setObject1Id(GetFirstPointId()); + line->setObject2Id(GetSecondPointId()); line->setLength(formula); line->SetAngle(angle); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); @@ -217,7 +217,7 @@ void DialogNormal::SetSecondPointId(const quint32 &value) VisToolNormal *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint2Id(value); + line->setObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -243,7 +243,7 @@ void DialogNormal::SetFirstPointId(const quint32 &value) VisToolNormal *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp index 5f2b35c31..137a9389d 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp @@ -103,13 +103,13 @@ void DialogPointFromArcAndTangent::SetTangentPointId(const quint32 &value) VisToolPointFromArcAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint1Id(value); + point->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- CrossCirclesPoint DialogPointFromArcAndTangent::GetCrossCirclesPoint() const { - return getCurrentCrossPoint(ui->comboBoxResult); + return getCurrentCrossPoint(ui->comboBoxResult); } //--------------------------------------------------------------------------------------------------------------------- @@ -182,7 +182,7 @@ void DialogPointFromArcAndTangent::SaveData() VisToolPointFromArcAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint1Id(GetTangentPointId()); + point->setObject1Id(GetTangentPointId()); point->setArcId(GetArcId()); point->setCrossPoint(GetCrossCirclesPoint()); point->RefreshGeometry(); diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp index 22605555d..7a7925867 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp @@ -112,7 +112,7 @@ void DialogPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value) VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint2Id(value); + point->setObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -153,13 +153,13 @@ void DialogPointFromCircleAndTangent::SetTangentPointId(const quint32 &value) VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint1Id(value); + point->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- CrossCirclesPoint DialogPointFromCircleAndTangent::GetCrossCirclesPoint() const { - return getCurrentCrossPoint(ui->comboBoxResult); + return getCurrentCrossPoint(ui->comboBoxResult); } //--------------------------------------------------------------------------------------------------------------------- @@ -201,7 +201,7 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject if (SetObject(id, ui->comboBoxCircleCenter, "")) { number = 0; - point->setPoint2Id(id); + point->setObject2Id(id); point->RefreshGeometry(); prepare = true; this->setModal(true); @@ -299,8 +299,8 @@ void DialogPointFromCircleAndTangent::SaveData() VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint1Id(GetTangentPointId()); - point->setPoint2Id(GetCircleCenterId()); + point->setObject1Id(GetTangentPointId()); + point->setObject2Id(GetCircleCenterId()); point->setCRadius(radius); point->setCrossPoint(GetCrossCirclesPoint()); point->RefreshGeometry(); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp index 24ba8f55f..7c7ae3cd0 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp @@ -214,7 +214,7 @@ void DialogPointOfContact::SaveData() VisToolPointOfContact *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetFirstPoint()); + line->setObject1Id(GetFirstPoint()); line->setLineP2Id(GetSecondPoint()); line->setRadiusId(getCenter()); line->setRadius(radius); @@ -253,7 +253,7 @@ void DialogPointOfContact::SetFirstPoint(const quint32 &value) VisToolPointOfContact *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp index cf350c8b4..2e954801c 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp @@ -110,7 +110,7 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point for Y value (horizontal)"))) { number++; - line->setPoint1Id(id); + line->setObject1Id(id); line->RefreshGeometry(); } break; @@ -141,7 +141,7 @@ void DialogPointOfIntersection::SaveData() VisToolPointOfIntersection *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetFirstPointId()); + line->setObject1Id(GetFirstPointId()); line->setPoint2Id(GetSecondPointId()); line->RefreshGeometry(); } @@ -182,7 +182,7 @@ void DialogPointOfIntersection::SetFirstPointId(const quint32 &value) VisToolPointOfIntersection *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp index ac04334a2..483951e19 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp @@ -113,7 +113,7 @@ void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- CrossCirclesPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const { - return getCurrentCrossPoint(ui->comboBoxResult); + return getCurrentCrossPoint(ui->comboBoxResult); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp index c2d00a8f6..053040b43 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp @@ -128,7 +128,7 @@ void DialogPointOfIntersectionCircles::SetFirstCircleCenterId(const quint32 &val VisToolPointOfIntersectionCircles *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint1Id(value); + point->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -144,7 +144,7 @@ void DialogPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &va VisToolPointOfIntersectionCircles *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint2Id(value); + point->setObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -200,7 +200,7 @@ void DialogPointOfIntersectionCircles::SetSecondCircleRadius(const QString &valu //--------------------------------------------------------------------------------------------------------------------- CrossCirclesPoint DialogPointOfIntersectionCircles::GetCrossCirclesPoint() const { - return getCurrentCrossPoint(ui->comboBoxResult); + return getCurrentCrossPoint(ui->comboBoxResult); } //--------------------------------------------------------------------------------------------------------------------- @@ -242,7 +242,7 @@ void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObjec if (SetObject(id, ui->comboBoxCircle2Center, "")) { number = 0; - point->setPoint2Id(id); + point->setObject2Id(id); point->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -389,8 +389,8 @@ void DialogPointOfIntersectionCircles::SaveData() VisToolPointOfIntersectionCircles *point = qobject_cast(vis); SCASSERT(point != nullptr); - point->setPoint1Id(GetFirstCircleCenterId()); - point->setPoint2Id(GetSecondCircleCenterId()); + point->setObject1Id(GetFirstCircleCenterId()); + point->setObject2Id(GetSecondCircleCenterId()); point->setC1Radius(c1Radius); point->setC2Radius(c2Radius); point->setCrossPoint(GetCrossCirclesPoint()); diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp new file mode 100644 index 000000000..9598a0bac --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp @@ -0,0 +1,204 @@ +/************************************************************************ + ** + ** @file dialogpointofintersectioncurves.cpp + ** @author Roman Telezhynskyi + ** @date 23 1, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** 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 . + ** + *************************************************************************/ + +#include "dialogpointofintersectioncurves.h" +#include "ui_dialogpointofintersectioncurves.h" +#include "../../visualization/vistoolpointofintersectioncurves.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContainer *data, const quint32 &toolId, + QWidget *parent) + :DialogTool(data, toolId, parent), + ui(new Ui::DialogPointOfIntersectionCurves) +{ + ui->setupUi(this); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + ui->lineEditNamePoint->setClearButtonEnabled(true); +#endif + + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + + InitOkCancelApply(ui); + + FillComboBoxCurves(ui->comboBoxCurve1); + FillComboBoxCurves(ui->comboBoxCurve2); + FillComboBoxVCrossCurvesPoint(ui->comboBoxVCorrection); + FillComboBoxHCrossCurvesPoint(ui->comboBoxHCorrection); + + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionCurves::NamePointChanged); + + vis = new VisToolPointOfIntersectionCurves(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointOfIntersectionCurves::~DialogPointOfIntersectionCurves() +{ + DeleteVisualization(); + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPointOfIntersectionCurves::GetFirstCurveId() const +{ + return getCurrentObjectId(ui->comboBoxCurve1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxCurve1, value); + + auto point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setObject1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPointOfIntersectionCurves::GetSecondCurveId() const +{ + return getCurrentObjectId(ui->comboBoxCurve2); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxCurve2, value); + + auto point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setObject2Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +VCrossCurvesPoint DialogPointOfIntersectionCurves::GetVCrossPoint() const +{ + return getCurrentCrossPoint(ui->comboBoxVCorrection); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetVCrossPoint(const VCrossCurvesPoint &vP) +{ + auto index = ui->comboBoxVCorrection->findData(static_cast(vP)); + if (index != -1) + { + ui->comboBoxVCorrection->setCurrentIndex(index); + + auto point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setVCrossPoint(vP); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +HCrossCurvesPoint DialogPointOfIntersectionCurves::GetHCrossPoint() const +{ + return getCurrentCrossPoint(ui->comboBoxHCorrection); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SetHCrossPoint(const HCrossCurvesPoint &hP) +{ + auto index = ui->comboBoxHCorrection->findData(static_cast(hP)); + if (index != -1) + { + ui->comboBoxHCorrection->setCurrentIndex(index); + + auto point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setHCrossPoint(hP); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Spline || type == SceneObject::Arc || type == SceneObject::SplinePath) + { + auto point = qobject_cast(vis); + SCASSERT(point != nullptr); + + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxCurve1, tr("Select second curve"))) + { + number++; + point->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxCurve1) != id) + { + if (SetObject(id, ui->comboBoxCurve2, "")) + { + number = 0; + point->setObject2Id(id); + point->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::ShowVisualization() +{ + AddVisualization(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointOfIntersectionCurves::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + + auto point = qobject_cast(vis); + SCASSERT(point != nullptr); + + point->setObject1Id(GetFirstCurveId()); + point->setObject2Id(GetSecondCurveId()); + point->setVCrossPoint(GetVCrossPoint()); + point->setHCrossPoint(GetHCrossPoint()); + point->RefreshGeometry(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h new file mode 100644 index 000000000..d70b1bc34 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file dialogpointofintersectioncurves.h + ** @author Roman Telezhynskyi + ** @date 23 1, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** 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 . + ** + *************************************************************************/ + +#ifndef DIALOGPOINTOFINTERSECTIONCURVES_H +#define DIALOGPOINTOFINTERSECTIONCURVES_H + +#include "dialogtool.h" + +namespace Ui { +class DialogPointOfIntersectionCurves; +} + +class DialogPointOfIntersectionCurves : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogPointOfIntersectionCurves(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + virtual ~DialogPointOfIntersectionCurves() Q_DECL_OVERRIDE; + + void SetPointName(const QString &value); + + quint32 GetFirstCurveId() const; + void SetFirstCurveId(const quint32 &value); + + quint32 GetSecondCurveId() const; + void SetSecondCurveId(const quint32 &value); + + VCrossCurvesPoint GetVCrossPoint() const; + void SetVCrossPoint(const VCrossCurvesPoint &vP); + + HCrossCurvesPoint GetHCrossPoint() const; + void SetHCrossPoint(const HCrossCurvesPoint &hP); + +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE; + +protected: + virtual void ShowVisualization() Q_DECL_OVERRIDE; + + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData() Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(DialogPointOfIntersectionCurves) + + Ui::DialogPointOfIntersectionCurves *ui; +}; + +#endif // DIALOGPOINTOFINTERSECTIONCURVES_H diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui new file mode 100644 index 000000000..2ce932e5d --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.ui @@ -0,0 +1,162 @@ + + + DialogPointOfIntersectionCurves + + + + 0 + 0 + 285 + 212 + + + + Tool point of intersection curves + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + + 0 + 0 + + + + First curve: + + + + + + + + + + + + + + + 0 + 0 + + + + Second curve: + + + + + + + + + + + 0 + 0 + + + + Point label: + + + + + + + + 0 + 0 + + + + Unique label + + + Choose unique label. + + + + + + + Vertical correction: + + + + + + + + + + Horizontal correction: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogPointOfIntersectionCurves + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPointOfIntersectionCurves + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp index dd7154bce..2854291af 100644 --- a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp @@ -219,7 +219,7 @@ void DialogShoulderPoint::SaveData() VisToolShoulderPoint *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetP3()); + line->setObject1Id(GetP3()); line->setLineP1Id(GetP1Line()); line->setLineP2Id(GetP2Line()); line->setLength(formula); @@ -245,7 +245,7 @@ void DialogShoulderPoint::SetP3(const quint32 &value) VisToolShoulderPoint *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp index 9a12ee58c..0af494282 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp @@ -119,7 +119,7 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) ui->spinBoxAngle1->setValue(static_cast(QLineF(p1, p4).angle())); ui->spinBoxAngle2->setValue(static_cast(QLineF(p4, p1).angle())); - path->setPoint4Id(id); + path->setObject4Id(id); path->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -150,8 +150,8 @@ void DialogSpline::SaveData() VisToolSpline *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(GetP1()); - path->setPoint4Id(GetP4()); + path->setObject1Id(GetP1()); + path->setObject4Id(GetP4()); path->SetAngle1(angle1); path->SetAngle2(angle2); path->SetKAsm1(kAsm1); @@ -287,7 +287,7 @@ void DialogSpline::SetP4(const quint32 &value) VisToolSpline *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint4Id(value); + path->setObject4Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -301,7 +301,7 @@ void DialogSpline::SetP1(const quint32 &value) VisToolSpline *path = qobject_cast(vis); SCASSERT(path != nullptr); - path->setPoint1Id(value); + path->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 4fd22ed37..7e3b768a7 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -227,6 +227,24 @@ void DialogTool::FillComboBoxCrossCirclesPoints(QComboBox *box) const box->addItem(tr("Second point"), QVariant(static_cast(CrossCirclesPoint::SecondPoint))); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::FillComboBoxVCrossCurvesPoint(QComboBox *box) const +{ + SCASSERT(box != nullptr); + + box->addItem(tr("Highest point"), QVariant(static_cast(VCrossCurvesPoint::HighestPoint))); + box->addItem(tr("Lowest point"), QVariant(static_cast(VCrossCurvesPoint::LowestPoint))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::FillComboBoxHCrossCurvesPoint(QComboBox *box) const +{ + SCASSERT(box != nullptr); + + box->addItem(tr("Leftmost point"), QVariant(static_cast(HCrossCurvesPoint::LeftPoint))); + box->addItem(tr("Rightmost point"), QVariant(static_cast(HCrossCurvesPoint::RightPoint))); +} + //--------------------------------------------------------------------------------------------------------------------- QString DialogTool::GetComboBoxCurrentData(const QComboBox *box) const { @@ -488,35 +506,6 @@ quint32 DialogTool::getCurrentObjectId(QComboBox *box) const } } -//--------------------------------------------------------------------------------------------------------------------- -CrossCirclesPoint DialogTool::getCurrentCrossPoint(QComboBox *box) const -{ - int value; - bool ok = false; -#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) - value = box->itemData(box->currentIndex()).toInt(&ok); -#else - value = box->currentData().toInt(&ok); -#endif - if (not ok) - { - return CrossCirclesPoint::FirstPoint; - } - - switch(value) - { - case 1: - return CrossCirclesPoint::FirstPoint; - break; - case 2: - return CrossCirclesPoint::SecondPoint; - break; - default: - return CrossCirclesPoint::FirstPoint; - break; - } -} - //--------------------------------------------------------------------------------------------------------------------- bool DialogTool::SetObject(const quint32 &id, QComboBox *box, const QString &toolTip) { diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index a12c8ad6f..5a20405d0 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -42,12 +42,12 @@ #include #include #include +#include Q_DECLARE_LOGGING_CATEGORY(vDialog) class QDoubleSpinBox; class QLabel; -class QComboBox; class QListWidgetItem; class VContainer; class QPlainTextEdit; @@ -196,6 +196,8 @@ protected: void FillComboBoxTypeLine(QComboBox *box, const QMap &stylesPics) const; void FillComboBoxLineColors(QComboBox *box)const; void FillComboBoxCrossCirclesPoints(QComboBox *box) const; + void FillComboBoxVCrossCurvesPoint(QComboBox *box) const; + void FillComboBoxHCrossCurvesPoint(QComboBox *box) const; virtual void CheckState(); QString GetComboBoxCurrentData(const QComboBox *box)const; @@ -219,8 +221,10 @@ protected: const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const; void setCurrentCurveId(QComboBox *box, const quint32 &value) const; - quint32 getCurrentObjectId(QComboBox *box) const; - CrossCirclesPoint getCurrentCrossPoint(QComboBox *box) const; + quint32 getCurrentObjectId(QComboBox *box) const; + + template + T getCurrentCrossPoint(QComboBox *box) const; bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip); void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight); @@ -362,4 +366,32 @@ inline void DialogTool::DeleteVisualization() } } +//--------------------------------------------------------------------------------------------------------------------- +template +inline T DialogTool::getCurrentCrossPoint(QComboBox *box) const +{ + int value; + bool ok = false; +#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) + value = box->itemData(box->currentIndex()).toInt(&ok); +#else + value = box->currentData().toInt(&ok); +#endif + if (not ok) + { + return static_cast(1); + } + + switch(value) + { + case 1: + case 2: + return static_cast(value); + break; + default: + return static_cast(1); + break; + } +} + #endif // DIALOGTOOL_H diff --git a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp index c11db6b9e..99bb0941a 100644 --- a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp @@ -109,7 +109,7 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point"))) { number++; - line->setPoint2Id(id); + line->setObject2Id(id); line->RefreshGeometry(); } } @@ -167,8 +167,8 @@ void DialogTriangle::SaveData() VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(GetAxisP1Id()); - line->setPoint2Id(GetAxisP2Id()); + line->setObject1Id(GetAxisP1Id()); + line->setObject2Id(GetAxisP2Id()); line->setHypotenuseP1Id(GetFirstPointId()); line->setHypotenuseP2Id(GetSecondPointId()); line->RefreshGeometry(); @@ -257,7 +257,7 @@ void DialogTriangle::SetAxisP2Id(const quint32 &value) VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint2Id(value); + line->setObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -271,7 +271,7 @@ void DialogTriangle::SetAxisP1Id(const quint32 &value) VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr); - line->setPoint1Id(value); + line->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp index ed9b1318a..259043ff5 100644 --- a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp @@ -130,7 +130,7 @@ void DialogTrueDarts::SetFirstBasePointId(const quint32 &value) VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr); - points->setPoint1Id(value); + points->setObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -146,7 +146,7 @@ void DialogTrueDarts::SetSecondBasePointId(const quint32 &value) VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr); - points->setPoint2Id(value); + points->setObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -230,7 +230,7 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point"))) { number++; - points->setPoint2Id(id); + points->setObject2Id(id); points->RefreshGeometry(); } } @@ -356,8 +356,8 @@ void DialogTrueDarts::SaveData() VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr); - points->setPoint1Id(GetFirstBasePointId()); - points->setPoint2Id(GetSecondBasePointId()); + points->setObject1Id(GetFirstBasePointId()); + points->setObject2Id(GetSecondBasePointId()); points->setD1PointId(GetFirstDartPointId()); points->setD2PointId(GetSecondDartPointId()); points->setD3PointId(GetThirdDartPointId()); diff --git a/src/libs/vtools/tools/drawTools/drawtools.h b/src/libs/vtools/tools/drawTools/drawtools.h index a81794070..58ba95ad7 100644 --- a/src/libs/vtools/tools/drawTools/drawtools.h +++ b/src/libs/vtools/tools/drawTools/drawtools.h @@ -52,6 +52,7 @@ #include "toolpoint/toolsinglepoint/vtoolpointofintersection.h" #include "toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" #include "toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" +#include "toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" #include "toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" #include "toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" #include "toolpoint/tooldoublepoint/vtooltruedarts.h" diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index f4b82d6e6..eb535d26b 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -355,7 +355,7 @@ void VToolArc::SetVisualization() SCASSERT(visual != nullptr); const VTranslateVars *trVars = qApp->TrVars(); - visual->setPoint1Id(arc->GetCenter().id()); + visual->setObject1Id(arc->GetCenter().id()); visual->setRadius(trVars->FormulaToUser(arc->GetFormulaRadius())); visual->setF1(trVars->FormulaToUser(arc->GetFormulaF1())); visual->setF2(trVars->FormulaToUser(arc->GetFormulaF2())); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index 3dbfa983a..27c61e84d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -311,7 +311,7 @@ void VToolArcWithLength::SetVisualization() SCASSERT(visual != nullptr); const VTranslateVars *trVars = qApp->TrVars(); - visual->setPoint1Id(arc->GetCenter().id()); + visual->setObject1Id(arc->GetCenter().id()); visual->setRadius(trVars->FormulaToUser(arc->GetFormulaRadius())); visual->setF1(trVars->FormulaToUser(arc->GetFormulaF1())); visual->setLength(trVars->FormulaToUser(arc->GetFormulaLength())); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 6af2977e2..fa98bcdeb 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -481,8 +481,8 @@ void VToolSpline::SetVisualization() SCASSERT(visual != nullptr); const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); - visual->setPoint1Id(spl->GetP1().id()); - visual->setPoint4Id(spl->GetP4().id()); + visual->setObject1Id(spl->GetP1().id()); + visual->setObject4Id(spl->GetP4().id()); visual->SetAngle1(spl->GetStartAngle()); visual->SetAngle2(spl->GetEndAngle()); visual->SetKAsm1(spl->GetKasm1()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index abc78d74d..078c57454 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -360,8 +360,8 @@ void VToolTrueDarts::SetVisualization() VisToolTrueDarts *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(baseLineP1Id); - visual->setPoint2Id(baseLineP2Id); + visual->setObject1Id(baseLineP1Id); + visual->setObject2Id(baseLineP2Id); visual->setD1PointId(dartP1Id); visual->setD2PointId(dartP2Id); visual->setD3PointId(dartP3Id); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index fda07b74b..45d0914c1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -241,7 +241,7 @@ void VToolCutArc::SetVisualization() VisToolCutArc *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(curveCutId); + visual->setObject1Id(curveCutId); visual->setLength(qApp->TrVars()->FormulaToUser(formula)); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index fcded45df..63630608b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -249,7 +249,7 @@ void VToolCutSpline::SetVisualization() VisToolCutSpline *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(curveCutId); + visual->setObject1Id(curveCutId); visual->setLength(qApp->TrVars()->FormulaToUser(formula)); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 3b659e0c4..57b631393 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -293,7 +293,7 @@ void VToolCutSplinePath::SetVisualization() VisToolCutSplinePath *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(curveCutId); + visual->setObject1Id(curveCutId); visual->setLength(qApp->TrVars()->FormulaToUser(formula)); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index 04aadefcf..46bc56705 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -143,8 +143,8 @@ void VToolAlongLine::SetVisualization() { VisToolAlongLine *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setPoint1Id(basePointId); - visual->setPoint2Id(secondPointId); + visual->setObject1Id(basePointId); + visual->setObject2Id(secondPointId); visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index 04522ac5c..a48ee267a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -302,9 +302,9 @@ void VToolBisector::SetVisualization() VisToolBisector *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(firstPointId); - visual->setPoint2Id(basePointId); - visual->setPoint3Id(thirdPointId); + visual->setObject1Id(firstPointId); + visual->setObject2Id(basePointId); + visual->setObject3Id(thirdPointId); visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 708f53cc4..42ce90295 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -278,7 +278,7 @@ void VToolCurveIntersectAxis::SetVisualization() VisToolCurveIntersectAxis *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(curveId); + visual->setObject1Id(curveId); visual->setAxisPointId(basePointId); visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index 55b6546ea..9304fbfd4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -240,7 +240,7 @@ void VToolEndLine::SetVisualization() VisToolEndLine *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(basePointId); + visual->setObject1Id(basePointId); visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength)); visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 4cddc1b2c..d35042c31 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -246,7 +246,7 @@ void VToolHeight::SetVisualization() VisToolHeight *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(basePointId); + visual->setObject1Id(basePointId); visual->setLineP1Id(p1LineId); visual->setLineP2Id(p2LineId); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 983c748a9..87ceeb2c7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -292,7 +292,7 @@ void VToolLineIntersectAxis::SetVisualization() VisToolLineIntersectAxis *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(firstPointId); + visual->setObject1Id(firstPointId); visual->setPoint2Id(secondPointId); visual->setAxisPointId(basePointId); visual->SetAngle(qApp->TrVars()->FormulaToUser(formulaAngle)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index 63573b65f..8d4d4a929 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -279,8 +279,8 @@ void VToolNormal::SetVisualization() VisToolNormal *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(basePointId); - visual->setPoint2Id(secondPointId); + visual->setObject1Id(basePointId); + visual->setObject2Id(secondPointId); visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength)); visual->SetAngle(angle); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index 984850531..1a6518a92 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -306,7 +306,7 @@ void VToolShoulderPoint::SetVisualization() VisToolShoulderPoint *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(pShoulder); + visual->setObject1Id(pShoulder); visual->setLineP1Id(basePointId); visual->setLineP2Id(p2Line); visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index af65be768..83561f1b0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -265,7 +265,7 @@ void VToolLineIntersect::SetVisualization() VisToolLineIntersect *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(p1Line1); + visual->setObject1Id(p1Line1); visual->setLine1P2Id(p2Line1); visual->setLine2P1Id(p1Line2); visual->setLine2P2Id(p2Line2); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 7b8250272..085663357 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -318,7 +318,7 @@ void VToolPointFromArcAndTangent::SetVisualization() VisToolPointFromArcAndTangent *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(tangentPointId); + visual->setObject1Id(tangentPointId); visual->setArcId(arcId); visual->setCrossPoint(crossPoint); visual->RefreshGeometry(); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index 5f33471e2..ab5ebd65f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -305,8 +305,8 @@ void VToolPointFromCircleAndTangent::SetVisualization() VisToolPointFromCircleAndTangent *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(tangentPointId); - visual->setPoint2Id(circleCenterId); + visual->setObject1Id(tangentPointId); + visual->setObject2Id(circleCenterId); visual->setCRadius(circleRadius); visual->setCrossPoint(crossPoint); visual->RefreshGeometry(); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index c4153c436..c8243c27b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -318,7 +318,7 @@ void VToolPointOfContact::SetVisualization() VisToolPointOfContact *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(firstPointId); + visual->setObject1Id(firstPointId); visual->setLineP2Id(secondPointId); visual->setRadiusId(center); visual->setRadius(qApp->TrVars()->FormulaToUser(arcRadius)); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index 3350ecc8e..005dda787 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -220,7 +220,7 @@ void VToolPointOfIntersection::SetVisualization() VisToolPointOfIntersection *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(firstPointId); + visual->setObject1Id(firstPointId); visual->setPoint2Id(secondPointId); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index 950ee3fa1..3307fb002 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -344,8 +344,8 @@ void VToolPointOfIntersectionCircles::SetVisualization() VisToolPointOfIntersectionCircles *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(firstCircleCenterId); - visual->setPoint2Id(secondCircleCenterId); + visual->setObject1Id(firstCircleCenterId); + visual->setObject2Id(secondCircleCenterId); visual->setC1Radius(firstCircleRadius); visual->setC2Radius(secondCircleRadius); visual->setCrossPoint(crossPoint); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp new file mode 100644 index 000000000..bcf1e17ae --- /dev/null +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -0,0 +1,388 @@ +/************************************************************************ + ** + ** @file vtoolpointofintersectioncurves.cpp + ** @author Roman Telezhynskyi + ** @date 22 1, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** 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 . + ** + *************************************************************************/ + +#include "vtoolpointofintersectioncurves.h" +#include "../../../../dialogs/tools/dialogpointofintersectioncurves.h" +#include "../../../../visualization/vistoolpointofintersectioncurves.h" + +const QString VToolPointOfIntersectionCurves::ToolType = QStringLiteral("pointOfIntersectionCurves"); + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(VAbstractPattern *doc, VContainer *data, + const quint32 &id, const quint32 firstCurveId, + quint32 secondCurveId, VCrossCurvesPoint vCrossPoint, + HCrossCurvesPoint hCrossPoint, const Source &typeCreation, + QGraphicsItem *parent) + :VToolSinglePoint(doc, data, id, parent), + firstCurveId(firstCurveId), + secondCurveId(secondCurveId), + vCrossPoint(vCrossPoint), + hCrossPoint(hCrossPoint) +{ + ToolCreation(typeCreation); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::setDialog() +{ + SCASSERT(dialog != nullptr); + auto dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + auto p = VAbstractTool::data.GeometricObject(id); + dialogTool->SetFirstCurveId(firstCurveId); + dialogTool->SetSecondCurveId(secondCurveId); + dialogTool->SetVCrossPoint(vCrossPoint); + dialogTool->SetHCrossPoint(hCrossPoint); + dialogTool->SetPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(DialogTool *dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + auto dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 firstCurveId = dialogTool->GetFirstCurveId(); + const quint32 secondCurveId = dialogTool->GetSecondCurveId(); + const VCrossCurvesPoint vCrossPoint = dialogTool->GetVCrossPoint(); + const HCrossCurvesPoint hCrossPoint = dialogTool->GetHCrossPoint(); + const QString pointName = dialogTool->getPointName(); + VToolPointOfIntersectionCurves *point = Create(0, pointName, firstCurveId, secondCurveId, vCrossPoint, hCrossPoint, + 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const quint32 _id, const QString &pointName, + quint32 firstCurveId, quint32 secondCurveId, + VCrossCurvesPoint vCrossPoint, + HCrossCurvesPoint hCrossPoint, const qreal &mx, + const qreal &my, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data, + const Document &parse, + const Source &typeCreation) +{ + auto curve1 = data->GeometricObject(firstCurveId); + auto curve2 = data->GeometricObject(secondCurveId); + + const QPointF point = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), + vCrossPoint, hCrossPoint); + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(new VPointF(point, pointName, mx, my)); + } + else + { + data->UpdateGObject(id, new VPointF(point, pointName, mx, my)); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::PointOfIntersectionCurves, doc); + if (parse == Document::FullParse) + { + auto point = new VToolPointOfIntersectionCurves(doc, data, id, firstCurveId, secondCurveId, vCrossPoint, + hCrossPoint, typeCreation); + scene->addItem(point); + connect(point, &VToolPointOfIntersectionCurves::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionCurves::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionCurves::Disable); + connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionCurves::EnableToolMove); + doc->AddTool(id, point); + doc->IncrementReferens(firstCurveId); + doc->IncrementReferens(secondCurveId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VToolPointOfIntersectionCurves::FindPoint(const QVector &curve1Points, + const QVector &curve2Points, + VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint) +{ + QVector intersections; + for ( auto i = 0; i < curve1Points.count()-1; ++i ) + { + intersections << VAbstractCurve::CurveIntersectLine(curve2Points, + QLineF(curve1Points.at(i), curve1Points.at(i+1))); + } + + if (intersections.isEmpty()) + { + return QPointF(); + } + + if (intersections.size() == 1) + { + return intersections.at(0); + } + + QVector vIntersections; + if (vCrossPoint == VCrossCurvesPoint::HighestPoint) + { + qreal minY = intersections.at(0).y(); + vIntersections.append(intersections.at(0)); + + for ( auto i = 1; i < intersections.count(); ++i ) + { + const QPointF p = intersections.at(i); + if (p.y() > minY) + { + continue; + } + else if (p.y() < minY) + { + minY = p.y(); + vIntersections.clear(); + vIntersections.append(p); + } + else + { + vIntersections.append(p); + } + } + } + else + { + qreal maxY = intersections.at(0).y(); + vIntersections.append(intersections.at(0)); + + for ( auto i = 1; i < intersections.count(); ++i ) + { + const QPointF p = intersections.at(i); + if (p.y() > maxY) + { + maxY = p.y(); + vIntersections.clear(); + vIntersections.append(p); + } + else if (p.y() < maxY) + { + continue; + } + else + { + vIntersections.append(p); + } + } + } + + if (vIntersections.isEmpty()) + { + return QPointF(); + } + + if (vIntersections.size() == 1) + { + return vIntersections.at(0); + } + + QPointF crossPoint = vIntersections.at(0); + + if (hCrossPoint == HCrossCurvesPoint::RightPoint) + { + qreal maxX = vIntersections.at(0).x(); + + for ( auto i = 1; i < vIntersections.count(); ++i ) + { + const QPointF p = vIntersections.at(i); + if (p.x() > maxX) + { + maxX = p.x(); + crossPoint = p; + } + } + } + else + { + qreal minX = vIntersections.at(0).x(); + + for ( auto i = 1; i < vIntersections.count(); ++i ) + { + const QPointF p = vIntersections.at(i); + if (p.x() < minX) + { + minX = p.x(); + crossPoint = p; + } + } + } + + return crossPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfIntersectionCurves::GetFirstCurveId() const +{ + return firstCurveId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value) +{ + if (value != NULL_ID) + { + firstCurveId = value; + + auto obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfIntersectionCurves::GetSecondCurveId() const +{ + return secondCurveId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value) +{ + if (value != NULL_ID) + { + secondCurveId = value; + + auto obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +VCrossCurvesPoint VToolPointOfIntersectionCurves::GetVCrossPoint() const +{ + return vCrossPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SetVCrossPoint(const VCrossCurvesPoint &value) +{ + vCrossPoint = value; + + auto obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +HCrossCurvesPoint VToolPointOfIntersectionCurves::GetHCrossPoint() const +{ + return hCrossPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SetHCrossPoint(const HCrossCurvesPoint &value) +{ + hCrossPoint = value; + + auto obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::ShowVisualization(bool show) +{ + ShowToolVisualization(show); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::RemoveReferens() +{ + doc->DecrementReferens(firstCurveId); + doc->DecrementReferens(secondCurveId); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + try + { + ContextMenu(this, event); + } + catch(const VExceptionToolWasDeleted &e) + { + Q_UNUSED(e); + return;//Leave this method immediately!!! + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + auto dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrCurve1, QString().setNum(dialogTool->GetFirstCurveId())); + doc->SetAttribute(domElement, AttrCurve2, QString().setNum(dialogTool->GetSecondCurveId())); + doc->SetAttribute(domElement, AttrVCrossPoint, QString().setNum(static_cast(dialogTool->GetVCrossPoint()))); + doc->SetAttribute(domElement, AttrHCrossPoint, QString().setNum(static_cast(dialogTool->GetHCrossPoint()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + VToolSinglePoint::SaveOptions(tag, obj); + + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrCurve1, firstCurveId); + doc->SetAttribute(tag, AttrCurve2, secondCurveId); + doc->SetAttribute(tag, AttrVCrossPoint, static_cast(vCrossPoint)); + doc->SetAttribute(tag, AttrHCrossPoint, static_cast(hCrossPoint)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::ReadToolAttributes(const QDomElement &domElement) +{ + firstCurveId = doc->GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR); + secondCurveId = doc->GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR); + vCrossPoint = static_cast(doc->GetParametrUInt(domElement, AttrVCrossPoint, "1")); + hCrossPoint = static_cast(doc->GetParametrUInt(domElement, AttrHCrossPoint, "1")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersectionCurves::SetVisualization() +{ + if (vis != nullptr) + { + auto visual = qobject_cast(vis); + SCASSERT(visual != nullptr); + + visual->setObject1Id(firstCurveId); + visual->setObject2Id(secondCurveId); + visual->setVCrossPoint(vCrossPoint); + visual->setHCrossPoint(hCrossPoint); + visual->RefreshGeometry(); + } +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h new file mode 100644 index 000000000..891ba17a6 --- /dev/null +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h @@ -0,0 +1,87 @@ +/************************************************************************ + ** + ** @file vtoolpointofintersectioncurves.h + ** @author Roman Telezhynskyi + ** @date 22 1, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** 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 . + ** + *************************************************************************/ + +#ifndef VTOOLPOINTOFINTERSECTIONCURVES_H +#define VTOOLPOINTOFINTERSECTIONCURVES_H + +#include "vtoolsinglepoint.h" + +class VToolPointOfIntersectionCurves : public VToolSinglePoint +{ + Q_OBJECT +public: + explicit VToolPointOfIntersectionCurves(VAbstractPattern *doc, VContainer *data, const quint32 &id, const + quint32 firstCurveId, quint32 secondCurveId, + VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint, + const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog() Q_DECL_OVERRIDE; + static VToolPointOfIntersectionCurves *Create(DialogTool *dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); + static VToolPointOfIntersectionCurves *Create(const quint32 _id, const QString &pointName, + quint32 firstCurveId, quint32 secondCurveId, + VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); + static QPointF FindPoint(const QVector &curve1Points, const QVector &curve2Points, + VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint); + static const QString ToolType; + virtual int type() const Q_DECL_OVERRIDE {return Type;} + enum { Type = UserType + static_cast(Tool::PointOfIntersectionCurves) }; + + quint32 GetFirstCurveId() const; + void SetFirstCurveId(const quint32 &value); + + quint32 GetSecondCurveId() const; + void SetSecondCurveId(const quint32 &value); + + VCrossCurvesPoint GetVCrossPoint() const; + void SetVCrossPoint(const VCrossCurvesPoint &value); + + HCrossCurvesPoint GetHCrossPoint() const; + void SetHCrossPoint(const HCrossCurvesPoint &value); + + virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; +protected: + virtual void RemoveReferens() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; +private: + Q_DISABLE_COPY(VToolPointOfIntersectionCurves) + + quint32 firstCurveId; + quint32 secondCurveId; + + VCrossCurvesPoint vCrossPoint; + HCrossCurvesPoint hCrossPoint; +}; + +#endif // VTOOLPOINTOFINTERSECTIONCURVES_H diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index c210f2265..b35cf5aaa 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -282,8 +282,8 @@ void VToolTriangle::SetVisualization() VisToolTriangle * visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(axisP1Id); - visual->setPoint2Id(axisP2Id); + visual->setObject1Id(axisP1Id); + visual->setObject2Id(axisP2Id); visual->setHypotenuseP1Id(firstPointId); visual->setHypotenuseP2Id(secondPointId); visual->RefreshGeometry(); diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index 59502a302..e853121b2 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -405,7 +405,7 @@ void VToolLine::SetVisualization() VisToolLine *visual = qobject_cast(vis); SCASSERT(visual != nullptr); - visual->setPoint1Id(firstPoint); + visual->setObject1Id(firstPoint); visual->setPoint2Id(secondPoint); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); diff --git a/src/libs/vtools/tools/tools.pri b/src/libs/vtools/tools/tools.pri index 37d9559d0..67eb8061e 100644 --- a/src/libs/vtools/tools/tools.pri +++ b/src/libs/vtools/tools/tools.pri @@ -46,7 +46,8 @@ HEADERS += \ $$PWD/drawTools/toolcurve/vtoolarcwithlength.h \ $$PWD/drawTools/toolpoint/vabstractpoint.h \ $$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h \ - $$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h + $$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h \ + $$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h SOURCES += \ $$PWD/vtooldetail.cpp \ @@ -90,4 +91,5 @@ SOURCES += \ $$PWD/drawTools/toolcurve/vtoolarcwithlength.cpp \ $$PWD/drawTools/toolpoint/vabstractpoint.cpp \ $$PWD/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp \ - $$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp + $$PWD/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp \ + $$PWD/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp diff --git a/src/libs/vtools/visualization/vistoolalongline.cpp b/src/libs/vtools/visualization/vistoolalongline.cpp index 2085bebb3..4d710b00b 100644 --- a/src/libs/vtools/visualization/vistoolalongline.cpp +++ b/src/libs/vtools/visualization/vistoolalongline.cpp @@ -32,7 +32,7 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), point2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), + : VisLine(data, parent), object2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), length(0) { this->mainColor = Qt::red; @@ -49,9 +49,9 @@ VisToolAlongLine::~VisToolAlongLine() {} //--------------------------------------------------------------------------------------------------------------------- -void VisToolAlongLine::setPoint2Id(const quint32 &value) +void VisToolAlongLine::setObject2Id(const quint32 &value) { - point2Id = value; + object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- @@ -63,18 +63,18 @@ void VisToolAlongLine::setLength(const QString &expression) //--------------------------------------------------------------------------------------------------------------------- void VisToolAlongLine::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); - if (point2Id <= NULL_ID) + if (object2Id <= NULL_ID) { DrawLine(line, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); } else { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(object2Id); DrawPoint(lineP2, second->toQPointF(), supportColor); DrawLine(line, QLineF(first->toQPointF(), second->toQPointF()), supportColor); diff --git a/src/libs/vtools/visualization/vistoolalongline.h b/src/libs/vtools/visualization/vistoolalongline.h index 2cf6466d1..8bf6129f6 100644 --- a/src/libs/vtools/visualization/vistoolalongline.h +++ b/src/libs/vtools/visualization/vistoolalongline.h @@ -41,13 +41,13 @@ public: virtual ~VisToolAlongLine() Q_DECL_OVERRIDE; virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void setPoint2Id(const quint32 &value); + void setObject2Id(const quint32 &value); void setLength(const QString &expression); virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Vis::ToolAlongLine)}; private: Q_DISABLE_COPY(VisToolAlongLine) - quint32 point2Id; + quint32 object2Id; QGraphicsEllipseItem *point; QGraphicsEllipseItem *lineP1; QGraphicsEllipseItem *lineP2; diff --git a/src/libs/vtools/visualization/vistoolarc.cpp b/src/libs/vtools/visualization/vistoolarc.cpp index 4b319af2d..6f93aeec8 100644 --- a/src/libs/vtools/visualization/vistoolarc.cpp +++ b/src/libs/vtools/visualization/vistoolarc.cpp @@ -45,9 +45,9 @@ VisToolArc::~VisToolArc() //--------------------------------------------------------------------------------------------------------------------- void VisToolArc::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(arcCenter, first->toQPointF(), supportColor); if (qFuzzyCompare(1 + radius, 1 + 0) == false && f1 >= 0 && f2 >= 0 && qFuzzyCompare(1 + f1, 1 + f2) == false) diff --git a/src/libs/vtools/visualization/vistoolarcwithlength.cpp b/src/libs/vtools/visualization/vistoolarcwithlength.cpp index a86b5ce5a..caeb445d4 100644 --- a/src/libs/vtools/visualization/vistoolarcwithlength.cpp +++ b/src/libs/vtools/visualization/vistoolarcwithlength.cpp @@ -45,9 +45,9 @@ VisToolArcWithLength::~VisToolArcWithLength() //--------------------------------------------------------------------------------------------------------------------- void VisToolArcWithLength::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(arcCenter, first->toQPointF(), supportColor); if (qFuzzyCompare(1 + radius, 1 + 0) == false && f1 >= 0 && qFuzzyCompare(1 + length, 1 + 0) == false) diff --git a/src/libs/vtools/visualization/vistoolbisector.cpp b/src/libs/vtools/visualization/vistoolbisector.cpp index 09aecac6f..be0d80e91 100644 --- a/src/libs/vtools/visualization/vistoolbisector.cpp +++ b/src/libs/vtools/visualization/vistoolbisector.cpp @@ -33,7 +33,7 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), point2Id(NULL_ID), point3Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr), + :VisLine(data, parent), object2Id(NULL_ID), object3Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr), line1(nullptr), line2P2(nullptr), line2(nullptr), length(0) { line1P1 = InitPoint(supportColor, this); @@ -47,15 +47,15 @@ VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent) } //--------------------------------------------------------------------------------------------------------------------- -void VisToolBisector::setPoint2Id(const quint32 &value) +void VisToolBisector::setObject2Id(const quint32 &value) { - point2Id = value; + object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- -void VisToolBisector::setPoint3Id(const quint32 &value) +void VisToolBisector::setObject3Id(const quint32 &value) { - point3Id = value; + object3Id = value; } //--------------------------------------------------------------------------------------------------------------------- @@ -71,29 +71,29 @@ VisToolBisector::~VisToolBisector() //--------------------------------------------------------------------------------------------------------------------- void VisToolBisector::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(line1P1, first->toQPointF(), supportColor); - if (point2Id <= NULL_ID) + if (object2Id <= NULL_ID) { DrawLine(line1, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); } else { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(object2Id); DrawPoint(line1P2, second->toQPointF(), supportColor); DrawLine(line1, QLineF(first->toQPointF(), second->toQPointF()), supportColor); - if (point3Id <= NULL_ID) + if (object3Id <= NULL_ID) { DrawLine(line2, QLineF(second->toQPointF(), Visualization::scenePos), supportColor); } else { - const QSharedPointer third = Visualization::data->GeometricObject(point3Id); + const QSharedPointer third = Visualization::data->GeometricObject(object3Id); DrawPoint(line2P2, third->toQPointF(), supportColor); DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor); diff --git a/src/libs/vtools/visualization/vistoolbisector.h b/src/libs/vtools/visualization/vistoolbisector.h index 0549566cc..429b28de2 100644 --- a/src/libs/vtools/visualization/vistoolbisector.h +++ b/src/libs/vtools/visualization/vistoolbisector.h @@ -39,15 +39,15 @@ public: virtual ~VisToolBisector() Q_DECL_OVERRIDE; virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void setPoint2Id(const quint32 &value); - void setPoint3Id(const quint32 &value); + void setObject2Id(const quint32 &value); + void setObject3Id(const quint32 &value); void setLength(const QString &expression); virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Vis::ToolBisector)}; private: Q_DISABLE_COPY(VisToolBisector) - quint32 point2Id; - quint32 point3Id; + quint32 object2Id; + quint32 object3Id; QGraphicsEllipseItem *point; QGraphicsEllipseItem *line1P1; QGraphicsEllipseItem *line1P2; diff --git a/src/libs/vtools/visualization/vistoolcurveintersectaxis.cpp b/src/libs/vtools/visualization/vistoolcurveintersectaxis.cpp index a1ff39d48..db7a87bbc 100644 --- a/src/libs/vtools/visualization/vistoolcurveintersectaxis.cpp +++ b/src/libs/vtools/visualization/vistoolcurveintersectaxis.cpp @@ -52,9 +52,9 @@ VisToolCurveIntersectAxis::~VisToolCurveIntersectAxis() //--------------------------------------------------------------------------------------------------------------------- void VisToolCurveIntersectAxis::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer curve = Visualization::data->GeometricObject(point1Id); + const QSharedPointer curve = Visualization::data->GeometricObject(object1Id); DrawPath(visCurve, curve->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); if (axisPointId > NULL_ID) diff --git a/src/libs/vtools/visualization/vistoolcutarc.cpp b/src/libs/vtools/visualization/vistoolcutarc.cpp index 59e5bc50f..53c023dfe 100644 --- a/src/libs/vtools/visualization/vistoolcutarc.cpp +++ b/src/libs/vtools/visualization/vistoolcutarc.cpp @@ -51,9 +51,9 @@ VisToolCutArc::~VisToolCutArc() //--------------------------------------------------------------------------------------------------------------------- void VisToolCutArc::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer arc = Visualization::data->GeometricObject(point1Id); + const QSharedPointer arc = Visualization::data->GeometricObject(object1Id); DrawPath(this, arc->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); if (qFuzzyCompare(1 + length, 1 + 0) == false) diff --git a/src/libs/vtools/visualization/vistoolcutspline.cpp b/src/libs/vtools/visualization/vistoolcutspline.cpp index 36cb6709b..a5ac3bb20 100644 --- a/src/libs/vtools/visualization/vistoolcutspline.cpp +++ b/src/libs/vtools/visualization/vistoolcutspline.cpp @@ -51,9 +51,9 @@ VisToolCutSpline::~VisToolCutSpline() //--------------------------------------------------------------------------------------------------------------------- void VisToolCutSpline::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer spl = Visualization::data->GeometricObject(point1Id); + const QSharedPointer spl = Visualization::data->GeometricObject(object1Id); DrawPath(this, spl->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); if (qFuzzyCompare(1 + length, 1 + 0) == false) diff --git a/src/libs/vtools/visualization/vistoolcutsplinepath.cpp b/src/libs/vtools/visualization/vistoolcutsplinepath.cpp index 2f37f64ac..622c2927f 100644 --- a/src/libs/vtools/visualization/vistoolcutsplinepath.cpp +++ b/src/libs/vtools/visualization/vistoolcutsplinepath.cpp @@ -51,9 +51,9 @@ VisToolCutSplinePath::~VisToolCutSplinePath() //--------------------------------------------------------------------------------------------------------------------- void VisToolCutSplinePath::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer splPath = Visualization::data->GeometricObject(point1Id); + const QSharedPointer splPath = Visualization::data->GeometricObject(object1Id); DrawPath(this, splPath->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); if (qFuzzyCompare(1 + length, 1 + 0) == false) diff --git a/src/libs/vtools/visualization/vistoolendline.cpp b/src/libs/vtools/visualization/vistoolendline.cpp index a6afe5e21..779bf342e 100644 --- a/src/libs/vtools/visualization/vistoolendline.cpp +++ b/src/libs/vtools/visualization/vistoolendline.cpp @@ -49,7 +49,7 @@ VisToolEndLine::~VisToolEndLine() //--------------------------------------------------------------------------------------------------------------------- void VisToolEndLine::RefreshGeometry() { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); QLineF line; if (qFuzzyCompare(1 + length, 1 + 0)) { diff --git a/src/libs/vtools/visualization/vistoolheight.cpp b/src/libs/vtools/visualization/vistoolheight.cpp index 100a80beb..aeb9da892 100644 --- a/src/libs/vtools/visualization/vistoolheight.cpp +++ b/src/libs/vtools/visualization/vistoolheight.cpp @@ -51,9 +51,9 @@ VisToolHeight::~VisToolHeight() //--------------------------------------------------------------------------------------------------------------------- void VisToolHeight::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(base_point, first->toQPointF(), supportColor); if (lineP1Id <= NULL_ID) diff --git a/src/libs/vtools/visualization/vistoolline.cpp b/src/libs/vtools/visualization/vistoolline.cpp index a0975fd47..9a5264087 100644 --- a/src/libs/vtools/visualization/vistoolline.cpp +++ b/src/libs/vtools/visualization/vistoolline.cpp @@ -46,7 +46,7 @@ VisToolLine::~VisToolLine() void VisToolLine::RefreshGeometry() { QLineF line; - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); if (point2Id == NULL_ID) { line = QLineF(first->toQPointF(), Visualization::scenePos); diff --git a/src/libs/vtools/visualization/vistoollineintersect.cpp b/src/libs/vtools/visualization/vistoollineintersect.cpp index 2cc7ded59..251455191 100644 --- a/src/libs/vtools/visualization/vistoollineintersect.cpp +++ b/src/libs/vtools/visualization/vistoollineintersect.cpp @@ -52,9 +52,9 @@ VisToolLineIntersect::~VisToolLineIntersect() //--------------------------------------------------------------------------------------------------------------------- void VisToolLineIntersect::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(line1P1, first->toQPointF(), supportColor); if (line1P2Id <= NULL_ID) diff --git a/src/libs/vtools/visualization/vistoollineintersectaxis.cpp b/src/libs/vtools/visualization/vistoollineintersectaxis.cpp index 50e592af2..3ba5ccc25 100644 --- a/src/libs/vtools/visualization/vistoollineintersectaxis.cpp +++ b/src/libs/vtools/visualization/vistoollineintersectaxis.cpp @@ -54,9 +54,9 @@ VisToolLineIntersectAxis::~VisToolLineIntersectAxis() //--------------------------------------------------------------------------------------------------------------------- void VisToolLineIntersectAxis::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); if (point2Id <= NULL_ID) diff --git a/src/libs/vtools/visualization/vistoolnormal.cpp b/src/libs/vtools/visualization/vistoolnormal.cpp index ed3acae8e..c5c29f8c1 100644 --- a/src/libs/vtools/visualization/vistoolnormal.cpp +++ b/src/libs/vtools/visualization/vistoolnormal.cpp @@ -32,7 +32,7 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), point2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), + : VisLine(data, parent), object2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), length(0), angle(0) { this->mainColor = Qt::red; @@ -51,12 +51,12 @@ VisToolNormal::~VisToolNormal() //--------------------------------------------------------------------------------------------------------------------- void VisToolNormal::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); - if (point2Id <= NULL_ID) + if (object2Id <= NULL_ID) { QLineF line_mouse(first->toQPointF(), Visualization::scenePos); DrawLine(line, line_mouse, supportColor); @@ -67,7 +67,7 @@ void VisToolNormal::RefreshGeometry() } else { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(object2Id); DrawPoint(lineP2, second->toQPointF(), supportColor); QLineF line_mouse(first->toQPointF(), second->toQPointF()); @@ -92,9 +92,9 @@ void VisToolNormal::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolNormal::setPoint2Id(const quint32 &value) +void VisToolNormal::setObject2Id(const quint32 &value) { - point2Id = value; + object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/vistoolnormal.h b/src/libs/vtools/visualization/vistoolnormal.h index 5fdf27677..bb2a4e67e 100644 --- a/src/libs/vtools/visualization/vistoolnormal.h +++ b/src/libs/vtools/visualization/vistoolnormal.h @@ -40,7 +40,7 @@ public: virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void setPoint2Id(const quint32 &value); + void setObject2Id(const quint32 &value); void setLength(const QString &expression); qreal GetAngle() const; void SetAngle(const qreal &value); @@ -48,7 +48,7 @@ public: enum { Type = UserType + static_cast(Vis::ToolNormal)}; private: Q_DISABLE_COPY(VisToolNormal) - quint32 point2Id; + quint32 object2Id; QGraphicsEllipseItem *point; QGraphicsEllipseItem *lineP1; QGraphicsEllipseItem *lineP2; diff --git a/src/libs/vtools/visualization/vistoolpointfromarcandtangent.cpp b/src/libs/vtools/visualization/vistoolpointfromarcandtangent.cpp index 2421a5454..162b672e5 100644 --- a/src/libs/vtools/visualization/vistoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/visualization/vistoolpointfromarcandtangent.cpp @@ -50,9 +50,9 @@ VisToolPointFromArcAndTangent::~VisToolPointFromArcAndTangent() //--------------------------------------------------------------------------------------------------------------------- void VisToolPointFromArcAndTangent::RefreshGeometry() { - if (point1Id > NULL_ID)// tangent point + if (object1Id > NULL_ID)// tangent point { - const QSharedPointer tan = Visualization::data->GeometricObject(point1Id); + const QSharedPointer tan = Visualization::data->GeometricObject(object1Id); DrawPoint(tangent, tan->toQPointF(), supportColor); if (arcId > NULL_ID)// circle center diff --git a/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.cpp b/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.cpp index 0206c67f8..9a702d7bd 100644 --- a/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.cpp @@ -33,7 +33,7 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), point2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint), + : VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint), point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr) { cPath = InitItem(Qt::darkGreen, this); @@ -50,14 +50,14 @@ VisToolPointFromCircleAndTangent::~VisToolPointFromCircleAndTangent() //--------------------------------------------------------------------------------------------------------------------- void VisToolPointFromCircleAndTangent::RefreshGeometry() { - if (point1Id > NULL_ID)// tangent point + if (object1Id > NULL_ID)// tangent point { - const QSharedPointer tan = Visualization::data->GeometricObject(point1Id); + const QSharedPointer tan = Visualization::data->GeometricObject(object1Id); DrawPoint(tangent, tan->toQPointF(), supportColor); - if (point2Id > NULL_ID)// circle center + if (object2Id > NULL_ID)// circle center { - const QSharedPointer center = Visualization::data->GeometricObject(point2Id); + const QSharedPointer center = Visualization::data->GeometricObject(object2Id); DrawPoint(cCenter, center->toQPointF(), supportColor); if (cRadius > 0) @@ -76,9 +76,9 @@ void VisToolPointFromCircleAndTangent::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointFromCircleAndTangent::setPoint2Id(const quint32 &value) +void VisToolPointFromCircleAndTangent::setObject2Id(const quint32 &value) { - point2Id = value; + object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.h b/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.h index 63aecf094..b4ea5f11b 100644 --- a/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.h +++ b/src/libs/vtools/visualization/vistoolpointfromcircleandtangent.h @@ -41,7 +41,7 @@ public: virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void setPoint2Id(const quint32 &value); + void setObject2Id(const quint32 &value); void setCRadius(const QString &value); void setCrossPoint(const CrossCirclesPoint &value); @@ -49,7 +49,7 @@ public: enum { Type = UserType + static_cast(Vis::ToolPointFromCircleAndTangent)}; private: Q_DISABLE_COPY(VisToolPointFromCircleAndTangent) - quint32 point2Id; + quint32 object2Id; qreal cRadius; CrossCirclesPoint crossPoint; QGraphicsEllipseItem *point; diff --git a/src/libs/vtools/visualization/vistoolpointofcontact.cpp b/src/libs/vtools/visualization/vistoolpointofcontact.cpp index 648c0be13..6fb471c4f 100644 --- a/src/libs/vtools/visualization/vistoolpointofcontact.cpp +++ b/src/libs/vtools/visualization/vistoolpointofcontact.cpp @@ -50,9 +50,9 @@ VisToolPointOfContact::~VisToolPointOfContact() //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfContact::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); if (lineP2Id <= NULL_ID) diff --git a/src/libs/vtools/visualization/vistoolpointofintersection.cpp b/src/libs/vtools/visualization/vistoolpointofintersection.cpp index 3c8b26f88..565919b9b 100644 --- a/src/libs/vtools/visualization/vistoolpointofintersection.cpp +++ b/src/libs/vtools/visualization/vistoolpointofintersection.cpp @@ -49,14 +49,14 @@ VisToolPointOfIntersection::~VisToolPointOfIntersection() void VisToolPointOfIntersection::RefreshGeometry() { QLineF axisL1; - if (point1Id <= NULL_ID) + if (object1Id <= NULL_ID) { axisL1 = Axis(Visualization::scenePos, 90); DrawLine(this, axisL1, supportColor, Qt::DashLine); } else { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(axisP1, first->toQPointF(), supportColor); axisL1 = Axis(first->toQPointF(), 90); diff --git a/src/libs/vtools/visualization/vistoolpointofintersectioncircles.cpp b/src/libs/vtools/visualization/vistoolpointofintersectioncircles.cpp index 8c4857355..1a624ef6b 100644 --- a/src/libs/vtools/visualization/vistoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/visualization/vistoolpointofintersectioncircles.cpp @@ -33,7 +33,7 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), point2Id(NULL_ID), c1Radius(0), c2Radius(0), + : VisLine(data, parent), object2Id(NULL_ID), c1Radius(0), c2Radius(0), crossPoint(CrossCirclesPoint::FirstPoint), point(nullptr), c1Center(nullptr), c2Center(nullptr), c1Path(nullptr), c2Path(nullptr) { @@ -51,14 +51,14 @@ VisToolPointOfIntersectionCircles::~VisToolPointOfIntersectionCircles() //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(c1Center, first->toQPointF(), supportColor); - if (point2Id > NULL_ID) + if (object2Id > NULL_ID) { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(object2Id); DrawPoint(c2Center, second->toQPointF(), supportColor); if (c1Radius > 0 && c2Radius > 0) @@ -84,7 +84,7 @@ void VisToolPointOfIntersectionCircles::VisualMode(const quint32 &id) VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr); - this->point1Id = id; + this->object1Id = id; Visualization::scenePos = scene->getScenePos(); RefreshGeometry(); @@ -92,9 +92,9 @@ void VisToolPointOfIntersectionCircles::VisualMode(const quint32 &id) } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCircles::setPoint2Id(const quint32 &value) +void VisToolPointOfIntersectionCircles::setObject2Id(const quint32 &value) { - point2Id = value; + object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/vistoolpointofintersectioncircles.h b/src/libs/vtools/visualization/vistoolpointofintersectioncircles.h index 46a72da98..73d97a0ad 100644 --- a/src/libs/vtools/visualization/vistoolpointofintersectioncircles.h +++ b/src/libs/vtools/visualization/vistoolpointofintersectioncircles.h @@ -42,7 +42,7 @@ public: virtual void RefreshGeometry() Q_DECL_OVERRIDE; virtual void VisualMode(const quint32 &id) Q_DECL_OVERRIDE; - void setPoint2Id(const quint32 &value); + void setObject2Id(const quint32 &value); void setC1Radius(const QString &value); void setC2Radius(const QString &value); void setCrossPoint(const CrossCirclesPoint &value); @@ -51,7 +51,7 @@ public: enum { Type = UserType + static_cast(Vis::ToolPointOfIntersectionCircles)}; private: Q_DISABLE_COPY(VisToolPointOfIntersectionCircles) - quint32 point2Id; + quint32 object2Id; qreal c1Radius; qreal c2Radius; CrossCirclesPoint crossPoint; diff --git a/src/libs/vtools/visualization/vistoolpointofintersectioncurves.cpp b/src/libs/vtools/visualization/vistoolpointofintersectioncurves.cpp new file mode 100644 index 000000000..7dc7f293f --- /dev/null +++ b/src/libs/vtools/visualization/vistoolpointofintersectioncurves.cpp @@ -0,0 +1,94 @@ +/************************************************************************ + ** + ** @file vistoolpointofintersectioncurves.cpp + ** @author Roman Telezhynskyi + ** @date 24 1, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** 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 . + ** + *************************************************************************/ + +#include "vistoolpointofintersectioncurves.h" +#include "../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointOfIntersectionCurves::VisToolPointOfIntersectionCurves(const VContainer *data, QGraphicsItem *parent) + :VisPath(data, parent), + object2Id(NULL_ID), + vCrossPoint(VCrossCurvesPoint::HighestPoint), + hCrossPoint(HCrossCurvesPoint::LeftPoint), + point(nullptr), + visCurve2(nullptr) +{ + visCurve2 = InitItem(supportColor, this); + point = InitPoint(mainColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionCurves::RefreshGeometry() +{ + if (object1Id > NULL_ID) + { + auto curve1 = Visualization::data->GeometricObject(object1Id); + DrawPath(this, curve1->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); + + if (object2Id > NULL_ID) + { + auto curve2 = Visualization::data->GeometricObject(object2Id); + DrawPath(visCurve2, curve2->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap); + + auto p = VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), vCrossPoint, + hCrossPoint); + DrawPoint(point, p, mainColor); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionCurves::VisualMode(const quint32 &id) +{ + auto scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr); + + this->object1Id = id; + Visualization::scenePos = scene->getScenePos(); + RefreshGeometry(); + + AddOnScene(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionCurves::setObject2Id(const quint32 &value) +{ + object2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionCurves::setVCrossPoint(const VCrossCurvesPoint &value) +{ + vCrossPoint = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointOfIntersectionCurves::setHCrossPoint(const HCrossCurvesPoint &value) +{ + hCrossPoint = value; +} diff --git a/src/libs/vtools/visualization/vistoolpointofintersectioncurves.h b/src/libs/vtools/visualization/vistoolpointofintersectioncurves.h new file mode 100644 index 000000000..c97fc550a --- /dev/null +++ b/src/libs/vtools/visualization/vistoolpointofintersectioncurves.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file vistoolpointofintersectioncurves.h + ** @author Roman Telezhynskyi + ** @date 24 1, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** 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 . + ** + *************************************************************************/ + +#ifndef VISTOOLPOINTOFINTERSECTIONCURVES_H +#define VISTOOLPOINTOFINTERSECTIONCURVES_H + +#include "vispath.h" +#include "../ifc/xml/vabstractpattern.h" + +class VisToolPointOfIntersectionCurves : public VisPath +{ + Q_OBJECT +public: + explicit VisToolPointOfIntersectionCurves(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolPointOfIntersectionCurves() Q_DECL_OVERRIDE {} + + virtual void RefreshGeometry() Q_DECL_OVERRIDE; + virtual void VisualMode(const quint32 &id) Q_DECL_OVERRIDE; + + void setObject2Id(const quint32 &value); + void setVCrossPoint(const VCrossCurvesPoint &value); + void setHCrossPoint(const HCrossCurvesPoint &value); + + virtual int type() const Q_DECL_OVERRIDE {return Type;} + enum { Type = UserType + static_cast(Vis::ToolPointOfIntersectionCurves)}; +private: + Q_DISABLE_COPY(VisToolPointOfIntersectionCurves) + quint32 object2Id; + VCrossCurvesPoint vCrossPoint; + HCrossCurvesPoint hCrossPoint; + + QGraphicsEllipseItem *point; + QGraphicsPathItem *visCurve2; + +}; + +#endif // VISTOOLPOINTOFINTERSECTIONCURVES_H diff --git a/src/libs/vtools/visualization/vistoolshoulderpoint.cpp b/src/libs/vtools/visualization/vistoolshoulderpoint.cpp index 2444c3ba0..bdee934e3 100644 --- a/src/libs/vtools/visualization/vistoolshoulderpoint.cpp +++ b/src/libs/vtools/visualization/vistoolshoulderpoint.cpp @@ -53,9 +53,9 @@ VisToolShoulderPoint::~VisToolShoulderPoint() //--------------------------------------------------------------------------------------------------------------------- void VisToolShoulderPoint::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(line1P1, first->toQPointF(), supportColor); if (lineP1Id <= NULL_ID) diff --git a/src/libs/vtools/visualization/vistoolspline.cpp b/src/libs/vtools/visualization/vistoolspline.cpp index 5c80ffeaf..229c959ed 100644 --- a/src/libs/vtools/visualization/vistoolspline.cpp +++ b/src/libs/vtools/visualization/vistoolspline.cpp @@ -35,7 +35,7 @@ const int EMPTY_ANGLE = -1; //--------------------------------------------------------------------------------------------------------------------- VisToolSpline::VisToolSpline(const VContainer *data, QGraphicsItem *parent) - : VisPath(data, parent), point4Id(NULL_ID), lineP1(nullptr), lineP4(nullptr), line(nullptr), angle1(EMPTY_ANGLE), + : VisPath(data, parent), object4Id(NULL_ID), lineP1(nullptr), lineP4(nullptr), line(nullptr), angle1(EMPTY_ANGLE), angle2(EMPTY_ANGLE), kAsm1(1), kAsm2(1), kCurve(1) { lineP1 = InitPoint(supportColor, this); @@ -50,18 +50,18 @@ VisToolSpline::~VisToolSpline() //--------------------------------------------------------------------------------------------------------------------- void VisToolSpline::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(lineP1, first->toQPointF(), supportColor); - if (point4Id <= NULL_ID) + if (object4Id <= NULL_ID) { DrawLine(line, QLineF(first->toQPointF(), Visualization::scenePos), mainColor); } else { - const QSharedPointer second = Visualization::data->GeometricObject(point4Id); + const QSharedPointer second = Visualization::data->GeometricObject(object4Id); DrawPoint(lineP4, second->toQPointF(), supportColor); if (qFuzzyCompare(angle1, EMPTY_ANGLE) || qFuzzyCompare(angle2, EMPTY_ANGLE)) @@ -78,9 +78,9 @@ void VisToolSpline::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::setPoint4Id(const quint32 &value) +void VisToolSpline::setObject4Id(const quint32 &value) { - point4Id = value; + object4Id = value; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/vistoolspline.h b/src/libs/vtools/visualization/vistoolspline.h index 4255f5fa6..fb6f780d3 100644 --- a/src/libs/vtools/visualization/vistoolspline.h +++ b/src/libs/vtools/visualization/vistoolspline.h @@ -40,7 +40,7 @@ public: virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void setPoint4Id(const quint32 &value); + void setObject4Id(const quint32 &value); void SetAngle1(const qreal &value); void SetAngle2(const qreal &value); void SetKAsm1(const qreal &value); @@ -51,7 +51,7 @@ public: enum { Type = UserType + static_cast(Vis::ToolSpline)}; protected: Q_DISABLE_COPY(VisToolSpline) - quint32 point4Id; + quint32 object4Id; QGraphicsEllipseItem *lineP1; QGraphicsEllipseItem *lineP4; QGraphicsLineItem *line; diff --git a/src/libs/vtools/visualization/vistooltriangle.cpp b/src/libs/vtools/visualization/vistooltriangle.cpp index 7de51bd49..7f84f8e41 100644 --- a/src/libs/vtools/visualization/vistooltriangle.cpp +++ b/src/libs/vtools/visualization/vistooltriangle.cpp @@ -34,7 +34,7 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), point2Id(NULL_ID), hypotenuseP1Id(NULL_ID), hypotenuseP2Id(NULL_ID), point(nullptr), + :VisLine(data, parent), object2Id(NULL_ID), hypotenuseP1Id(NULL_ID), hypotenuseP2Id(NULL_ID), point(nullptr), axisP1(nullptr), axisP2(nullptr), axis(nullptr), hypotenuseP1(nullptr), hypotenuseP2(nullptr), foot1(nullptr), foot2(nullptr) { @@ -56,18 +56,18 @@ VisToolTriangle::~VisToolTriangle() //--------------------------------------------------------------------------------------------------------------------- void VisToolTriangle::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(point1Id); + const QSharedPointer first = Visualization::data->GeometricObject(object1Id); DrawPoint(axisP1, first->toQPointF(), supportColor); - if (point2Id <= NULL_ID) + if (object2Id <= NULL_ID) { DrawAimedAxis(axis, QLineF(first->toQPointF(), Visualization::scenePos), supportColor); } else { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = Visualization::data->GeometricObject(object2Id); DrawPoint(axisP2, second->toQPointF(), supportColor); DrawAimedAxis(axis, QLineF(first->toQPointF(), second->toQPointF()), supportColor); @@ -112,9 +112,9 @@ void VisToolTriangle::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolTriangle::setPoint2Id(const quint32 &value) +void VisToolTriangle::setObject2Id(const quint32 &value) { - point2Id = value; + object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/vistooltriangle.h b/src/libs/vtools/visualization/vistooltriangle.h index a97d891a2..8e0e4de45 100644 --- a/src/libs/vtools/visualization/vistooltriangle.h +++ b/src/libs/vtools/visualization/vistooltriangle.h @@ -40,7 +40,7 @@ public: virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void setPoint2Id(const quint32 &value); + void setObject2Id(const quint32 &value); void setHypotenuseP1Id(const quint32 &value); void setHypotenuseP2Id(const quint32 &value); @@ -48,7 +48,7 @@ public: enum { Type = UserType + static_cast(Vis::ToolTriangle)}; private: Q_DISABLE_COPY(VisToolTriangle) - quint32 point2Id;//axis second point + quint32 object2Id;//axis second point quint32 hypotenuseP1Id; quint32 hypotenuseP2Id; QGraphicsEllipseItem *point; diff --git a/src/libs/vtools/visualization/vistooltruedarts.cpp b/src/libs/vtools/visualization/vistooltruedarts.cpp index ea52dd767..f0072ad3c 100644 --- a/src/libs/vtools/visualization/vistooltruedarts.cpp +++ b/src/libs/vtools/visualization/vistooltruedarts.cpp @@ -72,9 +72,9 @@ VisToolTrueDarts::~VisToolTrueDarts() //--------------------------------------------------------------------------------------------------------------------- void VisToolTrueDarts::RefreshGeometry() { - if (point1Id > NULL_ID) + if (object1Id > NULL_ID) { - const QSharedPointer blP1 = Visualization::data->GeometricObject(point1Id); + const QSharedPointer blP1 = Visualization::data->GeometricObject(object1Id); DrawPoint(baseLineP1, blP1->toQPointF(), supportColor); if (baseLineP2Id <= NULL_ID) @@ -135,7 +135,7 @@ void VisToolTrueDarts::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolTrueDarts::setPoint2Id(const quint32 &value) +void VisToolTrueDarts::setObject2Id(const quint32 &value) { baseLineP2Id = value; } diff --git a/src/libs/vtools/visualization/vistooltruedarts.h b/src/libs/vtools/visualization/vistooltruedarts.h index 4eaaba3da..4843472ce 100644 --- a/src/libs/vtools/visualization/vistooltruedarts.h +++ b/src/libs/vtools/visualization/vistooltruedarts.h @@ -40,7 +40,7 @@ public: virtual void RefreshGeometry() Q_DECL_OVERRIDE; - void setPoint2Id(const quint32 &value); + void setObject2Id(const quint32 &value); void setD1PointId(const quint32 &value); void setD2PointId(const quint32 &value); void setD3PointId(const quint32 &value); diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index 18203df56..021fe639a 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -38,7 +38,7 @@ Q_LOGGING_CATEGORY(vVis, "v.visualization") //--------------------------------------------------------------------------------------------------------------------- Visualization::Visualization(const VContainer *data) :QObject(), data(data), factor(VDrawTool::factor), scenePos(QPointF()), - mainColor(Qt::red), supportColor(Qt::magenta), lineStyle(Qt::SolidLine), point1Id(NULL_ID), toolTip(QString()) + mainColor(Qt::red), supportColor(Qt::magenta), lineStyle(Qt::SolidLine), object1Id(NULL_ID), toolTip(QString()) {} //--------------------------------------------------------------------------------------------------------------------- @@ -46,9 +46,9 @@ Visualization::~Visualization() {} //--------------------------------------------------------------------------------------------------------------------- -void Visualization::setPoint1Id(const quint32 &value) +void Visualization::setObject1Id(const quint32 &value) { - point1Id = value; + object1Id = value; } //--------------------------------------------------------------------------------------------------------------------- @@ -71,7 +71,7 @@ void Visualization::VisualMode(const quint32 &pointId) VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr); - this->point1Id = pointId; + this->object1Id = pointId; this->scenePos = scene->getScenePos(); RefreshGeometry(); diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h index ad3dc7b5e..a43f0bd36 100644 --- a/src/libs/vtools/visualization/visualization.h +++ b/src/libs/vtools/visualization/visualization.h @@ -48,7 +48,7 @@ public: virtual void RefreshGeometry()=0; - void setPoint1Id(const quint32 &value); + void setObject1Id(const quint32 &value); void setLineStyle(const Qt::PenStyle &value); void setScenePos(const QPointF &value); virtual void VisualMode(const quint32 &pointId); @@ -65,7 +65,7 @@ protected: QColor mainColor; QColor supportColor; Qt::PenStyle lineStyle; - quint32 point1Id; + quint32 object1Id; QString toolTip; virtual void InitPen()=0; diff --git a/src/libs/vtools/visualization/visualization.pri b/src/libs/vtools/visualization/visualization.pri index 23105fd73..bfb09ba0c 100644 --- a/src/libs/vtools/visualization/visualization.pri +++ b/src/libs/vtools/visualization/visualization.pri @@ -29,7 +29,8 @@ HEADERS += \ $$PWD/vistoolpointfromcircleandtangent.h \ $$PWD/vistoolpointfromarcandtangent.h \ $$PWD/vistoolarcwithlength.h \ - visualization/vistooltruedarts.h + $$PWD/vistooltruedarts.h \ + $$PWD/vistoolpointofintersectioncurves.h SOURCES += \ $$PWD/visline.cpp \ @@ -59,4 +60,5 @@ SOURCES += \ $$PWD/vistoolpointfromcircleandtangent.cpp \ $$PWD/vistoolpointfromarcandtangent.cpp \ $$PWD/vistoolarcwithlength.cpp \ - visualization/vistooltruedarts.cpp + $$PWD/vistooltruedarts.cpp \ + $$PWD/vistoolpointofintersectioncurves.cpp