New tool "Point of the intersection circles".
--HG-- branch : develop
This commit is contained in:
parent
6530b57a8a
commit
c3d5688f28
|
@ -388,6 +388,10 @@ QString DialogHistory::Record(const VToolRecord &tool)
|
|||
{
|
||||
return QString(tr("%1 - point of arcs intersection")).arg(PointName(tool.getId()));
|
||||
}
|
||||
case Tool::PointOfIntersectionCircles:
|
||||
{
|
||||
return QString(tr("%1 - point of circles intersection")).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:
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "tools/dialoglineintersectaxis.h"
|
||||
#include "tools/dialogcurveintersectaxis.h"
|
||||
#include "tools/dialogpointofintersectionarcs.h"
|
||||
#include "tools/dialogpointofintersectioncircles.h"
|
||||
|
||||
#include "app/dialoghistory.h"
|
||||
#include "app/dialogincrements.h"
|
||||
|
|
|
@ -45,7 +45,8 @@ HEADERS += \
|
|||
$$PWD/app/dialoglayoutsettings.h \
|
||||
$$PWD/app/dialoglayoutprogress.h \
|
||||
$$PWD/app/dialogsavelayout.h \
|
||||
$$PWD/tools/dialogpointofintersectionarcs.h
|
||||
$$PWD/tools/dialogpointofintersectionarcs.h \
|
||||
$$PWD/tools/dialogpointofintersectioncircles.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/tools/dialogtriangle.cpp \
|
||||
|
@ -89,7 +90,8 @@ SOURCES += \
|
|||
$$PWD/app/dialoglayoutsettings.cpp \
|
||||
$$PWD/app/dialoglayoutprogress.cpp \
|
||||
$$PWD/app/dialogsavelayout.cpp \
|
||||
$$PWD/tools/dialogpointofintersectionarcs.cpp
|
||||
$$PWD/tools/dialogpointofintersectionarcs.cpp \
|
||||
$$PWD/tools/dialogpointofintersectioncircles.cpp
|
||||
|
||||
FORMS += \
|
||||
$$PWD/tools/dialogtriangle.ui \
|
||||
|
@ -127,4 +129,5 @@ FORMS += \
|
|||
$$PWD/app/dialoglayoutsettings.ui \
|
||||
$$PWD/app/dialoglayoutprogress.ui \
|
||||
$$PWD/app/dialogsavelayout.ui \
|
||||
$$PWD/tools/dialogpointofintersectionarcs.ui
|
||||
$$PWD/tools/dialogpointofintersectionarcs.ui \
|
||||
$$PWD/tools/dialogpointofintersectioncircles.ui
|
||||
|
|
|
@ -48,7 +48,7 @@ DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *d
|
|||
|
||||
FillComboBoxArcs(ui->comboBoxArc1);
|
||||
FillComboBoxArcs(ui->comboBoxArc2);
|
||||
FillComboBoxCrossArcPoints();
|
||||
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
||||
|
||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionArcs::NamePointChanged);
|
||||
connect(ui->comboBoxArc1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
|
@ -106,36 +106,13 @@ void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
CrossArcsPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const
|
||||
CrossCirclesPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const
|
||||
{
|
||||
int value;
|
||||
bool ok = false;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
value = ui->comboBoxResult->itemData(box->currentIndex()).toInt(&ok);
|
||||
#else
|
||||
value = ui->comboBoxResult->currentData().toInt(&ok);
|
||||
#endif
|
||||
if (not ok)
|
||||
{
|
||||
return CrossArcsPoint::FirstPoint;
|
||||
}
|
||||
|
||||
switch(value)
|
||||
{
|
||||
case 1:
|
||||
return CrossArcsPoint::FirstPoint;
|
||||
break;
|
||||
case 2:
|
||||
return CrossArcsPoint::SecondPoint;
|
||||
break;
|
||||
default:
|
||||
return CrossArcsPoint::FirstPoint;
|
||||
break;
|
||||
}
|
||||
return getCurrentCrossPoint(ui->comboBoxResult);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossArcsPoint &p)
|
||||
void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossCirclesPoint &p)
|
||||
{
|
||||
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
||||
if (index != -1)
|
||||
|
@ -226,10 +203,3 @@ void DialogPointOfIntersectionArcs::SaveData()
|
|||
point->setCrossPoint(GetCrossArcPoint());
|
||||
point->RefreshGeometry();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionArcs::FillComboBoxCrossArcPoints()
|
||||
{
|
||||
ui->comboBoxResult->addItem(tr("First point"), QVariant(static_cast<int>(CrossArcsPoint::FirstPoint)));
|
||||
ui->comboBoxResult->addItem(tr("Second point"), QVariant(static_cast<int>(CrossArcsPoint::SecondPoint)));
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class DialogPointOfIntersectionArcs : public DialogTool
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, QWidget *parent = 0);
|
||||
DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, QWidget *parent = 0);
|
||||
virtual ~DialogPointOfIntersectionArcs();
|
||||
|
||||
void SetPointName(const QString &value);
|
||||
|
@ -53,8 +53,8 @@ public:
|
|||
quint32 GetSecondArcId() const;
|
||||
void SetSecondArcId(const quint32 &value);
|
||||
|
||||
CrossArcsPoint GetCrossArcPoint() const;
|
||||
void SetCrossArcPoint(CrossArcsPoint &p);
|
||||
CrossCirclesPoint GetCrossArcPoint() const;
|
||||
void SetCrossArcPoint(CrossCirclesPoint &p);
|
||||
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||
|
@ -71,8 +71,6 @@ private:
|
|||
Q_DISABLE_COPY(DialogPointOfIntersectionArcs)
|
||||
|
||||
Ui::DialogPointOfIntersectionArcs *ui;
|
||||
|
||||
void FillComboBoxCrossArcPoints();
|
||||
};
|
||||
|
||||
#endif // DIALOGPOINTOFINTERSECTIONARCS_H
|
||||
|
|
408
src/app/dialogs/tools/dialogpointofintersectioncircles.cpp
Normal file
408
src/app/dialogs/tools/dialogpointofintersectioncircles.cpp
Normal file
|
@ -0,0 +1,408 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpointofintersectioncircles.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 29 5, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "dialogpointofintersectioncircles.h"
|
||||
#include "ui_dialogpointofintersectioncircles.h"
|
||||
|
||||
#include "../../libs/vgeometry/vpointf.h"
|
||||
#include "../../container/vcontainer.h"
|
||||
#include "../../visualization/vistoolpointofintersectioncircles.h"
|
||||
#include "../../widgets/vmaingraphicsscene.h"
|
||||
#include "dialogeditwrongformula.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPointOfIntersectionCircles::DialogPointOfIntersectionCircles(const VContainer *data, const quint32 &toolId,
|
||||
QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersectionCircles), flagCircle1Radius(false),
|
||||
flagCircle2Radius(false), timerCircle1Radius(nullptr), timerCircle2Radius(nullptr), circle1Radius(),
|
||||
circle2Radius(), formulaBaseHeightCircle1Radius(0), formulaBaseHeightCircle2Radius(0),
|
||||
angleCircle1Radius(INT_MIN), angleCircle2Radius(INT_MIN)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
||||
plainTextEditFormula = ui->plainTextEditCircle1Radius;
|
||||
this->formulaBaseHeightCircle1Radius = ui->plainTextEditCircle1Radius->height();
|
||||
this->formulaBaseHeightCircle2Radius = ui->plainTextEditCircle2Radius->height();
|
||||
|
||||
ui->plainTextEditCircle1Radius->installEventFilter(this);
|
||||
ui->plainTextEditCircle2Radius->installEventFilter(this);
|
||||
|
||||
timerCircle1Radius = new QTimer(this);
|
||||
connect(timerCircle1Radius, &QTimer::timeout, this, &DialogPointOfIntersectionCircles::EvalCircle1Radius);
|
||||
|
||||
timerCircle2Radius = new QTimer(this);
|
||||
connect(timerCircle2Radius, &QTimer::timeout, this, &DialogPointOfIntersectionCircles::EvalCircle2Radius);
|
||||
|
||||
InitOkCancelApply(ui);
|
||||
CheckState();
|
||||
|
||||
FillComboBoxPoints(ui->comboBoxCircle1Center);
|
||||
FillComboBoxPoints(ui->comboBoxCircle2Center);
|
||||
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
||||
|
||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionCircles::NamePointChanged);
|
||||
connect(ui->comboBoxCircle1Center,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogPointOfIntersectionCircles::PointChanged);
|
||||
connect(ui->comboBoxCircle2Center,
|
||||
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &DialogPointOfIntersectionCircles::PointChanged);
|
||||
|
||||
connect(ui->toolButtonExprCircle1Radius, &QPushButton::clicked, this,
|
||||
&DialogPointOfIntersectionCircles::FXCircle1Radius);
|
||||
connect(ui->toolButtonExprCircle2Radius, &QPushButton::clicked, this,
|
||||
&DialogPointOfIntersectionCircles::FXCircle2Radius);
|
||||
|
||||
connect(ui->plainTextEditCircle1Radius, &QPlainTextEdit::textChanged, this,
|
||||
&DialogPointOfIntersectionCircles::Circle1RadiusChanged);
|
||||
connect(ui->plainTextEditCircle2Radius, &QPlainTextEdit::textChanged, this,
|
||||
&DialogPointOfIntersectionCircles::Circle2RadiusChanged);
|
||||
|
||||
connect(ui->pushButtonGrowCircle1Radius, &QPushButton::clicked, this,
|
||||
&DialogPointOfIntersectionCircles::DeployCircle1RadiusTextEdit);
|
||||
connect(ui->pushButtonGrowCircle2Radius, &QPushButton::clicked, this,
|
||||
&DialogPointOfIntersectionCircles::DeployCircle2RadiusTextEdit);
|
||||
|
||||
vis = new VisToolPointOfIntersectionCircles(data);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPointOfIntersectionCircles::~DialogPointOfIntersectionCircles()
|
||||
{
|
||||
DeleteVisualization<VisToolPointOfIntersectionCircles>();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetPointName(const QString &value)
|
||||
{
|
||||
pointName = value;
|
||||
ui->lineEditNamePoint->setText(pointName);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogPointOfIntersectionCircles::GetFirstCircleCenterId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxCircle1Center);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetFirstCircleCenterId(const quint32 &value)
|
||||
{
|
||||
setCurrentPointId(ui->comboBoxCircle1Center, value);
|
||||
|
||||
VisToolPointOfIntersectionCircles *point = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(point != nullptr);
|
||||
point->setPoint1Id(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 DialogPointOfIntersectionCircles::GetSecondCircleCenterId() const
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxCircle2Center);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &value)
|
||||
{
|
||||
setCurrentPointId(ui->comboBoxCircle2Center, value);
|
||||
|
||||
VisToolPointOfIntersectionCircles *point = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(point != nullptr);
|
||||
point->setPoint2Id(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCircles::GetFirstCircleRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(ui->plainTextEditCircle1Radius->toPlainText());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetFirstCircleRadius(const QString &value)
|
||||
{
|
||||
const QString formula = qApp->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
this->DeployCircle1RadiusTextEdit();
|
||||
}
|
||||
ui->plainTextEditCircle1Radius->setPlainText(formula);
|
||||
|
||||
VisToolPointOfIntersectionCircles *point = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(point != nullptr);
|
||||
point->setC1Radius(formula);
|
||||
|
||||
MoveCursorToEnd(ui->plainTextEditCircle1Radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPointOfIntersectionCircles::GetSecondCircleRadius() const
|
||||
{
|
||||
return qApp->FormulaFromUser(ui->plainTextEditCircle2Radius->toPlainText());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetSecondCircleRadius(const QString &value)
|
||||
{
|
||||
const QString formula = qApp->FormulaToUser(value);
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
{
|
||||
this->DeployCircle2RadiusTextEdit();
|
||||
}
|
||||
ui->plainTextEditCircle2Radius->setPlainText(formula);
|
||||
|
||||
VisToolPointOfIntersectionCircles *point = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(point != nullptr);
|
||||
point->setC2Radius(formula);
|
||||
|
||||
MoveCursorToEnd(ui->plainTextEditCircle2Radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
CrossCirclesPoint DialogPointOfIntersectionCircles::GetCrossCirclesPoint() const
|
||||
{
|
||||
return getCurrentCrossPoint(ui->comboBoxResult);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SetCrossCirclesPoint(CrossCirclesPoint &p)
|
||||
{
|
||||
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
||||
if (index != -1)
|
||||
{
|
||||
ui->comboBoxResult->setCurrentIndex(index);
|
||||
|
||||
VisToolPointOfIntersectionCircles *point = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(point != nullptr);
|
||||
point->setCrossPoint(p);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObject &type)
|
||||
{
|
||||
if (prepare == false)// After first choose we ignore all objects
|
||||
{
|
||||
if (type == SceneObject::Point)
|
||||
{
|
||||
VisToolPointOfIntersectionCircles *point = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(point != nullptr);
|
||||
|
||||
switch (number)
|
||||
{
|
||||
case 0:
|
||||
if (SetObject(id, ui->comboBoxCircle1Center, tr("Select second circle center")))
|
||||
{
|
||||
number++;
|
||||
point->VisualMode(id);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (getCurrentObjectId(ui->comboBoxCircle1Center) != id)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxCircle2Center, ""))
|
||||
{
|
||||
number = 0;
|
||||
point->setPoint2Id(id);
|
||||
point->RefreshGeometry();
|
||||
prepare = true;
|
||||
this->setModal(true);
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::PointChanged()
|
||||
{
|
||||
QColor color = okColor;
|
||||
if (getCurrentObjectId(ui->comboBoxCircle1Center) == getCurrentObjectId(ui->comboBoxCircle2Center))
|
||||
{
|
||||
flagError = false;
|
||||
color = errorColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
flagError = true;
|
||||
color = okColor;
|
||||
}
|
||||
ChangeColor(ui->labelCircle1Center, color);
|
||||
ChangeColor(ui->labelCircle1Center, color);
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::DeployCircle1RadiusTextEdit()
|
||||
{
|
||||
DeployFormula(ui->plainTextEditCircle1Radius, ui->pushButtonGrowCircle1Radius, formulaBaseHeightCircle1Radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::DeployCircle2RadiusTextEdit()
|
||||
{
|
||||
DeployFormula(ui->plainTextEditCircle2Radius, ui->pushButtonGrowCircle2Radius, formulaBaseHeightCircle2Radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::Circle1RadiusChanged()
|
||||
{
|
||||
labelEditFormula = ui->labelEditCircle1Radius;
|
||||
labelResultCalculation = ui->labelResultCircle1Radius;
|
||||
ValFormulaChanged(flagCircle1Radius, ui->plainTextEditCircle1Radius, timerCircle1Radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::Circle2RadiusChanged()
|
||||
{
|
||||
labelEditFormula = ui->labelEditCircle2Radius;
|
||||
labelResultCalculation = ui->labelResultCircle2Radius;
|
||||
ValFormulaChanged(flagCircle2Radius, ui->plainTextEditCircle2Radius, timerCircle2Radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::FXCircle1Radius()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
dialog->setWindowTitle(tr("Edit first circle radius"));
|
||||
dialog->SetFormula(GetFirstCircleRadius());
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
SetFirstCircleRadius(dialog->GetFormula());
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::FXCircle2Radius()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
dialog->setWindowTitle(tr("Edit second circle radius"));
|
||||
dialog->SetFormula(GetSecondCircleRadius());
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
SetSecondCircleRadius(dialog->GetFormula());
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::EvalCircle1Radius()
|
||||
{
|
||||
labelEditFormula = ui->labelEditCircle1Radius;
|
||||
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
||||
const qreal radius = Eval(ui->plainTextEditCircle1Radius->toPlainText(), flagCircle1Radius,
|
||||
ui->labelResultCircle1Radius, postfix);
|
||||
|
||||
if (radius < 0)
|
||||
{
|
||||
flagCircle2Radius = false;
|
||||
ChangeColor(labelEditFormula, Qt::red);
|
||||
ui->labelResultCircle1Radius->setText(tr("Error"));
|
||||
ui->labelResultCircle1Radius->setToolTip(tr("Radius can't be negative"));
|
||||
|
||||
DialogPointOfIntersectionCircles::CheckState();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::EvalCircle2Radius()
|
||||
{
|
||||
labelEditFormula = ui->labelEditCircle2Radius;
|
||||
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
||||
const qreal radius = Eval(ui->plainTextEditCircle2Radius->toPlainText(), flagCircle2Radius,
|
||||
ui->labelResultCircle2Radius, postfix);
|
||||
|
||||
if (radius < 0)
|
||||
{
|
||||
flagCircle2Radius = false;
|
||||
ChangeColor(labelEditFormula, Qt::red);
|
||||
ui->labelResultCircle2Radius->setText(tr("Error"));
|
||||
ui->labelResultCircle2Radius->setToolTip(tr("Radius can't be negative"));
|
||||
|
||||
DialogPointOfIntersectionCircles::CheckState();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::ShowVisualization()
|
||||
{
|
||||
AddVisualization<VisToolPointOfIntersectionCircles>();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::SaveData()
|
||||
{
|
||||
pointName = ui->lineEditNamePoint->text();
|
||||
|
||||
QString c1Radius = ui->plainTextEditCircle2Radius->toPlainText();
|
||||
c1Radius.replace("\n", " ");
|
||||
|
||||
QString c2Radius = ui->plainTextEditCircle2Radius->toPlainText();
|
||||
c2Radius.replace("\n", " ");
|
||||
|
||||
VisToolPointOfIntersectionCircles *point = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(point != nullptr);
|
||||
|
||||
point->setPoint1Id(GetFirstCircleCenterId());
|
||||
point->setPoint2Id(GetSecondCircleCenterId());
|
||||
point->setC1Radius(c1Radius);
|
||||
point->setC2Radius(c2Radius);
|
||||
point->setCrossPoint(GetCrossCirclesPoint());
|
||||
point->RefreshGeometry();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
ui->plainTextEditCircle1Radius->blockSignals(true);
|
||||
ui->plainTextEditCircle2Radius->blockSignals(true);
|
||||
DialogTool::closeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointOfIntersectionCircles::CheckState()
|
||||
{
|
||||
SCASSERT(bOk != nullptr);
|
||||
bOk->setEnabled(flagFormula && flagName && flagError && flagCircle1Radius && flagCircle2Radius);
|
||||
// In case dialog hasn't apply button
|
||||
if ( bApply != nullptr)
|
||||
{
|
||||
bApply->setEnabled(bOk->isEnabled());
|
||||
}
|
||||
}
|
111
src/app/dialogs/tools/dialogpointofintersectioncircles.h
Normal file
111
src/app/dialogs/tools/dialogpointofintersectioncircles.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpointofintersectioncircles.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 29 5, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef DIALOGPOINTOFINTERSECTIONCIRCLES_H
|
||||
#define DIALOGPOINTOFINTERSECTIONCIRCLES_H
|
||||
|
||||
#include "dialogtool.h"
|
||||
#include "../../xml/vpattern.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DialogPointOfIntersectionCircles;
|
||||
}
|
||||
|
||||
class DialogPointOfIntersectionCircles : public DialogTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DialogPointOfIntersectionCircles(const VContainer *data, const quint32 &toolId, QWidget *parent = 0);
|
||||
virtual ~DialogPointOfIntersectionCircles();
|
||||
|
||||
void SetPointName(const QString &value);
|
||||
|
||||
quint32 GetFirstCircleCenterId() const;
|
||||
void SetFirstCircleCenterId(const quint32 &value);
|
||||
|
||||
quint32 GetSecondCircleCenterId() const;
|
||||
void SetSecondCircleCenterId(const quint32 &value);
|
||||
|
||||
QString GetFirstCircleRadius() const;
|
||||
void SetFirstCircleRadius(const QString &value);
|
||||
|
||||
QString GetSecondCircleRadius() const;
|
||||
void SetSecondCircleRadius(const QString &value);
|
||||
|
||||
CrossCirclesPoint GetCrossCirclesPoint() const;
|
||||
void SetCrossCirclesPoint(CrossCirclesPoint &p);
|
||||
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||
void PointChanged();
|
||||
|
||||
void DeployCircle1RadiusTextEdit();
|
||||
void DeployCircle2RadiusTextEdit();
|
||||
|
||||
void Circle1RadiusChanged();
|
||||
void Circle2RadiusChanged();
|
||||
|
||||
void FXCircle1Radius();
|
||||
void FXCircle2Radius();
|
||||
|
||||
void EvalCircle1Radius();
|
||||
void EvalCircle2Radius();
|
||||
|
||||
protected:
|
||||
virtual void ShowVisualization();
|
||||
/**
|
||||
* @brief SaveData Put dialog data in local variables
|
||||
*/
|
||||
virtual void SaveData();
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
virtual void CheckState();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogPointOfIntersectionCircles)
|
||||
|
||||
Ui::DialogPointOfIntersectionCircles *ui;
|
||||
|
||||
bool flagCircle1Radius;
|
||||
bool flagCircle2Radius;
|
||||
|
||||
QTimer *timerCircle1Radius;
|
||||
QTimer *timerCircle2Radius;
|
||||
|
||||
QString circle1Radius;
|
||||
QString circle2Radius;
|
||||
|
||||
int formulaBaseHeightCircle1Radius;
|
||||
int formulaBaseHeightCircle2Radius;
|
||||
|
||||
qreal angleCircle1Radius;
|
||||
qreal angleCircle2Radius;
|
||||
};
|
||||
|
||||
#endif // DIALOGPOINTOFINTERSECTIONCIRCLES_H
|
522
src/app/dialogs/tools/dialogpointofintersectioncircles.ui
Normal file
522
src/app/dialogs/tools/dialogpointofintersectioncircles.ui
Normal file
|
@ -0,0 +1,522 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogPointOfIntersectionCircles</class>
|
||||
<widget class="QDialog" name="DialogPointOfIntersectionCircles">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>380</width>
|
||||
<height>323</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>380</width>
|
||||
<height>323</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>380</width>
|
||||
<height>323</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelEditCircle1Radius">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>159</red>
|
||||
<green>158</green>
|
||||
<blue>158</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radius of the first circle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButtonExprCircle1Radius">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../share/resources/icon.qrc">
|
||||
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelResultCircle1Radius">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>87</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Value of radius</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">_</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEditCircle1Radius">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="tabChangesFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonGrowCircle1Radius">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>18</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Show full calculation in message box</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="go-down">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelEditCircle2Radius">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>159</red>
|
||||
<green>158</green>
|
||||
<blue>158</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radius of the second circle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButtonExprCircle2Radius">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../share/resources/icon.qrc">
|
||||
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelResultCircle2Radius">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>87</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Value of first angle</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">_</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEditCircle2Radius">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="tabChangesFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonGrowCircle2Radius">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>18</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Show full calculation in message box</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="go-down">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelEditNamePoint">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Point label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditNamePoint"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelCircle1Center">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Center of the first circle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBoxCircle1Center">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>145</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select point of center of arc</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelCircle2Center">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Center of the second circle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBoxCircle2Center">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>143</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Take</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBoxResult"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../share/resources/icon.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogPointOfIntersectionCircles</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DialogPointOfIntersectionCircles</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -311,6 +311,15 @@ void DialogTool::FillComboBoxLineColors(QComboBox *box) const
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogTool::FillComboBoxCrossCirclesPoints(QComboBox *box) const
|
||||
{
|
||||
SCASSERT(box != nullptr);
|
||||
|
||||
box->addItem(tr("First point"), QVariant(static_cast<int>(CrossCirclesPoint::FirstPoint)));
|
||||
box->addItem(tr("Second point"), QVariant(static_cast<int>(CrossCirclesPoint::SecondPoint)));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogTool::GetComboBoxCurrentData(const QComboBox *box) const
|
||||
{
|
||||
|
@ -574,6 +583,35 @@ 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)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "../../utils/logging.h"
|
||||
#include "../../widgets/vmaingraphicsscene.h"
|
||||
#include "../../visualization/visualization.h"
|
||||
#include "../../xml/vpattern.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
|
@ -192,6 +193,7 @@ protected:
|
|||
void FillComboBoxCurves(QComboBox *box)const;
|
||||
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
|
||||
void FillComboBoxLineColors(QComboBox *box)const;
|
||||
void FillComboBoxCrossCirclesPoints(QComboBox *box) const;
|
||||
|
||||
virtual void CheckState();
|
||||
QString GetComboBoxCurrentData(const QComboBox *box)const;
|
||||
|
@ -208,7 +210,10 @@ protected:
|
|||
void setCurrentSplinePathId(QComboBox *box, const quint32 &value,
|
||||
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const;
|
||||
void setCurrentCurveId(QComboBox *box, const quint32 &value) const;
|
||||
quint32 getCurrentObjectId(QComboBox *box) const;
|
||||
|
||||
quint32 getCurrentObjectId(QComboBox *box) const;
|
||||
CrossCirclesPoint getCurrentCrossPoint(QComboBox *box) const;
|
||||
|
||||
bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip);
|
||||
void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight);
|
||||
template <typename T>
|
||||
|
|
|
@ -699,10 +699,20 @@ void MainWindow::ToolCurveIntersectAxis(bool checked)
|
|||
void MainWindow::ToolPointOfIntersectionArcs(bool checked)
|
||||
{
|
||||
SetToolButtonWithApply<DialogPointOfIntersectionArcs>(checked, Tool::PointOfIntersectionArcs,
|
||||
"://cursor/point_of_intersection_arcs.png",
|
||||
tr("Select first an arc"),
|
||||
&MainWindow::ClosedDialogWithApply<VToolPointOfIntersectionArcs>,
|
||||
&MainWindow::ApplyDialog<VToolPointOfIntersectionArcs>);
|
||||
"://cursor/point_of_intersection_arcs.png",
|
||||
tr("Select first an arc"),
|
||||
&MainWindow::ClosedDialogWithApply<VToolPointOfIntersectionArcs>,
|
||||
&MainWindow::ApplyDialog<VToolPointOfIntersectionArcs>);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::ToolPointOfIntersectionCircles(bool checked)
|
||||
{
|
||||
SetToolButtonWithApply<DialogPointOfIntersectionCircles>(checked, Tool::PointOfIntersectionCircles,
|
||||
"://cursor/point_of_intersection_circles.png",
|
||||
tr("Select first circle center "),
|
||||
&MainWindow::ClosedDialogWithApply<VToolPointOfIntersectionCircles>,
|
||||
&MainWindow::ApplyDialog<VToolPointOfIntersectionCircles>);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1000,7 +1010,10 @@ void MainWindow::InitToolButtons()
|
|||
connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis);
|
||||
connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis);
|
||||
connect(ui->toolButtonLayoutSettings, &QToolButton::clicked, this, &MainWindow::ToolLayoutSettings);
|
||||
connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersectionArcs);
|
||||
connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this,
|
||||
&MainWindow::ToolPointOfIntersectionArcs);
|
||||
connect(ui->toolButtonPointOfIntersectionCircles, &QToolButton::clicked, this,
|
||||
&MainWindow::ToolPointOfIntersectionCircles);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1117,6 +1130,9 @@ void MainWindow::CancelTool()
|
|||
case Tool::PointOfIntersectionArcs:
|
||||
ui->toolButtonPointOfIntersectionArcs->setChecked(false);
|
||||
break;
|
||||
case Tool::PointOfIntersectionCircles:
|
||||
ui->toolButtonPointOfIntersectionCircles->setChecked(false);
|
||||
break;
|
||||
case Tool::NodePoint:
|
||||
case Tool::NodeArc:
|
||||
case Tool::NodeSpline:
|
||||
|
@ -2143,6 +2159,7 @@ void MainWindow::SetEnableTool(bool enable)
|
|||
ui->toolButtonCurveIntersectAxis->setEnabled(drawTools);
|
||||
ui->toolButtonArcIntersectAxis->setEnabled(drawTools);
|
||||
ui->toolButtonPointOfIntersectionArcs->setEnabled(drawTools);
|
||||
ui->toolButtonPointOfIntersectionCircles->setEnabled(drawTools);
|
||||
|
||||
ui->actionLast_tool->setEnabled(drawTools);
|
||||
|
||||
|
@ -2505,6 +2522,10 @@ void MainWindow::LastUsedTool()
|
|||
ui->toolButtonCurveIntersectAxis->setChecked(true);
|
||||
ToolCurveIntersectAxis(true);
|
||||
break;
|
||||
case Tool::PointOfIntersectionCircles:
|
||||
ui->toolButtonPointOfIntersectionCircles->setChecked(true);
|
||||
ToolPointOfIntersectionCircles(true);
|
||||
break;
|
||||
case Tool::NodePoint:
|
||||
case Tool::NodeArc:
|
||||
case Tool::NodeSpline:
|
||||
|
|
|
@ -116,6 +116,7 @@ public slots:
|
|||
void ToolLineIntersectAxis(bool checked);
|
||||
void ToolCurveIntersectAxis(bool checked);
|
||||
void ToolPointOfIntersectionArcs(bool checked);
|
||||
void ToolPointOfIntersectionCircles(bool checked);
|
||||
|
||||
void ClosedDialogDetail(int result);
|
||||
void ClosedDialogUnionDetails(int result);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
|
@ -573,7 +573,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>120</width>
|
||||
<height>104</height>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -693,6 +693,32 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QToolButton" name="toolButtonPointOfIntersectionCircles">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Point of intersection circles</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="share/resources/icon.qrc">
|
||||
<normaloff>:/icon/32x32/point_of_intersection_circles.png</normaloff>:/icon/32x32/point_of_intersection_circles.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_5">
|
||||
|
|
|
@ -87,14 +87,15 @@ enum class Tool : unsigned char
|
|||
Triangle,
|
||||
LineIntersectAxis,
|
||||
PointOfIntersectionArcs,
|
||||
PointOfIntersectionCircles,
|
||||
CurveIntersectAxis,
|
||||
PointOfIntersection,
|
||||
UnionDetails // 31
|
||||
UnionDetails // 32
|
||||
};
|
||||
|
||||
enum class Vis : unsigned char
|
||||
{
|
||||
ControlPointSpline = 32, // increase this value if need more positions in Tool enum
|
||||
ControlPointSpline = 33, // increase this value if need more positions in Tool enum
|
||||
GraphicsSimpleTextItem,
|
||||
SimpleSplinePath,
|
||||
Line,
|
||||
|
@ -111,6 +112,7 @@ enum class Vis : unsigned char
|
|||
ToolPointOfContact,
|
||||
ToolPointOfIntersection,
|
||||
ToolPointOfIntersectionArcs,
|
||||
ToolPointOfIntersectionCircles,
|
||||
ToolShoulderPoint,
|
||||
ToolSpline,
|
||||
ToolTriangle,
|
||||
|
|
|
@ -25,5 +25,6 @@
|
|||
<file>cursor/arc_intersect_axis_cursor.png</file>
|
||||
<file>cursor/curve_intersect_axis_cursor.png</file>
|
||||
<file>cursor/point_of_intersection_arcs.png</file>
|
||||
<file>cursor/point_of_intersection_circles.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
src/app/share/resources/cursor/point_of_intersection_circles.png
Normal file
BIN
src/app/share/resources/cursor/point_of_intersection_circles.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -62,5 +62,6 @@
|
|||
<file>icon/16x16/progress.gif</file>
|
||||
<file>icon/32x32/export_to_picture_document.png</file>
|
||||
<file>icon/32x32/point_of_intersection_arcs.png</file>
|
||||
<file>icon/32x32/point_of_intersection_circles.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="32"
|
||||
height="32"
|
||||
id="svg2985"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="point_of_intersection_circles.svg"
|
||||
inkscape:export-filename="/home/dismine/CAD/Valentina/src/app/share/resources/icon/32x32/point_of_contact.png"
|
||||
inkscape:export-xdpi="92"
|
||||
inkscape:export-ydpi="92">
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1855"
|
||||
inkscape:window-height="1056"
|
||||
id="namedview12"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.9121197"
|
||||
inkscape:cx="46.515175"
|
||||
inkscape:cy="24.569283"
|
||||
inkscape:window-x="65"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg2985" />
|
||||
<defs
|
||||
id="defs2987" />
|
||||
<metadata
|
||||
id="metadata2990">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:none;stroke:#0000e6;stroke-width:0.67446876;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:2.69787508, 1.34893754;stroke-dashoffset:0"
|
||||
id="path2991"
|
||||
sodipodi:cx="4.9291468"
|
||||
sodipodi:cy="18.508039"
|
||||
sodipodi:rx="3.7284572"
|
||||
sodipodi:ry="12.860018"
|
||||
d="m 3.5425616,30.445683 a 3.7284572,12.860018 0 1 1 0.012136,0.01669"
|
||||
sodipodi:start="1.9518432"
|
||||
sodipodi:end="8.2315244"
|
||||
transform="matrix(2.950858,0,0,0.80771444,5.9140402,-3.9951667)"
|
||||
sodipodi:open="true" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:none;stroke:#00b400;stroke-width:0.67450106;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:4.04700648, 1.34900216;stroke-dashoffset:0"
|
||||
id="path2991-7"
|
||||
sodipodi:cx="4.9291468"
|
||||
sodipodi:cy="18.508039"
|
||||
sodipodi:rx="3.7284572"
|
||||
sodipodi:ry="12.860018"
|
||||
d="m 3.5137075,6.6107503 a 3.7284572,12.860018 0 1 1 -0.038644,0.055572"
|
||||
sodipodi:start="4.3229912"
|
||||
sodipodi:end="10.594947"
|
||||
transform="matrix(-2.9662914,-0.0242868,0.01454795,-0.83467136,26.058665,36.198905)"
|
||||
sodipodi:open="true" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#ff0034;fill-opacity:1;stroke:#ff0034;stroke-width:1.56700003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="path2985-2-9-3"
|
||||
d="m 24.284818,21.002233 a 1.7373301,1.7294948 0 0 1 -3.47466,0 1.7373301,1.7294948 0 1 1 3.47466,0 z" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#ff0034;fill-opacity:1;stroke:#ff0034;stroke-width:1.56700003;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
||||
id="path2985-2-9-3-5"
|
||||
d="m 10.963682,10.451396 a 1.7373301,1.7294948 0 0 1 -3.4746593,0 1.7373301,1.7294948 0 1 1 3.4746593,0 z" />
|
||||
</svg>
|
After Width: | Height: | Size: 3.6 KiB |
|
@ -45,6 +45,7 @@
|
|||
#include "vtooltriangle.h"
|
||||
#include "vtoolpointofintersection.h"
|
||||
#include "vtoolpointofintersectionarcs.h"
|
||||
#include "vtoolpointofintersectioncircles.h"
|
||||
#include "vtoolcutspline.h"
|
||||
#include "vtoolcutsplinepath.h"
|
||||
#include "vtoolcutarc.h"
|
||||
|
|
|
@ -37,7 +37,7 @@ const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIn
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id,
|
||||
const quint32 &firstArcId, const quint32 &secondArcId,
|
||||
CrossArcsPoint pType, const Source &typeCreation,
|
||||
CrossCirclesPoint pType, const Source &typeCreation,
|
||||
QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *d
|
|||
SCASSERT(dialogTool != nullptr);
|
||||
const quint32 firstArcId = dialogTool->GetFirstArcId();
|
||||
const quint32 secondArcId = dialogTool->GetSecondArcId();
|
||||
const CrossArcsPoint pType = dialogTool->GetCrossArcPoint();
|
||||
const CrossCirclesPoint pType = dialogTool->GetCrossArcPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointOfIntersectionArcs *point = nullptr;
|
||||
point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc, data, Document::FullParse,
|
||||
|
@ -81,7 +81,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *d
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName,
|
||||
const quint32 &firstArcId,
|
||||
const quint32 &secondArcId, CrossArcsPoint pType,
|
||||
const quint32 &secondArcId, CrossCirclesPoint pType,
|
||||
const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VPattern *doc,
|
||||
VContainer *data, const Document &parse,
|
||||
|
@ -123,7 +123,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcsPoint pType)
|
||||
QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossCirclesPoint pType)
|
||||
{
|
||||
QPointF p1, p2;
|
||||
const int res = VGObject::IntersectionCircles(arc1->GetCenter().toQPointF(), arc1->GetRadius(),
|
||||
|
@ -162,7 +162,7 @@ QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *ar
|
|||
switch(localRes)
|
||||
{
|
||||
case 2:
|
||||
if (pType == CrossArcsPoint::FirstPoint)
|
||||
if (pType == CrossCirclesPoint::FirstPoint)
|
||||
{
|
||||
return p1;
|
||||
}
|
||||
|
@ -244,13 +244,13 @@ void VToolPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
CrossArcsPoint VToolPointOfIntersectionArcs::GetCrossArcsPoint() const
|
||||
CrossCirclesPoint VToolPointOfIntersectionArcs::GetCrossCirclesPoint() const
|
||||
{
|
||||
return crossPoint;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::SetCrossArcsPoint(CrossArcsPoint &value)
|
||||
void VToolPointOfIntersectionArcs::SetCrossCirclesPoint(CrossCirclesPoint &value)
|
||||
{
|
||||
crossPoint = value;
|
||||
|
||||
|
@ -305,7 +305,7 @@ void VToolPointOfIntersectionArcs::ReadToolAttributes(const QDomElement &domElem
|
|||
{
|
||||
firstArcId = doc->GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR);
|
||||
secondArcId = doc->GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR);
|
||||
crossPoint = static_cast<CrossArcsPoint>(doc->GetParametrUInt(domElement, AttrCrossPoint, "1"));
|
||||
crossPoint = static_cast<CrossCirclesPoint>(doc->GetParametrUInt(domElement, AttrCrossPoint, "1"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -40,17 +40,17 @@ class VToolPointOfIntersectionArcs : public VToolPoint
|
|||
|
||||
public:
|
||||
VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId,
|
||||
const quint32 &secondArcId, CrossArcsPoint crossPoint, const Source &typeCreation,
|
||||
const quint32 &secondArcId, CrossCirclesPoint crossPoint, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
virtual void setDialog();
|
||||
static VToolPointOfIntersectionArcs *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId,
|
||||
const quint32 &secondArcId, CrossArcsPoint crossPoint,
|
||||
const quint32 &secondArcId, CrossCirclesPoint crossPoint,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VPattern *doc, VContainer *data, const Document &parse,
|
||||
const Source &typeCreation);
|
||||
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcsPoint crossPoint);
|
||||
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossCirclesPoint crossPoint);
|
||||
static const QString ToolType;
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::PointOfIntersectionArcs) };
|
||||
|
@ -61,8 +61,8 @@ public:
|
|||
quint32 GetSecondArcId() const;
|
||||
void SetSecondArcId(const quint32 &value);
|
||||
|
||||
CrossArcsPoint GetCrossArcsPoint() const;
|
||||
void SetCrossArcsPoint(CrossArcsPoint &value);
|
||||
CrossCirclesPoint GetCrossCirclesPoint() const;
|
||||
void SetCrossCirclesPoint(CrossCirclesPoint &value);
|
||||
|
||||
virtual void ShowVisualization(bool show);
|
||||
protected:
|
||||
|
@ -81,7 +81,7 @@ private:
|
|||
/** @brief secondArcId id second arc. */
|
||||
quint32 secondArcId;
|
||||
|
||||
CrossArcsPoint crossPoint;
|
||||
CrossCirclesPoint crossPoint;
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINTOFINTERSECTIONARCS_H
|
||||
|
|
345
src/app/tools/drawTools/vtoolpointofintersectioncircles.cpp
Normal file
345
src/app/tools/drawTools/vtoolpointofintersectioncircles.cpp
Normal file
|
@ -0,0 +1,345 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtoolpointofintersectioncircles.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 29 5, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vtoolpointofintersectioncircles.h"
|
||||
#include "../../dialogs/tools/dialogpointofintersectioncircles.h"
|
||||
#include "../../libs/vgeometry/vpointf.h"
|
||||
#include "../../libs/vgeometry/varc.h"
|
||||
#include "../../visualization/vistoolpointofintersectioncircles.h"
|
||||
#include "../container/vformula.h"
|
||||
|
||||
const QString VToolPointOfIntersectionCircles::ToolType = QStringLiteral("pointOfIntersectionCircles");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(VPattern *doc, VContainer *data, const quint32 &id,
|
||||
quint32 firstCircleCenterId,
|
||||
quint32 secondCircleCenterId,
|
||||
const QString &firstCircleRadius,
|
||||
const QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint,
|
||||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolPoint(doc, data, id, parent), firstCircleCenterId(firstCircleCenterId),
|
||||
secondCircleCenterId(secondCircleCenterId), firstCircleRadius(firstCircleRadius),
|
||||
secondCircleRadius(secondCircleRadius), crossPoint(crossPoint)
|
||||
{
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::setDialog()
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogPointOfIntersectionCircles *dialogTool = qobject_cast<DialogPointOfIntersectionCircles*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
dialogTool->SetFirstCircleCenterId(firstCircleCenterId);
|
||||
dialogTool->SetSecondCircleCenterId(secondCircleCenterId);
|
||||
dialogTool->SetFirstCircleRadius(firstCircleRadius);
|
||||
dialogTool->SetSecondCircleRadius(secondCircleRadius);
|
||||
dialogTool->SetCrossCirclesPoint(crossPoint);
|
||||
dialogTool->SetPointName(p->name());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(DialogTool *dialog, VMainGraphicsScene *scene,
|
||||
VPattern *doc, VContainer *data)
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogPointOfIntersectionCircles *dialogTool = qobject_cast<DialogPointOfIntersectionCircles*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
const quint32 firstCircleCenterId = dialogTool->GetFirstCircleCenterId();
|
||||
const quint32 secondCircleCenterId = dialogTool->GetSecondCircleCenterId();
|
||||
QString firstCircleRadius = dialogTool->GetFirstCircleRadius();
|
||||
QString secondCircleRadius = dialogTool->GetSecondCircleRadius();
|
||||
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
|
||||
const QString pointName = dialogTool->getPointName();
|
||||
VToolPointOfIntersectionCircles *point = nullptr;
|
||||
point = Create(0, pointName, firstCircleCenterId, secondCircleCenterId, firstCircleRadius, secondCircleRadius,
|
||||
pType, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||
if (point != nullptr)
|
||||
{
|
||||
point->dialog=dialogTool;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const quint32 _id, const QString &pointName,
|
||||
quint32 firstCircleCenterId,
|
||||
quint32 secondCircleCenterId,
|
||||
QString &firstCircleRadius,
|
||||
QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene,
|
||||
VPattern *doc, VContainer *data,
|
||||
const Document &parse,
|
||||
const Source &typeCreation)
|
||||
{
|
||||
const qreal calcC1Radius = qApp->toPixel(CheckFormula(_id, firstCircleRadius, data));
|
||||
const qreal calcC2Radius = qApp->toPixel(CheckFormula(_id, secondCircleRadius, data));
|
||||
|
||||
const VPointF c1Point = *data->GeometricObject<VPointF>(firstCircleCenterId);
|
||||
const VPointF c2Point = *data->GeometricObject<VPointF>(secondCircleCenterId);
|
||||
|
||||
const QPointF point = FindPoint(c1Point.toQPointF(), c2Point.toQPointF(), calcC1Radius, calcC2Radius, 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::PointOfIntersectionCircles, doc);
|
||||
if (parse == Document::FullParse)
|
||||
{
|
||||
VToolPointOfIntersectionCircles *point = new VToolPointOfIntersectionCircles(doc, data, id, firstCircleCenterId,
|
||||
secondCircleCenterId,
|
||||
firstCircleRadius,
|
||||
secondCircleRadius, crossPoint,
|
||||
typeCreation);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolPointOfIntersectionCircles::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionCircles::SetFactor);
|
||||
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionCircles::Disable);
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionCircles::EnableToolMove);
|
||||
doc->AddTool(id, point);
|
||||
doc->IncrementReferens(firstCircleCenterId);
|
||||
doc->IncrementReferens(secondCircleCenterId);
|
||||
return point;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VToolPointOfIntersectionCircles::FindPoint(const QPointF &c1Point, const QPointF &c2Point, qreal c1Radius,
|
||||
qreal c2Radius, const CrossCirclesPoint crossPoint)
|
||||
{
|
||||
QPointF p1, p2;
|
||||
const int res = VGObject::IntersectionCircles(c1Point, c1Radius, c2Point, c2Radius, p1, p2);
|
||||
|
||||
switch(res)
|
||||
{
|
||||
case 2:
|
||||
if (crossPoint == CrossCirclesPoint::FirstPoint)
|
||||
{
|
||||
return p1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p2;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
return p1;
|
||||
break;
|
||||
case 3:
|
||||
case 0:
|
||||
default:
|
||||
return QPointF(0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolPointOfIntersectionCircles::GetFirstCircleCenterId() const
|
||||
{
|
||||
return firstCircleCenterId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SetFirstCircleCenterId(const quint32 &value)
|
||||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
firstCircleCenterId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolPointOfIntersectionCircles::GetSecondCircleCenterId() const
|
||||
{
|
||||
return secondCircleCenterId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &value)
|
||||
{
|
||||
if (value != NULL_ID)
|
||||
{
|
||||
secondCircleCenterId = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolPointOfIntersectionCircles::GetFirstCircleRadius() const
|
||||
{
|
||||
VFormula radius(firstCircleRadius, getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SetFirstCircleRadius(const VFormula &value)
|
||||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
firstCircleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolPointOfIntersectionCircles::GetSecondCircleRadius() const
|
||||
{
|
||||
VFormula radius(secondCircleRadius, getData());
|
||||
radius.setCheckZero(true);
|
||||
radius.setToolId(id);
|
||||
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
|
||||
return radius;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SetSecondCircleRadius(const VFormula &value)
|
||||
{
|
||||
if (value.error() == false)
|
||||
{
|
||||
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
|
||||
{
|
||||
secondCircleRadius = value.GetFormula(FormulaType::FromUser);
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
CrossCirclesPoint VToolPointOfIntersectionCircles::GetCrossCirclesPoint() const
|
||||
{
|
||||
return crossPoint;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SetCrossCirclesPoint(CrossCirclesPoint &value)
|
||||
{
|
||||
crossPoint = value;
|
||||
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::ShowVisualization(bool show)
|
||||
{
|
||||
ShowToolVisualization<VisToolPointOfIntersectionCircles>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::RemoveReferens()
|
||||
{
|
||||
doc->DecrementReferens(firstCircleCenterId);
|
||||
doc->DecrementReferens(secondCircleCenterId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionCircles>(this, event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement)
|
||||
{
|
||||
SCASSERT(dialog != nullptr);
|
||||
DialogPointOfIntersectionCircles *dialogTool = qobject_cast<DialogPointOfIntersectionCircles*>(dialog);
|
||||
SCASSERT(dialogTool != nullptr);
|
||||
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
||||
doc->SetAttribute(domElement, AttrC1Center, QString().setNum(dialogTool->GetFirstCircleCenterId()));
|
||||
doc->SetAttribute(domElement, AttrC2Center, QString().setNum(dialogTool->GetSecondCircleCenterId()));
|
||||
doc->SetAttribute(domElement, AttrC1Radius, dialogTool->GetFirstCircleRadius());
|
||||
doc->SetAttribute(domElement, AttrC2Radius, dialogTool->GetSecondCircleRadius());
|
||||
doc->SetAttribute(domElement, AttrCrossPoint,
|
||||
QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint())));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolPoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrC1Center, firstCircleCenterId);
|
||||
doc->SetAttribute(tag, AttrC2Center, secondCircleCenterId);
|
||||
doc->SetAttribute(tag, AttrC1Radius, firstCircleRadius);
|
||||
doc->SetAttribute(tag, AttrC2Radius, secondCircleRadius);
|
||||
doc->SetAttribute(tag, AttrCrossPoint, static_cast<int>(crossPoint));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::ReadToolAttributes(const QDomElement &domElement)
|
||||
{
|
||||
firstCircleCenterId = doc->GetParametrUInt(domElement, AttrC1Center, NULL_ID_STR);
|
||||
secondCircleCenterId = doc->GetParametrUInt(domElement, AttrC2Center, NULL_ID_STR);
|
||||
firstCircleRadius = doc->GetParametrString(domElement, AttrC1Radius);
|
||||
secondCircleRadius = doc->GetParametrString(domElement, AttrC2Radius);
|
||||
crossPoint = static_cast<CrossCirclesPoint>(doc->GetParametrUInt(domElement, AttrCrossPoint, "1"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolPointOfIntersectionCircles *visual = qobject_cast<VisToolPointOfIntersectionCircles *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(firstCircleCenterId);
|
||||
visual->setPoint2Id(secondCircleCenterId);
|
||||
visual->setC1Radius(firstCircleRadius);
|
||||
visual->setC2Radius(secondCircleRadius);
|
||||
visual->setCrossPoint(crossPoint);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
97
src/app/tools/drawTools/vtoolpointofintersectioncircles.h
Normal file
97
src/app/tools/drawTools/vtoolpointofintersectioncircles.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vtoolpointofintersectioncircles.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 29 5, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||
#define VTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "../../xml/vpattern.h"
|
||||
|
||||
class VFormula;
|
||||
|
||||
class VToolPointOfIntersectionCircles : public VToolPoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolPointOfIntersectionCircles(VPattern *doc, VContainer *data, const quint32 &id, const
|
||||
quint32 firstCircleCenterId, quint32 secondCircleCenterId,
|
||||
const QString &firstCircleRadius, const QString &secondCircleRadius,
|
||||
CrossCirclesPoint crossPoint, const Source &typeCreation,
|
||||
QGraphicsItem * parent = nullptr);
|
||||
virtual void setDialog();
|
||||
static VToolPointOfIntersectionCircles *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolPointOfIntersectionCircles *Create(const quint32 _id, const QString &pointName,
|
||||
quint32 firstCircleCenterId, quint32 secondCircleCenterId,
|
||||
QString &firstCircleRadius, QString &secondCircleRadius,
|
||||
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 &c1Point, const QPointF &c2Point, qreal c1Radius, qreal c2Radius,
|
||||
const CrossCirclesPoint crossPoint);
|
||||
static const QString ToolType;
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::PointOfIntersectionCircles) };
|
||||
|
||||
quint32 GetFirstCircleCenterId() const;
|
||||
void SetFirstCircleCenterId(const quint32 &value);
|
||||
|
||||
quint32 GetSecondCircleCenterId() const;
|
||||
void SetSecondCircleCenterId(const quint32 &value);
|
||||
|
||||
VFormula GetFirstCircleRadius() const;
|
||||
void SetFirstCircleRadius(const VFormula &value);
|
||||
|
||||
VFormula GetSecondCircleRadius() const;
|
||||
void SetSecondCircleRadius(const VFormula &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<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolPointOfIntersectionCircles)
|
||||
|
||||
quint32 firstCircleCenterId;
|
||||
quint32 secondCircleCenterId;
|
||||
|
||||
QString firstCircleRadius;
|
||||
QString secondCircleRadius;
|
||||
|
||||
CrossCirclesPoint crossPoint;
|
||||
};
|
||||
|
||||
#endif // VTOOLPOINTOFINTERSECTIONCIRCLES_H
|
|
@ -39,7 +39,8 @@ HEADERS += \
|
|||
$$PWD/drawTools/vtoolcut.h \
|
||||
$$PWD/drawTools/vtoollineintersectaxis.h \
|
||||
$$PWD/drawTools/vtoolcurveintersectaxis.h \
|
||||
$$PWD/drawTools/vtoolpointofintersectionarcs.h
|
||||
$$PWD/drawTools/vtoolpointofintersectionarcs.h \
|
||||
$$PWD/drawTools/vtoolpointofintersectioncircles.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vtooldetail.cpp \
|
||||
|
@ -76,4 +77,5 @@ SOURCES += \
|
|||
$$PWD/drawTools/vtoolcut.cpp \
|
||||
$$PWD/drawTools/vtoollineintersectaxis.cpp \
|
||||
$$PWD/drawTools/vtoolcurveintersectaxis.cpp \
|
||||
$$PWD/drawTools/vtoolpointofintersectionarcs.cpp
|
||||
$$PWD/drawTools/vtoolpointofintersectionarcs.cpp \
|
||||
$$PWD/drawTools/vtoolpointofintersectioncircles.cpp
|
||||
|
|
|
@ -79,6 +79,10 @@ const QString VAbstractTool::AttrColor = QStringLiteral("color");
|
|||
const QString VAbstractTool::AttrFirstArc = QStringLiteral("firstArc");
|
||||
const QString VAbstractTool::AttrSecondArc = QStringLiteral("secondArc");
|
||||
const QString VAbstractTool::AttrCrossPoint = QStringLiteral("crossPoint");
|
||||
const QString VAbstractTool::AttrC1Center = QStringLiteral("c1Center");
|
||||
const QString VAbstractTool::AttrC2Center = QStringLiteral("c2Center");
|
||||
const QString VAbstractTool::AttrC1Radius = QStringLiteral("c1Radius");
|
||||
const QString VAbstractTool::AttrC2Radius = QStringLiteral("c2Radius");
|
||||
|
||||
const QString VAbstractTool::TypeLineNone = QStringLiteral("none");
|
||||
const QString VAbstractTool::TypeLineLine = QStringLiteral("hair");
|
||||
|
|
|
@ -94,6 +94,10 @@ public:
|
|||
static const QString AttrFirstArc;
|
||||
static const QString AttrSecondArc;
|
||||
static const QString AttrCrossPoint;
|
||||
static const QString AttrC1Center;
|
||||
static const QString AttrC2Center;
|
||||
static const QString AttrC1Radius;
|
||||
static const QString AttrC2Radius;
|
||||
|
||||
static const QString TypeLineNone;
|
||||
static const QString TypeLineLine;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent)
|
||||
: VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossArcsPoint::FirstPoint), point(nullptr),
|
||||
: VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossCirclesPoint::FirstPoint), point(nullptr),
|
||||
arc1Path(nullptr), arc2Path(nullptr)
|
||||
{
|
||||
arc1Path = InitItem<QGraphicsPathItem>(Qt::darkGreen, this);
|
||||
|
@ -95,7 +95,7 @@ void VisToolPointOfIntersectionArcs::setArc2Id(const quint32 &value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossArcsPoint &value)
|
||||
void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossCirclesPoint &value)
|
||||
{
|
||||
crossPoint = value;
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ public:
|
|||
|
||||
void setArc1Id(const quint32 &value);
|
||||
void setArc2Id(const quint32 &value);
|
||||
void setCrossPoint(const CrossArcsPoint &value);
|
||||
void setCrossPoint(const CrossCirclesPoint &value);
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionArcs)};
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
|
||||
quint32 arc1Id;
|
||||
quint32 arc2Id;
|
||||
CrossArcsPoint crossPoint;
|
||||
CrossCirclesPoint crossPoint;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsPathItem *arc1Path;
|
||||
QGraphicsPathItem *arc2Path;
|
||||
|
|
116
src/app/visualization/vistoolpointofintersectioncircles.cpp
Normal file
116
src/app/visualization/vistoolpointofintersectioncircles.cpp
Normal file
|
@ -0,0 +1,116 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vistoolpointofintersectioncircles.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 29 5, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vistoolpointofintersectioncircles.h"
|
||||
#include "../container/vcontainer.h"
|
||||
#include "../tools/drawTools/vtoolpointofintersectioncircles.h"
|
||||
#include "../libs/vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent)
|
||||
: VisLine(data, parent), point2Id(NULL_ID), c1Radius(0), c2Radius(0),
|
||||
crossPoint(CrossCirclesPoint::FirstPoint), point(nullptr), c1Center(nullptr), c2Center(nullptr), c1Path(nullptr),
|
||||
c2Path(nullptr)
|
||||
{
|
||||
c1Path = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
|
||||
c2Path = InitItem<QGraphicsEllipseItem>(Qt::darkRed, this);
|
||||
point = InitPoint(mainColor, this);
|
||||
c1Center = InitPoint(supportColor, this);
|
||||
c2Center = InitPoint(supportColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointOfIntersectionCircles::~VisToolPointOfIntersectionCircles()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCircles::RefreshGeometry()
|
||||
{
|
||||
if (point1Id > NULL_ID)
|
||||
{
|
||||
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(point1Id);
|
||||
DrawPoint(c1Center, first->toQPointF(), supportColor);
|
||||
|
||||
if (point2Id > NULL_ID)
|
||||
{
|
||||
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(point2Id);
|
||||
DrawPoint(c2Center, second->toQPointF(), supportColor);
|
||||
|
||||
if (c1Radius > 0 && c2Radius > 0)
|
||||
{
|
||||
c1Path->setRect(PointRect(c1Radius));
|
||||
DrawPoint(c1Path, first->toQPointF(), Qt::darkGreen, Qt::DashLine);
|
||||
|
||||
c2Path->setRect(PointRect(c2Radius));
|
||||
DrawPoint(c2Path, second->toQPointF(), Qt::darkRed, Qt::DashLine);
|
||||
|
||||
const QPointF fPoint = VToolPointOfIntersectionCircles::FindPoint(first->toQPointF(),
|
||||
second->toQPointF(), c1Radius,
|
||||
c2Radius, crossPoint);
|
||||
DrawPoint(point, fPoint, mainColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCircles::VisualMode(const quint32 &id)
|
||||
{
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr);
|
||||
|
||||
this->point1Id = id;
|
||||
Visualization::scenePos = scene->getScenePos();
|
||||
RefreshGeometry();
|
||||
|
||||
AddOnScene();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCircles::setPoint2Id(const quint32 &value)
|
||||
{
|
||||
point2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCircles::setC1Radius(const QString &value)
|
||||
{
|
||||
c1Radius = FindLength(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCircles::setC2Radius(const QString &value)
|
||||
{
|
||||
c2Radius = FindLength(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &value)
|
||||
{
|
||||
crossPoint = value;
|
||||
}
|
65
src/app/visualization/vistoolpointofintersectioncircles.h
Normal file
65
src/app/visualization/vistoolpointofintersectioncircles.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vistoolpointofintersectioncircles.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 29 5, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VISTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||
#define VISTOOLPOINTOFINTERSECTIONCIRCLES_H
|
||||
|
||||
#include "visline.h"
|
||||
#include "../xml/vpattern.h"
|
||||
|
||||
class VisToolPointOfIntersectionCircles : public VisLine
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent = 0);
|
||||
virtual ~VisToolPointOfIntersectionCircles();
|
||||
|
||||
virtual void RefreshGeometry();
|
||||
virtual void VisualMode(const quint32 &id);
|
||||
|
||||
void setPoint2Id(const quint32 &value);
|
||||
void setC1Radius(const QString &value);
|
||||
void setC2Radius(const QString &value);
|
||||
void setCrossPoint(const CrossCirclesPoint &value);
|
||||
|
||||
virtual int type() const {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCircles)};
|
||||
private:
|
||||
Q_DISABLE_COPY(VisToolPointOfIntersectionCircles)
|
||||
quint32 point2Id;
|
||||
qreal c1Radius;
|
||||
qreal c2Radius;
|
||||
CrossCirclesPoint crossPoint;
|
||||
QGraphicsEllipseItem *point;
|
||||
QGraphicsEllipseItem *c1Center;
|
||||
QGraphicsEllipseItem *c2Center;
|
||||
QGraphicsEllipseItem *c1Path;
|
||||
QGraphicsEllipseItem *c2Path;
|
||||
};
|
||||
|
||||
#endif // VISTOOLPOINTOFINTERSECTIONCIRCLES_H
|
|
@ -27,7 +27,8 @@ HEADERS += \
|
|||
$$PWD/vistoolcutsplinepath.h \
|
||||
$$PWD/vistoollineintersectaxis.h \
|
||||
$$PWD/vistoolcurveintersectaxis.h \
|
||||
$$PWD/vistoolpointofintersectionarcs.h
|
||||
$$PWD/vistoolpointofintersectionarcs.h \
|
||||
visualization/vistoolpointofintersectioncircles.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vgraphicssimpletextitem.cpp \
|
||||
|
@ -55,4 +56,5 @@ SOURCES += \
|
|||
$$PWD/vistoolcutsplinepath.cpp \
|
||||
$$PWD/vistoollineintersectaxis.cpp \
|
||||
$$PWD/vistoolcurveintersectaxis.cpp \
|
||||
$$PWD/vistoolpointofintersectionarcs.cpp
|
||||
$$PWD/vistoolpointofintersectionarcs.cpp \
|
||||
visualization/vistoolpointofintersectioncircles.cpp
|
||||
|
|
|
@ -119,6 +119,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
|||
case VToolPointOfIntersectionArcs::Type:
|
||||
ShowOptionsToolPointOfIntersectionArcs(item);
|
||||
break;
|
||||
case VToolPointOfIntersectionCircles::Type:
|
||||
ShowOptionsToolPointOfIntersectionCircles(item);
|
||||
break;
|
||||
case VToolShoulderPoint::Type:
|
||||
ShowOptionsToolShoulderPoint(item);
|
||||
break;
|
||||
|
@ -209,6 +212,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
|
|||
case VToolPointOfIntersectionArcs::Type:
|
||||
UpdateOptionsToolPointOfIntersectionArcs();
|
||||
break;
|
||||
case VToolPointOfIntersectionCircles::Type:
|
||||
UpdateOptionsToolPointOfIntersectionCircles();
|
||||
break;
|
||||
case VToolShoulderPoint::Type:
|
||||
UpdateOptionsToolShoulderPoint();
|
||||
break;
|
||||
|
@ -314,6 +320,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
|
|||
case VToolPointOfIntersectionArcs::Type:
|
||||
ChangeDataToolPointOfIntersectionArcs(prop);
|
||||
break;
|
||||
case VToolPointOfIntersectionCircles::Type:
|
||||
ChangeDataToolPointOfIntersectionCircles(prop);
|
||||
break;
|
||||
case VToolShoulderPoint::Type:
|
||||
ChangeDataToolShoulderPoint(prop);
|
||||
break;
|
||||
|
@ -403,7 +412,7 @@ 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<int>(i->GetCrossArcsPoint())-1);
|
||||
itemProperty->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
|
||||
AddProperty(itemProperty, VAbstractTool::AttrCrossPoint);
|
||||
}
|
||||
|
||||
|
@ -466,6 +475,40 @@ void VToolOptionsPropertyBrowser::SetPointName(const QString &name)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::SetCrossCirclesPoint(const QVariant value)
|
||||
{
|
||||
if (Tool *i = qgraphicsitem_cast<Tool *>(currentItem))
|
||||
{
|
||||
bool ok = false;
|
||||
const int val = value.toInt(&ok);
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't cast item";
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::AddProperty(VProperty *property, const QString &id)
|
||||
{
|
||||
|
@ -864,26 +907,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionArcs(VPropert
|
|||
case 28: // VAbstractTool::AttrCrossPoint
|
||||
{
|
||||
const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole);
|
||||
bool ok = false;
|
||||
const int val = value.toInt(&ok);
|
||||
|
||||
CrossArcsPoint cross = CrossArcsPoint::FirstPoint;
|
||||
if (ok)
|
||||
{
|
||||
switch(val)
|
||||
{
|
||||
case 0:
|
||||
cross = CrossArcsPoint::FirstPoint;
|
||||
break;
|
||||
case 1:
|
||||
cross = CrossArcsPoint::SecondPoint;
|
||||
break;
|
||||
default:
|
||||
cross = CrossArcsPoint::FirstPoint;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i->SetCrossArcsPoint(cross);
|
||||
SetCrossCirclesPoint<VToolPointOfIntersectionArcs>(value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -892,6 +916,39 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionArcs(VPropert
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionCircles(VProperty *property)
|
||||
{
|
||||
SCASSERT(property != nullptr)
|
||||
|
||||
const QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
|
||||
const QString id = propertyToId[property];
|
||||
|
||||
VToolPointOfIntersectionCircles *i = qgraphicsitem_cast<VToolPointOfIntersectionCircles *>(currentItem);
|
||||
SCASSERT(i != nullptr);
|
||||
switch (PropertiesList().indexOf(id))
|
||||
{
|
||||
case 0: // VAbstractTool::AttrName
|
||||
SetPointName<VToolPointOfIntersectionCircles>(value.toString());
|
||||
break;
|
||||
case 28: // VAbstractTool::AttrCrossPoint
|
||||
{
|
||||
const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole);
|
||||
SetCrossCirclesPoint<VToolPointOfIntersectionCircles>(value);
|
||||
break;
|
||||
}
|
||||
case 29: // VAbstractTool::AttrC1Radius
|
||||
i->SetFirstCircleRadius(value.value<VFormula>());
|
||||
break;
|
||||
case 30: // VAbstractTool::AttrC2Radius
|
||||
i->SetSecondCircleRadius(value.value<VFormula>());
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"Unknown property type. id = "<<id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ChangeDataToolShoulderPoint(VProperty *property)
|
||||
{
|
||||
|
@ -1247,6 +1304,19 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionArcs(QGraphi
|
|||
AddPropertyCrossPoint(i, tr("Take"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionCircles(QGraphicsItem *item)
|
||||
{
|
||||
VToolPointOfIntersectionCircles *i = qgraphicsitem_cast<VToolPointOfIntersectionCircles *>(item);
|
||||
i->ShowVisualization(true);
|
||||
formView->setTitle(tr("Tool to make point from intersection two circles"));
|
||||
|
||||
AddPropertyPointName(i, tr("Point label"));
|
||||
AddPropertyFormula(tr("First circle radius"), i->GetFirstCircleRadius(), VAbstractTool::AttrC1Radius);
|
||||
AddPropertyFormula(tr("Second circle radius"), i->GetSecondCircleRadius(), VAbstractTool::AttrC2Radius);
|
||||
AddPropertyCrossPoint(i, tr("Take"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item)
|
||||
{
|
||||
|
@ -1567,7 +1637,24 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs()
|
|||
VToolPointOfIntersectionArcs *i = qgraphicsitem_cast<VToolPointOfIntersectionArcs *>(currentItem);
|
||||
|
||||
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
|
||||
idToProperty[VAbstractTool::AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossArcsPoint())-1);
|
||||
idToProperty[VAbstractTool::AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCircles()
|
||||
{
|
||||
VToolPointOfIntersectionCircles *i = qgraphicsitem_cast<VToolPointOfIntersectionCircles *>(currentItem);
|
||||
|
||||
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
|
||||
idToProperty[VAbstractTool::AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
|
||||
|
||||
QVariant c1Radius;
|
||||
c1Radius.setValue(i->GetFirstCircleRadius());
|
||||
idToProperty[VAbstractTool::AttrC1Radius]->setValue(c1Radius);
|
||||
|
||||
QVariant c2Radius;
|
||||
c2Radius.setValue(i->GetSecondCircleRadius());
|
||||
idToProperty[VAbstractTool::AttrC2Radius]->setValue(c2Radius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1697,6 +1784,8 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
|||
<< VAbstractTool::AttrKCurve /* 25 */
|
||||
<< VAbstractTool::AttrLineColor /* 26 */
|
||||
<< VAbstractTool::AttrColor /* 27 */
|
||||
<< VAbstractTool::AttrCrossPoint; /* 28 */
|
||||
<< VAbstractTool::AttrCrossPoint /* 28 */
|
||||
<< VAbstractTool::AttrC1Radius /* 29 */
|
||||
<< VAbstractTool::AttrC2Radius; /* 30 */
|
||||
return attr;
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ private:
|
|||
template<class Tool>
|
||||
void SetPointName(const QString &name);
|
||||
|
||||
template<class Tool>
|
||||
void SetCrossCirclesPoint(const QVariant value);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyPointName(Tool *i, const QString &propertyName);
|
||||
|
||||
|
@ -100,6 +103,7 @@ private:
|
|||
void ChangeDataToolPointOfContact(VPE::VProperty *property);
|
||||
void ChangeDataToolPointOfIntersection(VPE::VProperty *property);
|
||||
void ChangeDataToolPointOfIntersectionArcs(VPE::VProperty *property);
|
||||
void ChangeDataToolPointOfIntersectionCircles(VPE::VProperty *property);
|
||||
void ChangeDataToolShoulderPoint(VPE::VProperty *property);
|
||||
void ChangeDataToolSpline(VPE::VProperty *property);
|
||||
void ChangeDataToolSplinePath(VPE::VProperty *property);
|
||||
|
@ -122,6 +126,7 @@ private:
|
|||
void ShowOptionsToolPointOfContact(QGraphicsItem *item);
|
||||
void ShowOptionsToolPointOfIntersection(QGraphicsItem *item);
|
||||
void ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item);
|
||||
void ShowOptionsToolPointOfIntersectionCircles(QGraphicsItem *item);
|
||||
void ShowOptionsToolShoulderPoint(QGraphicsItem *item);
|
||||
void ShowOptionsToolSpline(QGraphicsItem *item);
|
||||
void ShowOptionsToolSplinePath(QGraphicsItem *item);
|
||||
|
@ -144,6 +149,7 @@ private:
|
|||
void UpdateOptionsToolPointOfContact();
|
||||
void UpdateOptionsToolPointOfIntersection();
|
||||
void UpdateOptionsToolPointOfIntersectionArcs();
|
||||
void UpdateOptionsToolPointOfIntersectionCircles();
|
||||
void UpdateOptionsToolShoulderPoint();
|
||||
void UpdateOptionsToolSpline();
|
||||
void UpdateOptionsToolSplinePath();
|
||||
|
|
|
@ -1143,7 +1143,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
<< VToolPointOfIntersection::ToolType << VToolCutSpline::ToolType
|
||||
<< VToolCutSplinePath::ToolType << VToolCutArc::ToolType
|
||||
<< VToolLineIntersectAxis::ToolType << VToolCurveIntersectAxis::ToolType
|
||||
<< VToolPointOfIntersectionArcs::ToolType;
|
||||
<< VToolPointOfIntersectionArcs::ToolType
|
||||
<< VToolPointOfIntersectionCircles::ToolType;
|
||||
switch (points.indexOf(type))
|
||||
{
|
||||
case 0: //VToolSinglePoint::ToolType
|
||||
|
@ -1640,7 +1641,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||
const quint32 firstArcId = GetParametrUInt(domElement, VAbstractTool::AttrFirstArc, NULL_ID_STR);
|
||||
const quint32 secondArcId = GetParametrUInt(domElement, VAbstractTool::AttrSecondArc, NULL_ID_STR);
|
||||
const CrossArcsPoint crossPoint = static_cast<CrossArcsPoint>(GetParametrUInt(domElement,
|
||||
const CrossCirclesPoint crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement,
|
||||
VAbstractTool::AttrCrossPoint,
|
||||
"1"));
|
||||
|
||||
|
@ -1654,6 +1655,37 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
throw excep;
|
||||
}
|
||||
break;
|
||||
case 18: //VToolPointOfIntersectionCircles::ToolType
|
||||
try
|
||||
{
|
||||
PointsCommonAttributes(domElement, id, name, mx, my);
|
||||
const quint32 c1CenterId = GetParametrUInt(domElement, VAbstractTool::AttrC1Center, NULL_ID_STR);
|
||||
const quint32 c2CenterId = GetParametrUInt(domElement, VAbstractTool::AttrC2Center, NULL_ID_STR);
|
||||
const QString c1Radius = GetParametrString(domElement, VAbstractTool::AttrC1Radius);
|
||||
QString c1R = c1Radius;
|
||||
const QString c2Radius = GetParametrString(domElement, VAbstractTool::AttrC2Radius);
|
||||
QString c2R = c2Radius;
|
||||
const CrossCirclesPoint crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement,
|
||||
VAbstractTool::AttrCrossPoint,
|
||||
"1"));
|
||||
|
||||
VToolPointOfIntersectionCircles::Create(id, name, c1CenterId, c2CenterId, c1R, c2R, crossPoint, mx, my,
|
||||
scene, this, data, parse, Source::FromFile);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
if (c1R != c1Radius || c2R != c2Radius)
|
||||
{
|
||||
SetAttribute(domElement, VAbstractTool::AttrC1Center, c1R);
|
||||
SetAttribute(domElement, VAbstractTool::AttrC2Center, c2R);
|
||||
haveLiteChange();
|
||||
}
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
VExceptionObjectError excep(tr("Error creating or updating point of intersection circles"), domElement);
|
||||
excep.AddMoreInformation(e.ErrorMessage());
|
||||
throw excep;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Illegal point type in VDomDocument::ParsePointElement().";
|
||||
break;
|
||||
|
|
|
@ -38,7 +38,7 @@ class VMainGraphicsScene;
|
|||
|
||||
enum class Document : char { LiteParse, LitePPParse, FullParse };
|
||||
enum class LabelType : char {NewPatternPiece, NewLabel};
|
||||
enum class CrossArcsPoint : char {FirstPoint = 1, SecondPoint = 2};
|
||||
enum class CrossCirclesPoint : char {FirstPoint = 1, SecondPoint = 2};
|
||||
|
||||
/**
|
||||
* @brief The VPattern class working with pattern file.
|
||||
|
|
|
@ -126,6 +126,10 @@
|
|||
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="crossPoint" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
||||
|
|
Loading…
Reference in New Issue
Block a user