diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index d4663186d..81362cb04 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -392,6 +392,14 @@ QString DialogHistory::Record(const VToolRecord &tool) { return QString(tr("%1 - point of circles intersection")).arg(PointName(tool.getId())); } + case Tool::PointFromCircleAndTangent: + { + return QString(tr("%1 - point from circle and tangent")).arg(PointName(tool.getId())); + } + case Tool::PointFromArcAndTangent: + { + return QString(tr("%1 - point from arc and tangent")).arg(PointName(tool.getId())); + } //Because "history" not only show history of pattern, but help restore current data for each pattern's //piece, we need add record about details and nodes, but don't show them. case Tool::Detail: diff --git a/src/app/dialogs/dialogs.h b/src/app/dialogs/dialogs.h index fd7f165a6..dddeeed3e 100644 --- a/src/app/dialogs/dialogs.h +++ b/src/app/dialogs/dialogs.h @@ -54,6 +54,7 @@ #include "tools/dialogpointofintersectionarcs.h" #include "tools/dialogpointofintersectioncircles.h" #include "tools/dialogpointfromcircleandtangent.h" +#include "tools/dialogpointfromarcandtangent.h" #include "app/dialoghistory.h" #include "app/dialogincrements.h" diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri index 92a97ef7f..33234c153 100644 --- a/src/app/dialogs/dialogs.pri +++ b/src/app/dialogs/dialogs.pri @@ -47,7 +47,8 @@ HEADERS += \ $$PWD/app/dialogsavelayout.h \ $$PWD/tools/dialogpointofintersectionarcs.h \ $$PWD/tools/dialogpointofintersectioncircles.h \ - $$PWD/tools/dialogpointfromcircleandtangent.h + $$PWD/tools/dialogpointfromcircleandtangent.h \ + dialogs/tools/dialogpointfromarcandtangent.h SOURCES += \ $$PWD/tools/dialogtriangle.cpp \ @@ -93,7 +94,8 @@ SOURCES += \ $$PWD/app/dialogsavelayout.cpp \ $$PWD/tools/dialogpointofintersectionarcs.cpp \ $$PWD/tools/dialogpointofintersectioncircles.cpp \ - $$PWD/tools/dialogpointfromcircleandtangent.cpp + $$PWD/tools/dialogpointfromcircleandtangent.cpp \ + dialogs/tools/dialogpointfromarcandtangent.cpp FORMS += \ $$PWD/tools/dialogtriangle.ui \ @@ -133,4 +135,5 @@ FORMS += \ $$PWD/app/dialogsavelayout.ui \ $$PWD/tools/dialogpointofintersectionarcs.ui \ $$PWD/tools/dialogpointofintersectioncircles.ui \ - $$PWD/tools/dialogpointfromcircleandtangent.ui + $$PWD/tools/dialogpointfromcircleandtangent.ui \ + dialogs/tools/dialogpointfromarcandtangent.ui diff --git a/src/app/dialogs/tools/dialogpointfromarcandtangent.cpp b/src/app/dialogs/tools/dialogpointfromarcandtangent.cpp new file mode 100644 index 000000000..87c1810cc --- /dev/null +++ b/src/app/dialogs/tools/dialogpointfromarcandtangent.cpp @@ -0,0 +1,186 @@ +/************************************************************************ + ** + ** @file dialogpointfromarcandtangent.cpp + ** @author Roman Telezhynskyi + ** @date 5 6, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** 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 "dialogpointfromarcandtangent.h" +#include "ui_dialogpointfromarcandtangent.h" + +#include "../../libs/vgeometry/vpointf.h" +#include "../../container/vcontainer.h" +#include "../../visualization/vistoolpointfromarcandtangent.h" +#include "../../widgets/vmaingraphicsscene.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId, + QWidget *parent) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointFromArcAndTangent) +{ + ui->setupUi(this); + + ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); + labelEditNamePoint = ui->labelEditNamePoint; + + InitOkCancelApply(ui); + CheckState(); + + FillComboBoxPoints(ui->comboBoxTangentPoint); + FillComboBoxArcs(ui->comboBoxArc); + FillComboBoxCrossCirclesPoints(ui->comboBoxResult); + + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointFromArcAndTangent::NamePointChanged); + + vis = new VisToolPointFromArcAndTangent(data); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogPointFromArcAndTangent::~DialogPointFromArcAndTangent() +{ + DeleteVisualization(); + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointFromArcAndTangent::SetPointName(const QString &value) +{ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPointFromArcAndTangent::GetArcId() const +{ + return getCurrentObjectId(ui->comboBoxArc); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointFromArcAndTangent::SetArcId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxArc, value); + + VisToolPointFromArcAndTangent *point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setArcId(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 DialogPointFromArcAndTangent::GetTangentPointId() const +{ + return getCurrentObjectId(ui->comboBoxTangentPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointFromArcAndTangent::SetTangentPointId(const quint32 &value) +{ + setCurrentPointId(ui->comboBoxTangentPoint, value); + + VisToolPointFromArcAndTangent *point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +CrossCirclesPoint DialogPointFromArcAndTangent::GetCrossCirclesPoint() const +{ + return getCurrentCrossPoint(ui->comboBoxResult); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint &p) +{ + const qint32 index = ui->comboBoxResult->findData(static_cast(p)); + if (index != -1) + { + ui->comboBoxResult->setCurrentIndex(index); + + VisToolPointFromArcAndTangent *point = qobject_cast(vis); + SCASSERT(point != nullptr); + point->setCrossPoint(p); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &type) +{ + if (prepare == false)// After first choose we ignore all objects + { + if (type == SceneObject::Point || type == SceneObject::Arc) + { + VisToolPointFromArcAndTangent *point = qobject_cast(vis); + SCASSERT(point != nullptr); + + switch (number) + { + case 0: + if (type == SceneObject::Point) + { + if (SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc"))) + { + number++; + point->VisualMode(id); + } + } + break; + case 1: + if (type == SceneObject::Arc) + { + if (SetObject(id, ui->comboBoxArc, "")) + { + number = 0; + point->setArcId(id); + point->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } + break; + default: + break; + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointFromArcAndTangent::ShowVisualization() +{ + AddVisualization(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPointFromArcAndTangent::SaveData() +{ + pointName = ui->lineEditNamePoint->text(); + + VisToolPointFromArcAndTangent *point = qobject_cast(vis); + SCASSERT(point != nullptr); + + point->setPoint1Id(GetTangentPointId()); + point->setArcId(GetArcId()); + point->setCrossPoint(GetCrossCirclesPoint()); + point->RefreshGeometry(); +} diff --git a/src/app/dialogs/tools/dialogpointfromarcandtangent.h b/src/app/dialogs/tools/dialogpointfromarcandtangent.h new file mode 100644 index 000000000..2b21f4bab --- /dev/null +++ b/src/app/dialogs/tools/dialogpointfromarcandtangent.h @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file dialogpointfromarcandtangent.h + ** @author Roman Telezhynskyi + ** @date 5 6, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** 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 DIALOGPOINTFROMARCANDTANGENT_H +#define DIALOGPOINTFROMARCANDTANGENT_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogPointFromArcAndTangent; +} + +class DialogPointFromArcAndTangent : public DialogTool +{ + Q_OBJECT + +public: + DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = 0); + ~DialogPointFromArcAndTangent(); + + + void SetPointName(const QString &value); + + quint32 GetArcId() const; + void SetArcId(const quint32 &value); + + quint32 GetTangentPointId() const; + void SetTangentPointId(const quint32 &value); + + CrossCirclesPoint GetCrossCirclesPoint() const; + void SetCrossCirclesPoint(CrossCirclesPoint &p); + +public slots: + virtual void ChosenObject(quint32 id, const SceneObject &type); + +protected: + virtual void ShowVisualization(); + /** + * @brief SaveData Put dialog data in local variables + */ + virtual void SaveData(); + +private: + Q_DISABLE_COPY(DialogPointFromArcAndTangent) + + Ui::DialogPointFromArcAndTangent *ui; +}; + +#endif // DIALOGPOINTFROMARCANDTANGENT_H diff --git a/src/app/dialogs/tools/dialogpointfromarcandtangent.ui b/src/app/dialogs/tools/dialogpointfromarcandtangent.ui new file mode 100644 index 000000000..bf40054db --- /dev/null +++ b/src/app/dialogs/tools/dialogpointfromarcandtangent.ui @@ -0,0 +1,173 @@ + + + DialogPointFromArcAndTangent + + + + 0 + 0 + 370 + 179 + + + + + 370 + 179 + + + + + 370 + 179 + + + + Dialog + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + + 0 + 0 + + + + Point label + + + + + + + + + + + 0 + 0 + + + + Tangent point + + + + + + + + 0 + 0 + + + + + 143 + 0 + + + + + + + + + 0 + 0 + + + + Arc + + + + + + + + 0 + 0 + + + + + 145 + 0 + + + + Select point of center of arc + + + + + + + Take + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogPointFromArcAndTangent + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPointFromArcAndTangent + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index a2a28d5d2..7df3198d9 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -722,7 +722,17 @@ void MainWindow::ToolPointFromCircleAndTangent(bool checked) "://cursor/point_from_circle_and_tangent_cursor.png", tr("Select point on tangent "), &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ApplyDialog); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolPointFromArcAndTangent(bool checked) +{ + SetToolButtonWithApply(checked, Tool::PointFromArcAndTangent, + "://cursor/point_from_arc_and_tangent_cursor.png", + tr("Select point on tangent "), + &MainWindow::ClosedDialogWithApply, + &MainWindow::ApplyDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1026,6 +1036,7 @@ void MainWindow::InitToolButtons() &MainWindow::ToolPointOfIntersectionCircles); connect(ui->toolButtonPointFromCircleAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromCircleAndTangent); + connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent); } //--------------------------------------------------------------------------------------------------------------------- @@ -2173,6 +2184,7 @@ void MainWindow::SetEnableTool(bool enable) ui->toolButtonPointOfIntersectionArcs->setEnabled(drawTools); ui->toolButtonPointOfIntersectionCircles->setEnabled(drawTools); ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools); + ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools); @@ -2543,6 +2555,10 @@ void MainWindow::LastUsedTool() ui->toolButtonPointFromCircleAndTangent->setChecked(true); ToolPointFromCircleAndTangent(true); break; + case Tool::PointFromArcAndTangent: + ui->toolButtonPointFromArcAndTangent->setChecked(true); + ToolPointFromArcAndTangent(true); + break; case Tool::NodePoint: case Tool::NodeArc: case Tool::NodeSpline: diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 2455b8de5..e580938d1 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -118,6 +118,7 @@ public slots: void ToolPointOfIntersectionArcs(bool checked); void ToolPointOfIntersectionCircles(bool checked); void ToolPointFromCircleAndTangent(bool checked); + void ToolPointFromArcAndTangent(bool checked); void ClosedDialogDetail(int result); void ClosedDialogUnionDetails(int result); diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index e7ed1cf2f..3860bec9b 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -573,7 +573,7 @@ 0 0 120 - 150 + 196 @@ -745,6 +745,32 @@ + + + + false + + + Point from arc and tangent + + + ... + + + + :/icon/32x32/point_from_arc_and_tangent.png:/icon/32x32/point_from_arc_and_tangent.png + + + + 32 + 32 + + + + true + + + diff --git a/src/app/options.h b/src/app/options.h index 7abc0feec..f265dfc5f 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -91,12 +91,13 @@ enum class Tool : unsigned char CurveIntersectAxis, PointOfIntersection, PointFromCircleAndTangent, - UnionDetails // 33 + PointFromArcAndTangent, + UnionDetails // 34 }; enum class Vis : unsigned char { - ControlPointSpline = 34, // increase this value if need more positions in Tool enum + ControlPointSpline = 35, // increase this value if need more positions in Tool enum GraphicsSimpleTextItem, SimpleSplinePath, Line, @@ -115,6 +116,7 @@ enum class Vis : unsigned char ToolPointOfIntersectionArcs, ToolPointOfIntersectionCircles, ToolPointFromCircleAndTangent, + ToolPointFromArcAndTangent, ToolShoulderPoint, ToolSpline, ToolTriangle, diff --git a/src/app/share/resources/cursor.qrc b/src/app/share/resources/cursor.qrc index 442106fb8..a4059e34f 100644 --- a/src/app/share/resources/cursor.qrc +++ b/src/app/share/resources/cursor.qrc @@ -27,5 +27,6 @@ cursor/point_of_intersection_arcs.png cursor/point_of_intersection_circles.png cursor/point_from_circle_and_tangent_cursor.png + cursor/point_from_arc_and_tangent_cursor.png diff --git a/src/app/share/resources/cursor/point_from_arc_and_tangent_cursor.png b/src/app/share/resources/cursor/point_from_arc_and_tangent_cursor.png new file mode 100644 index 000000000..cdff4a74d Binary files /dev/null and b/src/app/share/resources/cursor/point_from_arc_and_tangent_cursor.png differ diff --git a/src/app/share/resources/icon.qrc b/src/app/share/resources/icon.qrc index 9dde5b4e5..bd9405c17 100644 --- a/src/app/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -64,5 +64,6 @@ icon/32x32/point_of_intersection_arcs.png icon/32x32/point_of_intersection_circles.png icon/32x32/point_from_circle_and_tangent.png + icon/32x32/point_from_arc_and_tangent.png diff --git a/src/app/share/resources/icon/32x32/point_from_arc_and_tangent.png b/src/app/share/resources/icon/32x32/point_from_arc_and_tangent.png new file mode 100644 index 000000000..d021dd57d Binary files /dev/null and b/src/app/share/resources/icon/32x32/point_from_arc_and_tangent.png differ diff --git a/src/app/share/resources/icon/svg/point_from_arc_and_tangent.svg b/src/app/share/resources/icon/svg/point_from_arc_and_tangent.svg new file mode 100644 index 000000000..ac6cce9ee --- /dev/null +++ b/src/app/share/resources/icon/svg/point_from_arc_and_tangent.svg @@ -0,0 +1,80 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/app/tools/drawTools/drawtools.h b/src/app/tools/drawTools/drawtools.h index ab8766669..e9a73ca45 100644 --- a/src/app/tools/drawTools/drawtools.h +++ b/src/app/tools/drawTools/drawtools.h @@ -52,5 +52,6 @@ #include "vtoollineintersectaxis.h" #include "vtoolcurveintersectaxis.h" #include "vtoolpointfromcircleandtangent.h" +#include "vtoolpointfromarcandtangent.h" #endif // DRAWTOOLS_H diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index 9792f96a8..8f1a35d89 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -34,7 +34,6 @@ #include "../../visualization/vistoolcutarc.h" const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); -const QString VToolCutArc::AttrArc = QStringLiteral("arc"); //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h index 1c5b4978b..cfe4d11b6 100644 --- a/src/app/tools/drawTools/vtoolcutarc.h +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -47,7 +47,6 @@ public: const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; - static const QString AttrArc; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::CutArc)}; virtual void ShowVisualization(bool show); diff --git a/src/app/tools/drawTools/vtoolpointfromarcandtangent.cpp b/src/app/tools/drawTools/vtoolpointfromarcandtangent.cpp new file mode 100644 index 000000000..937328390 --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointfromarcandtangent.cpp @@ -0,0 +1,319 @@ +/************************************************************************ + ** + ** @file vtoolpointfromarcandtangent.cpp + ** @author Roman Telezhynskyi + ** @date 6 6, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** 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 "vtoolpointfromarcandtangent.h" +#include "../../dialogs/tools/dialogpointfromarcandtangent.h" +#include "../../libs/vgeometry/vpointf.h" +#include "../../libs/vgeometry/varc.h" +#include "../../visualization/vistoolpointfromarcandtangent.h" + +const QString VToolPointFromArcAndTangent::ToolType = QStringLiteral("pointFromArcAndTangent"); + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(VPattern *doc, VContainer *data, const quint32 &id, + quint32 arcId, quint32 tangentPointId, + CrossCirclesPoint crossPoint, const Source &typeCreation, + QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), arcId(arcId), tangentPointId(tangentPointId), crossPoint(crossPoint) +{ + ToolCreation(typeCreation); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::setDialog() +{ + SCASSERT(dialog != nullptr); + DialogPointFromArcAndTangent *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const QSharedPointer p = VAbstractTool::data.GeometricObject(id); + dialogTool->SetArcId(arcId); + dialogTool->SetCrossCirclesPoint(crossPoint); + dialogTool->SetTangentPointId(tangentPointId); + dialogTool->SetPointName(p->name()); +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(DialogTool *dialog, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data) +{ + SCASSERT(dialog != nullptr); + DialogPointFromArcAndTangent *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + const quint32 arcId = dialogTool->GetArcId(); + const quint32 tangentPointId = dialogTool->GetTangentPointId(); + const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint(); + const QString pointName = dialogTool->getPointName(); + VToolPointFromArcAndTangent *point = nullptr; + point = Create(0, pointName, arcId, tangentPointId, pType, 5, 10, scene, doc, data, Document::FullParse, + Source::FromGui); + if (point != nullptr) + { + point->dialog=dialogTool; + } + return point; +} + +//--------------------------------------------------------------------------------------------------------------------- +VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _id, const QString &pointName, + quint32 arcId, quint32 tangentPointId, + CrossCirclesPoint crossPoint, const qreal &mx, + const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + const VArc arc = *data->GeometricObject(arcId); + const VPointF tPoint = *data->GeometricObject(tangentPointId); + + const QPointF point = VToolPointFromArcAndTangent::FindPoint(tPoint.toQPointF(), &arc, crossPoint); + 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::PointFromArcAndTangent, doc); + if (parse == Document::FullParse) + { + VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId, + crossPoint, typeCreation); + scene->addItem(point); + connect(point, &VToolPointFromArcAndTangent::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointFromArcAndTangent::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromArcAndTangent::Disable); + connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromArcAndTangent::EnableToolMove); + doc->AddTool(id, point); + doc->IncrementReferens(arcId); + doc->IncrementReferens(tangentPointId); + return point; + } + return nullptr; +} + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VToolPointFromArcAndTangent::FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType) +{ + QPointF p1, p2; + const QPointF center = arc->GetCenter().toQPointF(); + const qreal radius = arc->GetRadius(); + const int res = VGObject::ContactPoints (p, center, radius, p1, p2); + + QLineF r1Arc(center, p1); + r1Arc.setLength(radius+10); + + QLineF r2Arc(center, p2); + r2Arc.setLength(radius+10); + + switch(res) + { + case 2: + { + int localRes = 0; + bool flagP1 = false; + + if (arc->IsIntersectLine(r1Arc)) + { + ++localRes; + flagP1 = true; + } + + if (arc->IsIntersectLine(r2Arc)) + { + ++localRes; + } + + switch(localRes) + { + case 2: + if (pType == CrossCirclesPoint::FirstPoint) + { + return p1; + } + else + { + return p2; + } + break; + case 1: + if (flagP1) + { + return p1; + } + else + { + return p2; + } + break; + case 0: + default: + return QPointF(0, 0); + break; + } + + break; + } + case 1: + if (arc->IsIntersectLine(r1Arc)) + { + return p1; + } + else + { + return QPointF(0, 0); + } + break; + case 3: + case 0: + default: + return QPointF(0, 0); + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointFromArcAndTangent::GetTangentPointId() const +{ + return tangentPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::SetTangentPointId(const quint32 &value) +{ + if (value != NULL_ID) + { + tangentPointId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointFromArcAndTangent::GetArcId() const +{ + return arcId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::SetArcId(const quint32 &value) +{ + if (value != NULL_ID) + { + arcId = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +CrossCirclesPoint VToolPointFromArcAndTangent::GetCrossCirclesPoint() const +{ + return crossPoint; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint &value) +{ + crossPoint = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::ShowVisualization(bool show) +{ + ShowToolVisualization(show); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::RemoveReferens() +{ + doc->DecrementReferens(arcId); + doc->DecrementReferens(tangentPointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + ContextMenu(this, event); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement) +{ + SCASSERT(dialog != nullptr); + DialogPointFromArcAndTangent *dialogTool = qobject_cast(dialog); + SCASSERT(dialogTool != nullptr); + doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); + doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->GetArcId())); + doc->SetAttribute(domElement, AttrTangent, QString().setNum(dialogTool->GetTangentPointId())); + doc->SetAttribute(domElement, AttrCrossPoint, + QString().setNum(static_cast(dialogTool->GetCrossCirclesPoint()))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::SaveOptions(QDomElement &tag, QSharedPointer &obj) +{ + VToolPoint::SaveOptions(tag, obj); + + doc->SetAttribute(tag, AttrType, ToolType); + doc->SetAttribute(tag, AttrArc, arcId); + doc->SetAttribute(tag, AttrTangent, tangentPointId); + doc->SetAttribute(tag, AttrCrossPoint, static_cast(crossPoint)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::ReadToolAttributes(const QDomElement &domElement) +{ + arcId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR); + tangentPointId = doc->GetParametrUInt(domElement, AttrTangent, NULL_ID_STR); + crossPoint = static_cast(doc->GetParametrUInt(domElement, AttrCrossPoint, "1")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointFromArcAndTangent::SetVisualization() +{ + if (vis != nullptr) + { + VisToolPointFromArcAndTangent *visual = qobject_cast(vis); + SCASSERT(visual != nullptr); + + visual->setPoint1Id(tangentPointId); + visual->setArcId(arcId); + visual->setCrossPoint(crossPoint); + visual->RefreshGeometry(); + } +} diff --git a/src/app/tools/drawTools/vtoolpointfromarcandtangent.h b/src/app/tools/drawTools/vtoolpointfromarcandtangent.h new file mode 100644 index 000000000..2d4744db6 --- /dev/null +++ b/src/app/tools/drawTools/vtoolpointfromarcandtangent.h @@ -0,0 +1,79 @@ +/************************************************************************ + ** + ** @file vtoolpointfromarcandtangent.h + ** @author Roman Telezhynskyi + ** @date 6 6, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** 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 VTOOLPOINTFROMARCANDTANGENT_H +#define VTOOLPOINTFROMARCANDTANGENT_H + +#include "vtoolpoint.h" +#include "../../xml/vpattern.h" + +class VToolPointFromArcAndTangent : public VToolPoint +{ + Q_OBJECT +public: + VToolPointFromArcAndTangent(VPattern *doc, VContainer *data, const quint32 &id, quint32 arcId, + quint32 tangentPointId, CrossCirclesPoint crossPoint, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolPointFromArcAndTangent *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data); + static VToolPointFromArcAndTangent *Create(const quint32 _id, const QString &pointName, quint32 arcId, + quint32 tangentPointId, CrossCirclesPoint crossPoint, const qreal &mx, + const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); + static QPointF FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType); + static const QString ToolType; + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Tool::PointFromArcAndTangent) }; + + quint32 GetTangentPointId() const; + void SetTangentPointId(const quint32 &value); + + quint32 GetArcId() const; + void SetArcId(const quint32 &value); + + CrossCirclesPoint GetCrossCirclesPoint() const; + void SetCrossCirclesPoint(CrossCirclesPoint &value); + + virtual void ShowVisualization(bool show); +protected: + virtual void RemoveReferens(); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void SaveDialog(QDomElement &domElement); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); + virtual void SetVisualization(); +private: + Q_DISABLE_COPY(VToolPointFromArcAndTangent) + + quint32 arcId; + quint32 tangentPointId; + CrossCirclesPoint crossPoint; +}; + +#endif // VTOOLPOINTFROMARCANDTANGENT_H diff --git a/src/app/tools/drawTools/vtoolpointfromcircleandtangent.cpp b/src/app/tools/drawTools/vtoolpointfromcircleandtangent.cpp index 0e9673489..745b93d10 100644 --- a/src/app/tools/drawTools/vtoolpointfromcircleandtangent.cpp +++ b/src/app/tools/drawTools/vtoolpointfromcircleandtangent.cpp @@ -56,6 +56,7 @@ void VToolPointFromCircleAndTangent::setDialog() dialogTool->SetCircleCenterId(circleCenterId); dialogTool->SetCircleRadius(circleRadius); dialogTool->SetCrossCirclesPoint(crossPoint); + dialogTool->SetTangentPointId(tangentPointId); dialogTool->SetPointName(p->name()); } @@ -110,7 +111,7 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const qui doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Tool::PointOfIntersectionCircles, doc); + VDrawTool::AddRecord(id, Tool::PointFromCircleAndTangent, doc); if (parse == Document::FullParse) { VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(doc, data, id, circleCenterId, diff --git a/src/app/tools/tools.pri b/src/app/tools/tools.pri index fc6c4a542..1d2ace23b 100644 --- a/src/app/tools/tools.pri +++ b/src/app/tools/tools.pri @@ -41,7 +41,8 @@ HEADERS += \ $$PWD/drawTools/vtoolcurveintersectaxis.h \ $$PWD/drawTools/vtoolpointofintersectionarcs.h \ $$PWD/drawTools/vtoolpointofintersectioncircles.h \ - $$PWD/drawTools/vtoolpointfromcircleandtangent.h + $$PWD/drawTools/vtoolpointfromcircleandtangent.h \ + tools/drawTools/vtoolpointfromarcandtangent.h SOURCES += \ $$PWD/vtooldetail.cpp \ @@ -80,4 +81,5 @@ SOURCES += \ $$PWD/drawTools/vtoolcurveintersectaxis.cpp \ $$PWD/drawTools/vtoolpointofintersectionarcs.cpp \ $$PWD/drawTools/vtoolpointofintersectioncircles.cpp \ - $$PWD/drawTools/vtoolpointfromcircleandtangent.cpp + $$PWD/drawTools/vtoolpointfromcircleandtangent.cpp \ + tools/drawTools/vtoolpointfromarcandtangent.cpp diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 4b6c73336..e0f63e15d 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -86,6 +86,7 @@ const QString VAbstractTool::AttrC2Radius = QStringLiteral("c2Radius"); const QString VAbstractTool::AttrCCenter = QStringLiteral("cCenter"); const QString VAbstractTool::AttrTangent = QStringLiteral("tangent"); const QString VAbstractTool::AttrCRadius = QStringLiteral("cRadius"); +const QString VAbstractTool::AttrArc = QStringLiteral("arc"); const QString VAbstractTool::TypeLineNone = QStringLiteral("none"); const QString VAbstractTool::TypeLineLine = QStringLiteral("hair"); diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h index 46c17cf1a..0ccb20ea2 100644 --- a/src/app/tools/vabstracttool.h +++ b/src/app/tools/vabstracttool.h @@ -101,6 +101,7 @@ public: static const QString AttrCCenter; static const QString AttrTangent; static const QString AttrCRadius; + static const QString AttrArc; static const QString TypeLineNone; static const QString TypeLineLine; diff --git a/src/app/visualization/vistoolpointfromarcandtangent.cpp b/src/app/visualization/vistoolpointfromarcandtangent.cpp new file mode 100644 index 000000000..e7ee06e70 --- /dev/null +++ b/src/app/visualization/vistoolpointfromarcandtangent.cpp @@ -0,0 +1,145 @@ +/************************************************************************ + ** + ** @file vistoolpointfromarcandtangent.cpp + ** @author Roman Telezhynskyi + ** @date 6 6, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** 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 "vistoolpointfromarcandtangent.h" +#include "../container/vcontainer.h" +#include "../tools/drawTools/vtoolpointfromarcandtangent.h" +#include "../libs/vgeometry/vpointf.h" +#include "../libs/vgeometry/varc.h" + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent) + : VisLine(data, parent), arcId(NULL_ID), crossPoint(CrossCirclesPoint::FirstPoint), + point(nullptr), tangent(nullptr), arcPath(nullptr), tangentLine2(nullptr) +{ + arcPath = InitItem(Qt::darkGreen, this); + point = InitPoint(mainColor, this); + tangent = InitPoint(supportColor, this); + tangentLine2 = InitItem(supportColor, this); +} + +//--------------------------------------------------------------------------------------------------------------------- +VisToolPointFromArcAndTangent::~VisToolPointFromArcAndTangent() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointFromArcAndTangent::RefreshGeometry() +{ + if (point1Id > NULL_ID)// tangent point + { + const QSharedPointer tan = Visualization::data->GeometricObject(point1Id); + DrawPoint(tangent, tan->toQPointF(), supportColor); + + if (arcId > NULL_ID)// circle center + { + const QSharedPointer arc = Visualization::data->GeometricObject(arcId); + DrawPath(arcPath, arc->GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); + + FindRays(tan->toQPointF(), arc.data()); + + const QPointF fPoint = VToolPointFromArcAndTangent::FindPoint(tan->toQPointF(), arc.data(), crossPoint); + DrawPoint(point, fPoint, mainColor); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointFromArcAndTangent::setArcId(const quint32 &value) +{ + arcId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointFromArcAndTangent::setCrossPoint(const CrossCirclesPoint &value) +{ + crossPoint = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc) +{ + QPointF p1, p2; + const QPointF center = arc->GetCenter().toQPointF(); + const qreal radius = arc->GetRadius(); + const int res = VGObject::ContactPoints (p, center, radius, p1, p2); + + QLineF r1Arc(center, p1); + r1Arc.setLength(radius+10); + + QLineF r2Arc(center, p2); + r2Arc.setLength(radius+10); + + switch(res) + { + case 2: + { + int localRes = 0; + bool flagP1 = false; + + if (arc->IsIntersectLine(r1Arc)) + { + ++localRes; + flagP1 = true; + } + + if (arc->IsIntersectLine(r2Arc)) + { + ++localRes; + } + + switch(localRes) + { + case 2: + DrawRay(this, p, p1, supportColor, Qt::DashLine); + DrawRay(tangentLine2, p, p2, supportColor, Qt::DashLine); + break; + case 1: + DrawRay(this, p, p1, supportColor, Qt::DashLine); + tangentLine2->setVisible(false); + break; + case 0: + default: + this->setVisible(false); + tangentLine2->setVisible(false); + break; + } + + break; + } + case 1: + DrawRay(this, p, p1, supportColor, Qt::DashLine); + tangentLine2->setVisible(false); + break; + case 3: + case 0: + default: + this->setVisible(false); + tangentLine2->setVisible(false); + break; + } +} diff --git a/src/app/visualization/vistoolpointfromarcandtangent.h b/src/app/visualization/vistoolpointfromarcandtangent.h new file mode 100644 index 000000000..9d01ca781 --- /dev/null +++ b/src/app/visualization/vistoolpointfromarcandtangent.h @@ -0,0 +1,61 @@ +/************************************************************************ + ** + ** @file vistoolpointfromarcandtangent.h + ** @author Roman Telezhynskyi + ** @date 6 6, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** 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 VISTOOLPOINTFROMARCANDTANGENT_H +#define VISTOOLPOINTFROMARCANDTANGENT_H + +#include "visline.h" +#include "../xml/vpattern.h" + +class VisToolPointFromArcAndTangent : public VisLine +{ + Q_OBJECT +public: + VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent = 0); + virtual ~VisToolPointFromArcAndTangent(); + + virtual void RefreshGeometry(); + + void setArcId(const quint32 &value); + void setCrossPoint(const CrossCirclesPoint &value); + + virtual int type() const {return Type;} + enum { Type = UserType + static_cast(Vis::ToolPointFromArcAndTangent)}; +private: + Q_DISABLE_COPY(VisToolPointFromArcAndTangent) + quint32 arcId; + CrossCirclesPoint crossPoint; + QGraphicsEllipseItem *point; + QGraphicsEllipseItem *tangent; + QGraphicsPathItem *arcPath; + QGraphicsLineItem *tangentLine2; + + void FindRays(const QPointF &p, const VArc *arc); +}; + +#endif // VISTOOLPOINTFROMARCANDTANGENT_H diff --git a/src/app/visualization/visualization.pri b/src/app/visualization/visualization.pri index ec1876e2e..2db154543 100644 --- a/src/app/visualization/visualization.pri +++ b/src/app/visualization/visualization.pri @@ -29,7 +29,8 @@ HEADERS += \ $$PWD/vistoolcurveintersectaxis.h \ $$PWD/vistoolpointofintersectionarcs.h \ $$PWD/vistoolpointofintersectioncircles.h \ - $$PWD/vistoolpointfromcircleandtangent.h + $$PWD/vistoolpointfromcircleandtangent.h \ + visualization/vistoolpointfromarcandtangent.h SOURCES += \ $$PWD/vgraphicssimpletextitem.cpp \ @@ -59,4 +60,5 @@ SOURCES += \ $$PWD/vistoolcurveintersectaxis.cpp \ $$PWD/vistoolpointofintersectionarcs.cpp \ $$PWD/vistoolpointofintersectioncircles.cpp \ - $$PWD/vistoolpointfromcircleandtangent.cpp + $$PWD/vistoolpointfromcircleandtangent.cpp \ + visualization/vistoolpointfromarcandtangent.cpp diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index 7f5e93647..ae4ce5842 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -155,6 +155,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) case VToolPointFromCircleAndTangent::Type: ShowOptionsToolPointFromCircleAndTangent(item); break; + case VToolPointFromArcAndTangent::Type: + ShowOptionsToolPointFromArcAndTangent(item); + break; default: break; } @@ -245,6 +248,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions() case VToolPointFromCircleAndTangent::Type: UpdateOptionsToolPointFromCircleAndTangent(); break; + case VToolPointFromArcAndTangent::Type: + UpdateOptionsToolPointFromArcAndTangent(); + break; default: break; } @@ -350,6 +356,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) case VToolPointFromCircleAndTangent::Type: ChangeDataToolPointFromCircleAndTangent(prop); break; + case VToolPointFromArcAndTangent::Type: + ChangeDataToolPointFromArcAndTangent(prop); + break; default: break; } @@ -986,6 +995,31 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointFromCircleAndTangent(VPrope } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ChangeDataToolPointFromArcAndTangent(VProperty *property) +{ + SCASSERT(property != nullptr) + + const QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 28: // VAbstractTool::AttrCrossPoint + { + const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole); + SetCrossCirclesPoint(value); + break; + } + default: + qWarning()<<"Unknown property type. id = "<(item); + i->ShowVisualization(true); + formView->setTitle(tr("Tool to make point from arc and tangent")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyCrossPoint(i, tr("Take")); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item) { @@ -1719,6 +1764,15 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromCircleAndTangent() idToProperty[VAbstractTool::AttrCRadius]->setValue(cRadius); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromArcAndTangent() +{ + VToolPointFromArcAndTangent *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + idToProperty[VAbstractTool::AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() { diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h index b78842558..0b0d068de 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.h +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -105,6 +105,7 @@ private: void ChangeDataToolPointOfIntersectionArcs(VPE::VProperty *property); void ChangeDataToolPointOfIntersectionCircles(VPE::VProperty *property); void ChangeDataToolPointFromCircleAndTangent(VPE::VProperty *property); + void ChangeDataToolPointFromArcAndTangent(VPE::VProperty *property); void ChangeDataToolShoulderPoint(VPE::VProperty *property); void ChangeDataToolSpline(VPE::VProperty *property); void ChangeDataToolSplinePath(VPE::VProperty *property); @@ -129,6 +130,7 @@ private: void ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item); void ShowOptionsToolPointOfIntersectionCircles(QGraphicsItem *item); void ShowOptionsToolPointFromCircleAndTangent(QGraphicsItem *item); + void ShowOptionsToolPointFromArcAndTangent(QGraphicsItem *item); void ShowOptionsToolShoulderPoint(QGraphicsItem *item); void ShowOptionsToolSpline(QGraphicsItem *item); void ShowOptionsToolSplinePath(QGraphicsItem *item); @@ -153,6 +155,7 @@ private: void UpdateOptionsToolPointOfIntersectionArcs(); void UpdateOptionsToolPointOfIntersectionCircles(); void UpdateOptionsToolPointFromCircleAndTangent(); + void UpdateOptionsToolPointFromArcAndTangent(); void UpdateOptionsToolShoulderPoint(); void UpdateOptionsToolSpline(); void UpdateOptionsToolSplinePath(); diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 4517301e1..6adef18db 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -1145,7 +1145,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem << VToolLineIntersectAxis::ToolType << VToolCurveIntersectAxis::ToolType << VToolPointOfIntersectionArcs::ToolType << VToolPointOfIntersectionCircles::ToolType - << VToolPointFromCircleAndTangent::ToolType; + << VToolPointFromCircleAndTangent::ToolType + << VToolPointFromArcAndTangent::ToolType; switch (points.indexOf(type)) { case 0: //VToolSinglePoint::ToolType @@ -1715,6 +1716,26 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem throw excep; } break; + case 20: //VToolPointFromArcAndTangent::ToolType + try + { + PointsCommonAttributes(domElement, id, name, mx, my); + const quint32 arcId = GetParametrUInt(domElement, VAbstractTool::AttrArc, NULL_ID_STR); + const quint32 tangentId = GetParametrUInt(domElement, VAbstractTool::AttrTangent, NULL_ID_STR); + const CrossCirclesPoint crossPoint = static_cast(GetParametrUInt(domElement, + VAbstractTool::AttrCrossPoint, + "1")); + + VToolPointFromArcAndTangent::Create(id, name, arcId, tangentId, crossPoint, mx, my, + scene, this, data, parse, Source::FromFile); + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating point from arc and tangent"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + break; default: qDebug() << "Illegal point type in VDomDocument::ParsePointElement()."; break;