2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file dialogarc.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-11-15 13:41:26 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-08-06 09:56:09 +02:00
|
|
|
#include "dialogarc.h"
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <limits.h>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
#include <QPointer>
|
2013-11-21 13:05:26 +01:00
|
|
|
#include <QPushButton>
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QTimer>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QToolButton>
|
|
|
|
#include <Qt>
|
2014-06-08 20:10:57 +02:00
|
|
|
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
|
|
|
#include "../vpatterndb/vtranslatevars.h"
|
2019-02-11 12:25:27 +01:00
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../../visualization/path/vistoolarc.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../visualization/visualization.h"
|
2015-06-18 19:23:24 +02:00
|
|
|
#include "../support/dialogeditwrongformula.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vmisc/vcommonsettings.h"
|
|
|
|
#include "ui_dialogarc.h"
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogArc create dialog
|
|
|
|
* @param data container with data
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2019-02-11 12:25:27 +01:00
|
|
|
DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
|
|
|
|
: DialogTool(data, toolId, parent),
|
|
|
|
ui(new Ui::DialogArc),
|
|
|
|
flagRadius(false),
|
|
|
|
flagF1(false),
|
|
|
|
flagF2(false),
|
|
|
|
timerRadius(new QTimer(this)),
|
|
|
|
timerF1(new QTimer(this)),
|
|
|
|
timerF2(new QTimer(this)),
|
|
|
|
radius(),
|
|
|
|
f1(),
|
|
|
|
f2(),
|
|
|
|
formulaBaseHeight(0),
|
|
|
|
formulaBaseHeightF1(0),
|
|
|
|
formulaBaseHeightF2(0),
|
|
|
|
angleF1(INT_MIN),
|
|
|
|
angleF2(INT_MIN)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
ui->setupUi(this);
|
|
|
|
|
2017-10-11 12:51:06 +02:00
|
|
|
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
|
|
|
|
2014-06-19 14:01:38 +02:00
|
|
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
|
|
|
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
|
|
|
|
this->formulaBaseHeightF2 = ui->plainTextEditF2->height();
|
2014-06-19 11:29:56 +02:00
|
|
|
|
2014-10-29 19:00:38 +01:00
|
|
|
ui->plainTextEditFormula->installEventFilter(this);
|
|
|
|
ui->plainTextEditF1->installEventFilter(this);
|
|
|
|
ui->plainTextEditF2->installEventFilter(this);
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
timerRadius->setSingleShot(true);
|
2013-08-06 09:56:09 +02:00
|
|
|
connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius);
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
timerF1->setSingleShot(true);
|
2014-11-21 15:57:47 +01:00
|
|
|
connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
timerF2->setSingleShot(true);
|
2014-11-21 15:57:47 +01:00
|
|
|
connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
2014-06-09 22:38:10 +02:00
|
|
|
InitOkCancelApply(ui);
|
|
|
|
|
2013-08-06 09:56:09 +02:00
|
|
|
FillComboBoxPoints(ui->comboBoxBasePoint);
|
2015-02-02 12:10:02 +01:00
|
|
|
FillComboBoxLineColors(ui->comboBoxColor);
|
2017-05-16 12:07:53 +02:00
|
|
|
FillComboBoxTypeLine(ui->comboBoxPenStyle, CurvePenStylesPics());
|
2013-08-06 09:56:09 +02:00
|
|
|
|
2015-04-29 19:32:27 +02:00
|
|
|
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogArc::FXRadius);
|
|
|
|
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogArc::FXF1);
|
|
|
|
connect(ui->toolButtonExprF2, &QPushButton::clicked, this, &DialogArc::FXF2);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
|
|
|
{
|
|
|
|
timerRadius->start(formulaTimerTimeout);
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, [this]()
|
|
|
|
{
|
|
|
|
timerF1->start(formulaTimerTimeout);
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, [this]()
|
|
|
|
{
|
|
|
|
timerF2->start(formulaTimerTimeout);
|
|
|
|
});
|
2014-06-09 22:38:10 +02:00
|
|
|
|
2014-06-19 11:29:56 +02:00
|
|
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit);
|
|
|
|
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
|
|
|
|
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
|
2014-08-15 15:54:24 +02:00
|
|
|
|
2015-05-21 21:24:31 +02:00
|
|
|
vis = new VisToolArc(data);
|
2014-06-09 22:38:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::DeployFormulaTextEdit()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
2014-06-19 11:29:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::DeployF1TextEdit()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
DeployFormula(this, ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
|
2014-06-19 11:29:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::DeployF2TextEdit()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
DeployFormula(this, ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
DialogArc::~DialogArc()
|
|
|
|
{
|
2013-10-26 19:55:06 +02:00
|
|
|
delete ui;
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief SetCenter set id of center point
|
|
|
|
* @param value id
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogArc::SetCenter(const quint32 &value)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-02-03 09:17:59 +01:00
|
|
|
ChangeCurrentData(ui->comboBoxBasePoint, value);
|
2016-01-24 17:15:08 +01:00
|
|
|
vis->setObject1Id(value);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief SetF2 set formula second angle of arc
|
|
|
|
* @param value formula
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogArc::SetF2(const QString &value)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
f2 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
|
2014-06-19 11:29:56 +02:00
|
|
|
// increase height if needed.
|
|
|
|
if (f2.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployF2TextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditF2->setPlainText(f2);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
|
|
|
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(path != nullptr)
|
2014-08-15 15:54:24 +02:00
|
|
|
path->setF2(f2);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2014-10-29 14:40:56 +01:00
|
|
|
MoveCursorToEnd(ui->plainTextEditF2);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogArc::GetPenStyle() const
|
|
|
|
{
|
|
|
|
return GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::SetPenStyle(const QString &value)
|
|
|
|
{
|
|
|
|
ChangeCurrentData(ui->comboBoxPenStyle, value);
|
|
|
|
}
|
|
|
|
|
2015-02-03 10:27:33 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogArc::GetColor() const
|
|
|
|
{
|
2016-10-17 13:53:46 +02:00
|
|
|
return GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack);
|
2015-02-03 10:27:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::SetColor(const QString &value)
|
|
|
|
{
|
|
|
|
ChangeCurrentData(ui->comboBoxColor, value);
|
|
|
|
}
|
|
|
|
|
2017-10-11 12:51:06 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal DialogArc::GetApproximationScale() const
|
|
|
|
{
|
|
|
|
return ui->doubleSpinBoxApproximationScale->value();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::SetApproximationScale(qreal value)
|
|
|
|
{
|
|
|
|
ui->doubleSpinBoxApproximationScale->setValue(value);
|
|
|
|
|
|
|
|
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
|
|
|
|
SCASSERT(path != nullptr)
|
|
|
|
path->setApproximationScale(value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief SetF1 set formula first angle of arc
|
|
|
|
* @param value formula
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogArc::SetF1(const QString &value)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
f1 = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
|
2014-06-19 11:29:56 +02:00
|
|
|
// increase height if needed.
|
|
|
|
if (f1.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployF1TextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditF1->setPlainText(f1);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
|
|
|
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(path != nullptr)
|
2014-08-15 15:54:24 +02:00
|
|
|
path->setF1(f1);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2014-10-29 14:40:56 +01:00
|
|
|
MoveCursorToEnd(ui->plainTextEditF1);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief SetRadius set formula of radius
|
|
|
|
* @param value formula
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogArc::SetRadius(const QString &value)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
radius = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
|
2014-06-09 22:38:10 +02:00
|
|
|
// increase height if needed.
|
|
|
|
if (radius.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployFormulaTextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditFormula->setPlainText(radius);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
|
|
|
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(path != nullptr)
|
2014-08-15 15:54:24 +02:00
|
|
|
path->setRadius(radius);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2014-10-29 14:40:56 +01:00
|
|
|
MoveCursorToEnd(ui->plainTextEditFormula);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
|
|
|
* @param id id of point or detail
|
|
|
|
* @param type type of object
|
|
|
|
*/
|
2014-07-15 16:42:41 +02:00
|
|
|
void DialogArc::ChosenObject(quint32 id, const SceneObject &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-17 20:49:29 +02:00
|
|
|
if (prepare == false)// After first choose we ignore all objects
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-17 20:49:29 +02:00
|
|
|
if (type == SceneObject::Point)
|
|
|
|
{
|
2018-03-14 15:01:24 +01:00
|
|
|
if (SetObject(id, ui->comboBoxBasePoint, QString()))
|
2014-08-17 20:49:29 +02:00
|
|
|
{
|
2015-05-21 21:24:31 +02:00
|
|
|
vis->VisualMode(id);
|
2014-08-17 20:49:29 +02:00
|
|
|
prepare = true;
|
|
|
|
this->setModal(true);
|
|
|
|
this->show();
|
|
|
|
}
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-15 15:54:24 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::ShowVisualization()
|
|
|
|
{
|
2015-05-21 21:24:31 +02:00
|
|
|
AddVisualization<VisToolArc>();
|
2014-08-15 15:54:24 +02:00
|
|
|
}
|
|
|
|
|
2014-06-09 22:38:10 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::SaveData()
|
|
|
|
{
|
|
|
|
radius = ui->plainTextEditFormula->toPlainText();
|
2014-06-19 11:29:56 +02:00
|
|
|
f1 = ui->plainTextEditF1->toPlainText();
|
|
|
|
f2 = ui->plainTextEditF2->toPlainText();
|
2014-08-15 15:54:24 +02:00
|
|
|
|
2015-05-21 21:24:31 +02:00
|
|
|
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(path != nullptr)
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
path->setObject1Id(GetCenter());
|
2014-08-15 15:54:24 +02:00
|
|
|
path->setRadius(radius);
|
|
|
|
path->setF1(f1);
|
|
|
|
path->setF2(f2);
|
2017-10-11 12:51:06 +02:00
|
|
|
path->setApproximationScale(ui->doubleSpinBoxApproximationScale->value());
|
2014-08-15 15:54:24 +02:00
|
|
|
path->RefreshGeometry();
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-11-22 19:37:59 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
ui->plainTextEditFormula->blockSignals(true);
|
|
|
|
ui->plainTextEditF1->blockSignals(true);
|
|
|
|
ui->plainTextEditF2->blockSignals(true);
|
|
|
|
DialogTool::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
2015-04-29 19:32:27 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::FXRadius()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit radius"));
|
|
|
|
dialog->SetFormula(GetRadius());
|
2020-10-15 17:05:21 +02:00
|
|
|
dialog->setPostfix(UnitsToStr(qApp->patternUnits(), true));
|
2015-04-29 19:32:27 +02:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetRadius(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::FXF1()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit first angle"));
|
|
|
|
dialog->SetFormula(GetF1());
|
2015-07-03 17:54:25 +02:00
|
|
|
dialog->setPostfix(degreeSymbol);
|
2015-04-29 19:32:27 +02:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetF1(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogArc::FXF2()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit second angle"));
|
|
|
|
dialog->SetFormula(GetF2());
|
2015-07-03 17:54:25 +02:00
|
|
|
dialog->setPostfix(degreeSymbol);
|
2015-04-29 19:32:27 +02:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetF2(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief EvalRadius calculate value of radius
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogArc::EvalRadius()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
FormulaData formulaData;
|
|
|
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
|
|
|
formulaData.variables = data->DataVariables();
|
|
|
|
formulaData.labelEditFormula = ui->labelEditRadius;
|
|
|
|
formulaData.labelResult = ui->labelResultRadius;
|
2020-10-15 17:05:21 +02:00
|
|
|
formulaData.postfix = UnitsToStr(qApp->patternUnits(), true);
|
2019-02-11 12:25:27 +01:00
|
|
|
|
|
|
|
const qreal radius = Eval(formulaData, flagRadius);
|
2014-11-22 11:57:05 +01:00
|
|
|
|
|
|
|
if (radius < 0)
|
|
|
|
{
|
|
|
|
flagRadius = false;
|
2019-02-11 12:25:27 +01:00
|
|
|
ChangeColor(ui->labelEditRadius, errorColor);
|
2014-11-22 11:57:05 +01:00
|
|
|
ui->labelResultRadius->setText(tr("Error"));
|
|
|
|
ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
|
|
|
|
|
|
|
|
DialogArc::CheckState();
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
2014-11-21 15:57:47 +01:00
|
|
|
* @brief EvalF1 calculate value of angle
|
2014-06-02 16:28:02 +02:00
|
|
|
*/
|
2014-11-21 15:57:47 +01:00
|
|
|
void DialogArc::EvalF()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
FormulaData formulaData;
|
|
|
|
formulaData.formula = ui->plainTextEditF1->toPlainText();
|
|
|
|
formulaData.variables = data->DataVariables();
|
|
|
|
formulaData.labelEditFormula = ui->labelEditF1;
|
|
|
|
formulaData.labelResult = ui->labelResultF1;
|
|
|
|
formulaData.postfix = degreeSymbol;
|
|
|
|
formulaData.checkZero = false;
|
|
|
|
|
|
|
|
angleF1 = Eval(formulaData, flagF1);
|
|
|
|
|
|
|
|
formulaData.formula = ui->plainTextEditF2->toPlainText();
|
|
|
|
formulaData.labelEditFormula = ui->labelEditF2;
|
|
|
|
formulaData.labelResult = ui->labelResultF2;
|
2013-08-06 09:56:09 +02:00
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
angleF2 = Eval(formulaData, flagF2);
|
2014-11-21 15:57:47 +01:00
|
|
|
}
|
2015-02-02 16:11:48 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief GetCenter return id of center point
|
|
|
|
* @return id id
|
|
|
|
*/
|
|
|
|
quint32 DialogArc::GetCenter() const
|
|
|
|
{
|
2015-02-03 09:17:59 +01:00
|
|
|
return getCurrentObjectId(ui->comboBoxBasePoint);
|
2015-02-02 16:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief GetRadius return formula of radius
|
|
|
|
* @return formula
|
|
|
|
*/
|
|
|
|
QString DialogArc::GetRadius() const
|
|
|
|
{
|
2016-03-05 16:27:07 +01:00
|
|
|
return qApp->TrVars()->TryFormulaFromUser(radius, qApp->Settings()->GetOsSeparator());
|
2015-02-02 16:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief GetF1 return formula first angle of arc
|
|
|
|
* @return formula
|
|
|
|
*/
|
|
|
|
QString DialogArc::GetF1() const
|
|
|
|
{
|
2016-03-05 16:27:07 +01:00
|
|
|
return qApp->TrVars()->TryFormulaFromUser(f1, qApp->Settings()->GetOsSeparator());
|
2015-02-02 16:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief GetF2 return formula second angle of arc
|
|
|
|
* @return formula
|
|
|
|
*/
|
|
|
|
QString DialogArc::GetF2() const
|
|
|
|
{
|
2016-03-05 16:27:07 +01:00
|
|
|
return qApp->TrVars()->TryFormulaFromUser(f2, qApp->Settings()->GetOsSeparator());
|
2015-02-02 16:11:48 +01:00
|
|
|
}
|