Refactoring tool dialogs.
--HG-- branch : develop
This commit is contained in:
parent
03e9c3068a
commit
0c3cce5122
|
@ -68,6 +68,7 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent ( QCloseEvent * event ) override;
|
virtual void closeEvent ( QCloseEvent * event ) override;
|
||||||
virtual void changeEvent(QEvent* event) override;
|
virtual void changeEvent(QEvent* event) override;
|
||||||
|
virtual bool IsValid() const final {return true;}
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogHistory)
|
Q_DISABLE_COPY(DialogHistory)
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ protected:
|
||||||
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
virtual void showEvent( QShowEvent *event ) override;
|
virtual void showEvent( QShowEvent *event ) override;
|
||||||
virtual void resizeEvent(QResizeEvent *event) override;
|
virtual void resizeEvent(QResizeEvent *event) override;
|
||||||
|
virtual bool IsValid() const final {return true;}
|
||||||
private slots:
|
private slots:
|
||||||
void ShowIncrementDetails();
|
void ShowIncrementDetails();
|
||||||
void AddIncrement();
|
void AddIncrement();
|
||||||
|
|
|
@ -48,7 +48,8 @@ HEADERS += \
|
||||||
$$PWD/tools/piece/dialoginsertnode.h \
|
$$PWD/tools/piece/dialoginsertnode.h \
|
||||||
$$PWD/support/dialogeditlabel.h \
|
$$PWD/support/dialogeditlabel.h \
|
||||||
$$PWD/tools/piece/dialogplacelabel.h \
|
$$PWD/tools/piece/dialogplacelabel.h \
|
||||||
$$PWD/tools/piece/dialogduplicatedetail.h
|
$$PWD/tools/piece/dialogduplicatedetail.h \
|
||||||
|
$$PWD/dialogtoolbox.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/tools/dialogalongline.cpp \
|
$$PWD/tools/dialogalongline.cpp \
|
||||||
|
@ -96,7 +97,8 @@ SOURCES += \
|
||||||
$$PWD/tools/piece/dialoginsertnode.cpp \
|
$$PWD/tools/piece/dialoginsertnode.cpp \
|
||||||
$$PWD/support/dialogeditlabel.cpp \
|
$$PWD/support/dialogeditlabel.cpp \
|
||||||
$$PWD/tools/piece/dialogplacelabel.cpp \
|
$$PWD/tools/piece/dialogplacelabel.cpp \
|
||||||
$$PWD/tools/piece/dialogduplicatedetail.cpp
|
$$PWD/tools/piece/dialogduplicatedetail.cpp \
|
||||||
|
$$PWD/dialogtoolbox.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/tools/dialogalongline.ui \
|
$$PWD/tools/dialogalongline.ui \
|
||||||
|
|
239
src/libs/vtools/dialogs/dialogtoolbox.cpp
Normal file
239
src/libs/vtools/dialogs/dialogtoolbox.cpp
Normal file
|
@ -0,0 +1,239 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogtoolbox.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 25 1, 2019
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2019 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 "dialogtoolbox.h"
|
||||||
|
|
||||||
|
#include "../vmisc/def.h"
|
||||||
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
#include "../vpatterndb/calculator.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QTextCursor>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
const QColor errorColor = Qt::red;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const int dialogMaxFormulaHeight = 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
|
||||||
|
{
|
||||||
|
SCASSERT(plainTextEdit != nullptr)
|
||||||
|
QTextCursor cursor = plainTextEdit->textCursor();
|
||||||
|
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||||
|
plainTextEdit->setTextCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DeployFormula(QDialog *dialog, QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight)
|
||||||
|
{
|
||||||
|
SCASSERT(dialog != nullptr)
|
||||||
|
SCASSERT(formula != nullptr)
|
||||||
|
SCASSERT(buttonGrowLength != nullptr)
|
||||||
|
|
||||||
|
const QTextCursor cursor = formula->textCursor();
|
||||||
|
|
||||||
|
//Before deploy ned to release dialog size
|
||||||
|
//I don't know why, but don't need to fixate again.
|
||||||
|
//A dialog will be lefted fixated. That's what we need.
|
||||||
|
dialog->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||||
|
dialog->setMinimumSize(QSize(0, 0));
|
||||||
|
|
||||||
|
if (formula->height() < dialogMaxFormulaHeight)
|
||||||
|
{
|
||||||
|
formula->setFixedHeight(dialogMaxFormulaHeight);
|
||||||
|
//Set icon from theme (internal for Windows system)
|
||||||
|
buttonGrowLength->setIcon(QIcon::fromTheme(QStringLiteral("go-next"),
|
||||||
|
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
formula->setFixedHeight(formulaBaseHeight);
|
||||||
|
//Set icon from theme (internal for Windows system)
|
||||||
|
buttonGrowLength->setIcon(QIcon::fromTheme(QStringLiteral("go-down"),
|
||||||
|
QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png")));
|
||||||
|
}
|
||||||
|
|
||||||
|
// I found that after change size of formula field, it was filed for angle formula, field for formula became black.
|
||||||
|
// This code prevent this.
|
||||||
|
dialog->setUpdatesEnabled(false);
|
||||||
|
dialog->repaint();
|
||||||
|
dialog->setUpdatesEnabled(true);
|
||||||
|
|
||||||
|
formula->setFocus();
|
||||||
|
formula->setTextCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool FilterObject(QObject *object, QEvent *event)
|
||||||
|
{
|
||||||
|
if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object))
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
||||||
|
{
|
||||||
|
if (qApp->Settings()->GetOsSeparator())
|
||||||
|
{
|
||||||
|
plainTextEdit->insertPlainText(QLocale().decimalPoint());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plainTextEdit->insertPlainText(QLocale::c().decimalPoint());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal EvalToolFormula(QDialog *dialog, const FormulaData &data, bool &flag)
|
||||||
|
{
|
||||||
|
SCASSERT(data.labelResult != nullptr)
|
||||||
|
SCASSERT(data.labelEditFormula != nullptr)
|
||||||
|
|
||||||
|
qreal result = INT_MIN;//Value can be 0, so use max imposible value
|
||||||
|
|
||||||
|
if (data.formula.isEmpty())
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
ChangeColor(data.labelEditFormula, errorColor);
|
||||||
|
data.labelResult->setText(QObject::tr("Error") + " (" + data.postfix + ")");
|
||||||
|
data.labelResult->setToolTip(QObject::tr("Empty formula"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Translate to internal look.
|
||||||
|
QString formula = qApp->TrVars()->FormulaFromUser(data.formula, qApp->Settings()->GetOsSeparator());
|
||||||
|
QScopedPointer<Calculator> cal(new Calculator());
|
||||||
|
result = cal->EvalFormula(data.variables, formula);
|
||||||
|
|
||||||
|
if (qIsInf(result) || qIsNaN(result))
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
ChangeColor(data.labelEditFormula, errorColor);
|
||||||
|
data.labelResult->setText(QObject::tr("Error") + " (" + data.postfix + ")");
|
||||||
|
data.labelResult->setToolTip(QObject::tr("Invalid result. Value is infinite or NaN. Please, check "
|
||||||
|
"your calculations."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//if result equal 0
|
||||||
|
if (data.checkZero && qFuzzyIsNull(result))
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
ChangeColor(data.labelEditFormula, errorColor);
|
||||||
|
data.labelResult->setText(QObject::tr("Error") + " (" + data.postfix + ")");
|
||||||
|
data.labelResult->setToolTip(QObject::tr("Value can't be 0"));
|
||||||
|
}
|
||||||
|
else if (data.checkLessThanZero && result < 0)
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
ChangeColor(data.labelEditFormula, errorColor);
|
||||||
|
data.labelResult->setText(QObject::tr("Error") + " (" + data.postfix + ")");
|
||||||
|
data.labelResult->setToolTip(QObject::tr("Value can't be less than 0"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.labelResult->setText(qApp->LocaleToString(result) + QChar(QChar::Space) + data.postfix);
|
||||||
|
flag = true;
|
||||||
|
ChangeColor(data.labelEditFormula, OkColor(dialog));
|
||||||
|
data.labelResult->setToolTip(QObject::tr("Value"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (qmu::QmuParserError &e)
|
||||||
|
{
|
||||||
|
data.labelResult->setText(QObject::tr("Error") + " (" + data.postfix + ")");
|
||||||
|
flag = false;
|
||||||
|
ChangeColor(data.labelEditFormula, errorColor);
|
||||||
|
data.labelResult->setToolTip(QObject::tr("Parser error: %1").arg(e.GetMsg()));
|
||||||
|
qDebug() << "\nMath parser error:\n"
|
||||||
|
<< "--------------------------------------\n"
|
||||||
|
<< "Message: " << e.GetMsg() << "\n"
|
||||||
|
<< "Expression: " << e.GetExpr() << "\n"
|
||||||
|
<< "--------------------------------------";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void ChangeColor(QWidget *widget, const QColor &color)
|
||||||
|
{
|
||||||
|
SCASSERT(widget != nullptr)
|
||||||
|
QPalette palette = widget->palette();
|
||||||
|
palette.setColor(QPalette::Active, widget->foregroundRole(), color);
|
||||||
|
palette.setColor(QPalette::Inactive, widget->foregroundRole(), color);
|
||||||
|
widget->setPalette(palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QColor OkColor(QWidget *widget)
|
||||||
|
{
|
||||||
|
SCASSERT(widget != nullptr);
|
||||||
|
return widget->palette().color(QPalette::Active, QPalette::WindowText);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void CheckPointLabel(QDialog *dialog, QLineEdit* edit, QLabel *labelEditNamePoint, const QString &pointName,
|
||||||
|
const VContainer *data, bool &flag)
|
||||||
|
{
|
||||||
|
SCASSERT(dialog != nullptr)
|
||||||
|
SCASSERT(edit != nullptr)
|
||||||
|
SCASSERT(labelEditNamePoint != nullptr)
|
||||||
|
|
||||||
|
QString name = edit->text();
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
|
if (name.isEmpty() || (not (pointName != name && data->IsUnique(name))) || not rx.match(name).hasMatch())
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
ChangeColor(labelEditNamePoint, errorColor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
ChangeColor(labelEditNamePoint, OkColor(dialog));
|
||||||
|
}
|
||||||
|
}
|
77
src/libs/vtools/dialogs/dialogtoolbox.h
Normal file
77
src/libs/vtools/dialogs/dialogtoolbox.h
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogtoolbox.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 25 1, 2019
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2019 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 DIALOGTOOLBOX_H
|
||||||
|
#define DIALOGTOOLBOX_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "../vpatterndb/variables/vinternalvariable.h"
|
||||||
|
|
||||||
|
class QPlainTextEdit;
|
||||||
|
class QPushButton;
|
||||||
|
class QDialog;
|
||||||
|
class QObject;
|
||||||
|
class QEvent;
|
||||||
|
class QLabel;
|
||||||
|
class QWidget;
|
||||||
|
class QColor;
|
||||||
|
class QLineEdit;
|
||||||
|
class VContainer;
|
||||||
|
|
||||||
|
constexpr int formulaTimerTimeout = 300;
|
||||||
|
|
||||||
|
extern const QColor errorColor;
|
||||||
|
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||||
|
|
||||||
|
struct FormulaData
|
||||||
|
{
|
||||||
|
QString formula;
|
||||||
|
const QHash<QString, QSharedPointer<VInternalVariable> > *variables{nullptr};
|
||||||
|
QLabel *labelEditFormula{nullptr};
|
||||||
|
QLabel *labelResult{nullptr};
|
||||||
|
QString postfix;
|
||||||
|
bool checkZero{true};
|
||||||
|
bool checkLessThanZero{false};
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_WARNING_POP
|
||||||
|
|
||||||
|
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit);
|
||||||
|
void DeployFormula(QDialog *dialog, QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight);
|
||||||
|
bool FilterObject(QObject *object, QEvent *event);
|
||||||
|
qreal EvalToolFormula(QDialog *dialog, const FormulaData &data, bool &flag);
|
||||||
|
void ChangeColor(QWidget *widget, const QColor &color);
|
||||||
|
QColor OkColor(QWidget *widget);
|
||||||
|
void CheckPointLabel(QDialog *dialog, QLineEdit* edit, QLabel *labelEditNamePoint, const QString &pointName,
|
||||||
|
const VContainer *data, bool &flag);
|
||||||
|
|
||||||
|
#endif // DIALOGTOOLBOX_H
|
|
@ -51,6 +51,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
@ -73,18 +74,28 @@ template <class T> class QSharedPointer;
|
||||||
enum {ColumnName = 0, ColumnFullName};
|
enum {ColumnName = 0, ColumnFullName};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0),
|
: DialogTool(data, toolId, parent),
|
||||||
checkZero(false), checkLessThanZero(false), postfix(QString()), restoreCursor(false)
|
ui(new Ui::DialogEditWrongFormula),
|
||||||
|
formula(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
checkZero(false),
|
||||||
|
checkLessThanZero(false),
|
||||||
|
postfix(),
|
||||||
|
restoreCursor(false),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogEditWrongFormula::EvalFormula);
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
setWindowFlags(Qt::Window);
|
setWindowFlags(Qt::Window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InitVariables();
|
InitVariables();
|
||||||
InitFormulaUI(ui);
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
ui->filterFormulaInputs->setClearButtonEnabled(true);
|
ui->filterFormulaInputs->setClearButtonEnabled(true);
|
||||||
|
@ -92,13 +103,14 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
|
||||||
connect(ui->filterFormulaInputs, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FilterVariablesEdited);
|
connect(ui->filterFormulaInputs, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FilterVariablesEdited);
|
||||||
|
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
flagFormula = false;
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere);
|
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere);
|
||||||
connect(ui->tableWidget, &QTableWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal);
|
connect(ui->tableWidget, &QTableWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal);
|
||||||
|
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged);
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
//Disable Qt::WaitCursor
|
//Disable Qt::WaitCursor
|
||||||
#ifndef QT_NO_CURSOR
|
#ifndef QT_NO_CURSOR
|
||||||
|
@ -146,11 +158,17 @@ void DialogEditWrongFormula::DialogRejected()
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEditWrongFormula::EvalFormula()
|
void DialogEditWrongFormula::EvalFormula()
|
||||||
{
|
{
|
||||||
SCASSERT(plainTextEditFormula != nullptr)
|
FormulaData formulaData;
|
||||||
SCASSERT(labelResultCalculation != nullptr)
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, checkZero,
|
formulaData.variables = data->DataVariables();
|
||||||
checkLessThanZero);
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = postfix;
|
||||||
|
formulaData.checkZero = checkZero;
|
||||||
|
formulaData.checkLessThanZero = checkLessThanZero;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -336,13 +354,6 @@ void DialogEditWrongFormula::Functions()
|
||||||
ShowFunctions();
|
ShowFunctions();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogEditWrongFormula::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagFormula);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEditWrongFormula::closeEvent(QCloseEvent *event)
|
void DialogEditWrongFormula::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
|
@ -371,6 +382,8 @@ void DialogEditWrongFormula::showEvent(QShowEvent *event)
|
||||||
resize(sz);
|
resize(sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckState();
|
||||||
|
|
||||||
isInitialized = true;//first show windows are held
|
isInitialized = true;//first show windows are held
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class DialogEditWrongFormula : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogEditWrongFormula(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogEditWrongFormula() override;
|
virtual ~DialogEditWrongFormula() override;
|
||||||
|
|
||||||
QString GetFormula() const;
|
QString GetFormula() const;
|
||||||
|
@ -73,7 +73,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void DialogAccepted() override;
|
virtual void DialogAccepted() override;
|
||||||
virtual void DialogRejected() override;
|
virtual void DialogRejected() override;
|
||||||
virtual void EvalFormula() override;
|
void EvalFormula();
|
||||||
void ValChanged(int row);
|
void ValChanged(int row);
|
||||||
void PutHere();
|
void PutHere();
|
||||||
void PutVal(QTableWidgetItem * item);
|
void PutVal(QTableWidgetItem * item);
|
||||||
|
@ -89,7 +89,7 @@ public slots:
|
||||||
void PreviewCalculations();
|
void PreviewCalculations();
|
||||||
void Functions();
|
void Functions();
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
virtual bool IsValid() const final;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual void showEvent( QShowEvent *event ) override;
|
virtual void showEvent( QShowEvent *event ) override;
|
||||||
virtual void resizeEvent(QResizeEvent *event) override;
|
virtual void resizeEvent(QResizeEvent *event) override;
|
||||||
|
@ -110,6 +110,10 @@ private:
|
||||||
QString postfix;
|
QString postfix;
|
||||||
bool restoreCursor;
|
bool restoreCursor;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
|
||||||
void InitVariables();
|
void InitVariables();
|
||||||
|
|
||||||
template <class key, class val>
|
template <class key, class val>
|
||||||
|
@ -121,5 +125,10 @@ private:
|
||||||
void SetDescription(const QString &name, qreal value, const QString &unit, const QString &description);
|
void SetDescription(const QString &name, qreal value, const QString &unit, const QString &description);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogEditWrongFormula::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGEDITWRONGFORMULA_H
|
#endif // DIALOGEDITWRONGFORMULA_H
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
@ -61,24 +62,31 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogAlongLine::DialogAlongLine(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine),
|
: DialogTool(data, toolId, parent),
|
||||||
formula(QString()), formulaBaseHeight(0), buildMidpoint(false)
|
ui(new Ui::DialogAlongLine),
|
||||||
|
formula(),
|
||||||
|
pointName(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
buildMidpoint(false),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagError(true),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogAlongLine::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
@ -86,8 +94,15 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
|
||||||
FillComboBoxLineColors(ui->comboBoxLineColor);
|
FillComboBoxLineColors(ui->comboBoxLineColor);
|
||||||
|
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogAlongLine::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogAlongLine::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit);
|
||||||
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogAlongLine::PointChanged);
|
this, &DialogAlongLine::PointChanged);
|
||||||
|
@ -100,16 +115,10 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
|
||||||
SetTypeLine(TypeLineNone);//By default don't show line
|
SetTypeLine(TypeLineNone);//By default don't show line
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogAlongLine::FormulaTextChanged()
|
|
||||||
{
|
|
||||||
this->FormulaChangedPlainText();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogAlongLine::PointChanged()
|
void DialogAlongLine::PointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (GetFirstPointId() == GetSecondPointId())
|
if (GetFirstPointId() == GetSecondPointId())
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -118,7 +127,7 @@ void DialogAlongLine::PointChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
SetCurrentLength();
|
SetCurrentLength();
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
|
@ -140,6 +149,20 @@ void DialogAlongLine::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogAlongLine::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogAlongLine::ShowVisualization()
|
void DialogAlongLine::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -149,7 +172,7 @@ void DialogAlongLine::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogAlongLine::DeployFormulaTextEdit()
|
void DialogAlongLine::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -191,7 +214,7 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
line->setObject2Id(id);
|
line->setObject2Id(id);
|
||||||
if (buildMidpoint)
|
if (buildMidpoint)
|
||||||
{
|
{
|
||||||
SetFormula(currentLength + QLatin1String("/2"));
|
SetFormula(currentLength + QStringLiteral("/2"));
|
||||||
}
|
}
|
||||||
line->RefreshGeometry();
|
line->RefreshGeometry();
|
||||||
prepare = true;
|
prepare = true;
|
||||||
|
@ -254,7 +277,7 @@ void DialogAlongLine::SetCurrentLength()
|
||||||
* @brief SetSecondPointId set id second point of line
|
* @brief SetSecondPointId set id second point of line
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogAlongLine::SetSecondPointId(const quint32 &value)
|
void DialogAlongLine::SetSecondPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||||
|
|
||||||
|
@ -280,7 +303,7 @@ void DialogAlongLine::Build(const Tool &type)
|
||||||
* @brief SetFirstPointId set id first point of line
|
* @brief SetFirstPointId set id first point of line
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogAlongLine::SetFirstPointId(const quint32 &value)
|
void DialogAlongLine::SetFirstPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||||
|
|
||||||
|
@ -334,6 +357,12 @@ void DialogAlongLine::SetLineColor(const QString &value)
|
||||||
ChangeCurrentData(ui->comboBoxLineColor, value);
|
ChangeCurrentData(ui->comboBoxLineColor, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogAlongLine::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief SetPointName set name of point
|
* @brief SetPointName set name of point
|
||||||
|
|
|
@ -50,9 +50,10 @@ class DialogAlongLine : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogAlongLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogAlongLine() override;
|
virtual ~DialogAlongLine() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -65,10 +66,10 @@ public:
|
||||||
void SetFormula(const QString &value);
|
void SetFormula(const QString &value);
|
||||||
|
|
||||||
quint32 GetFirstPointId() const;
|
quint32 GetFirstPointId() const;
|
||||||
void SetFirstPointId(const quint32 &value);
|
void SetFirstPointId(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondPointId() const;
|
quint32 GetSecondPointId() const;
|
||||||
void SetSecondPointId(const quint32 &value);
|
void SetSecondPointId(quint32 value);
|
||||||
|
|
||||||
virtual void Build(const Tool &type) override;
|
virtual void Build(const Tool &type) override;
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -77,13 +78,10 @@ public slots:
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
/**
|
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
|
||||||
*/
|
|
||||||
void FormulaTextChanged();
|
|
||||||
void PointChanged();
|
void PointChanged();
|
||||||
|
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -91,6 +89,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogAlongLine)
|
Q_DISABLE_COPY(DialogAlongLine)
|
||||||
|
|
||||||
|
@ -98,14 +97,28 @@ private:
|
||||||
Ui::DialogAlongLine *ui;
|
Ui::DialogAlongLine *ui;
|
||||||
|
|
||||||
/** @brief formula formula */
|
/** @brief formula formula */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
bool buildMidpoint;
|
bool buildMidpoint;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagError;
|
||||||
|
bool flagName;
|
||||||
|
|
||||||
void SetCurrentLength();
|
void SetCurrentLength();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogAlongLine::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName &&flagFormula && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGALONGLINE_H
|
#endif // DIALOGALONGLINE_H
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#include "../ifc/xml/vdomdocument.h"
|
#include "../ifc/xml/vdomdocument.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/path/vistoolarc.h"
|
#include "../../visualization/path/vistoolarc.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../support/dialogeditwrongformula.h"
|
#include "../support/dialogeditwrongformula.h"
|
||||||
|
@ -53,16 +54,28 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
|
: DialogTool(data, toolId, parent),
|
||||||
timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), radius(QString()), f1(QString()), f2(QString()),
|
ui(new Ui::DialogArc),
|
||||||
formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), angleF1(INT_MIN), angleF2(INT_MIN)
|
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)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
||||||
|
|
||||||
plainTextEditFormula = ui->plainTextEditFormula;
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
|
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
|
||||||
this->formulaBaseHeightF2 = ui->plainTextEditF2->height();
|
this->formulaBaseHeightF2 = ui->plainTextEditF2->height();
|
||||||
|
@ -71,13 +84,13 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
|
||||||
ui->plainTextEditF1->installEventFilter(this);
|
ui->plainTextEditF1->installEventFilter(this);
|
||||||
ui->plainTextEditF2->installEventFilter(this);
|
ui->plainTextEditF2->installEventFilter(this);
|
||||||
|
|
||||||
timerRadius = new QTimer(this);
|
timerRadius->setSingleShot(true);
|
||||||
connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius);
|
connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius);
|
||||||
|
|
||||||
timerF1 = new QTimer(this);
|
timerF1->setSingleShot(true);
|
||||||
connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF);
|
connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF);
|
||||||
|
|
||||||
timerF2 = new QTimer(this);
|
timerF2->setSingleShot(true);
|
||||||
connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF);
|
connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -86,15 +99,24 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
|
||||||
FillComboBoxLineColors(ui->comboBoxColor);
|
FillComboBoxLineColors(ui->comboBoxColor);
|
||||||
FillComboBoxTypeLine(ui->comboBoxPenStyle, CurvePenStylesPics());
|
FillComboBoxTypeLine(ui->comboBoxPenStyle, CurvePenStylesPics());
|
||||||
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogArc::FXRadius);
|
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogArc::FXRadius);
|
||||||
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogArc::FXF1);
|
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogArc::FXF1);
|
||||||
connect(ui->toolButtonExprF2, &QPushButton::clicked, this, &DialogArc::FXF2);
|
connect(ui->toolButtonExprF2, &QPushButton::clicked, this, &DialogArc::FXF2);
|
||||||
|
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogArc::RadiusChanged);
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogArc::F1Changed);
|
{
|
||||||
connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, &DialogArc::F2Changed);
|
timerRadius->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerF1->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerF2->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit);
|
||||||
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
|
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
|
||||||
|
@ -106,19 +128,19 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArc::DeployFormulaTextEdit()
|
void DialogArc::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArc::DeployF1TextEdit()
|
void DialogArc::DeployF1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
|
DeployFormula(this, ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArc::DeployF2TextEdit()
|
void DialogArc::DeployF2TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2);
|
DeployFormula(this, ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -300,40 +322,6 @@ void DialogArc::closeEvent(QCloseEvent *event)
|
||||||
DialogTool::closeEvent(event);
|
DialogTool::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief RadiusChanged after change formula of radius calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogArc::RadiusChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditRadius;
|
|
||||||
labelResultCalculation = ui->labelResultRadius;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagRadius, ui->plainTextEditFormula, timerRadius, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief F1Changed after change formula of first angle calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogArc::F1Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditF1;
|
|
||||||
labelResultCalculation = ui->labelResultF1;
|
|
||||||
ValFormulaChanged(flagF1, ui->plainTextEditF1, timerF1, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief F2Changed after change formula of second angle calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogArc::F2Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditF2;
|
|
||||||
labelResultCalculation = ui->labelResultF2;
|
|
||||||
ValFormulaChanged(flagF2, ui->plainTextEditF2, timerF2, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArc::FXRadius()
|
void DialogArc::FXRadius()
|
||||||
{
|
{
|
||||||
|
@ -376,32 +364,25 @@ void DialogArc::FXF2()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief CheckState if all is right enable button ok
|
|
||||||
*/
|
|
||||||
void DialogArc::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagRadius && flagF1 && flagF2);
|
|
||||||
SCASSERT(bApply != nullptr)
|
|
||||||
bApply->setEnabled(flagRadius && flagF1 && flagF2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief EvalRadius calculate value of radius
|
* @brief EvalRadius calculate value of radius
|
||||||
*/
|
*/
|
||||||
void DialogArc::EvalRadius()
|
void DialogArc::EvalRadius()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditRadius;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
const qreal radius = Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, ui->labelResultRadius, postfix);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditRadius;
|
||||||
|
formulaData.labelResult = ui->labelResultRadius;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
const qreal radius = Eval(formulaData, flagRadius);
|
||||||
|
|
||||||
if (radius < 0)
|
if (radius < 0)
|
||||||
{
|
{
|
||||||
flagRadius = false;
|
flagRadius = false;
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
ChangeColor(ui->labelEditRadius, errorColor);
|
||||||
ui->labelResultRadius->setText(tr("Error"));
|
ui->labelResultRadius->setText(tr("Error"));
|
||||||
ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
|
ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
|
||||||
|
|
||||||
|
@ -415,11 +396,21 @@ void DialogArc::EvalRadius()
|
||||||
*/
|
*/
|
||||||
void DialogArc::EvalF()
|
void DialogArc::EvalF()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditF1;
|
FormulaData formulaData;
|
||||||
angleF1 = Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditF1->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditF1;
|
||||||
|
formulaData.labelResult = ui->labelResultF1;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditF2;
|
angleF1 = Eval(formulaData, flagF1);
|
||||||
angleF2 = Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false);
|
|
||||||
|
formulaData.formula = ui->plainTextEditF2->toPlainText();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditF2;
|
||||||
|
formulaData.labelResult = ui->labelResultF2;
|
||||||
|
|
||||||
|
angleF2 = Eval(formulaData, flagF2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DialogArc : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogArc() override;
|
virtual ~DialogArc() override;
|
||||||
|
|
||||||
quint32 GetCenter() const;
|
quint32 GetCenter() const;
|
||||||
|
@ -81,21 +81,19 @@ public slots:
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
void DeployF1TextEdit();
|
void DeployF1TextEdit();
|
||||||
void DeployF2TextEdit();
|
void DeployF2TextEdit();
|
||||||
void RadiusChanged();
|
|
||||||
void F1Changed();
|
|
||||||
void F2Changed();
|
|
||||||
|
|
||||||
void FXRadius();
|
void FXRadius();
|
||||||
void FXF1();
|
void FXF1();
|
||||||
void FXF2();
|
void FXF2();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogArc)
|
Q_DISABLE_COPY(DialogArc)
|
||||||
|
|
||||||
|
@ -141,4 +139,10 @@ private:
|
||||||
void EvalF();
|
void EvalF();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogArc::IsValid() const
|
||||||
|
{
|
||||||
|
return flagRadius && flagF1 && flagF2;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGARC_H
|
#endif // DIALOGARC_H
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#include "../ifc/xml/vdomdocument.h"
|
#include "../ifc/xml/vdomdocument.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/path/vistoolarcwithlength.h"
|
#include "../../visualization/path/vistoolarcwithlength.h"
|
||||||
#include "../support/dialogeditwrongformula.h"
|
#include "../support/dialogeditwrongformula.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
@ -48,15 +49,25 @@
|
||||||
#include "ui_dialogarcwithlength.h"
|
#include "ui_dialogarcwithlength.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogArcWithLength::DialogArcWithLength(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogArcWithLength), flagRadius(false), flagF1(false),
|
: DialogTool(data, toolId, parent),
|
||||||
flagLength(false), timerRadius(nullptr), timerF1(nullptr), timerLength(nullptr), radius(QString()), f1(QString()),
|
ui(new Ui::DialogArcWithLength),
|
||||||
length(QString()),formulaBaseHeightRadius(0), formulaBaseHeightF1(0), formulaBaseHeightLength(0), angleF1(INT_MIN)
|
flagRadius(false),
|
||||||
|
flagF1(false),
|
||||||
|
flagLength(false),
|
||||||
|
timerRadius(new QTimer(this)),
|
||||||
|
timerF1(new QTimer(this)),
|
||||||
|
timerLength(new QTimer(this)),
|
||||||
|
radius(),
|
||||||
|
f1(),
|
||||||
|
length(),
|
||||||
|
formulaBaseHeightRadius(0),
|
||||||
|
formulaBaseHeightF1(0),
|
||||||
|
formulaBaseHeightLength(0)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
plainTextEditFormula = ui->plainTextEditRadius;
|
this->formulaBaseHeightRadius = ui->plainTextEditRadius->height();
|
||||||
this->formulaBaseHeightLength = ui->plainTextEditRadius->height();
|
|
||||||
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
|
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
|
||||||
this->formulaBaseHeightLength = ui->plainTextEditLength->height();
|
this->formulaBaseHeightLength = ui->plainTextEditLength->height();
|
||||||
|
|
||||||
|
@ -64,13 +75,13 @@ DialogArcWithLength::DialogArcWithLength(const VContainer *data, const quint32 &
|
||||||
ui->plainTextEditF1->installEventFilter(this);
|
ui->plainTextEditF1->installEventFilter(this);
|
||||||
ui->plainTextEditLength->installEventFilter(this);
|
ui->plainTextEditLength->installEventFilter(this);
|
||||||
|
|
||||||
timerRadius = new QTimer(this);
|
timerRadius->setSingleShot(true);
|
||||||
connect(timerRadius, &QTimer::timeout, this, &DialogArcWithLength::Radius);
|
connect(timerRadius, &QTimer::timeout, this, &DialogArcWithLength::Radius);
|
||||||
|
|
||||||
timerF1 = new QTimer(this);
|
timerF1->setSingleShot(true);
|
||||||
connect(timerF1, &QTimer::timeout, this, &DialogArcWithLength::EvalF);
|
connect(timerF1, &QTimer::timeout, this, &DialogArcWithLength::EvalF);
|
||||||
|
|
||||||
timerLength = new QTimer(this);
|
timerLength->setSingleShot(true);
|
||||||
connect(timerLength, &QTimer::timeout, this, &DialogArcWithLength::Length);
|
connect(timerLength, &QTimer::timeout, this, &DialogArcWithLength::Length);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -81,15 +92,24 @@ DialogArcWithLength::DialogArcWithLength(const VContainer *data, const quint32 &
|
||||||
|
|
||||||
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
||||||
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogArcWithLength::FXRadius);
|
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogArcWithLength::FXRadius);
|
||||||
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogArcWithLength::FXF1);
|
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogArcWithLength::FXF1);
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogArcWithLength::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogArcWithLength::FXLength);
|
||||||
|
|
||||||
connect(ui->plainTextEditRadius, &QPlainTextEdit::textChanged, this, &DialogArcWithLength::RadiusChanged);
|
connect(ui->plainTextEditRadius, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogArcWithLength::F1Changed);
|
{
|
||||||
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, &DialogArcWithLength::LengthChanged);
|
timerRadius->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerF1->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerLength->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowLengthRadius, &QPushButton::clicked, this, &DialogArcWithLength::DeployRadiusTextEdit);
|
connect(ui->pushButtonGrowLengthRadius, &QPushButton::clicked, this, &DialogArcWithLength::DeployRadiusTextEdit);
|
||||||
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArcWithLength::DeployF1TextEdit);
|
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArcWithLength::DeployF1TextEdit);
|
||||||
|
@ -249,45 +269,19 @@ void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::DeployRadiusTextEdit()
|
void DialogArcWithLength::DeployRadiusTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditRadius, ui->pushButtonGrowLengthArcLength, formulaBaseHeightRadius);
|
DeployFormula(this, ui->plainTextEditRadius, ui->pushButtonGrowLengthArcLength, formulaBaseHeightRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::DeployF1TextEdit()
|
void DialogArcWithLength::DeployF1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
|
DeployFormula(this, ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::DeployLengthTextEdit()
|
void DialogArcWithLength::DeployLengthTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditLength, ui->pushButtonGrowLengthArcLength, formulaBaseHeightLength);
|
DeployFormula(this, ui->plainTextEditLength, ui->pushButtonGrowLengthArcLength, formulaBaseHeightLength);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogArcWithLength::RadiusChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditRadius;
|
|
||||||
labelResultCalculation = ui->labelResultRadius;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagRadius, ui->plainTextEditRadius, timerRadius, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogArcWithLength::F1Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditF1;
|
|
||||||
labelResultCalculation = ui->labelResultF1;
|
|
||||||
ValFormulaChanged(flagF1, ui->plainTextEditF1, timerF1, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogArcWithLength::LengthChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditLength;
|
|
||||||
labelResultCalculation = ui->labelResultLength;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagLength, ui->plainTextEditLength, timerLength, postfix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -332,18 +326,6 @@ void DialogArcWithLength::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogArcWithLength::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagRadius && flagF1 && flagLength);
|
|
||||||
// In case dialog hasn't apply button
|
|
||||||
if ( bApply != nullptr)
|
|
||||||
{
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::ShowVisualization()
|
void DialogArcWithLength::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -380,42 +362,40 @@ void DialogArcWithLength::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::Radius()
|
void DialogArcWithLength::Radius()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditRadius;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditRadius->toPlainText();
|
||||||
const qreal radius = Eval(ui->plainTextEditRadius->toPlainText(), flagRadius, ui->labelResultRadius, postfix);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditRadius;
|
||||||
|
formulaData.labelResult = ui->labelResultRadius;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
if (radius < 0)
|
Eval(formulaData, flagRadius);
|
||||||
{
|
|
||||||
flagRadius = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultRadius->setText(tr("Error"));
|
|
||||||
ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
|
|
||||||
|
|
||||||
DialogArcWithLength::CheckState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::Length()
|
void DialogArcWithLength::Length()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditLength;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditLength->toPlainText();
|
||||||
const qreal length = Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditLength;
|
||||||
|
formulaData.labelResult = ui->labelResultLength;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
if (qFuzzyIsNull(length))
|
Eval(formulaData, flagLength);
|
||||||
{
|
|
||||||
flagLength = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultLength->setText(tr("Error"));
|
|
||||||
ui->labelResultLength->setToolTip(tr("Length can't be equal 0"));
|
|
||||||
|
|
||||||
DialogArcWithLength::CheckState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::EvalF()
|
void DialogArcWithLength::EvalF()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditF1;
|
FormulaData formulaData;
|
||||||
angleF1 = Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditF1->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditF1;
|
||||||
|
formulaData.labelResult = ui->labelResultF1;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagF1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class DialogArcWithLength : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogArcWithLength(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogArcWithLength(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
~DialogArcWithLength();
|
~DialogArcWithLength();
|
||||||
|
|
||||||
quint32 GetCenter() const;
|
quint32 GetCenter() const;
|
||||||
|
@ -80,22 +80,18 @@ public slots:
|
||||||
void DeployF1TextEdit();
|
void DeployF1TextEdit();
|
||||||
void DeployLengthTextEdit();
|
void DeployLengthTextEdit();
|
||||||
|
|
||||||
void RadiusChanged();
|
|
||||||
void F1Changed();
|
|
||||||
void LengthChanged();
|
|
||||||
|
|
||||||
void FXRadius();
|
void FXRadius();
|
||||||
void FXF1();
|
void FXF1();
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogArcWithLength)
|
Q_DISABLE_COPY(DialogArcWithLength)
|
||||||
|
@ -130,11 +126,15 @@ private:
|
||||||
int formulaBaseHeightF1;
|
int formulaBaseHeightF1;
|
||||||
int formulaBaseHeightLength;
|
int formulaBaseHeightLength;
|
||||||
|
|
||||||
qreal angleF1;
|
|
||||||
|
|
||||||
void Radius();
|
void Radius();
|
||||||
void Length();
|
void Length();
|
||||||
void EvalF();
|
void EvalF();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogArcWithLength::IsValid() const
|
||||||
|
{
|
||||||
|
return flagRadius && flagF1 && flagLength;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGARCWITHLENGTH_H
|
#endif // DIALOGARCWITHLENGTH_H
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../../visualization/line/vistoolbisector.h"
|
#include "../../visualization/line/vistoolbisector.h"
|
||||||
|
@ -47,6 +48,7 @@
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "ui_dialogbisector.h"
|
#include "ui_dialogbisector.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -55,22 +57,29 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), formula(QString()), formulaBaseHeight(0)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogBisector),
|
||||||
|
formula(),
|
||||||
|
pointName(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagError(true),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogBisector::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
@ -79,8 +88,15 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
|
||||||
FillComboBoxLineColors(ui->comboBoxLineColor);
|
FillComboBoxLineColors(ui->comboBoxLineColor);
|
||||||
|
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogBisector::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogBisector::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogBisector::FormulaTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit);
|
||||||
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogBisector::PointNameChanged);
|
this, &DialogBisector::PointNameChanged);
|
||||||
|
@ -92,12 +108,6 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
|
||||||
vis = new VisToolBisector(data);
|
vis = new VisToolBisector(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogBisector::FormulaTextChanged()
|
|
||||||
{
|
|
||||||
this->FormulaChangedPlainText();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogBisector::PointNameChanged()
|
void DialogBisector::PointNameChanged()
|
||||||
{
|
{
|
||||||
|
@ -106,7 +116,7 @@ void DialogBisector::PointNameChanged()
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
|
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxThirdPoint));
|
set.insert(getCurrentObjectId(ui->comboBoxThirdPoint));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() != 3)
|
if (set.size() != 3)
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -115,7 +125,7 @@ void DialogBisector::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
ChangeColor(ui->labelSecondPoint, color);
|
ChangeColor(ui->labelSecondPoint, color);
|
||||||
|
@ -137,6 +147,20 @@ void DialogBisector::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogBisector::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogBisector::ShowVisualization()
|
void DialogBisector::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -146,7 +170,7 @@ void DialogBisector::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogBisector::DeployFormulaTextEdit()
|
void DialogBisector::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -155,6 +179,12 @@ DialogBisector::~DialogBisector()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogBisector::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||||
|
|
|
@ -51,9 +51,10 @@ class DialogBisector : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogBisector() override;
|
virtual ~DialogBisector() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -79,12 +80,10 @@ public slots:
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
/**
|
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
|
||||||
*/
|
|
||||||
void FormulaTextChanged();
|
|
||||||
virtual void PointNameChanged() override;
|
virtual void PointNameChanged() override;
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -92,6 +91,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogBisector)
|
Q_DISABLE_COPY(DialogBisector)
|
||||||
|
|
||||||
|
@ -99,10 +99,23 @@ private:
|
||||||
Ui::DialogBisector *ui;
|
Ui::DialogBisector *ui;
|
||||||
|
|
||||||
/** @brief formula formula */
|
/** @brief formula formula */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagError;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogBisector::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagError && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGBISECTOR_H
|
#endif // DIALOGBISECTOR_H
|
||||||
|
|
|
@ -44,11 +44,12 @@
|
||||||
#include "ui_dialogcubicbezier.h"
|
#include "ui_dialogcubicbezier.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogCubicBezier::DialogCubicBezier(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogCubicBezier::DialogCubicBezier(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogCubicBezier),
|
ui(new Ui::DialogCubicBezier),
|
||||||
spl(),
|
spl(),
|
||||||
newDuplicate(-1)
|
newDuplicate(-1),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -62,8 +63,6 @@ DialogCubicBezier::DialogCubicBezier(const VContainer *data, const quint32 &tool
|
||||||
|
|
||||||
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
||||||
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
connect(ui->comboBoxP1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogCubicBezier::PointNameChanged);
|
this, &DialogCubicBezier::PointNameChanged);
|
||||||
connect(ui->comboBoxP2, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP2, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -174,7 +173,7 @@ void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCubicBezier::PointNameChanged()
|
void DialogCubicBezier::PointNameChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxP1) == getCurrentObjectId(ui->comboBoxP4))
|
if (getCurrentObjectId(ui->comboBoxP1) == getCurrentObjectId(ui->comboBoxP4))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -185,7 +184,7 @@ void DialogCubicBezier::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
|
|
||||||
if (getCurrentObjectId(ui->comboBoxP1) == spl.GetP1().id() &&
|
if (getCurrentObjectId(ui->comboBoxP1) == spl.GetP1().id() &&
|
||||||
getCurrentObjectId(ui->comboBoxP4) == spl.GetP4().id())
|
getCurrentObjectId(ui->comboBoxP4) == spl.GetP4().id())
|
||||||
|
|
|
@ -52,7 +52,7 @@ class DialogCubicBezier : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogCubicBezier(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogCubicBezier(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogCubicBezier();
|
virtual ~DialogCubicBezier();
|
||||||
|
|
||||||
VCubicBezier GetSpline() const;
|
VCubicBezier GetSpline() const;
|
||||||
|
@ -66,6 +66,7 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogCubicBezier)
|
Q_DISABLE_COPY(DialogCubicBezier)
|
||||||
Ui::DialogCubicBezier *ui;
|
Ui::DialogCubicBezier *ui;
|
||||||
|
@ -75,10 +76,18 @@ private:
|
||||||
|
|
||||||
qint32 newDuplicate;
|
qint32 newDuplicate;
|
||||||
|
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
const QSharedPointer<VPointF> GetP1() const;
|
const QSharedPointer<VPointF> GetP1() const;
|
||||||
const QSharedPointer<VPointF> GetP2() const;
|
const QSharedPointer<VPointF> GetP2() const;
|
||||||
const QSharedPointer<VPointF> GetP3() const;
|
const QSharedPointer<VPointF> GetP3() const;
|
||||||
const QSharedPointer<VPointF> GetP4() const;
|
const QSharedPointer<VPointF> GetP4() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogCubicBezier::IsValid() const
|
||||||
|
{
|
||||||
|
return flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGCUBICBEZIER_H
|
#endif // DIALOGCUBICBEZIER_H
|
||||||
|
|
|
@ -58,11 +58,12 @@
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogCubicBezierPath::DialogCubicBezierPath(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogCubicBezierPath::DialogCubicBezierPath(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogCubicBezierPath),
|
ui(new Ui::DialogCubicBezierPath),
|
||||||
path(),
|
path(),
|
||||||
newDuplicate(-1)
|
newDuplicate(-1),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -223,7 +224,7 @@ void DialogCubicBezierPath::currentPointChanged(int index)
|
||||||
DataPoint(*point);
|
DataPoint(*point);
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(*point));
|
item->setData(Qt::UserRole, QVariant::fromValue(*point));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (not IsPathValid())
|
if (not IsPathValid())
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -234,7 +235,7 @@ void DialogCubicBezierPath::currentPointChanged(int index)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
|
|
||||||
auto first = qvariant_cast<VPointF>(ui->listWidget->item(0)->data(Qt::UserRole));
|
auto first = qvariant_cast<VPointF>(ui->listWidget->item(0)->data(Qt::UserRole));
|
||||||
auto last = qvariant_cast<VPointF>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
|
auto last = qvariant_cast<VPointF>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
|
||||||
|
|
|
@ -51,7 +51,7 @@ class DialogCubicBezierPath : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogCubicBezierPath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogCubicBezierPath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogCubicBezierPath();
|
virtual ~DialogCubicBezierPath();
|
||||||
|
|
||||||
VCubicBezierPath GetPath() const;
|
VCubicBezierPath GetPath() const;
|
||||||
|
@ -62,6 +62,7 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private slots:
|
private slots:
|
||||||
void PointChanged(int row);
|
void PointChanged(int row);
|
||||||
void currentPointChanged(int index);
|
void currentPointChanged(int index);
|
||||||
|
@ -75,6 +76,8 @@ private:
|
||||||
|
|
||||||
qint32 newDuplicate;
|
qint32 newDuplicate;
|
||||||
|
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
void NewItem(const VPointF &point);
|
void NewItem(const VPointF &point);
|
||||||
void DataPoint(const VPointF &p);
|
void DataPoint(const VPointF &p);
|
||||||
void SavePath();
|
void SavePath();
|
||||||
|
@ -83,4 +86,10 @@ private:
|
||||||
VCubicBezierPath ExtractPath() const;
|
VCubicBezierPath ExtractPath() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogCubicBezierPath::IsValid() const
|
||||||
|
{
|
||||||
|
return flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGCUBICBEZIERPATH_H
|
#endif // DIALOGCUBICBEZIERPATH_H
|
||||||
|
|
|
@ -54,26 +54,28 @@
|
||||||
#include "ui_dialogcurveintersectaxis.h"
|
#include "ui_dialogcurveintersectaxis.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogCurveIntersectAxis),
|
ui(new Ui::DialogCurveIntersectAxis),
|
||||||
formulaAngle(),
|
formulaAngle(),
|
||||||
formulaBaseHeightAngle(0),
|
formulaBaseHeightAngle(0),
|
||||||
m_firstRelease(false)
|
pointName(),
|
||||||
|
m_firstRelease(false),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
formulaBaseHeightAngle = ui->plainTextEditFormula->height();
|
||||||
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
|
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxAxisPoint);
|
FillComboBoxPoints(ui->comboBoxAxisPoint);
|
||||||
FillComboBoxCurves(ui->comboBoxCurve);
|
FillComboBoxCurves(ui->comboBoxCurve);
|
||||||
|
@ -81,8 +83,15 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
|
||||||
FillComboBoxLineColors(ui->comboBoxLineColor);
|
FillComboBoxLineColors(ui->comboBoxLineColor);
|
||||||
|
|
||||||
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::FXAngle);
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::FXAngle);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCurveIntersectAxis::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCurveIntersectAxis::AngleTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::DeployAngleTextEdit);
|
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::DeployAngleTextEdit);
|
||||||
connect(timerFormula, &QTimer::timeout, this, &DialogCurveIntersectAxis::EvalAngle);
|
connect(timerFormula, &QTimer::timeout, this, &DialogCurveIntersectAxis::EvalAngle);
|
||||||
|
|
||||||
|
@ -95,6 +104,12 @@ DialogCurveIntersectAxis::~DialogCurveIntersectAxis()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogCurveIntersectAxis::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCurveIntersectAxis::SetPointName(const QString &value)
|
void DialogCurveIntersectAxis::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -147,7 +162,7 @@ quint32 DialogCurveIntersectAxis::GetBasePointId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCurveIntersectAxis::SetBasePointId(const quint32 &value)
|
void DialogCurveIntersectAxis::SetBasePointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxAxisPoint, value);
|
setCurrentPointId(ui->comboBoxAxisPoint, value);
|
||||||
|
|
||||||
|
@ -163,7 +178,7 @@ quint32 DialogCurveIntersectAxis::getCurveId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCurveIntersectAxis::setCurveId(const quint32 &value)
|
void DialogCurveIntersectAxis::setCurveId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentCurveId(ui->comboBoxCurve, value);
|
setCurrentCurveId(ui->comboBoxCurve, value);
|
||||||
|
|
||||||
|
@ -269,19 +284,21 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCurveIntersectAxis::EvalAngle()
|
void DialogCurveIntersectAxis::EvalAngle()
|
||||||
{
|
{
|
||||||
Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, degreeSymbol, false);
|
FormulaData formulaData;
|
||||||
}
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
Eval(formulaData, flagFormula);
|
||||||
void DialogCurveIntersectAxis::AngleTextChanged()
|
|
||||||
{
|
|
||||||
ValFormulaChanged(flagError, ui->plainTextEditFormula, timerFormula, degreeSymbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCurveIntersectAxis::DeployAngleTextEdit()
|
void DialogCurveIntersectAxis::DeployAngleTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -48,9 +48,10 @@ class DialogCurveIntersectAxis : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogCurveIntersectAxis(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogCurveIntersectAxis() override;
|
virtual ~DialogCurveIntersectAxis() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -60,10 +61,10 @@ public:
|
||||||
void SetAngle(const QString &value);
|
void SetAngle(const QString &value);
|
||||||
|
|
||||||
quint32 GetBasePointId() const;
|
quint32 GetBasePointId() const;
|
||||||
void SetBasePointId(const quint32 &value);
|
void SetBasePointId(quint32 value);
|
||||||
|
|
||||||
quint32 getCurveId() const;
|
quint32 getCurveId() const;
|
||||||
void setCurveId(const quint32 &value);
|
void setCurveId(quint32 value);
|
||||||
|
|
||||||
QString GetLineColor() const;
|
QString GetLineColor() const;
|
||||||
void SetLineColor(const QString &value);
|
void SetLineColor(const QString &value);
|
||||||
|
@ -72,7 +73,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
void AngleTextChanged();
|
|
||||||
void DeployAngleTextEdit();
|
void DeployAngleTextEdit();
|
||||||
void FXAngle();
|
void FXAngle();
|
||||||
protected:
|
protected:
|
||||||
|
@ -82,6 +82,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogCurveIntersectAxis)
|
Q_DISABLE_COPY(DialogCurveIntersectAxis)
|
||||||
Ui::DialogCurveIntersectAxis *ui;
|
Ui::DialogCurveIntersectAxis *ui;
|
||||||
|
@ -89,7 +90,20 @@ private:
|
||||||
QString formulaAngle;
|
QString formulaAngle;
|
||||||
int formulaBaseHeightAngle;
|
int formulaBaseHeightAngle;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
bool m_firstRelease;
|
bool m_firstRelease;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogCurveIntersectAxis::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGCURVEINTERSECTAXIS_H
|
#endif // DIALOGCURVEINTERSECTAXIS_H
|
||||||
|
|
|
@ -33,9 +33,11 @@
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/path/vistoolcutarc.h"
|
#include "../../visualization/path/vistoolcutarc.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
|
@ -51,39 +53,46 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogCutArc),
|
||||||
|
formula(),
|
||||||
|
pointName(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogCutArc::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxArcs(ui->comboBoxArc);
|
FillComboBoxArcs(ui->comboBoxArc);
|
||||||
|
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutArc::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutArc::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit);
|
||||||
|
|
||||||
vis = new VisToolCutArc(data);
|
vis = new VisToolCutArc(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogCutArc::FormulaTextChanged()
|
|
||||||
{
|
|
||||||
this->FormulaChangedPlainText();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutArc::FXLength()
|
void DialogCutArc::FXLength()
|
||||||
{
|
{
|
||||||
|
@ -98,6 +107,20 @@ void DialogCutArc::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogCutArc::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutArc::ShowVisualization()
|
void DialogCutArc::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -107,7 +130,7 @@ void DialogCutArc::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutArc::DeployFormulaTextEdit()
|
void DialogCutArc::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -116,6 +139,12 @@ DialogCutArc::~DialogCutArc()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogCutArc::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||||
|
@ -165,7 +194,7 @@ void DialogCutArc::closeEvent(QCloseEvent *event)
|
||||||
* @brief setArcId set id of arc
|
* @brief setArcId set id of arc
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogCutArc::setArcId(const quint32 &value)
|
void DialogCutArc::setArcId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentArcId(ui->comboBoxArc, value);
|
setCurrentArcId(ui->comboBoxArc, value);
|
||||||
|
|
||||||
|
|
|
@ -51,27 +51,26 @@ class DialogCutArc : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogCutArc() override;
|
virtual ~DialogCutArc() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetFormula() const;
|
QString GetFormula() const;
|
||||||
void SetFormula(const QString &value);
|
void SetFormula(const QString &value);
|
||||||
|
|
||||||
quint32 getArcId() const;
|
quint32 getArcId() const;
|
||||||
void setArcId(const quint32 &value);
|
void setArcId(quint32 value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
/**
|
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
|
||||||
*/
|
|
||||||
void FormulaTextChanged();
|
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -79,16 +78,29 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogCutArc)
|
Q_DISABLE_COPY(DialogCutArc)
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogCutArc *ui;
|
Ui::DialogCutArc *ui;
|
||||||
|
|
||||||
/** @brief formula string with formula */
|
/** @brief formula string with formula */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogCutArc::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGCUTARC_H
|
#endif // DIALOGCUTARC_H
|
||||||
|
|
|
@ -33,9 +33,11 @@
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/path/vistoolcutspline.h"
|
#include "../../visualization/path/vistoolcutspline.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
|
@ -51,28 +53,41 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogCutSpline),
|
||||||
|
formula(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
pointName(),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogCutSpline::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxSplines(ui->comboBoxSpline);
|
FillComboBoxSplines(ui->comboBoxSpline);
|
||||||
|
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
|
||||||
|
|
||||||
vis = new VisToolCutSpline(data);
|
vis = new VisToolCutSpline(data);
|
||||||
|
@ -84,6 +99,12 @@ DialogCutSpline::~DialogCutSpline()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogCutSpline::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief SetPointName set name of point
|
* @brief SetPointName set name of point
|
||||||
|
@ -123,7 +144,7 @@ void DialogCutSpline::SetFormula(const QString &value)
|
||||||
* @brief setSplineId set id spline
|
* @brief setSplineId set id spline
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogCutSpline::setSplineId(const quint32 &value)
|
void DialogCutSpline::setSplineId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentSplineId(ui->comboBoxSpline, value);
|
setCurrentSplineId(ui->comboBoxSpline, value);
|
||||||
|
|
||||||
|
@ -179,7 +200,7 @@ void DialogCutSpline::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::DeployFormulaTextEdit()
|
void DialogCutSpline::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -196,6 +217,20 @@ void DialogCutSpline::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogCutSpline::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::ShowVisualization()
|
void DialogCutSpline::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,16 +50,17 @@ class DialogCutSpline : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogCutSpline(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogCutSpline() override;
|
virtual ~DialogCutSpline() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetFormula() const;
|
QString GetFormula() const;
|
||||||
void SetFormula(const QString &value);
|
void SetFormula(const QString &value);
|
||||||
|
|
||||||
quint32 getSplineId() const;
|
quint32 getSplineId() const;
|
||||||
void setSplineId(const quint32 &value);
|
void setSplineId(quint32 value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +68,7 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -74,6 +76,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogCutSpline)
|
Q_DISABLE_COPY(DialogCutSpline)
|
||||||
|
|
||||||
|
@ -81,10 +84,23 @@ private:
|
||||||
Ui::DialogCutSpline *ui;
|
Ui::DialogCutSpline *ui;
|
||||||
|
|
||||||
/** @brief formula string with formula */
|
/** @brief formula string with formula */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogCutSpline::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGCUTSPLINE_H
|
#endif // DIALOGCUTSPLINE_H
|
||||||
|
|
|
@ -33,9 +33,11 @@
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/path/vistoolcutsplinepath.h"
|
#include "../../visualization/path/vistoolcutsplinepath.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
|
@ -51,28 +53,41 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogCutSplinePath),
|
||||||
|
formula(),
|
||||||
|
pointName(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogCutSplinePath::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxSplinesPath(ui->comboBoxSplinePath);
|
FillComboBoxSplinesPath(ui->comboBoxSplinePath);
|
||||||
|
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSplinePath::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSplinePath::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
|
||||||
|
|
||||||
vis = new VisToolCutSplinePath(data);
|
vis = new VisToolCutSplinePath(data);
|
||||||
|
@ -84,6 +99,12 @@ DialogCutSplinePath::~DialogCutSplinePath()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogCutSplinePath::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief SetPointName set name of point
|
* @brief SetPointName set name of point
|
||||||
|
@ -123,7 +144,7 @@ void DialogCutSplinePath::SetFormula(const QString &value)
|
||||||
* @brief setSplineId set id spline
|
* @brief setSplineId set id spline
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogCutSplinePath::setSplinePathId(const quint32 &value)
|
void DialogCutSplinePath::setSplinePathId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentSplinePathId(ui->comboBoxSplinePath, value);
|
setCurrentSplinePathId(ui->comboBoxSplinePath, value);
|
||||||
|
|
||||||
|
@ -179,7 +200,7 @@ void DialogCutSplinePath::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSplinePath::DeployFormulaTextEdit()
|
void DialogCutSplinePath::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -196,6 +217,20 @@ void DialogCutSplinePath::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogCutSplinePath::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSplinePath::ShowVisualization()
|
void DialogCutSplinePath::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,16 +50,17 @@ class DialogCutSplinePath : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogCutSplinePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogCutSplinePath() override;
|
virtual ~DialogCutSplinePath() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetFormula() const;
|
QString GetFormula() const;
|
||||||
void SetFormula(const QString &value);
|
void SetFormula(const QString &value);
|
||||||
|
|
||||||
quint32 getSplinePathId() const;
|
quint32 getSplinePathId() const;
|
||||||
void setSplinePathId(const quint32 &value);
|
void setSplinePathId(quint32 value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +68,7 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -74,6 +76,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogCutSplinePath)
|
Q_DISABLE_COPY(DialogCutSplinePath)
|
||||||
|
|
||||||
|
@ -81,10 +84,22 @@ private:
|
||||||
Ui::DialogCutSplinePath *ui;
|
Ui::DialogCutSplinePath *ui;
|
||||||
|
|
||||||
/** @brief formula string with formula */
|
/** @brief formula string with formula */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogCutSplinePath::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGCUTSPLINEPATH_H
|
#endif // DIALOGCUTSPLINEPATH_H
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogEllipticalArc),
|
ui(new Ui::DialogEllipticalArc),
|
||||||
flagRadius1(false),
|
flagRadius1(false),
|
||||||
|
@ -62,11 +62,11 @@ DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, const quint32 &
|
||||||
flagF1(false),
|
flagF1(false),
|
||||||
flagF2(false),
|
flagF2(false),
|
||||||
flagRotationAngle(false),
|
flagRotationAngle(false),
|
||||||
timerRadius1(nullptr),
|
timerRadius1(new QTimer(this)),
|
||||||
timerRadius2(nullptr),
|
timerRadius2(new QTimer(this)),
|
||||||
timerF1(nullptr),
|
timerF1(new QTimer(this)),
|
||||||
timerF2(nullptr),
|
timerF2(new QTimer(this)),
|
||||||
timerRotationAngle(nullptr),
|
timerRotationAngle(new QTimer(this)),
|
||||||
radius1(),
|
radius1(),
|
||||||
radius2(),
|
radius2(),
|
||||||
f1(),
|
f1(),
|
||||||
|
@ -95,19 +95,19 @@ DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, const quint32 &
|
||||||
ui->plainTextEditF2->installEventFilter(this);
|
ui->plainTextEditF2->installEventFilter(this);
|
||||||
ui->plainTextEditRotationAngle->installEventFilter(this);
|
ui->plainTextEditRotationAngle->installEventFilter(this);
|
||||||
|
|
||||||
timerRadius1 = new QTimer(this);
|
timerRadius1->setSingleShot(true);
|
||||||
connect(timerRadius1, &QTimer::timeout, this, &DialogEllipticalArc::EvalRadiuses);
|
connect(timerRadius1, &QTimer::timeout, this, &DialogEllipticalArc::EvalRadiuses);
|
||||||
|
|
||||||
timerRadius2 = new QTimer(this);
|
timerRadius2->setSingleShot(true);
|
||||||
connect(timerRadius2, &QTimer::timeout, this, &DialogEllipticalArc::EvalRadiuses);
|
connect(timerRadius2, &QTimer::timeout, this, &DialogEllipticalArc::EvalRadiuses);
|
||||||
|
|
||||||
timerF1 = new QTimer(this);
|
timerF1->setSingleShot(true);
|
||||||
connect(timerF1, &QTimer::timeout, this, &DialogEllipticalArc::EvalAngles);
|
connect(timerF1, &QTimer::timeout, this, &DialogEllipticalArc::EvalAngles);
|
||||||
|
|
||||||
timerF2 = new QTimer(this);
|
timerF2->setSingleShot(true);
|
||||||
connect(timerF2, &QTimer::timeout, this, &DialogEllipticalArc::EvalAngles);
|
connect(timerF2, &QTimer::timeout, this, &DialogEllipticalArc::EvalAngles);
|
||||||
|
|
||||||
timerRotationAngle = new QTimer(this);
|
timerRotationAngle->setSingleShot(true);
|
||||||
connect(timerRotationAngle, &QTimer::timeout, this, &DialogEllipticalArc::EvalAngles);
|
connect(timerRotationAngle, &QTimer::timeout, this, &DialogEllipticalArc::EvalAngles);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -116,20 +116,36 @@ DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, const quint32 &
|
||||||
FillComboBoxLineColors(ui->comboBoxColor);
|
FillComboBoxLineColors(ui->comboBoxColor);
|
||||||
FillComboBoxTypeLine(ui->comboBoxPenStyle, CurvePenStylesPics());
|
FillComboBoxTypeLine(ui->comboBoxPenStyle, CurvePenStylesPics());
|
||||||
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->toolButtonExprRadius1, &QPushButton::clicked, this, &DialogEllipticalArc::FXRadius1);
|
connect(ui->toolButtonExprRadius1, &QPushButton::clicked, this, &DialogEllipticalArc::FXRadius1);
|
||||||
connect(ui->toolButtonExprRadius2, &QPushButton::clicked, this, &DialogEllipticalArc::FXRadius2);
|
connect(ui->toolButtonExprRadius2, &QPushButton::clicked, this, &DialogEllipticalArc::FXRadius2);
|
||||||
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogEllipticalArc::FXF1);
|
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogEllipticalArc::FXF1);
|
||||||
connect(ui->toolButtonExprF2, &QPushButton::clicked, this, &DialogEllipticalArc::FXF2);
|
connect(ui->toolButtonExprF2, &QPushButton::clicked, this, &DialogEllipticalArc::FXF2);
|
||||||
connect(ui->toolButtonExprRotationAngle, &QPushButton::clicked, this, &DialogEllipticalArc::FXRotationAngle);
|
connect(ui->toolButtonExprRotationAngle, &QPushButton::clicked, this, &DialogEllipticalArc::FXRotationAngle);
|
||||||
|
|
||||||
connect(ui->plainTextEditRadius1, &QPlainTextEdit::textChanged, this, &DialogEllipticalArc::Radius1Changed);
|
connect(ui->plainTextEditRadius1, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditRadius2, &QPlainTextEdit::textChanged, this, &DialogEllipticalArc::Radius2Changed);
|
{
|
||||||
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogEllipticalArc::F1Changed);
|
timerRadius1->start(formulaTimerTimeout);
|
||||||
connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, &DialogEllipticalArc::F2Changed);
|
});
|
||||||
connect(ui->plainTextEditRotationAngle, &QPlainTextEdit::textChanged,
|
|
||||||
this, &DialogEllipticalArc::RotationAngleChanged);
|
connect(ui->plainTextEditRadius2, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerRadius2->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerF1->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerF2->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditRotationAngle, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerRotationAngle->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowLengthRadius1, &QPushButton::clicked, this, &DialogEllipticalArc::DeployRadius1TextEdit);
|
connect(ui->pushButtonGrowLengthRadius1, &QPushButton::clicked, this, &DialogEllipticalArc::DeployRadius1TextEdit);
|
||||||
connect(ui->pushButtonGrowLengthRadius2, &QPushButton::clicked, this, &DialogEllipticalArc::DeployRadius2TextEdit);
|
connect(ui->pushButtonGrowLengthRadius2, &QPushButton::clicked, this, &DialogEllipticalArc::DeployRadius2TextEdit);
|
||||||
|
@ -366,31 +382,21 @@ void DialogEllipticalArc::SetColor(const QString &value)
|
||||||
*/
|
*/
|
||||||
void DialogEllipticalArc::EvalRadiuses()
|
void DialogEllipticalArc::EvalRadiuses()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditRadius1;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditRadius1->toPlainText();
|
||||||
const qreal radius_1 = Eval(ui->plainTextEditRadius1->toPlainText(), flagRadius1, ui->labelResultRadius1, postfix);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditRadius1;
|
||||||
|
formulaData.labelResult = ui->labelResultRadius1;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
if (radius_1 < 0)
|
Eval(formulaData, flagRadius1);
|
||||||
{
|
|
||||||
flagRadius1 = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultRadius1->setText(tr("Error"));
|
|
||||||
ui->labelResultRadius1->setToolTip(tr("Radius can't be negative"));
|
|
||||||
|
|
||||||
DialogEllipticalArc::CheckState();
|
formulaData.formula = ui->plainTextEditRadius2->toPlainText();
|
||||||
}
|
formulaData.labelEditFormula = ui->labelEditRadius2;
|
||||||
|
formulaData.labelResult = ui->labelResultRadius2;
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditRadius2;
|
Eval(formulaData, flagRadius2);
|
||||||
const qreal radius_2 = Eval(ui->plainTextEditRadius2->toPlainText(), flagRadius2, ui->labelResultRadius2, postfix);
|
|
||||||
if (radius_2 < 0)
|
|
||||||
{
|
|
||||||
flagRadius2 = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultRadius2->setText(tr("Error"));
|
|
||||||
ui->labelResultRadius2->setToolTip(tr("Radius can't be negative"));
|
|
||||||
|
|
||||||
DialogEllipticalArc::CheckState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -399,15 +405,27 @@ void DialogEllipticalArc::EvalRadiuses()
|
||||||
*/
|
*/
|
||||||
void DialogEllipticalArc::EvalAngles()
|
void DialogEllipticalArc::EvalAngles()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditF1;
|
FormulaData formulaData;
|
||||||
angleF1 = Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditF1->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditF1;
|
||||||
|
formulaData.labelResult = ui->labelResultF1;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditF2;
|
angleF1 = Eval(formulaData, flagF1);
|
||||||
angleF2 = Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false);
|
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditRotationAngle;
|
formulaData.formula = ui->plainTextEditF2->toPlainText();
|
||||||
angleRotation = Eval(ui->plainTextEditRotationAngle->toPlainText(), flagRotationAngle,
|
formulaData.labelEditFormula = ui->labelEditF2;
|
||||||
ui->labelResultRotationAngle, degreeSymbol, false);
|
formulaData.labelResult = ui->labelResultF2;
|
||||||
|
|
||||||
|
angleF2 = Eval(formulaData, flagF2);
|
||||||
|
|
||||||
|
formulaData.formula = ui->plainTextEditRotationAngle->toPlainText();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditRotationAngle;
|
||||||
|
formulaData.labelResult = ui->labelResultRotationAngle;
|
||||||
|
|
||||||
|
angleRotation = Eval(formulaData, flagRotationAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -480,91 +498,34 @@ void DialogEllipticalArc::FXRotationAngle()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief Radius1Changed after change formula of radius1 calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogEllipticalArc::Radius1Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditRadius1;
|
|
||||||
labelResultCalculation = ui->labelResultRadius1;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagRadius1, ui->plainTextEditRadius1, timerRadius1, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief Radius2Changed after change formula of radius2 calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogEllipticalArc::Radius2Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditRadius2;
|
|
||||||
labelResultCalculation = ui->labelResultRadius2;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagRadius2, ui->plainTextEditRadius2, timerRadius2, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief F1Changed after change formula of first angle calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogEllipticalArc::F1Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditF1;
|
|
||||||
labelResultCalculation = ui->labelResultF1;
|
|
||||||
ValFormulaChanged(flagF1, ui->plainTextEditF1, timerF1, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief F2Changed after change formula of second angle calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogEllipticalArc::F2Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditF2;
|
|
||||||
labelResultCalculation = ui->labelResultF2;
|
|
||||||
ValFormulaChanged(flagF2, ui->plainTextEditF2, timerF2, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief RotationAngleChanged after change formula of rotation angle calculate value and show result
|
|
||||||
*/
|
|
||||||
void DialogEllipticalArc::RotationAngleChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditRotationAngle;
|
|
||||||
labelResultCalculation = ui->labelResultF2;
|
|
||||||
ValFormulaChanged(flagRotationAngle, ui->plainTextEditRotationAngle, timerRotationAngle, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEllipticalArc::DeployRadius1TextEdit()
|
void DialogEllipticalArc::DeployRadius1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditRadius1, ui->pushButtonGrowLengthRadius1, formulaBaseHeightRadius1);
|
DeployFormula(this, ui->plainTextEditRadius1, ui->pushButtonGrowLengthRadius1, formulaBaseHeightRadius1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEllipticalArc::DeployRadius2TextEdit()
|
void DialogEllipticalArc::DeployRadius2TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditRadius2, ui->pushButtonGrowLengthRadius2, formulaBaseHeightRadius2);
|
DeployFormula(this, ui->plainTextEditRadius2, ui->pushButtonGrowLengthRadius2, formulaBaseHeightRadius2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEllipticalArc::DeployF1TextEdit()
|
void DialogEllipticalArc::DeployF1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
|
DeployFormula(this, ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEllipticalArc::DeployF2TextEdit()
|
void DialogEllipticalArc::DeployF2TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2);
|
DeployFormula(this, ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEllipticalArc::DeployRotationAngleTextEdit()
|
void DialogEllipticalArc::DeployRotationAngleTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditRotationAngle, ui->pushButtonGrowLengthRotationAngle,formulaBaseHeightRotationAngle);
|
DeployFormula(this, ui->plainTextEditRotationAngle, ui->pushButtonGrowLengthRotationAngle,formulaBaseHeightRotationAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -590,18 +551,6 @@ void DialogEllipticalArc::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief CheckState if all is right enable button ok
|
|
||||||
*/
|
|
||||||
void DialogEllipticalArc::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagRadius1 && flagRadius2 && flagF1 && flagF2 && flagRotationAngle);
|
|
||||||
SCASSERT(bApply != nullptr)
|
|
||||||
bApply->setEnabled(flagRadius1 && flagRadius2 && flagF1 && flagF2 && flagRotationAngle);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEllipticalArc::ShowVisualization()
|
void DialogEllipticalArc::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ class DialogEllipticalArc : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogEllipticalArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogEllipticalArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogEllipticalArc() override;
|
virtual ~DialogEllipticalArc() override;
|
||||||
|
|
||||||
quint32 GetCenter() const;
|
quint32 GetCenter() const;
|
||||||
|
@ -85,12 +85,6 @@ public slots:
|
||||||
void DeployF2TextEdit();
|
void DeployF2TextEdit();
|
||||||
void DeployRotationAngleTextEdit();
|
void DeployRotationAngleTextEdit();
|
||||||
|
|
||||||
void Radius1Changed();
|
|
||||||
void Radius2Changed();
|
|
||||||
void F1Changed();
|
|
||||||
void F2Changed();
|
|
||||||
void RotationAngleChanged();
|
|
||||||
|
|
||||||
void FXRadius1();
|
void FXRadius1();
|
||||||
void FXRadius2();
|
void FXRadius2();
|
||||||
void FXF1();
|
void FXF1();
|
||||||
|
@ -98,13 +92,13 @@ public slots:
|
||||||
void FXRotationAngle();
|
void FXRotationAngle();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogEllipticalArc)
|
Q_DISABLE_COPY(DialogEllipticalArc)
|
||||||
|
@ -172,4 +166,10 @@ private:
|
||||||
void EvalAngles();
|
void EvalAngles();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogEllipticalArc::IsValid() const
|
||||||
|
{
|
||||||
|
return flagRadius1 && flagRadius2 && flagF1 && flagF2 && flagRotationAngle;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGELLIPTICALARC_H
|
#endif // DIALOGELLIPTICALARC_H
|
||||||
|
|
|
@ -61,22 +61,29 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogEndLine::DialogEndLine(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogEndLine),
|
ui(new Ui::DialogEndLine),
|
||||||
formulaLength(),
|
formulaLength(),
|
||||||
formulaAngle(),
|
formulaAngle(),
|
||||||
formulaBaseHeight(0),
|
formulaBaseHeight(0),
|
||||||
formulaBaseHeightAngle(0),
|
formulaBaseHeightAngle(0),
|
||||||
m_firstRelease(false)
|
pointName(),
|
||||||
|
m_firstRelease(false),
|
||||||
|
timerFormulaLength(new QTimer(this)),
|
||||||
|
timerFormulaAngle(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagError(false),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormulaLength->setSingleShot(true);
|
||||||
|
timerFormulaAngle->setSingleShot(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
|
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
|
||||||
|
|
||||||
|
@ -85,7 +92,6 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
flagFormula = false;
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxBasePoint);
|
FillComboBoxPoints(ui->comboBoxBasePoint);
|
||||||
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
||||||
|
@ -94,15 +100,27 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogEndLine::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogEndLine::FXLength);
|
||||||
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogEndLine::FXAngle);
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogEndLine::FXAngle);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEndLine::FormulaTextChanged);
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, &DialogEndLine::AngleTextChanged);
|
{
|
||||||
|
timerFormulaLength->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormulaAngle->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit);
|
||||||
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogEndLine::DeployAngleTextEdit);
|
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogEndLine::DeployAngleTextEdit);
|
||||||
|
|
||||||
connect(timerFormula, &QTimer::timeout, this, &DialogEndLine::EvalAngle);
|
connect(timerFormulaLength, &QTimer::timeout, this, &DialogEndLine::EvalLength);
|
||||||
|
connect(timerFormulaAngle, &QTimer::timeout, this, &DialogEndLine::EvalAngle);
|
||||||
|
|
||||||
vis = new VisToolEndLine(data);
|
vis = new VisToolEndLine(data);
|
||||||
}
|
}
|
||||||
|
@ -113,35 +131,41 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
|
||||||
*/
|
*/
|
||||||
void DialogEndLine::EvalAngle()
|
void DialogEndLine::EvalAngle()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditAngle;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditAngle->toPlainText(), flagError, ui->labelResultCalculationAngle, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditAngle->toPlainText();
|
||||||
labelEditFormula = ui->labelEditFormula;
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAngle;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculationAngle;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagError);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEndLine::FormulaTextChanged()
|
void DialogEndLine::EvalLength()
|
||||||
{
|
{
|
||||||
this->FormulaChangedPlainText();
|
FormulaData formulaData;
|
||||||
}
|
formulaData.formula = ui->plainTextEditAngle->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
Eval(formulaData, flagFormula);
|
||||||
void DialogEndLine::AngleTextChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditAngle;
|
|
||||||
ValFormulaChanged(flagError, ui->plainTextEditAngle, timerFormula, degreeSymbol);
|
|
||||||
labelEditFormula = ui->labelEditFormula;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEndLine::DeployFormulaTextEdit()
|
void DialogEndLine::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEndLine::DeployAngleTextEdit()
|
void DialogEndLine::DeployAngleTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditAngle, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
|
DeployFormula(this, ui->plainTextEditAngle, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -329,7 +353,7 @@ void DialogEndLine::ShowDialog(bool click)
|
||||||
this->SetAngle(line->Angle());//Show in dialog angle what user choose
|
this->SetAngle(line->Angle());//Show in dialog angle what user choose
|
||||||
this->SetFormula(line->Length());
|
this->SetFormula(line->Length());
|
||||||
emit ToolTip(QString());
|
emit ToolTip(QString());
|
||||||
timerFormula->start();
|
timerFormulaLength->start();
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,6 +395,12 @@ DialogEndLine::~DialogEndLine()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogEndLine::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief GetTypeLine return type of line
|
* @brief GetTypeLine return type of line
|
||||||
|
|
|
@ -50,9 +50,10 @@ class DialogEndLine : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogEndLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogEndLine() override;
|
virtual ~DialogEndLine() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -73,17 +74,12 @@ public:
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
|
||||||
*/
|
|
||||||
void DeployFormulaTextEdit();
|
|
||||||
/**
|
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
|
||||||
*/
|
|
||||||
void FormulaTextChanged();
|
|
||||||
|
|
||||||
|
void EvalLength();
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
void AngleTextChanged();
|
|
||||||
|
/** @brief DeployFormulaTextEdit grow or shrink formula input */
|
||||||
|
void DeployFormulaTextEdit();
|
||||||
void DeployAngleTextEdit();
|
void DeployAngleTextEdit();
|
||||||
|
|
||||||
void FXAngle();
|
void FXAngle();
|
||||||
|
@ -95,6 +91,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogEndLine)
|
Q_DISABLE_COPY(DialogEndLine)
|
||||||
|
|
||||||
|
@ -102,16 +99,31 @@ private:
|
||||||
Ui::DialogEndLine *ui;
|
Ui::DialogEndLine *ui;
|
||||||
|
|
||||||
/** @brief formula formula */
|
/** @brief formula formula */
|
||||||
QString formulaLength;
|
QString formulaLength;
|
||||||
|
|
||||||
/** @brief angle angle of line */
|
/** @brief angle angle of line */
|
||||||
QString formulaAngle;
|
QString formulaAngle;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
int formulaBaseHeightAngle;
|
int formulaBaseHeightAngle;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
bool m_firstRelease;
|
bool m_firstRelease;
|
||||||
|
|
||||||
|
QTimer *timerFormulaLength;
|
||||||
|
QTimer *timerFormulaAngle;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagError;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogEndLine::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagError && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGENDLINE_H
|
#endif // DIALOGENDLINE_H
|
||||||
|
|
|
@ -59,12 +59,14 @@
|
||||||
#include "ui_dialogflippingbyaxis.h"
|
#include "ui_dialogflippingbyaxis.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogFlippingByAxis),
|
ui(new Ui::DialogFlippingByAxis),
|
||||||
objects(),
|
objects(),
|
||||||
stage1(true),
|
stage1(true),
|
||||||
m_suffix()
|
m_suffix(),
|
||||||
|
flagName(false),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -75,9 +77,6 @@ DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, const quint32
|
||||||
FillComboBoxPoints(ui->comboBoxOriginPoint);
|
FillComboBoxPoints(ui->comboBoxOriginPoint);
|
||||||
FillComboBoxAxisType(ui->comboBoxAxisType);
|
FillComboBoxAxisType(ui->comboBoxAxisType);
|
||||||
|
|
||||||
flagName = true;
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByAxis::SuffixChanged);
|
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByAxis::SuffixChanged);
|
||||||
connect(ui->comboBoxOriginPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxOriginPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogFlippingByAxis::PointChanged);
|
this, &DialogFlippingByAxis::PointChanged);
|
||||||
|
@ -244,7 +243,7 @@ void DialogFlippingByAxis::SuffixChanged()
|
||||||
if (suffix.isEmpty())
|
if (suffix.isEmpty())
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +259,7 @@ void DialogFlippingByAxis::SuffixChanged()
|
||||||
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -269,20 +268,11 @@ void DialogFlippingByAxis::SuffixChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
flagName = true;
|
flagName = true;
|
||||||
ChangeColor(ui->labelSuffix, okColor);
|
ChangeColor(ui->labelSuffix, OkColor(this));
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogFlippingByAxis::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagError && flagName);
|
|
||||||
SCASSERT(bApply != nullptr)
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByAxis::ShowVisualization()
|
void DialogFlippingByAxis::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -306,7 +296,7 @@ void DialogFlippingByAxis::SaveData()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByAxis::PointChanged()
|
void DialogFlippingByAxis::PointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
|
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -315,7 +305,7 @@ void DialogFlippingByAxis::PointChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelOriginPoint, color);
|
ChangeColor(ui->labelOriginPoint, color);
|
||||||
CheckState();
|
CheckState();
|
||||||
|
|
|
@ -51,7 +51,7 @@ class DialogFlippingByAxis : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogFlippingByAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogFlippingByAxis(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogFlippingByAxis();
|
virtual ~DialogFlippingByAxis();
|
||||||
|
|
||||||
quint32 GetOriginPointId() const;
|
quint32 GetOriginPointId() const;
|
||||||
|
@ -75,11 +75,11 @@ private slots:
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
|
||||||
/** @brief SaveData Put dialog data in local variables */
|
/** @brief SaveData Put dialog data in local variables */
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void PointChanged();
|
void PointChanged();
|
||||||
|
@ -95,7 +95,16 @@ private:
|
||||||
|
|
||||||
QString m_suffix;
|
QString m_suffix;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
static void FillComboBoxAxisType(QComboBox *box);
|
static void FillComboBoxAxisType(QComboBox *box);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogFlippingByAxis::IsValid() const
|
||||||
|
{
|
||||||
|
return flagError && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGFLIPPINGBYAXIS_H
|
#endif // DIALOGFLIPPINGBYAXIS_H
|
||||||
|
|
|
@ -59,12 +59,14 @@
|
||||||
#include "ui_dialogflippingbyline.h"
|
#include "ui_dialogflippingbyline.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogFlippingByLine),
|
ui(new Ui::DialogFlippingByLine),
|
||||||
objects(),
|
objects(),
|
||||||
stage1(true),
|
stage1(true),
|
||||||
m_suffix()
|
m_suffix(),
|
||||||
|
flagName(false),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -75,9 +77,6 @@ DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, const quint32
|
||||||
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
|
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
|
FillComboBoxPoints(ui->comboBoxSecondLinePoint);
|
||||||
|
|
||||||
flagName = true;
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByLine::SuffixChanged);
|
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogFlippingByLine::SuffixChanged);
|
||||||
connect(ui->comboBoxFirstLinePoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstLinePoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogFlippingByLine::PointChanged);
|
this, &DialogFlippingByLine::PointChanged);
|
||||||
|
@ -271,7 +270,7 @@ void DialogFlippingByLine::SuffixChanged()
|
||||||
if (suffix.isEmpty())
|
if (suffix.isEmpty())
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +286,7 @@ void DialogFlippingByLine::SuffixChanged()
|
||||||
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -296,20 +295,11 @@ void DialogFlippingByLine::SuffixChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
flagName = true;
|
flagName = true;
|
||||||
ChangeColor(ui->labelSuffix, okColor);
|
ChangeColor(ui->labelSuffix, OkColor(this));
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogFlippingByLine::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagError && flagName);
|
|
||||||
SCASSERT(bApply != nullptr)
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByLine::ShowVisualization()
|
void DialogFlippingByLine::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -333,7 +323,7 @@ void DialogFlippingByLine::SaveData()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogFlippingByLine::PointChanged()
|
void DialogFlippingByLine::PointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color = OkColor(this);
|
||||||
flagError = true;
|
flagError = true;
|
||||||
ChangeColor(ui->labelFirstLinePoint, color);
|
ChangeColor(ui->labelFirstLinePoint, color);
|
||||||
ChangeColor(ui->labelSecondLinePoint, color);
|
ChangeColor(ui->labelSecondLinePoint, color);
|
||||||
|
|
|
@ -51,7 +51,7 @@ class DialogFlippingByLine : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogFlippingByLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogFlippingByLine();
|
virtual ~DialogFlippingByLine();
|
||||||
|
|
||||||
quint32 GetFirstLinePointId() const;
|
quint32 GetFirstLinePointId() const;
|
||||||
|
@ -75,11 +75,11 @@ private slots:
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
|
||||||
/** @brief SaveData Put dialog data in local variables */
|
/** @brief SaveData Put dialog data in local variables */
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void PointChanged();
|
void PointChanged();
|
||||||
|
@ -94,6 +94,15 @@ private:
|
||||||
bool stage1;
|
bool stage1;
|
||||||
|
|
||||||
QString m_suffix;
|
QString m_suffix;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogFlippingByLine::IsValid() const
|
||||||
|
{
|
||||||
|
return flagError && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGFLIPPINGBYLINE_H
|
#endif // DIALOGFLIPPINGBYLINE_H
|
||||||
|
|
|
@ -33,14 +33,14 @@
|
||||||
#include "ui_dialoggroup.h"
|
#include "ui_dialoggroup.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogGroup::DialogGroup(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogGroup::DialogGroup(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogGroup),
|
ui(new Ui::DialogGroup),
|
||||||
group()
|
group(),
|
||||||
|
flagName(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogGroup::NameChanged);
|
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogGroup::NameChanged);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class DialogGroup : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogGroup(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogGroup(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
~DialogGroup();
|
~DialogGroup();
|
||||||
|
|
||||||
void SetName(const QString &name);
|
void SetName(const QString &name);
|
||||||
|
@ -61,6 +61,9 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void NameChanged();
|
void NameChanged();
|
||||||
|
|
||||||
|
@ -68,6 +71,13 @@ private:
|
||||||
Q_DISABLE_COPY(DialogGroup)
|
Q_DISABLE_COPY(DialogGroup)
|
||||||
Ui::DialogGroup *ui;
|
Ui::DialogGroup *ui;
|
||||||
QMap<quint32, quint32> group;
|
QMap<quint32, quint32> group;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogGroup::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGGROUP_H
|
#endif // DIALOGGROUP_H
|
||||||
|
|
|
@ -57,17 +57,19 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogHeight::DialogHeight(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogHeight),
|
||||||
|
pointName(),
|
||||||
|
flagError(true),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxBasePoint);
|
FillComboBoxPoints(ui->comboBoxBasePoint);
|
||||||
FillComboBoxPoints(ui->comboBoxP1Line);
|
FillComboBoxPoints(ui->comboBoxP1Line);
|
||||||
|
@ -75,7 +77,11 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
||||||
FillComboBoxLineColors(ui->comboBoxLineColor);
|
FillComboBoxLineColors(ui->comboBoxLineColor);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxBasePoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxBasePoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogHeight::PointNameChanged);
|
this, &DialogHeight::PointNameChanged);
|
||||||
connect(ui->comboBoxP1Line, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP1Line, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -92,6 +98,12 @@ DialogHeight::~DialogHeight()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogHeight::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief SetPointName set name of point
|
* @brief SetPointName set name of point
|
||||||
|
@ -260,7 +272,7 @@ void DialogHeight::PointNameChanged()
|
||||||
const QPointF p1Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p1LineId));
|
const QPointF p1Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p1LineId));
|
||||||
const QPointF p2Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p2LineId));
|
const QPointF p2Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p2LineId));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line, p2Line), basePoint) == QPointF())
|
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line, p2Line), basePoint) == QPointF())
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -269,7 +281,7 @@ void DialogHeight::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelBasePoint, color);
|
ChangeColor(ui->labelBasePoint, color);
|
||||||
ChangeColor(ui->labelFirstLinePoint, color);
|
ChangeColor(ui->labelFirstLinePoint, color);
|
||||||
|
|
|
@ -50,9 +50,10 @@ class DialogHeight : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogHeight(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogHeight() override;
|
virtual ~DialogHeight() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -78,11 +79,23 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogHeight)
|
Q_DISABLE_COPY(DialogHeight)
|
||||||
|
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogHeight *ui;
|
Ui::DialogHeight *ui;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagError;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogHeight::IsValid() const
|
||||||
|
{
|
||||||
|
return flagError && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGHEIGHT_H
|
#endif // DIALOGHEIGHT_H
|
||||||
|
|
|
@ -48,8 +48,10 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogLine::DialogLine(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogLine)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogLine),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -83,7 +85,7 @@ DialogLine::~DialogLine()
|
||||||
* @brief SetSecondPoint set id second point
|
* @brief SetSecondPoint set id second point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogLine::SetSecondPoint(const quint32 &value)
|
void DialogLine::SetSecondPoint(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||||
|
|
||||||
|
@ -120,7 +122,7 @@ void DialogLine::SetLineColor(const QString &value)
|
||||||
* @brief SetFirstPoint set id first point
|
* @brief SetFirstPoint set id first point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogLine::SetFirstPoint(const quint32 &value)
|
void DialogLine::SetFirstPoint(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||||
|
|
||||||
|
@ -132,7 +134,7 @@ void DialogLine::SetFirstPoint(const quint32 &value)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLine::PointNameChanged()
|
void DialogLine::PointNameChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -141,7 +143,7 @@ void DialogLine::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
ChangeColor(ui->labelSecondPoint, color);
|
ChangeColor(ui->labelSecondPoint, color);
|
||||||
|
|
|
@ -50,14 +50,14 @@ class DialogLine : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogLine() override;
|
virtual ~DialogLine() override;
|
||||||
|
|
||||||
quint32 GetFirstPoint() const;
|
quint32 GetFirstPoint() const;
|
||||||
void SetFirstPoint(const quint32 &value);
|
void SetFirstPoint(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondPoint() const;
|
quint32 GetSecondPoint() const;
|
||||||
void SetSecondPoint(const quint32 &value);
|
void SetSecondPoint(quint32 value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
void SetTypeLine(const QString &value);
|
void SetTypeLine(const QString &value);
|
||||||
|
@ -73,11 +73,20 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogLine)
|
Q_DISABLE_COPY(DialogLine)
|
||||||
|
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogLine *ui;
|
Ui::DialogLine *ui;
|
||||||
|
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogLine::IsValid() const
|
||||||
|
{
|
||||||
|
return flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGLINE_H
|
#endif // DIALOGLINE_H
|
||||||
|
|
|
@ -56,8 +56,13 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogLineIntersect::DialogLineIntersect(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), flagPoint(true)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogLineIntersect),
|
||||||
|
pointName(),
|
||||||
|
flagError(true),
|
||||||
|
flagPoint(true),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -66,14 +71,17 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &
|
||||||
number = 0;
|
number = 0;
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxP1Line1);
|
FillComboBoxPoints(ui->comboBoxP1Line1);
|
||||||
FillComboBoxPoints(ui->comboBoxP2Line1);
|
FillComboBoxPoints(ui->comboBoxP2Line1);
|
||||||
FillComboBoxPoints(ui->comboBoxP1Line2);
|
FillComboBoxPoints(ui->comboBoxP1Line2);
|
||||||
FillComboBoxPoints(ui->comboBoxP2Line2);
|
FillComboBoxPoints(ui->comboBoxP2Line2);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxP1Line1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP1Line1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogLineIntersect::PointNameChanged);
|
this, &DialogLineIntersect::PointNameChanged);
|
||||||
connect(ui->comboBoxP2Line1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP2Line1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -229,7 +237,7 @@ void DialogLineIntersect::PointNameChanged()
|
||||||
QPointF fPoint;
|
QPointF fPoint;
|
||||||
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() < 3 || intersect == QLineF::NoIntersection)
|
if (set.size() < 3 || intersect == QLineF::NoIntersection)
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -238,7 +246,7 @@ void DialogLineIntersect::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelP1Line1, color);
|
ChangeColor(ui->labelP1Line1, color);
|
||||||
ChangeColor(ui->labelP2Line1, color);
|
ChangeColor(ui->labelP2Line1, color);
|
||||||
|
@ -253,16 +261,6 @@ void DialogLineIntersect::ShowVisualization()
|
||||||
AddVisualization<VisToolLineIntersect>();
|
AddVisualization<VisToolLineIntersect>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief CheckState check state of dialog. Enable or disable button ok.
|
|
||||||
*/
|
|
||||||
void DialogLineIntersect::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagName && flagPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief CheckIntersecion check intersection of points
|
* @brief CheckIntersecion check intersection of points
|
||||||
|
@ -294,13 +292,19 @@ bool DialogLineIntersect::CheckIntersecion()
|
||||||
* @brief SetP2Line2 set id second point of second line
|
* @brief SetP2Line2 set id second point of second line
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogLineIntersect::SetP2Line2(const quint32 &value)
|
void DialogLineIntersect::SetP2Line2(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxP2Line2, value);
|
setCurrentPointId(ui->comboBoxP2Line2, value);
|
||||||
|
|
||||||
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
|
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setLine2P2Id(value);
|
line->setLine2P2Id(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogLineIntersect::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -308,7 +312,7 @@ void DialogLineIntersect::SetP2Line2(const quint32 &value)
|
||||||
* @brief SetP1Line2 set id first point of second line
|
* @brief SetP1Line2 set id first point of second line
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogLineIntersect::SetP1Line2(const quint32 &value)
|
void DialogLineIntersect::SetP1Line2(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxP1Line2, value);
|
setCurrentPointId(ui->comboBoxP1Line2, value);
|
||||||
|
|
||||||
|
@ -322,7 +326,7 @@ void DialogLineIntersect::SetP1Line2(const quint32 &value)
|
||||||
* @brief SetP2Line1 set id second point of first line
|
* @brief SetP2Line1 set id second point of first line
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogLineIntersect::SetP2Line1(const quint32 &value)
|
void DialogLineIntersect::SetP2Line1(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxP2Line1, value);
|
setCurrentPointId(ui->comboBoxP2Line1, value);
|
||||||
|
|
||||||
|
@ -336,7 +340,7 @@ void DialogLineIntersect::SetP2Line1(const quint32 &value)
|
||||||
* @brief SetP1Line1 set id first point of first line
|
* @brief SetP1Line1 set id first point of first line
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogLineIntersect::SetP1Line1(const quint32 &value)
|
void DialogLineIntersect::SetP1Line1(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxP1Line1, value);
|
setCurrentPointId(ui->comboBoxP1Line1, value);
|
||||||
|
|
||||||
|
|
|
@ -50,21 +50,22 @@ class DialogLineIntersect : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogLineIntersect(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogLineIntersect() override;
|
virtual ~DialogLineIntersect() override;
|
||||||
|
|
||||||
quint32 GetP1Line1() const;
|
quint32 GetP1Line1() const;
|
||||||
void SetP1Line1(const quint32 &value);
|
void SetP1Line1(quint32 value);
|
||||||
|
|
||||||
quint32 GetP2Line1() const;
|
quint32 GetP2Line1() const;
|
||||||
void SetP2Line1(const quint32 &value);
|
void SetP2Line1(quint32 value);
|
||||||
|
|
||||||
quint32 GetP1Line2() const;
|
quint32 GetP1Line2() const;
|
||||||
void SetP1Line2(const quint32 &value);
|
void SetP1Line2(quint32 value);
|
||||||
|
|
||||||
quint32 GetP2Line2() const;
|
quint32 GetP2Line2() const;
|
||||||
void SetP2Line2(const quint32 &value);
|
void SetP2Line2(quint32 value);
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
@ -76,17 +77,29 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogLineIntersect)
|
Q_DISABLE_COPY(DialogLineIntersect)
|
||||||
|
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogLineIntersect *ui;
|
Ui::DialogLineIntersect *ui;
|
||||||
|
|
||||||
/** @brief flagPoint keep state of point */
|
QString pointName;
|
||||||
bool flagPoint;
|
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
|
/** @brief flagPoint keep state of point */
|
||||||
|
bool flagPoint;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
|
|
||||||
virtual void CheckState() final;
|
|
||||||
bool CheckIntersecion();
|
bool CheckIntersecion();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogLineIntersect::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName && flagError && flagPoint;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGLINEINTERSECT_H
|
#endif // DIALOGLINEINTERSECT_H
|
||||||
|
|
|
@ -59,26 +59,29 @@
|
||||||
#include "ui_dialoglineintersectaxis.h"
|
#include "ui_dialoglineintersectaxis.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogLineIntersectAxis),
|
ui(new Ui::DialogLineIntersectAxis),
|
||||||
formulaAngle(),
|
formulaAngle(),
|
||||||
formulaBaseHeightAngle(0),
|
formulaBaseHeightAngle(0),
|
||||||
m_firstRelease(false)
|
pointName(),
|
||||||
|
m_firstRelease(false),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagError(true),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
|
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxAxisPoint);
|
FillComboBoxPoints(ui->comboBoxAxisPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
|
FillComboBoxPoints(ui->comboBoxFirstLinePoint);
|
||||||
|
@ -87,8 +90,15 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
|
||||||
FillComboBoxLineColors(ui->comboBoxLineColor);
|
FillComboBoxLineColors(ui->comboBoxLineColor);
|
||||||
|
|
||||||
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::FXAngle);
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::FXAngle);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersectAxis::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogLineIntersectAxis::AngleTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::DeployAngleTextEdit);
|
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::DeployAngleTextEdit);
|
||||||
connect(timerFormula, &QTimer::timeout, this, &DialogLineIntersectAxis::EvalAngle);
|
connect(timerFormula, &QTimer::timeout, this, &DialogLineIntersectAxis::EvalAngle);
|
||||||
connect(ui->comboBoxFirstLinePoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstLinePoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -107,6 +117,12 @@ DialogLineIntersectAxis::~DialogLineIntersectAxis()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogLineIntersectAxis::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLineIntersectAxis::SetPointName(const QString &value)
|
void DialogLineIntersectAxis::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -159,7 +175,7 @@ quint32 DialogLineIntersectAxis::GetBasePointId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLineIntersectAxis::SetBasePointId(const quint32 &value)
|
void DialogLineIntersectAxis::SetBasePointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxAxisPoint, value);
|
setCurrentPointId(ui->comboBoxAxisPoint, value);
|
||||||
|
|
||||||
|
@ -175,7 +191,7 @@ quint32 DialogLineIntersectAxis::GetFirstPointId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLineIntersectAxis::SetFirstPointId(const quint32 &value)
|
void DialogLineIntersectAxis::SetFirstPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxFirstLinePoint, value);
|
setCurrentPointId(ui->comboBoxFirstLinePoint, value);
|
||||||
|
|
||||||
|
@ -191,7 +207,7 @@ quint32 DialogLineIntersectAxis::GetSecondPointId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLineIntersectAxis::SetSecondPointId(const quint32 &value)
|
void DialogLineIntersectAxis::SetSecondPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxSecondLinePoint, value);
|
setCurrentPointId(ui->comboBoxSecondLinePoint, value);
|
||||||
|
|
||||||
|
@ -311,19 +327,21 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLineIntersectAxis::EvalAngle()
|
void DialogLineIntersectAxis::EvalAngle()
|
||||||
{
|
{
|
||||||
Eval(ui->plainTextEditFormula->toPlainText(), flagError, ui->labelResultCalculation, degreeSymbol, false);
|
FormulaData formulaData;
|
||||||
}
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
Eval(formulaData, flagFormula);
|
||||||
void DialogLineIntersectAxis::AngleTextChanged()
|
|
||||||
{
|
|
||||||
ValFormulaChanged(flagError, ui->plainTextEditFormula, timerFormula, degreeSymbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLineIntersectAxis::DeployAngleTextEdit()
|
void DialogLineIntersectAxis::DeployAngleTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -334,7 +352,7 @@ void DialogLineIntersectAxis::PointNameChanged()
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint));
|
set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint));
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxAxisPoint));
|
set.insert(getCurrentObjectId(ui->comboBoxAxisPoint));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() != 3)
|
if (set.size() != 3)
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -343,7 +361,7 @@ void DialogLineIntersectAxis::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstLinePoint, color);
|
ChangeColor(ui->labelFirstLinePoint, color);
|
||||||
ChangeColor(ui->labelSecondLinePoint, color);
|
ChangeColor(ui->labelSecondLinePoint, color);
|
||||||
|
|
|
@ -48,9 +48,10 @@ class DialogLineIntersectAxis : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogLineIntersectAxis(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogLineIntersectAxis() override;
|
virtual ~DialogLineIntersectAxis() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -60,13 +61,13 @@ public:
|
||||||
void SetAngle(const QString &value);
|
void SetAngle(const QString &value);
|
||||||
|
|
||||||
quint32 GetBasePointId() const;
|
quint32 GetBasePointId() const;
|
||||||
void SetBasePointId(const quint32 &value);
|
void SetBasePointId(quint32 value);
|
||||||
|
|
||||||
quint32 GetFirstPointId() const;
|
quint32 GetFirstPointId() const;
|
||||||
void SetFirstPointId(const quint32 &value);
|
void SetFirstPointId(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondPointId() const;
|
quint32 GetSecondPointId() const;
|
||||||
void SetSecondPointId(const quint32 &value);
|
void SetSecondPointId(quint32 value);
|
||||||
|
|
||||||
QString GetLineColor() const;
|
QString GetLineColor() const;
|
||||||
void SetLineColor(const QString &value);
|
void SetLineColor(const QString &value);
|
||||||
|
@ -75,7 +76,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
void AngleTextChanged();
|
|
||||||
void DeployAngleTextEdit();
|
void DeployAngleTextEdit();
|
||||||
virtual void PointNameChanged() override;
|
virtual void PointNameChanged() override;
|
||||||
void FXAngle();
|
void FXAngle();
|
||||||
|
@ -86,6 +86,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogLineIntersectAxis)
|
Q_DISABLE_COPY(DialogLineIntersectAxis)
|
||||||
Ui::DialogLineIntersectAxis *ui;
|
Ui::DialogLineIntersectAxis *ui;
|
||||||
|
@ -93,7 +94,21 @@ private:
|
||||||
QString formulaAngle;
|
QString formulaAngle;
|
||||||
int formulaBaseHeightAngle;
|
int formulaBaseHeightAngle;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
bool m_firstRelease;
|
bool m_firstRelease;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagError;
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogLineIntersectAxis::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGLINEINTERSECTAXIS_H
|
#endif // DIALOGLINEINTERSECTAXIS_H
|
||||||
|
|
|
@ -67,12 +67,9 @@
|
||||||
DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogMove),
|
ui(new Ui::DialogMove),
|
||||||
flagAngle(false),
|
timerAngle(new QTimer(this)),
|
||||||
flagRotationAngle(false),
|
timerRotationAngle(new QTimer(this)),
|
||||||
flagLength(false),
|
timerLength(new QTimer(this)),
|
||||||
timerAngle(nullptr),
|
|
||||||
timerRotationAngle(nullptr),
|
|
||||||
timerLength(nullptr),
|
|
||||||
formulaAngle(),
|
formulaAngle(),
|
||||||
formulaRotationAngle(),
|
formulaRotationAngle(),
|
||||||
formulaLength(),
|
formulaLength(),
|
||||||
|
@ -83,7 +80,11 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
stage1(true),
|
stage1(true),
|
||||||
stage2(false),
|
stage2(false),
|
||||||
m_suffix(),
|
m_suffix(),
|
||||||
optionalRotationOrigin(false)
|
optionalRotationOrigin(false),
|
||||||
|
flagAngle(false),
|
||||||
|
flagRotationAngle(false),
|
||||||
|
flagLength(false),
|
||||||
|
flagName(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -98,13 +99,13 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
|
|
||||||
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
|
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
|
||||||
|
|
||||||
timerAngle = new QTimer(this);
|
timerAngle->setSingleShot(true);
|
||||||
connect(timerAngle, &QTimer::timeout, this, &DialogMove::EvalAngle);
|
connect(timerAngle, &QTimer::timeout, this, &DialogMove::EvalAngle);
|
||||||
|
|
||||||
timerRotationAngle = new QTimer(this);
|
timerRotationAngle->setSingleShot(true);
|
||||||
connect(timerRotationAngle, &QTimer::timeout, this, &DialogMove::EvalRotationAngle);
|
connect(timerRotationAngle, &QTimer::timeout, this, &DialogMove::EvalRotationAngle);
|
||||||
|
|
||||||
timerLength = new QTimer(this);
|
timerLength->setSingleShot(true);
|
||||||
connect(timerLength, &QTimer::timeout, this, &DialogMove::EvalLength);
|
connect(timerLength, &QTimer::timeout, this, &DialogMove::EvalLength);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -115,16 +116,25 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
ui->comboBoxRotationOriginPoint->addItem(tr("Center point"), NULL_ID);
|
ui->comboBoxRotationOriginPoint->addItem(tr("Center point"), NULL_ID);
|
||||||
ui->comboBoxRotationOriginPoint->blockSignals(false);
|
ui->comboBoxRotationOriginPoint->blockSignals(false);
|
||||||
|
|
||||||
flagName = true;
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogMove::SuffixChanged);
|
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogMove::SuffixChanged);
|
||||||
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogMove::FXAngle);
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogMove::FXAngle);
|
||||||
connect(ui->toolButtonExprRotationAngle, &QPushButton::clicked, this, &DialogMove::FXRotationAngle);
|
connect(ui->toolButtonExprRotationAngle, &QPushButton::clicked, this, &DialogMove::FXRotationAngle);
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogMove::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogMove::FXLength);
|
||||||
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, &DialogMove::AngleChanged);
|
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditRotationAngle, &QPlainTextEdit::textChanged, this, &DialogMove::RotationAngleChanged);
|
{
|
||||||
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, &DialogMove::LengthChanged);
|
timerAngle->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditRotationAngle, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerRotationAngle->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerLength->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogMove::DeployAngleTextEdit);
|
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogMove::DeployAngleTextEdit);
|
||||||
connect(ui->pushButtonGrowRotationAngle, &QPushButton::clicked, this, &DialogMove::DeployRotationAngleTextEdit);
|
connect(ui->pushButtonGrowRotationAngle, &QPushButton::clicked, this, &DialogMove::DeployRotationAngleTextEdit);
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
|
||||||
|
@ -373,43 +383,19 @@ void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::DeployAngleTextEdit()
|
void DialogMove::DeployAngleTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditAngle, ui->pushButtonGrowAngle, formulaBaseHeightAngle);
|
DeployFormula(this, ui->plainTextEditAngle, ui->pushButtonGrowAngle, formulaBaseHeightAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::DeployRotationAngleTextEdit()
|
void DialogMove::DeployRotationAngleTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditRotationAngle, ui->pushButtonGrowRotationAngle, formulaBaseHeightRotationAngle);
|
DeployFormula(this, ui->plainTextEditRotationAngle, ui->pushButtonGrowRotationAngle, formulaBaseHeightRotationAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::DeployLengthTextEdit()
|
void DialogMove::DeployLengthTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditLength, ui->pushButtonGrowLength, formulaBaseHeightLength);
|
DeployFormula(this, ui->plainTextEditLength, ui->pushButtonGrowLength, formulaBaseHeightLength);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogMove::AngleChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditAngle;
|
|
||||||
labelResultCalculation = ui->labelResultAngle;
|
|
||||||
ValFormulaChanged(flagAngle, ui->plainTextEditAngle, timerAngle, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogMove::RotationAngleChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditRotationAngle;
|
|
||||||
labelResultCalculation = ui->labelResultRotationAngle;
|
|
||||||
ValFormulaChanged(flagRotationAngle, ui->plainTextEditRotationAngle, timerRotationAngle, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogMove::LengthChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditLength;
|
|
||||||
labelResultCalculation = ui->labelResultLength;
|
|
||||||
ValFormulaChanged(flagLength, ui->plainTextEditLength, timerLength, degreeSymbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -464,7 +450,7 @@ void DialogMove::SuffixChanged()
|
||||||
if (suffix.isEmpty())
|
if (suffix.isEmpty())
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +466,7 @@ void DialogMove::SuffixChanged()
|
||||||
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -489,20 +475,11 @@ void DialogMove::SuffixChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
flagName = true;
|
flagName = true;
|
||||||
ChangeColor(ui->labelSuffix, okColor);
|
ChangeColor(ui->labelSuffix, OkColor(this));
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogMove::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagAngle && flagRotationAngle && flagLength && flagName);
|
|
||||||
SCASSERT(bApply != nullptr)
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::ShowVisualization()
|
void DialogMove::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -540,22 +517,40 @@ void DialogMove::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::EvalAngle()
|
void DialogMove::EvalAngle()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditAngle;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditAngle->toPlainText(), flagAngle, ui->labelResultAngle, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditAngle->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAngle;
|
||||||
|
formulaData.labelResult = ui->labelResultAngle;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::EvalRotationAngle()
|
void DialogMove::EvalRotationAngle()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditRotationAngle;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditRotationAngle->toPlainText(), flagRotationAngle, ui->labelResultRotationAngle, degreeSymbol,
|
formulaData.formula = ui->plainTextEditRotationAngle->toPlainText();
|
||||||
false);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditRotationAngle;
|
||||||
|
formulaData.labelResult = ui->labelResultRotationAngle;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagRotationAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMove::EvalLength()
|
void DialogMove::EvalLength()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditLength;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditLength->toPlainText();
|
||||||
Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditLength;
|
||||||
|
formulaData.labelResult = ui->labelResultLength;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
Eval(formulaData, flagLength);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,6 @@ private slots:
|
||||||
void DeployRotationAngleTextEdit();
|
void DeployRotationAngleTextEdit();
|
||||||
void DeployLengthTextEdit();
|
void DeployLengthTextEdit();
|
||||||
|
|
||||||
void AngleChanged();
|
|
||||||
void RotationAngleChanged();
|
|
||||||
void LengthChanged();
|
|
||||||
|
|
||||||
void FXAngle();
|
void FXAngle();
|
||||||
void FXRotationAngle();
|
void FXRotationAngle();
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
@ -93,22 +89,17 @@ private slots:
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
|
||||||
/** @brief SaveData Put dialog data in local variables */
|
/** @brief SaveData Put dialog data in local variables */
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogMove)
|
Q_DISABLE_COPY(DialogMove)
|
||||||
Ui::DialogMove *ui;
|
Ui::DialogMove *ui;
|
||||||
|
|
||||||
/** @brief flagAngle true if value of angle is correct */
|
|
||||||
bool flagAngle;
|
|
||||||
bool flagRotationAngle;
|
|
||||||
bool flagLength;
|
|
||||||
|
|
||||||
/** @brief timerAngle timer of check formula of angle */
|
/** @brief timerAngle timer of check formula of angle */
|
||||||
QTimer *timerAngle;
|
QTimer *timerAngle;
|
||||||
QTimer *timerRotationAngle;
|
QTimer *timerRotationAngle;
|
||||||
|
@ -133,9 +124,21 @@ private:
|
||||||
|
|
||||||
bool optionalRotationOrigin;
|
bool optionalRotationOrigin;
|
||||||
|
|
||||||
|
/** @brief flagAngle true if value of angle is correct */
|
||||||
|
bool flagAngle;
|
||||||
|
bool flagRotationAngle;
|
||||||
|
bool flagLength;
|
||||||
|
bool flagName;
|
||||||
|
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
void EvalRotationAngle();
|
void EvalRotationAngle();
|
||||||
void EvalLength();
|
void EvalLength();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogMove::IsValid() const
|
||||||
|
{
|
||||||
|
return flagAngle && flagRotationAngle && flagLength && flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGMOVING_H
|
#endif // DIALOGMOVING_H
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
@ -56,33 +57,56 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogNormal::DialogNormal(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), formula(QString()), angle(0), formulaBaseHeight(0)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogNormal),
|
||||||
|
formula(),
|
||||||
|
angle(0),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
pointName(),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagName(true),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogNormal::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
||||||
FillComboBoxLineColors(ui->comboBoxLineColor);
|
FillComboBoxLineColors(ui->comboBoxLineColor);
|
||||||
|
|
||||||
InitArrow(ui);
|
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, [this](){ui->doubleSpinBoxAngle->setValue(270);});
|
||||||
|
connect(ui->toolButtonArrowUp, &QPushButton::clicked, this, [this](){ui->doubleSpinBoxAngle->setValue(90);});
|
||||||
|
connect(ui->toolButtonArrowLeft, &QPushButton::clicked, this, [this](){ui->doubleSpinBoxAngle->setValue(180);});
|
||||||
|
connect(ui->toolButtonArrowRight, &QPushButton::clicked, this, [this](){ui->doubleSpinBoxAngle->setValue(0);});
|
||||||
|
connect(ui->toolButtonArrowLeftUp, &QPushButton::clicked, this, [this](){ui->doubleSpinBoxAngle->setValue(135);});
|
||||||
|
connect(ui->toolButtonArrowLeftDown, &QPushButton::clicked, this, [this](){ui->doubleSpinBoxAngle->setValue(225);});
|
||||||
|
connect(ui->toolButtonArrowRightUp, &QPushButton::clicked, this, [this](){ui->doubleSpinBoxAngle->setValue(45);});
|
||||||
|
connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this,
|
||||||
|
[this](){ui->doubleSpinBoxAngle->setValue(315);});
|
||||||
|
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogNormal::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogNormal::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogNormal::FormulaTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit);
|
||||||
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogNormal::PointNameChanged);
|
this, &DialogNormal::PointNameChanged);
|
||||||
|
@ -92,16 +116,10 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
vis = new VisToolNormal(data);
|
vis = new VisToolNormal(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogNormal::FormulaTextChanged()
|
|
||||||
{
|
|
||||||
this->FormulaChangedPlainText();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogNormal::PointNameChanged()
|
void DialogNormal::PointNameChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -110,7 +128,7 @@ void DialogNormal::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
ChangeColor(ui->labelSecondPoint, color);
|
ChangeColor(ui->labelSecondPoint, color);
|
||||||
|
@ -131,6 +149,19 @@ void DialogNormal::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogNormal::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogNormal::ShowVisualization()
|
void DialogNormal::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -140,7 +171,7 @@ void DialogNormal::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogNormal::DeployFormulaTextEdit()
|
void DialogNormal::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -149,6 +180,12 @@ DialogNormal::~DialogNormal()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogNormal::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||||
|
@ -223,7 +260,7 @@ void DialogNormal::closeEvent(QCloseEvent *event)
|
||||||
* @brief SetSecondPointId set id of second point
|
* @brief SetSecondPointId set id of second point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogNormal::SetSecondPointId(const quint32 &value)
|
void DialogNormal::SetSecondPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||||
|
|
||||||
|
@ -249,7 +286,7 @@ void DialogNormal::SetLineColor(const QString &value)
|
||||||
* @brief SetFirstPointId set id of first point
|
* @brief SetFirstPointId set id of first point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogNormal::SetFirstPointId(const quint32 &value)
|
void DialogNormal::SetFirstPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||||
|
|
||||||
|
@ -263,7 +300,7 @@ void DialogNormal::SetFirstPointId(const quint32 &value)
|
||||||
* @brief SetAngle set aditional angle of normal
|
* @brief SetAngle set aditional angle of normal
|
||||||
* @param value angle in degree
|
* @param value angle in degree
|
||||||
*/
|
*/
|
||||||
void DialogNormal::SetAngle(const qreal &value)
|
void DialogNormal::SetAngle(qreal value)
|
||||||
{
|
{
|
||||||
angle = value;
|
angle = value;
|
||||||
ui->doubleSpinBoxAngle->setValue(angle);
|
ui->doubleSpinBoxAngle->setValue(angle);
|
||||||
|
|
|
@ -50,9 +50,10 @@ class DialogNormal : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogNormal(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogNormal() override;
|
virtual ~DialogNormal() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -62,13 +63,13 @@ public:
|
||||||
void SetFormula(const QString &value);
|
void SetFormula(const QString &value);
|
||||||
|
|
||||||
qreal GetAngle() const;
|
qreal GetAngle() const;
|
||||||
void SetAngle(const qreal &value);
|
void SetAngle(qreal value);
|
||||||
|
|
||||||
quint32 GetFirstPointId() const;
|
quint32 GetFirstPointId() const;
|
||||||
void SetFirstPointId(const quint32 &value);
|
void SetFirstPointId(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondPointId() const;
|
quint32 GetSecondPointId() const;
|
||||||
void SetSecondPointId(const quint32 &value);
|
void SetSecondPointId(quint32 value);
|
||||||
|
|
||||||
QString GetLineColor() const;
|
QString GetLineColor() const;
|
||||||
void SetLineColor(const QString &value);
|
void SetLineColor(const QString &value);
|
||||||
|
@ -78,12 +79,9 @@ public slots:
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
/**
|
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
|
||||||
*/
|
|
||||||
void FormulaTextChanged();
|
|
||||||
virtual void PointNameChanged() override;
|
virtual void PointNameChanged() override;
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -91,6 +89,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogNormal)
|
Q_DISABLE_COPY(DialogNormal)
|
||||||
|
|
||||||
|
@ -98,13 +97,27 @@ private:
|
||||||
Ui::DialogNormal *ui;
|
Ui::DialogNormal *ui;
|
||||||
|
|
||||||
/** @brief formula formula */
|
/** @brief formula formula */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
|
||||||
/** @brief angle aditional angle of normal */
|
/** @brief angle aditional angle of normal */
|
||||||
qreal angle;
|
qreal angle;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogNormal::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGNORMAL_H
|
#endif // DIALOGNORMAL_H
|
||||||
|
|
|
@ -39,25 +39,29 @@
|
||||||
#include "ui_dialogpointfromarcandtangent.h"
|
#include "ui_dialogpointfromarcandtangent.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId,
|
DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
QWidget *parent)
|
: DialogTool(data, toolId, parent),
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointFromArcAndTangent)
|
ui(new Ui::DialogPointFromArcAndTangent),
|
||||||
|
pointName(),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxTangentPoint);
|
FillComboBoxPoints(ui->comboBoxTangentPoint);
|
||||||
FillComboBoxArcs(ui->comboBoxArc);
|
FillComboBoxArcs(ui->comboBoxArc);
|
||||||
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointFromArcAndTangent::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
|
||||||
vis = new VisToolPointFromArcAndTangent(data);
|
vis = new VisToolPointFromArcAndTangent(data);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +72,12 @@ DialogPointFromArcAndTangent::~DialogPointFromArcAndTangent()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogPointFromArcAndTangent::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromArcAndTangent::SetPointName(const QString &value)
|
void DialogPointFromArcAndTangent::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +92,7 @@ quint32 DialogPointFromArcAndTangent::GetArcId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromArcAndTangent::SetArcId(const quint32 &value)
|
void DialogPointFromArcAndTangent::SetArcId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentArcId(ui->comboBoxArc, value);
|
setCurrentArcId(ui->comboBoxArc, value);
|
||||||
|
|
||||||
|
@ -98,7 +108,7 @@ quint32 DialogPointFromArcAndTangent::GetTangentPointId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromArcAndTangent::SetTangentPointId(const quint32 &value)
|
void DialogPointFromArcAndTangent::SetTangentPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxTangentPoint, value);
|
setCurrentPointId(ui->comboBoxTangentPoint, value);
|
||||||
|
|
||||||
|
@ -114,7 +124,7 @@ CrossCirclesPoint DialogPointFromArcAndTangent::GetCrossCirclesPoint() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromArcAndTangent::SetCrossCirclesPoint(const CrossCirclesPoint &p)
|
void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint p)
|
||||||
{
|
{
|
||||||
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
|
|
@ -49,20 +49,20 @@ class DialogPointFromArcAndTangent : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogPointFromArcAndTangent(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
~DialogPointFromArcAndTangent();
|
~DialogPointFromArcAndTangent();
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
quint32 GetArcId() const;
|
quint32 GetArcId() const;
|
||||||
void SetArcId(const quint32 &value);
|
void SetArcId(quint32 value);
|
||||||
|
|
||||||
quint32 GetTangentPointId() const;
|
quint32 GetTangentPointId() const;
|
||||||
void SetTangentPointId(const quint32 &value);
|
void SetTangentPointId(quint32 value);
|
||||||
|
|
||||||
CrossCirclesPoint GetCrossCirclesPoint() const;
|
CrossCirclesPoint GetCrossCirclesPoint() const;
|
||||||
void SetCrossCirclesPoint(const CrossCirclesPoint &p);
|
void SetCrossCirclesPoint(CrossCirclesPoint p);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
@ -73,11 +73,22 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPointFromArcAndTangent)
|
Q_DISABLE_COPY(DialogPointFromArcAndTangent)
|
||||||
|
|
||||||
Ui::DialogPointFromArcAndTangent *ui;
|
Ui::DialogPointFromArcAndTangent *ui;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPointFromArcAndTangent::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTFROMARCANDTANGENT_H
|
#endif // DIALOGPOINTFROMARCANDTANGENT_H
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../../visualization/line/vistoolpointfromcircleandtangent.h"
|
#include "../../visualization/line/vistoolpointfromcircleandtangent.h"
|
||||||
#include "../ifc/xml/vdomdocument.h"
|
#include "../ifc/xml/vdomdocument.h"
|
||||||
|
@ -51,19 +52,24 @@
|
||||||
#include "ui_dialogpointfromcircleandtangent.h"
|
#include "ui_dialogpointfromcircleandtangent.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContainer *data, const quint32 &toolId,
|
DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointFromCircleAndTangent), flagCircleRadius(false),
|
: DialogTool(data, toolId, parent),
|
||||||
timerCircleRadius(nullptr), circleRadius(), formulaBaseHeightCircleRadius(0)
|
ui(new Ui::DialogPointFromCircleAndTangent),
|
||||||
|
timerCircleRadius(nullptr),
|
||||||
|
circleRadius(),
|
||||||
|
formulaBaseHeightCircleRadius(0),
|
||||||
|
pointName(),
|
||||||
|
flagCircleRadius(false),
|
||||||
|
flagName(true),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
plainTextEditFormula = ui->plainTextEditRadius;
|
|
||||||
this->formulaBaseHeightCircleRadius = ui->plainTextEditRadius->height();
|
this->formulaBaseHeightCircleRadius = ui->plainTextEditRadius->height();
|
||||||
|
|
||||||
ui->plainTextEditRadius->installEventFilter(this);
|
ui->plainTextEditRadius->installEventFilter(this);
|
||||||
|
@ -72,21 +78,26 @@ DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContaine
|
||||||
connect(timerCircleRadius, &QTimer::timeout, this, &DialogPointFromCircleAndTangent::EvalCircleRadius);
|
connect(timerCircleRadius, &QTimer::timeout, this, &DialogPointFromCircleAndTangent::EvalCircleRadius);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxCircleCenter);
|
FillComboBoxPoints(ui->comboBoxCircleCenter);
|
||||||
FillComboBoxPoints(ui->comboBoxTangentPoint);
|
FillComboBoxPoints(ui->comboBoxTangentPoint);
|
||||||
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointFromCircleAndTangent::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxCircleCenter, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxCircleCenter, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogPointFromCircleAndTangent::PointChanged);
|
this, &DialogPointFromCircleAndTangent::PointChanged);
|
||||||
|
|
||||||
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this,
|
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this,
|
||||||
&DialogPointFromCircleAndTangent::FXCircleRadius);
|
&DialogPointFromCircleAndTangent::FXCircleRadius);
|
||||||
|
|
||||||
connect(ui->plainTextEditRadius, &QPlainTextEdit::textChanged, this,
|
connect(ui->plainTextEditRadius, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
&DialogPointFromCircleAndTangent::CircleRadiusChanged);
|
{
|
||||||
|
timerCircleRadius->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowRadius, &QPushButton::clicked, this,
|
connect(ui->pushButtonGrowRadius, &QPushButton::clicked, this,
|
||||||
&DialogPointFromCircleAndTangent::DeployCircleRadiusTextEdit);
|
&DialogPointFromCircleAndTangent::DeployCircleRadiusTextEdit);
|
||||||
|
@ -100,6 +111,12 @@ DialogPointFromCircleAndTangent::~DialogPointFromCircleAndTangent()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogPointFromCircleAndTangent::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::SetPointName(const QString &value)
|
void DialogPointFromCircleAndTangent::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +244,7 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::PointChanged()
|
void DialogPointFromCircleAndTangent::PointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxCircleCenter) == getCurrentObjectId(ui->comboBoxTangentPoint))
|
if (getCurrentObjectId(ui->comboBoxCircleCenter) == getCurrentObjectId(ui->comboBoxTangentPoint))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -236,7 +253,7 @@ void DialogPointFromCircleAndTangent::PointChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelCircleCenter, color);
|
ChangeColor(ui->labelCircleCenter, color);
|
||||||
ChangeColor(ui->labelTangentPoint, color);
|
ChangeColor(ui->labelTangentPoint, color);
|
||||||
|
@ -246,16 +263,7 @@ void DialogPointFromCircleAndTangent::PointChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::DeployCircleRadiusTextEdit()
|
void DialogPointFromCircleAndTangent::DeployCircleRadiusTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditRadius, ui->pushButtonGrowRadius, formulaBaseHeightCircleRadius);
|
DeployFormula(this, ui->plainTextEditRadius, ui->pushButtonGrowRadius, formulaBaseHeightCircleRadius);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPointFromCircleAndTangent::CircleRadiusChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditRadius;
|
|
||||||
labelResultCalculation = ui->labelResultCircleRadius;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagCircleRadius, ui->plainTextEditRadius, timerCircleRadius, postfix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -275,15 +283,19 @@ void DialogPointFromCircleAndTangent::FXCircleRadius()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::EvalCircleRadius()
|
void DialogPointFromCircleAndTangent::EvalCircleRadius()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditRadius;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditRadius->toPlainText();
|
||||||
const qreal radius = Eval(ui->plainTextEditRadius->toPlainText(), flagCircleRadius,
|
formulaData.variables = data->DataVariables();
|
||||||
ui->labelResultCircleRadius, postfix);
|
formulaData.labelEditFormula = ui->labelEditRadius;
|
||||||
|
formulaData.labelResult = ui->labelResultCircleRadius;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
const qreal radius = Eval(formulaData, flagCircleRadius);
|
||||||
|
|
||||||
if (radius < 0)
|
if (radius < 0)
|
||||||
{
|
{
|
||||||
flagCircleRadius = false;
|
flagCircleRadius = false;
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
ChangeColor(ui->labelEditRadius, errorColor);
|
||||||
ui->labelResultCircleRadius->setText(tr("Error"));
|
ui->labelResultCircleRadius->setText(tr("Error"));
|
||||||
ui->labelResultCircleRadius->setToolTip(tr("Radius can't be negative"));
|
ui->labelResultCircleRadius->setToolTip(tr("Radius can't be negative"));
|
||||||
|
|
||||||
|
@ -318,15 +330,3 @@ void DialogPointFromCircleAndTangent::closeEvent(QCloseEvent *event)
|
||||||
ui->plainTextEditRadius->blockSignals(true);
|
ui->plainTextEditRadius->blockSignals(true);
|
||||||
DialogTool::closeEvent(event);
|
DialogTool::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPointFromCircleAndTangent::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagFormula && flagName && flagError && flagCircleRadius);
|
|
||||||
// In case dialog hasn't apply button
|
|
||||||
if ( bApply != nullptr)
|
|
||||||
{
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -49,9 +49,10 @@ class DialogPointFromCircleAndTangent : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogPointFromCircleAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
~DialogPointFromCircleAndTangent();
|
~DialogPointFromCircleAndTangent();
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
quint32 GetCircleCenterId() const;
|
quint32 GetCircleCenterId() const;
|
||||||
|
@ -71,7 +72,6 @@ public slots:
|
||||||
void PointChanged();
|
void PointChanged();
|
||||||
|
|
||||||
void DeployCircleRadiusTextEdit();
|
void DeployCircleRadiusTextEdit();
|
||||||
void CircleRadiusChanged();
|
|
||||||
void FXCircleRadius();
|
void FXCircleRadius();
|
||||||
void EvalCircleRadius();
|
void EvalCircleRadius();
|
||||||
|
|
||||||
|
@ -82,17 +82,26 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual void CheckState() final;
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPointFromCircleAndTangent)
|
Q_DISABLE_COPY(DialogPointFromCircleAndTangent)
|
||||||
|
|
||||||
Ui::DialogPointFromCircleAndTangent *ui;
|
Ui::DialogPointFromCircleAndTangent *ui;
|
||||||
|
|
||||||
bool flagCircleRadius;
|
QTimer* timerCircleRadius;
|
||||||
QTimer *timerCircleRadius;
|
QString circleRadius;
|
||||||
QString circleRadius;
|
int formulaBaseHeightCircleRadius;
|
||||||
int formulaBaseHeightCircleRadius;
|
QString pointName;
|
||||||
|
bool flagCircleRadius;
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPointFromCircleAndTangent::IsValid() const
|
||||||
|
{
|
||||||
|
return flagCircleRadius && flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTFROMCIRCLEANDTANGENT_H
|
#endif // DIALOGPOINTFROMCIRCLEANDTANGENT_H
|
||||||
|
|
|
@ -37,9 +37,11 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../../visualization/line/vistoolpointofcontact.h"
|
#include "../../visualization/line/vistoolpointofcontact.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
|
@ -55,30 +57,44 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogPointOfContact::DialogPointOfContact(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), radius(QString()), formulaBaseHeight(0)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogPointOfContact),
|
||||||
|
radius(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
pointName(),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
flagFormula(false),
|
||||||
|
flagName(true),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogPointOfContact::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxCenter);
|
FillComboBoxPoints(ui->comboBoxCenter);
|
||||||
|
|
||||||
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogPointOfContact::FXRadius);
|
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogPointOfContact::FXRadius);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogPointOfContact::FormulaTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogPointOfContact::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogPointOfContact::DeployFormulaTextEdit);
|
||||||
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogPointOfContact::PointNameChanged);
|
this, &DialogPointOfContact::PointNameChanged);
|
||||||
|
@ -97,9 +113,9 @@ DialogPointOfContact::~DialogPointOfContact()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfContact::FormulaTextChanged()
|
QString DialogPointOfContact::GetPointName() const
|
||||||
{
|
{
|
||||||
this->FormulaChangedPlainText();
|
return pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -110,7 +126,7 @@ void DialogPointOfContact::PointNameChanged()
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
|
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxCenter));
|
set.insert(getCurrentObjectId(ui->comboBoxCenter));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() != 3)
|
if (set.size() != 3)
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -119,7 +135,7 @@ void DialogPointOfContact::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
ChangeColor(ui->labelSecondPoint, color);
|
ChangeColor(ui->labelSecondPoint, color);
|
||||||
|
@ -141,6 +157,19 @@ void DialogPointOfContact::FXRadius()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogPointOfContact::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfContact::ShowVisualization()
|
void DialogPointOfContact::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -150,7 +179,7 @@ void DialogPointOfContact::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfContact::DeployFormulaTextEdit()
|
void DialogPointOfContact::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -243,7 +272,7 @@ void DialogPointOfContact::closeEvent(QCloseEvent *event)
|
||||||
* @brief SetSecondPoint set id second point
|
* @brief SetSecondPoint set id second point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogPointOfContact::SetSecondPoint(const quint32 &value)
|
void DialogPointOfContact::SetSecondPoint(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||||
|
|
||||||
|
@ -257,7 +286,7 @@ void DialogPointOfContact::SetSecondPoint(const quint32 &value)
|
||||||
* @brief SetFirstPoint set id first point
|
* @brief SetFirstPoint set id first point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogPointOfContact::SetFirstPoint(const quint32 &value)
|
void DialogPointOfContact::SetFirstPoint(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||||
|
|
||||||
|
@ -271,7 +300,7 @@ void DialogPointOfContact::SetFirstPoint(const quint32 &value)
|
||||||
* @brief SetCenter set id of center point
|
* @brief SetCenter set id of center point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogPointOfContact::setCenter(const quint32 &value)
|
void DialogPointOfContact::setCenter(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxCenter, value);
|
setCurrentPointId(ui->comboBoxCenter, value);
|
||||||
|
|
||||||
|
|
|
@ -51,34 +51,32 @@ class DialogPointOfContact : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogPointOfContact(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogPointOfContact() override;
|
virtual ~DialogPointOfContact() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString getRadius() const;
|
QString getRadius() const;
|
||||||
void setRadius(const QString &value);
|
void setRadius(const QString &value);
|
||||||
|
|
||||||
quint32 getCenter() const;
|
quint32 getCenter() const;
|
||||||
void setCenter(const quint32 &value);
|
void setCenter(quint32 value);
|
||||||
|
|
||||||
quint32 GetFirstPoint() const;
|
quint32 GetFirstPoint() const;
|
||||||
void SetFirstPoint(const quint32 &value);
|
void SetFirstPoint(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondPoint() const;
|
quint32 GetSecondPoint() const;
|
||||||
void SetSecondPoint(const quint32 &value);
|
void SetSecondPoint(quint32 value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
/**
|
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
|
||||||
*/
|
|
||||||
void FormulaTextChanged();
|
|
||||||
virtual void PointNameChanged() override;
|
virtual void PointNameChanged() override;
|
||||||
void FXRadius();
|
void FXRadius();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -86,6 +84,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPointOfContact)
|
Q_DISABLE_COPY(DialogPointOfContact)
|
||||||
|
|
||||||
|
@ -93,10 +92,24 @@ private:
|
||||||
Ui::DialogPointOfContact *ui;
|
Ui::DialogPointOfContact *ui;
|
||||||
|
|
||||||
/** @brief radius radius of arc */
|
/** @brief radius radius of arc */
|
||||||
QString radius;
|
QString radius;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPointOfContact::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTOFCONTACT_H
|
#endif // DIALOGPOINTOFCONTACT_H
|
||||||
|
|
|
@ -48,23 +48,29 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogPointOfIntersection),
|
||||||
|
pointName(),
|
||||||
|
flagName(true),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogPointOfIntersection::PointNameChanged);
|
this, &DialogPointOfIntersection::PointNameChanged);
|
||||||
connect(ui->comboBoxSecondPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxSecondPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -80,12 +86,18 @@ DialogPointOfIntersection::~DialogPointOfIntersection()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogPointOfIntersection::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief SetSecondPointId set id of second point
|
* @brief SetSecondPointId set id of second point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogPointOfIntersection::SetSecondPointId(const quint32 &value)
|
void DialogPointOfIntersection::SetSecondPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||||
|
|
||||||
|
@ -154,7 +166,7 @@ void DialogPointOfIntersection::SaveData()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersection::PointNameChanged()
|
void DialogPointOfIntersection::PointNameChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -163,7 +175,7 @@ void DialogPointOfIntersection::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
ChangeColor(ui->labelSecondPoint, color);
|
ChangeColor(ui->labelSecondPoint, color);
|
||||||
|
@ -181,7 +193,7 @@ void DialogPointOfIntersection::ShowVisualization()
|
||||||
* @brief SetFirstPointId set id of first point
|
* @brief SetFirstPointId set id of first point
|
||||||
* @param value id
|
* @param value id
|
||||||
*/
|
*/
|
||||||
void DialogPointOfIntersection::SetFirstPointId(const quint32 &value)
|
void DialogPointOfIntersection::SetFirstPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||||
|
|
||||||
|
|
|
@ -50,16 +50,17 @@ class DialogPointOfIntersection : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogPointOfIntersection(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogPointOfIntersection() override;
|
virtual ~DialogPointOfIntersection() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
quint32 GetFirstPointId() const;
|
quint32 GetFirstPointId() const;
|
||||||
void SetFirstPointId(const quint32 &value);
|
void SetFirstPointId(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondPointId() const;
|
quint32 GetSecondPointId() const;
|
||||||
void SetSecondPointId(const quint32 &value);
|
void SetSecondPointId(quint32 value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
virtual void PointNameChanged() override;
|
virtual void PointNameChanged() override;
|
||||||
|
@ -69,11 +70,23 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPointOfIntersection)
|
Q_DISABLE_COPY(DialogPointOfIntersection)
|
||||||
|
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogPointOfIntersection *ui;
|
Ui::DialogPointOfIntersection *ui;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPointOfIntersection::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTOFINTERSECTION_H
|
#endif // DIALOGPOINTOFINTERSECTION_H
|
||||||
|
|
|
@ -41,25 +41,30 @@
|
||||||
#include "ui_dialogpointofintersectionarcs.h"
|
#include "ui_dialogpointofintersectionarcs.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId,
|
DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
QWidget *parent)
|
: DialogTool(data, toolId, parent),
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersectionArcs)
|
ui(new Ui::DialogPointOfIntersectionArcs),
|
||||||
|
pointName(),
|
||||||
|
flagName(true),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxArcs(ui->comboBoxArc1);
|
FillComboBoxArcs(ui->comboBoxArc1);
|
||||||
FillComboBoxArcs(ui->comboBoxArc2);
|
FillComboBoxArcs(ui->comboBoxArc2);
|
||||||
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionArcs::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxArc1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxArc1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogPointOfIntersectionArcs::ArcChanged);
|
this, &DialogPointOfIntersectionArcs::ArcChanged);
|
||||||
connect(ui->comboBoxArc1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxArc1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -74,6 +79,12 @@ DialogPointOfIntersectionArcs::~DialogPointOfIntersectionArcs()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogPointOfIntersectionArcs::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionArcs::SetPointName(const QString &value)
|
void DialogPointOfIntersectionArcs::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +99,7 @@ quint32 DialogPointOfIntersectionArcs::GetFirstArcId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionArcs::SetFirstArcId(const quint32 &value)
|
void DialogPointOfIntersectionArcs::SetFirstArcId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentArcId(ui->comboBoxArc1, value);
|
setCurrentArcId(ui->comboBoxArc1, value);
|
||||||
|
|
||||||
|
@ -104,7 +115,7 @@ quint32 DialogPointOfIntersectionArcs::GetSecondArcId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
|
void DialogPointOfIntersectionArcs::SetSecondArcId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentArcId(ui->comboBoxArc2, value);
|
setCurrentArcId(ui->comboBoxArc2, value);
|
||||||
|
|
||||||
|
@ -120,7 +131,7 @@ CrossCirclesPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionArcs::SetCrossArcPoint(const CrossCirclesPoint &p)
|
void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossCirclesPoint p)
|
||||||
{
|
{
|
||||||
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
@ -175,7 +186,7 @@ void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionArcs::ArcChanged()
|
void DialogPointOfIntersectionArcs::ArcChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxArc1) == getCurrentObjectId(ui->comboBoxArc2))
|
if (getCurrentObjectId(ui->comboBoxArc1) == getCurrentObjectId(ui->comboBoxArc2))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -184,7 +195,7 @@ void DialogPointOfIntersectionArcs::ArcChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelArc1, color);
|
ChangeColor(ui->labelArc1, color);
|
||||||
ChangeColor(ui->labelArc2, color);
|
ChangeColor(ui->labelArc2, color);
|
||||||
|
|
|
@ -49,19 +49,20 @@ class DialogPointOfIntersectionArcs : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogPointOfIntersectionArcs(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogPointOfIntersectionArcs() override;
|
virtual ~DialogPointOfIntersectionArcs() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
quint32 GetFirstArcId() const;
|
quint32 GetFirstArcId() const;
|
||||||
void SetFirstArcId(const quint32 &value);
|
void SetFirstArcId(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondArcId() const;
|
quint32 GetSecondArcId() const;
|
||||||
void SetSecondArcId(const quint32 &value);
|
void SetSecondArcId(quint32 value);
|
||||||
|
|
||||||
CrossCirclesPoint GetCrossArcPoint() const;
|
CrossCirclesPoint GetCrossArcPoint() const;
|
||||||
void SetCrossArcPoint(const CrossCirclesPoint &p);
|
void SetCrossArcPoint(CrossCirclesPoint p);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
@ -73,11 +74,23 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPointOfIntersectionArcs)
|
Q_DISABLE_COPY(DialogPointOfIntersectionArcs)
|
||||||
|
|
||||||
Ui::DialogPointOfIntersectionArcs *ui;
|
Ui::DialogPointOfIntersectionArcs *ui;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPointOfIntersectionArcs::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTOFINTERSECTIONARCS_H
|
#endif // DIALOGPOINTOFINTERSECTIONARCS_H
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../../visualization/line/vistoolpointofintersectioncircles.h"
|
#include "../../visualization/line/vistoolpointofintersectioncircles.h"
|
||||||
#include "../ifc/xml/vdomdocument.h"
|
#include "../ifc/xml/vdomdocument.h"
|
||||||
|
@ -51,40 +52,51 @@
|
||||||
#include "ui_dialogpointofintersectioncircles.h"
|
#include "ui_dialogpointofintersectioncircles.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogPointOfIntersectionCircles::DialogPointOfIntersectionCircles(const VContainer *data, const quint32 &toolId,
|
DialogPointOfIntersectionCircles::DialogPointOfIntersectionCircles(const VContainer *data, quint32 toolId,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersectionCircles), flagCircle1Radius(false),
|
: DialogTool(data, toolId, parent),
|
||||||
flagCircle2Radius(false), timerCircle1Radius(nullptr), timerCircle2Radius(nullptr), circle1Radius(),
|
ui(new Ui::DialogPointOfIntersectionCircles),
|
||||||
circle2Radius(), formulaBaseHeightCircle1Radius(0), formulaBaseHeightCircle2Radius(0)
|
timerCircle1Radius(new QTimer(this)),
|
||||||
|
timerCircle2Radius(new QTimer(this)),
|
||||||
|
circle1Radius(),
|
||||||
|
circle2Radius(),
|
||||||
|
formulaBaseHeightCircle1Radius(0),
|
||||||
|
formulaBaseHeightCircle2Radius(0),
|
||||||
|
pointName(),
|
||||||
|
flagCircle1Radius(false),
|
||||||
|
flagCircle2Radius(false),
|
||||||
|
flagName(true),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
plainTextEditFormula = ui->plainTextEditCircle1Radius;
|
|
||||||
this->formulaBaseHeightCircle1Radius = ui->plainTextEditCircle1Radius->height();
|
this->formulaBaseHeightCircle1Radius = ui->plainTextEditCircle1Radius->height();
|
||||||
this->formulaBaseHeightCircle2Radius = ui->plainTextEditCircle2Radius->height();
|
this->formulaBaseHeightCircle2Radius = ui->plainTextEditCircle2Radius->height();
|
||||||
|
|
||||||
ui->plainTextEditCircle1Radius->installEventFilter(this);
|
ui->plainTextEditCircle1Radius->installEventFilter(this);
|
||||||
ui->plainTextEditCircle2Radius->installEventFilter(this);
|
ui->plainTextEditCircle2Radius->installEventFilter(this);
|
||||||
|
|
||||||
timerCircle1Radius = new QTimer(this);
|
timerCircle1Radius->setSingleShot(true);
|
||||||
connect(timerCircle1Radius, &QTimer::timeout, this, &DialogPointOfIntersectionCircles::EvalCircle1Radius);
|
connect(timerCircle1Radius, &QTimer::timeout, this, &DialogPointOfIntersectionCircles::EvalCircle1Radius);
|
||||||
|
|
||||||
timerCircle2Radius = new QTimer(this);
|
timerCircle2Radius->setSingleShot(true);
|
||||||
connect(timerCircle2Radius, &QTimer::timeout, this, &DialogPointOfIntersectionCircles::EvalCircle2Radius);
|
connect(timerCircle2Radius, &QTimer::timeout, this, &DialogPointOfIntersectionCircles::EvalCircle2Radius);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxCircle1Center);
|
FillComboBoxPoints(ui->comboBoxCircle1Center);
|
||||||
FillComboBoxPoints(ui->comboBoxCircle2Center);
|
FillComboBoxPoints(ui->comboBoxCircle2Center);
|
||||||
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionCircles::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxCircle1Center, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxCircle1Center, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogPointOfIntersectionCircles::PointChanged);
|
this, &DialogPointOfIntersectionCircles::PointChanged);
|
||||||
connect(ui->comboBoxCircle2Center, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxCircle2Center, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -95,10 +107,15 @@ DialogPointOfIntersectionCircles::DialogPointOfIntersectionCircles(const VContai
|
||||||
connect(ui->toolButtonExprCircle2Radius, &QPushButton::clicked, this,
|
connect(ui->toolButtonExprCircle2Radius, &QPushButton::clicked, this,
|
||||||
&DialogPointOfIntersectionCircles::FXCircle2Radius);
|
&DialogPointOfIntersectionCircles::FXCircle2Radius);
|
||||||
|
|
||||||
connect(ui->plainTextEditCircle1Radius, &QPlainTextEdit::textChanged, this,
|
connect(ui->plainTextEditCircle1Radius, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
&DialogPointOfIntersectionCircles::Circle1RadiusChanged);
|
{
|
||||||
connect(ui->plainTextEditCircle2Radius, &QPlainTextEdit::textChanged, this,
|
timerCircle1Radius->start(formulaTimerTimeout);
|
||||||
&DialogPointOfIntersectionCircles::Circle2RadiusChanged);
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditCircle2Radius, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerCircle2Radius->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowCircle1Radius, &QPushButton::clicked, this,
|
connect(ui->pushButtonGrowCircle1Radius, &QPushButton::clicked, this,
|
||||||
&DialogPointOfIntersectionCircles::DeployCircle1RadiusTextEdit);
|
&DialogPointOfIntersectionCircles::DeployCircle1RadiusTextEdit);
|
||||||
|
@ -114,6 +131,12 @@ DialogPointOfIntersectionCircles::~DialogPointOfIntersectionCircles()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogPointOfIntersectionCircles::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCircles::SetPointName(const QString &value)
|
void DialogPointOfIntersectionCircles::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -266,7 +289,7 @@ void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObjec
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCircles::PointChanged()
|
void DialogPointOfIntersectionCircles::PointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxCircle1Center) == getCurrentObjectId(ui->comboBoxCircle2Center))
|
if (getCurrentObjectId(ui->comboBoxCircle1Center) == getCurrentObjectId(ui->comboBoxCircle2Center))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -275,7 +298,7 @@ void DialogPointOfIntersectionCircles::PointChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelCircle1Center, color);
|
ChangeColor(ui->labelCircle1Center, color);
|
||||||
ChangeColor(ui->labelCircle1Center, color);
|
ChangeColor(ui->labelCircle1Center, color);
|
||||||
|
@ -285,31 +308,13 @@ void DialogPointOfIntersectionCircles::PointChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCircles::DeployCircle1RadiusTextEdit()
|
void DialogPointOfIntersectionCircles::DeployCircle1RadiusTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditCircle1Radius, ui->pushButtonGrowCircle1Radius, formulaBaseHeightCircle1Radius);
|
DeployFormula(this, ui->plainTextEditCircle1Radius, ui->pushButtonGrowCircle1Radius, formulaBaseHeightCircle1Radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCircles::DeployCircle2RadiusTextEdit()
|
void DialogPointOfIntersectionCircles::DeployCircle2RadiusTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditCircle2Radius, ui->pushButtonGrowCircle2Radius, formulaBaseHeightCircle2Radius);
|
DeployFormula(this, ui->plainTextEditCircle2Radius, ui->pushButtonGrowCircle2Radius, formulaBaseHeightCircle2Radius);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPointOfIntersectionCircles::Circle1RadiusChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditCircle1Radius;
|
|
||||||
labelResultCalculation = ui->labelResultCircle1Radius;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagCircle1Radius, ui->plainTextEditCircle1Radius, timerCircle1Radius, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPointOfIntersectionCircles::Circle2RadiusChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditCircle2Radius;
|
|
||||||
labelResultCalculation = ui->labelResultCircle2Radius;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagCircle2Radius, ui->plainTextEditCircle2Radius, timerCircle2Radius, postfix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -343,15 +348,19 @@ void DialogPointOfIntersectionCircles::FXCircle2Radius()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCircles::EvalCircle1Radius()
|
void DialogPointOfIntersectionCircles::EvalCircle1Radius()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditCircle1Radius;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditCircle1Radius->toPlainText();
|
||||||
const qreal radius = Eval(ui->plainTextEditCircle1Radius->toPlainText(), flagCircle1Radius,
|
formulaData.variables = data->DataVariables();
|
||||||
ui->labelResultCircle1Radius, postfix);
|
formulaData.labelEditFormula = ui->labelEditCircle1Radius;
|
||||||
|
formulaData.labelResult = ui->labelResultCircle1Radius;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
const qreal radius = Eval(formulaData, flagCircle1Radius);
|
||||||
|
|
||||||
if (radius < 0)
|
if (radius < 0)
|
||||||
{
|
{
|
||||||
flagCircle2Radius = false;
|
flagCircle2Radius = false;
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
ChangeColor(ui->labelEditCircle1Radius, errorColor);
|
||||||
ui->labelResultCircle1Radius->setText(tr("Error"));
|
ui->labelResultCircle1Radius->setText(tr("Error"));
|
||||||
ui->labelResultCircle1Radius->setToolTip(tr("Radius can't be negative"));
|
ui->labelResultCircle1Radius->setToolTip(tr("Radius can't be negative"));
|
||||||
|
|
||||||
|
@ -362,15 +371,19 @@ void DialogPointOfIntersectionCircles::EvalCircle1Radius()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCircles::EvalCircle2Radius()
|
void DialogPointOfIntersectionCircles::EvalCircle2Radius()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditCircle2Radius;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditCircle2Radius->toPlainText();
|
||||||
const qreal radius = Eval(ui->plainTextEditCircle2Radius->toPlainText(), flagCircle2Radius,
|
formulaData.variables = data->DataVariables();
|
||||||
ui->labelResultCircle2Radius, postfix);
|
formulaData.labelEditFormula = ui->labelEditCircle2Radius;
|
||||||
|
formulaData.labelResult = ui->labelResultCircle1Radius;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
const qreal radius = Eval(formulaData, flagCircle2Radius);
|
||||||
|
|
||||||
if (radius < 0)
|
if (radius < 0)
|
||||||
{
|
{
|
||||||
flagCircle2Radius = false;
|
flagCircle2Radius = false;
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
ChangeColor(ui->labelEditCircle2Radius, errorColor);
|
||||||
ui->labelResultCircle2Radius->setText(tr("Error"));
|
ui->labelResultCircle2Radius->setText(tr("Error"));
|
||||||
ui->labelResultCircle2Radius->setToolTip(tr("Radius can't be negative"));
|
ui->labelResultCircle2Radius->setToolTip(tr("Radius can't be negative"));
|
||||||
|
|
||||||
|
@ -407,15 +420,3 @@ void DialogPointOfIntersectionCircles::closeEvent(QCloseEvent *event)
|
||||||
ui->plainTextEditCircle2Radius->blockSignals(true);
|
ui->plainTextEditCircle2Radius->blockSignals(true);
|
||||||
DialogTool::closeEvent(event);
|
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -49,9 +49,10 @@ class DialogPointOfIntersectionCircles : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogPointOfIntersectionCircles(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogPointOfIntersectionCircles(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogPointOfIntersectionCircles() override;
|
virtual ~DialogPointOfIntersectionCircles() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
quint32 GetFirstCircleCenterId() const;
|
quint32 GetFirstCircleCenterId() const;
|
||||||
|
@ -76,9 +77,6 @@ public slots:
|
||||||
void DeployCircle1RadiusTextEdit();
|
void DeployCircle1RadiusTextEdit();
|
||||||
void DeployCircle2RadiusTextEdit();
|
void DeployCircle2RadiusTextEdit();
|
||||||
|
|
||||||
void Circle1RadiusChanged();
|
|
||||||
void Circle2RadiusChanged();
|
|
||||||
|
|
||||||
void FXCircle1Radius();
|
void FXCircle1Radius();
|
||||||
void FXCircle2Radius();
|
void FXCircle2Radius();
|
||||||
|
|
||||||
|
@ -92,24 +90,34 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual void CheckState() final;
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPointOfIntersectionCircles)
|
Q_DISABLE_COPY(DialogPointOfIntersectionCircles)
|
||||||
|
|
||||||
Ui::DialogPointOfIntersectionCircles *ui;
|
Ui::DialogPointOfIntersectionCircles *ui;
|
||||||
|
|
||||||
bool flagCircle1Radius;
|
QTimer *timerCircle1Radius;
|
||||||
bool flagCircle2Radius;
|
QTimer *timerCircle2Radius;
|
||||||
|
|
||||||
QTimer *timerCircle1Radius;
|
QString circle1Radius;
|
||||||
QTimer *timerCircle2Radius;
|
QString circle2Radius;
|
||||||
|
|
||||||
QString circle1Radius;
|
int formulaBaseHeightCircle1Radius;
|
||||||
QString circle2Radius;
|
int formulaBaseHeightCircle2Radius;
|
||||||
|
|
||||||
int formulaBaseHeightCircle1Radius;
|
QString pointName;
|
||||||
int formulaBaseHeightCircle2Radius;
|
|
||||||
|
bool flagCircle1Radius;
|
||||||
|
bool flagCircle2Radius;
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPointOfIntersectionCircles::IsValid() const
|
||||||
|
{
|
||||||
|
return flagCircle1Radius && flagCircle2Radius && flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTOFINTERSECTIONCIRCLES_H
|
#endif // DIALOGPOINTOFINTERSECTIONCIRCLES_H
|
||||||
|
|
|
@ -42,27 +42,32 @@
|
||||||
#include "ui_dialogpointofintersectioncurves.h"
|
#include "ui_dialogpointofintersectioncurves.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContainer *data, const quint32 &toolId,
|
DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContainer *data, quint32 toolId,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogPointOfIntersectionCurves)
|
ui(new Ui::DialogPointOfIntersectionCurves),
|
||||||
|
pointName(),
|
||||||
|
flagName(false),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
CheckState();
|
|
||||||
|
|
||||||
FillComboBoxCurves(ui->comboBoxCurve1);
|
FillComboBoxCurves(ui->comboBoxCurve1);
|
||||||
FillComboBoxCurves(ui->comboBoxCurve2);
|
FillComboBoxCurves(ui->comboBoxCurve2);
|
||||||
FillComboBoxVCrossCurvesPoint(ui->comboBoxVCorrection);
|
FillComboBoxVCrossCurvesPoint(ui->comboBoxVCorrection);
|
||||||
FillComboBoxHCrossCurvesPoint(ui->comboBoxHCorrection);
|
FillComboBoxHCrossCurvesPoint(ui->comboBoxHCorrection);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionCurves::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxCurve1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxCurve1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogPointOfIntersectionCurves::CurveChanged);
|
this, &DialogPointOfIntersectionCurves::CurveChanged);
|
||||||
connect(ui->comboBoxCurve2, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxCurve2, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -77,6 +82,12 @@ DialogPointOfIntersectionCurves::~DialogPointOfIntersectionCurves()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogPointOfIntersectionCurves::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCurves::SetPointName(const QString &value)
|
void DialogPointOfIntersectionCurves::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +102,7 @@ quint32 DialogPointOfIntersectionCurves::GetFirstCurveId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value)
|
void DialogPointOfIntersectionCurves::SetFirstCurveId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentCurveId(ui->comboBoxCurve1, value);
|
setCurrentCurveId(ui->comboBoxCurve1, value);
|
||||||
|
|
||||||
|
@ -107,7 +118,7 @@ quint32 DialogPointOfIntersectionCurves::GetSecondCurveId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value)
|
void DialogPointOfIntersectionCurves::SetSecondCurveId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentCurveId(ui->comboBoxCurve2, value);
|
setCurrentCurveId(ui->comboBoxCurve2, value);
|
||||||
|
|
||||||
|
@ -123,7 +134,7 @@ VCrossCurvesPoint DialogPointOfIntersectionCurves::GetVCrossPoint() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCurves::SetVCrossPoint(const VCrossCurvesPoint &vP)
|
void DialogPointOfIntersectionCurves::SetVCrossPoint(VCrossCurvesPoint vP)
|
||||||
{
|
{
|
||||||
auto index = ui->comboBoxVCorrection->findData(static_cast<int>(vP));
|
auto index = ui->comboBoxVCorrection->findData(static_cast<int>(vP));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
@ -143,7 +154,7 @@ HCrossCurvesPoint DialogPointOfIntersectionCurves::GetHCrossPoint() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCurves::SetHCrossPoint(const HCrossCurvesPoint &hP)
|
void DialogPointOfIntersectionCurves::SetHCrossPoint(HCrossCurvesPoint hP)
|
||||||
{
|
{
|
||||||
auto index = ui->comboBoxHCorrection->findData(static_cast<int>(hP));
|
auto index = ui->comboBoxHCorrection->findData(static_cast<int>(hP));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
@ -219,22 +230,10 @@ void DialogPointOfIntersectionCurves::SaveData()
|
||||||
point->RefreshGeometry();
|
point->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPointOfIntersectionCurves::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagName && flagError);
|
|
||||||
// In case dialog hasn't apply button
|
|
||||||
if ( bApply != nullptr)
|
|
||||||
{
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointOfIntersectionCurves::CurveChanged()
|
void DialogPointOfIntersectionCurves::CurveChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxCurve1) == getCurrentObjectId(ui->comboBoxCurve2))
|
if (getCurrentObjectId(ui->comboBoxCurve1) == getCurrentObjectId(ui->comboBoxCurve2))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -243,7 +242,7 @@ void DialogPointOfIntersectionCurves::CurveChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelCurve1, color);
|
ChangeColor(ui->labelCurve1, color);
|
||||||
ChangeColor(ui->labelCurve2, color);
|
ChangeColor(ui->labelCurve2, color);
|
||||||
|
|
|
@ -48,22 +48,23 @@ class DialogPointOfIntersectionCurves : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogPointOfIntersectionCurves(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogPointOfIntersectionCurves(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogPointOfIntersectionCurves() override;
|
virtual ~DialogPointOfIntersectionCurves() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
quint32 GetFirstCurveId() const;
|
quint32 GetFirstCurveId() const;
|
||||||
void SetFirstCurveId(const quint32 &value);
|
void SetFirstCurveId(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondCurveId() const;
|
quint32 GetSecondCurveId() const;
|
||||||
void SetSecondCurveId(const quint32 &value);
|
void SetSecondCurveId(quint32 value);
|
||||||
|
|
||||||
VCrossCurvesPoint GetVCrossPoint() const;
|
VCrossCurvesPoint GetVCrossPoint() const;
|
||||||
void SetVCrossPoint(const VCrossCurvesPoint &vP);
|
void SetVCrossPoint(VCrossCurvesPoint vP);
|
||||||
|
|
||||||
HCrossCurvesPoint GetHCrossPoint() const;
|
HCrossCurvesPoint GetHCrossPoint() const;
|
||||||
void SetHCrossPoint(const HCrossCurvesPoint &hP);
|
void SetHCrossPoint(HCrossCurvesPoint hP);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
@ -75,7 +76,7 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void CheckState() final;
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void CurveChanged();
|
void CurveChanged();
|
||||||
|
@ -84,6 +85,17 @@ private:
|
||||||
Q_DISABLE_COPY(DialogPointOfIntersectionCurves)
|
Q_DISABLE_COPY(DialogPointOfIntersectionCurves)
|
||||||
|
|
||||||
Ui::DialogPointOfIntersectionCurves *ui;
|
Ui::DialogPointOfIntersectionCurves *ui;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPointOfIntersectionCurves::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTOFINTERSECTIONCURVES_H
|
#endif // DIALOGPOINTOFINTERSECTIONCURVES_H
|
||||||
|
|
|
@ -64,17 +64,19 @@
|
||||||
#include "ui_dialogrotation.h"
|
#include "ui_dialogrotation.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogRotation),
|
ui(new Ui::DialogRotation),
|
||||||
flagAngle(false),
|
timerAngle(new QTimer(this)),
|
||||||
timerAngle(nullptr),
|
|
||||||
formulaAngle(),
|
formulaAngle(),
|
||||||
formulaBaseHeightAngle(0),
|
formulaBaseHeightAngle(0),
|
||||||
objects(),
|
objects(),
|
||||||
stage1(true),
|
stage1(true),
|
||||||
m_suffix(),
|
m_suffix(),
|
||||||
m_firstRelease(false)
|
m_firstRelease(false),
|
||||||
|
flagAngle(false),
|
||||||
|
flagName(false),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -83,19 +85,19 @@ DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QW
|
||||||
|
|
||||||
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
|
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
|
||||||
|
|
||||||
timerAngle = new QTimer(this);
|
timerAngle->setSingleShot(true);
|
||||||
connect(timerAngle, &QTimer::timeout, this, &DialogRotation::EvalAngle);
|
connect(timerAngle, &QTimer::timeout, this, &DialogRotation::EvalAngle);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxOriginPoint);
|
FillComboBoxPoints(ui->comboBoxOriginPoint);
|
||||||
|
|
||||||
flagName = true;
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogRotation::SuffixChanged);
|
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogRotation::SuffixChanged);
|
||||||
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogRotation::FXAngle);
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogRotation::FXAngle);
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogRotation::AngleChanged);
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerAngle->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogRotation::DeployAngleTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogRotation::DeployAngleTextEdit);
|
||||||
connect(ui->comboBoxOriginPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxOriginPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogRotation::PointChanged);
|
this, &DialogRotation::PointChanged);
|
||||||
|
@ -116,7 +118,7 @@ quint32 DialogRotation::GetOrigPointId() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::SetOrigPointId(const quint32 &value)
|
void DialogRotation::SetOrigPointId(quint32 value)
|
||||||
{
|
{
|
||||||
ChangeCurrentData(ui->comboBoxOriginPoint, value);
|
ChangeCurrentData(ui->comboBoxOriginPoint, value);
|
||||||
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
|
||||||
|
@ -291,15 +293,7 @@ void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::DeployAngleTextEdit()
|
void DialogRotation::DeployAngleTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeightAngle);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeightAngle);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogRotation::AngleChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditAngle;
|
|
||||||
labelResultCalculation = ui->labelResultAngle;
|
|
||||||
ValFormulaChanged(flagAngle, ui->plainTextEditFormula, timerAngle, degreeSymbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -326,7 +320,7 @@ void DialogRotation::SuffixChanged()
|
||||||
if (suffix.isEmpty())
|
if (suffix.isEmpty())
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +336,7 @@ void DialogRotation::SuffixChanged()
|
||||||
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(ui->labelSuffix, Qt::red);
|
ChangeColor(ui->labelSuffix, errorColor);
|
||||||
CheckState();
|
CheckState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -351,20 +345,11 @@ void DialogRotation::SuffixChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
flagName = true;
|
flagName = true;
|
||||||
ChangeColor(ui->labelSuffix, okColor);
|
ChangeColor(ui->labelSuffix, OkColor(this));
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogRotation::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagAngle && flagName && flagError);
|
|
||||||
SCASSERT(bApply != nullptr)
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::ShowVisualization()
|
void DialogRotation::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -396,7 +381,7 @@ void DialogRotation::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::PointChanged()
|
void DialogRotation::PointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
|
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -405,7 +390,7 @@ void DialogRotation::PointChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelOriginPoint, color);
|
ChangeColor(ui->labelOriginPoint, color);
|
||||||
CheckState();
|
CheckState();
|
||||||
|
@ -414,6 +399,13 @@ void DialogRotation::PointChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogRotation::EvalAngle()
|
void DialogRotation::EvalAngle()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditAngle;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditFormula->toPlainText(), flagAngle, ui->labelResultAngle, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAngle;
|
||||||
|
formulaData.labelResult = ui->labelResultAngle;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagAngle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,11 @@ class DialogRotation : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogRotation(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogRotation();
|
virtual ~DialogRotation();
|
||||||
|
|
||||||
quint32 GetOrigPointId() const;
|
quint32 GetOrigPointId() const;
|
||||||
void SetOrigPointId(const quint32 &value);
|
void SetOrigPointId(quint32 value);
|
||||||
|
|
||||||
QString GetAngle() const;
|
QString GetAngle() const;
|
||||||
void SetAngle(const QString &value);
|
void SetAngle(const QString &value);
|
||||||
|
@ -72,17 +72,17 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
/** @brief DeployAngleTextEdit grow or shrink formula input */
|
/** @brief DeployAngleTextEdit grow or shrink formula input */
|
||||||
void DeployAngleTextEdit();
|
void DeployAngleTextEdit();
|
||||||
void AngleChanged();
|
|
||||||
void FXAngle();
|
void FXAngle();
|
||||||
void SuffixChanged();
|
void SuffixChanged();
|
||||||
|
void EvalAngle();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
|
||||||
/** @brief SaveData Put dialog data in local variables */
|
/** @brief SaveData Put dialog data in local variables */
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void PointChanged();
|
void PointChanged();
|
||||||
|
@ -91,9 +91,6 @@ private:
|
||||||
Q_DISABLE_COPY(DialogRotation)
|
Q_DISABLE_COPY(DialogRotation)
|
||||||
Ui::DialogRotation *ui;
|
Ui::DialogRotation *ui;
|
||||||
|
|
||||||
/** @brief flagAngle true if value of angle is correct */
|
|
||||||
bool flagAngle;
|
|
||||||
|
|
||||||
/** @brief timerAngle timer of check formula of angle */
|
/** @brief timerAngle timer of check formula of angle */
|
||||||
QTimer *timerAngle;
|
QTimer *timerAngle;
|
||||||
|
|
||||||
|
@ -111,7 +108,16 @@ private:
|
||||||
|
|
||||||
bool m_firstRelease;
|
bool m_firstRelease;
|
||||||
|
|
||||||
void EvalAngle();
|
/** @brief flagAngle true if value of angle is correct */
|
||||||
|
bool flagAngle;
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogRotation::IsValid() const
|
||||||
|
{
|
||||||
|
return flagAngle && flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGROTATION_H
|
#endif // DIALOGROTATION_H
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
|
@ -56,23 +57,29 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), formula(QString()),
|
: DialogTool(data, toolId, parent),
|
||||||
formulaBaseHeight(0)
|
ui(new Ui::DialogShoulderPoint),
|
||||||
|
formula(),
|
||||||
|
formulaBaseHeight(0),
|
||||||
|
timerFormula(new QTimer(this)),
|
||||||
|
pointName(),
|
||||||
|
flagFormula(false),
|
||||||
|
flagName(true),
|
||||||
|
flagError(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
timerFormula->setSingleShot(true);
|
||||||
|
connect(timerFormula, &QTimer::timeout, this, &DialogShoulderPoint::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
InitFormulaUI(ui);
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
flagFormula = false;
|
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
FillComboBoxTypeLine(ui->comboBoxLineType, LineStylesPics());
|
||||||
FillComboBoxPoints(ui->comboBoxP1Line);
|
FillComboBoxPoints(ui->comboBoxP1Line);
|
||||||
|
@ -81,8 +88,15 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
|
||||||
FillComboBoxLineColors(ui->comboBoxLineColor);
|
FillComboBoxLineColors(ui->comboBoxLineColor);
|
||||||
|
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogShoulderPoint::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogShoulderPoint::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogShoulderPoint::FormulaTextChanged);
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerFormula->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit);
|
||||||
connect(ui->comboBoxP1Line, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP1Line, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogShoulderPoint::PointNameChanged);
|
this, &DialogShoulderPoint::PointNameChanged);
|
||||||
|
@ -94,12 +108,6 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
|
||||||
vis = new VisToolShoulderPoint(data);
|
vis = new VisToolShoulderPoint(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogShoulderPoint::FormulaTextChanged()
|
|
||||||
{
|
|
||||||
this->FormulaChangedPlainText();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogShoulderPoint::PointNameChanged()
|
void DialogShoulderPoint::PointNameChanged()
|
||||||
{
|
{
|
||||||
|
@ -108,7 +116,7 @@ void DialogShoulderPoint::PointNameChanged()
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxP2Line));
|
set.insert(getCurrentObjectId(ui->comboBoxP2Line));
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxP3));
|
set.insert(getCurrentObjectId(ui->comboBoxP3));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() != 3)
|
if (set.size() != 3)
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -117,7 +125,7 @@ void DialogShoulderPoint::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
ChangeColor(ui->labelSecondPoint, color);
|
ChangeColor(ui->labelSecondPoint, color);
|
||||||
|
@ -139,6 +147,19 @@ void DialogShoulderPoint::FXLength()
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogShoulderPoint::EvalFormula()
|
||||||
|
{
|
||||||
|
FormulaData formulaData;
|
||||||
|
formulaData.formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormula;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormula);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogShoulderPoint::ShowVisualization()
|
void DialogShoulderPoint::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -148,7 +169,7 @@ void DialogShoulderPoint::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogShoulderPoint::DeployFormulaTextEdit()
|
void DialogShoulderPoint::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -157,6 +178,12 @@ DialogShoulderPoint::~DialogShoulderPoint()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogShoulderPoint::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||||
|
|
|
@ -50,9 +50,10 @@ class DialogShoulderPoint : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogShoulderPoint(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogShoulderPoint() override;
|
virtual ~DialogShoulderPoint() override;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
QString GetTypeLine() const;
|
||||||
|
@ -78,12 +79,9 @@ public slots:
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
/**
|
|
||||||
* @brief FormulaTextChanged when formula text changes for validation and calc
|
|
||||||
*/
|
|
||||||
void FormulaTextChanged();
|
|
||||||
virtual void PointNameChanged() override;
|
virtual void PointNameChanged() override;
|
||||||
void FXLength();
|
void FXLength();
|
||||||
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
|
@ -91,6 +89,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogShoulderPoint)
|
Q_DISABLE_COPY(DialogShoulderPoint)
|
||||||
|
|
||||||
|
@ -98,10 +97,24 @@ private:
|
||||||
Ui::DialogShoulderPoint *ui;
|
Ui::DialogShoulderPoint *ui;
|
||||||
|
|
||||||
/** @brief formula formula */
|
/** @brief formula formula */
|
||||||
QString formula;
|
QString formula;
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int formulaBaseHeight;
|
||||||
|
|
||||||
|
QTimer *timerFormula;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagFormula;
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogShoulderPoint::IsValid() const
|
||||||
|
{
|
||||||
|
return flagFormula && flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGSHOULDERPOINT_H
|
#endif // DIALOGSHOULDERPOINT_H
|
||||||
|
|
|
@ -42,8 +42,12 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogSinglePoint::DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogSinglePoint::DialogSinglePoint(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogSinglePoint), point(QPointF())
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogSinglePoint),
|
||||||
|
point(),
|
||||||
|
pointName(),
|
||||||
|
flagName(true)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -51,13 +55,13 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, const quint32 &tool
|
||||||
|
|
||||||
ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize));
|
ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize));
|
||||||
ui->doubleSpinBoxY->setRange(0, qApp->fromPixel(SceneSize));
|
ui->doubleSpinBoxY->setRange(0, qApp->fromPixel(SceneSize));
|
||||||
labelEditNamePoint = ui->labelEditName;
|
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
|
|
||||||
flagName = true;
|
connect(ui->lineEditName, &QLineEdit::textChanged, this, [this]()
|
||||||
DialogTool::CheckState();
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditName, ui->labelEditName, pointName, this->data, flagName);
|
||||||
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogTool::NamePointChanged);
|
CheckState();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -118,3 +122,9 @@ QPointF DialogSinglePoint::GetPoint() const
|
||||||
{
|
{
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogSinglePoint::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
|
@ -50,12 +50,14 @@ class DialogSinglePoint : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogSinglePoint(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogSinglePoint() override;
|
virtual ~DialogSinglePoint() override;
|
||||||
|
|
||||||
void SetData(const QString &name, const QPointF &point);
|
void SetData(const QString &name, const QPointF &point);
|
||||||
QPointF GetPoint()const;
|
QPointF GetPoint()const;
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void mousePress(const QPointF &scenePos);
|
void mousePress(const QPointF &scenePos);
|
||||||
protected:
|
protected:
|
||||||
|
@ -63,6 +65,7 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogSinglePoint)
|
Q_DISABLE_COPY(DialogSinglePoint)
|
||||||
|
|
||||||
|
@ -70,7 +73,17 @@ private:
|
||||||
Ui::DialogSinglePoint *ui;
|
Ui::DialogSinglePoint *ui;
|
||||||
|
|
||||||
/** @brief point data of point */
|
/** @brief point data of point */
|
||||||
QPointF point;
|
QPointF point;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogSinglePoint::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGSINGLEPOINT_H
|
#endif // DIALOGSINGLEPOINT_H
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogSpline::DialogSpline(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogSpline),
|
ui(new Ui::DialogSpline),
|
||||||
spl(),
|
spl(),
|
||||||
|
@ -79,12 +79,11 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
flagAngle1(false),
|
flagAngle1(false),
|
||||||
flagAngle2(false),
|
flagAngle2(false),
|
||||||
flagLength1(false),
|
flagLength1(false),
|
||||||
flagLength2(false)
|
flagLength2(false),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
plainTextEditFormula = ui->plainTextEditAngle1F;
|
|
||||||
|
|
||||||
formulaBaseHeightAngle1 = ui->plainTextEditAngle1F->height();
|
formulaBaseHeightAngle1 = ui->plainTextEditAngle1F->height();
|
||||||
formulaBaseHeightAngle2 = ui->plainTextEditAngle2F->height();
|
formulaBaseHeightAngle2 = ui->plainTextEditAngle2F->height();
|
||||||
formulaBaseHeightLength1 = ui->plainTextEditLength1F->height();
|
formulaBaseHeightLength1 = ui->plainTextEditLength1F->height();
|
||||||
|
@ -95,6 +94,11 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
ui->plainTextEditLength1F->installEventFilter(this);
|
ui->plainTextEditLength1F->installEventFilter(this);
|
||||||
ui->plainTextEditLength2F->installEventFilter(this);
|
ui->plainTextEditLength2F->installEventFilter(this);
|
||||||
|
|
||||||
|
timerAngle1->setSingleShot(true);
|
||||||
|
timerAngle2->setSingleShot(true);
|
||||||
|
timerLength1->setSingleShot(true);
|
||||||
|
timerLength2->setSingleShot(true);
|
||||||
|
|
||||||
connect(timerAngle1, &QTimer::timeout, this, &DialogSpline::EvalAngle1);
|
connect(timerAngle1, &QTimer::timeout, this, &DialogSpline::EvalAngle1);
|
||||||
connect(timerAngle2, &QTimer::timeout, this, &DialogSpline::EvalAngle2);
|
connect(timerAngle2, &QTimer::timeout, this, &DialogSpline::EvalAngle2);
|
||||||
connect(timerLength1, &QTimer::timeout, this, &DialogSpline::EvalLength1);
|
connect(timerLength1, &QTimer::timeout, this, &DialogSpline::EvalLength1);
|
||||||
|
@ -109,8 +113,6 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
|
|
||||||
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
|
||||||
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->comboBoxP1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP1, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogSpline::PointNameChanged);
|
this, &DialogSpline::PointNameChanged);
|
||||||
connect(ui->comboBoxP4, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxP4, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -121,10 +123,25 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge
|
||||||
connect(ui->toolButtonExprLength1, &QPushButton::clicked, this, &DialogSpline::FXLength1);
|
connect(ui->toolButtonExprLength1, &QPushButton::clicked, this, &DialogSpline::FXLength1);
|
||||||
connect(ui->toolButtonExprLength2, &QPushButton::clicked, this, &DialogSpline::FXLength2);
|
connect(ui->toolButtonExprLength2, &QPushButton::clicked, this, &DialogSpline::FXLength2);
|
||||||
|
|
||||||
connect(ui->plainTextEditAngle1F, &QPlainTextEdit::textChanged, this, &DialogSpline::Angle1Changed);
|
connect(ui->plainTextEditAngle1F, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditAngle2F, &QPlainTextEdit::textChanged, this, &DialogSpline::Angle2Changed);
|
{
|
||||||
connect(ui->plainTextEditLength1F, &QPlainTextEdit::textChanged, this, &DialogSpline::Length1Changed);
|
timerAngle1->start(formulaTimerTimeout);
|
||||||
connect(ui->plainTextEditLength2F, &QPlainTextEdit::textChanged, this, &DialogSpline::Length2Changed);
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditAngle2F, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerAngle2->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditLength1F, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerLength1->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditLength2F, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerLength2->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowAngle1, &QPushButton::clicked, this, &DialogSpline::DeployAngle1TextEdit);
|
connect(ui->pushButtonGrowAngle1, &QPushButton::clicked, this, &DialogSpline::DeployAngle1TextEdit);
|
||||||
connect(ui->pushButtonGrowAngle2, &QPushButton::clicked, this, &DialogSpline::DeployAngle2TextEdit);
|
connect(ui->pushButtonGrowAngle2, &QPushButton::clicked, this, &DialogSpline::DeployAngle2TextEdit);
|
||||||
|
@ -229,59 +246,25 @@ void DialogSpline::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::DeployAngle1TextEdit()
|
void DialogSpline::DeployAngle1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditAngle1F, ui->pushButtonGrowAngle1, formulaBaseHeightAngle1);
|
DeployFormula(this, ui->plainTextEditAngle1F, ui->pushButtonGrowAngle1, formulaBaseHeightAngle1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::DeployAngle2TextEdit()
|
void DialogSpline::DeployAngle2TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditAngle2F, ui->pushButtonGrowAngle2, formulaBaseHeightAngle2);
|
DeployFormula(this, ui->plainTextEditAngle2F, ui->pushButtonGrowAngle2, formulaBaseHeightAngle2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::DeployLength1TextEdit()
|
void DialogSpline::DeployLength1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditLength1F, ui->pushButtonGrowLength1, formulaBaseHeightLength1);
|
DeployFormula(this, ui->plainTextEditLength1F, ui->pushButtonGrowLength1, formulaBaseHeightLength1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::DeployLength2TextEdit()
|
void DialogSpline::DeployLength2TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditLength2F, ui->pushButtonGrowLength2, formulaBaseHeightLength2);
|
DeployFormula(this, ui->plainTextEditLength2F, ui->pushButtonGrowLength2, formulaBaseHeightLength2);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSpline::Angle1Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditAngle1;
|
|
||||||
labelResultCalculation = ui->labelResultAngle1;
|
|
||||||
ValFormulaChanged(flagAngle1, ui->plainTextEditAngle1F, timerAngle1, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSpline::Angle2Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditAngle2;
|
|
||||||
labelResultCalculation = ui->labelResultAngle2;
|
|
||||||
ValFormulaChanged(flagAngle2, ui->plainTextEditAngle2F, timerAngle2, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSpline::Length1Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditLength1;
|
|
||||||
labelResultCalculation = ui->labelResultLength1;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagLength1, ui->plainTextEditLength1F, timerLength1, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSpline::Length2Changed()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditLength2;
|
|
||||||
labelResultCalculation = ui->labelResultLength2;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagLength2, ui->plainTextEditLength2F, timerLength2, postfix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -391,53 +374,59 @@ const QSharedPointer<VPointF> DialogSpline::GetP4() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::EvalAngle1()
|
void DialogSpline::EvalAngle1()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditAngle1;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditAngle1F->toPlainText(), flagAngle1, ui->labelResultAngle1, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditAngle1F->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAngle1;
|
||||||
|
formulaData.labelResult = ui->labelResultAngle1;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagAngle1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::EvalAngle2()
|
void DialogSpline::EvalAngle2()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditAngle2;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditAngle2F->toPlainText(), flagAngle2, ui->labelResultAngle2, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditAngle2F->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAngle2;
|
||||||
|
formulaData.labelResult = ui->labelResultAngle2;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagAngle2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::EvalLength1()
|
void DialogSpline::EvalLength1()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditLength1;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditLength1F->toPlainText();
|
||||||
const qreal length1 = Eval(ui->plainTextEditLength1F->toPlainText(), flagLength1, ui->labelResultLength1, postfix,
|
formulaData.variables = data->DataVariables();
|
||||||
false);
|
formulaData.labelEditFormula = ui->labelEditLength1;
|
||||||
|
formulaData.labelResult = ui->labelResultLength1;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
if (length1 < 0)
|
Eval(formulaData, flagLength1);
|
||||||
{
|
|
||||||
flagLength1 = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultLength1->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
ui->labelResultLength1->setToolTip(tr("Length can't be negative"));
|
|
||||||
|
|
||||||
DialogSpline::CheckState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::EvalLength2()
|
void DialogSpline::EvalLength2()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditLength2;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditLength2F->toPlainText();
|
||||||
const qreal length2 = Eval(ui->plainTextEditLength2F->toPlainText(), flagLength2, ui->labelResultLength2, postfix,
|
formulaData.variables = data->DataVariables();
|
||||||
false);
|
formulaData.labelEditFormula = ui->labelEditLength2;
|
||||||
|
formulaData.labelResult = ui->labelResultLength2;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
if (length2 < 0)
|
Eval(formulaData, flagLength2);
|
||||||
{
|
|
||||||
flagLength2 = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultLength2->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
ui->labelResultLength2->setToolTip(tr("Length can't be negative"));
|
|
||||||
|
|
||||||
DialogSpline::CheckState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -477,7 +466,7 @@ void DialogSpline::PointNameChanged()
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxP1));
|
set.insert(getCurrentObjectId(ui->comboBoxP1));
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxP4));
|
set.insert(getCurrentObjectId(ui->comboBoxP4));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxP1) == getCurrentObjectId(ui->comboBoxP4))
|
if (getCurrentObjectId(ui->comboBoxP1) == getCurrentObjectId(ui->comboBoxP4))
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -488,7 +477,7 @@ void DialogSpline::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
|
|
||||||
if (getCurrentObjectId(ui->comboBoxP1) == spl.GetP1().id() &&
|
if (getCurrentObjectId(ui->comboBoxP1) == spl.GetP1().id() &&
|
||||||
getCurrentObjectId(ui->comboBoxP4) == spl.GetP4().id())
|
getCurrentObjectId(ui->comboBoxP4) == spl.GetP4().id())
|
||||||
|
@ -548,18 +537,6 @@ void DialogSpline::ShowDialog(bool click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSpline::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagAngle1 && flagAngle2 && flagLength1 && flagLength2 && flagError);
|
|
||||||
// In case dialog hasn't apply button
|
|
||||||
if ( bApply != nullptr)
|
|
||||||
{
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::ShowVisualization()
|
void DialogSpline::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,7 +54,7 @@ class DialogSpline : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogSpline(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogSpline() override;
|
virtual ~DialogSpline() override;
|
||||||
|
|
||||||
VSpline GetSpline() const;
|
VSpline GetSpline() const;
|
||||||
|
@ -65,28 +65,28 @@ public slots:
|
||||||
virtual void PointNameChanged() override;
|
virtual void PointNameChanged() override;
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private slots:
|
private slots:
|
||||||
void DeployAngle1TextEdit();
|
void DeployAngle1TextEdit();
|
||||||
void DeployAngle2TextEdit();
|
void DeployAngle2TextEdit();
|
||||||
void DeployLength1TextEdit();
|
void DeployLength1TextEdit();
|
||||||
void DeployLength2TextEdit();
|
void DeployLength2TextEdit();
|
||||||
|
|
||||||
void Angle1Changed();
|
|
||||||
void Angle2Changed();
|
|
||||||
void Length1Changed();
|
|
||||||
void Length2Changed();
|
|
||||||
|
|
||||||
void FXAngle1();
|
void FXAngle1();
|
||||||
void FXAngle2();
|
void FXAngle2();
|
||||||
void FXLength1();
|
void FXLength1();
|
||||||
void FXLength2();
|
void FXLength2();
|
||||||
|
|
||||||
|
void EvalAngle1();
|
||||||
|
void EvalAngle2();
|
||||||
|
void EvalLength1();
|
||||||
|
void EvalLength2();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogSpline)
|
Q_DISABLE_COPY(DialogSpline)
|
||||||
|
|
||||||
|
@ -115,16 +115,18 @@ private:
|
||||||
bool flagAngle2;
|
bool flagAngle2;
|
||||||
bool flagLength1;
|
bool flagLength1;
|
||||||
bool flagLength2;
|
bool flagLength2;
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
const QSharedPointer<VPointF> GetP1() const;
|
const QSharedPointer<VPointF> GetP1() const;
|
||||||
const QSharedPointer<VPointF> GetP4() const;
|
const QSharedPointer<VPointF> GetP4() const;
|
||||||
|
|
||||||
void EvalAngle1();
|
|
||||||
void EvalAngle2();
|
|
||||||
void EvalLength1();
|
|
||||||
void EvalLength2();
|
|
||||||
|
|
||||||
VSpline CurrentSpline() const;
|
VSpline CurrentSpline() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogSpline::IsValid() const
|
||||||
|
{
|
||||||
|
return flagAngle1 && flagAngle2 && flagLength1 && flagLength2 && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGSPLINE_H
|
#endif // DIALOGSPLINE_H
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogSplinePath::DialogSplinePath(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogSplinePath),
|
ui(new Ui::DialogSplinePath),
|
||||||
path(),
|
path(),
|
||||||
|
@ -82,12 +82,11 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId
|
||||||
flagAngle1(),
|
flagAngle1(),
|
||||||
flagAngle2(),
|
flagAngle2(),
|
||||||
flagLength1(),
|
flagLength1(),
|
||||||
flagLength2()
|
flagLength2(),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
plainTextEditFormula = ui->plainTextEditAngle1F;
|
|
||||||
|
|
||||||
formulaBaseHeightAngle1 = ui->plainTextEditAngle1F->height();
|
formulaBaseHeightAngle1 = ui->plainTextEditAngle1F->height();
|
||||||
formulaBaseHeightAngle2 = ui->plainTextEditAngle2F->height();
|
formulaBaseHeightAngle2 = ui->plainTextEditAngle2F->height();
|
||||||
formulaBaseHeightLength1 = ui->plainTextEditLength1F->height();
|
formulaBaseHeightLength1 = ui->plainTextEditLength1F->height();
|
||||||
|
@ -172,6 +171,8 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
|
||||||
SCASSERT(visPath != nullptr)
|
SCASSERT(visPath != nullptr)
|
||||||
visPath->setPath(path);
|
visPath->setPath(path);
|
||||||
ui->listWidget->blockSignals(false);
|
ui->listWidget->blockSignals(false);
|
||||||
|
|
||||||
|
flagError = IsPathValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -234,29 +235,6 @@ void DialogSplinePath::SaveData()
|
||||||
visPath->RefreshGeometry();
|
visPath->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSplinePath::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
|
|
||||||
bool fAngle1 = true, fAngle2 = true, fLength1 = true, fLength2 = true;
|
|
||||||
|
|
||||||
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
|
|
||||||
{
|
|
||||||
fAngle1 = fAngle1 && flagAngle1.at(i);
|
|
||||||
fAngle2 = fAngle2 && flagAngle2.at(i);
|
|
||||||
fLength1 = fLength1 && flagLength1.at(i);
|
|
||||||
fLength2 = fLength2 && flagLength2.at(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
bOk->setEnabled(fAngle1 && fAngle2 && fLength1 && fLength2 && flagError);
|
|
||||||
// In case dialog hasn't apply button
|
|
||||||
if (bApply != nullptr)
|
|
||||||
{
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSplinePath::closeEvent(QCloseEvent *event)
|
void DialogSplinePath::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
|
@ -270,25 +248,25 @@ void DialogSplinePath::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSplinePath::DeployAngle1TextEdit()
|
void DialogSplinePath::DeployAngle1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditAngle1F, ui->pushButtonGrowAngle1, formulaBaseHeightAngle1);
|
DeployFormula(this, ui->plainTextEditAngle1F, ui->pushButtonGrowAngle1, formulaBaseHeightAngle1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSplinePath::DeployAngle2TextEdit()
|
void DialogSplinePath::DeployAngle2TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditAngle2F, ui->pushButtonGrowAngle2, formulaBaseHeightAngle2);
|
DeployFormula(this, ui->plainTextEditAngle2F, ui->pushButtonGrowAngle2, formulaBaseHeightAngle2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSplinePath::DeployLength1TextEdit()
|
void DialogSplinePath::DeployLength1TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditLength1F, ui->pushButtonGrowLength1, formulaBaseHeightLength1);
|
DeployFormula(this, ui->plainTextEditLength1F, ui->pushButtonGrowLength1, formulaBaseHeightLength1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSplinePath::DeployLength2TextEdit()
|
void DialogSplinePath::DeployLength2TextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditLength2F, ui->pushButtonGrowLength2, formulaBaseHeightLength2);
|
DeployFormula(this, ui->plainTextEditLength2F, ui->pushButtonGrowLength2, formulaBaseHeightLength2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -518,8 +496,15 @@ void DialogSplinePath::EvalAngle1()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditAngle1;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditAngle1F->toPlainText(), flagAngle1[row], ui->labelResultAngle1, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditAngle1F->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAngle1;
|
||||||
|
formulaData.labelResult = ui->labelResultAngle1;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagAngle1[row]);
|
||||||
|
|
||||||
QListWidgetItem *item = ui->listWidget->item(row);
|
QListWidgetItem *item = ui->listWidget->item(row);
|
||||||
SCASSERT(item != nullptr)
|
SCASSERT(item != nullptr)
|
||||||
|
@ -537,8 +522,15 @@ void DialogSplinePath::EvalAngle2()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditAngle2;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditAngle2F->toPlainText(), flagAngle2[row], ui->labelResultAngle2, degreeSymbol, false);
|
formulaData.formula = ui->plainTextEditAngle2F->toPlainText();
|
||||||
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAngle2;
|
||||||
|
formulaData.labelResult = ui->labelResultAngle2;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, flagAngle2[row]);
|
||||||
|
|
||||||
QListWidgetItem *item = ui->listWidget->item(row);
|
QListWidgetItem *item = ui->listWidget->item(row);
|
||||||
SCASSERT(item != nullptr)
|
SCASSERT(item != nullptr)
|
||||||
|
@ -556,20 +548,16 @@ void DialogSplinePath::EvalLength1()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditLength1;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditLength1F->toPlainText();
|
||||||
const qreal length1 = Eval(ui->plainTextEditLength1F->toPlainText(), flagLength1[row], ui->labelResultLength1,
|
formulaData.variables = data->DataVariables();
|
||||||
postfix, false);
|
formulaData.labelEditFormula = ui->labelEditLength1;
|
||||||
|
formulaData.labelResult = ui->labelResultLength1;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
if (length1 < 0)
|
Eval(formulaData, flagLength1[row]);
|
||||||
{
|
|
||||||
flagLength1[row] = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultLength1->setText(tr("Error") + QLatin1String(" (") + postfix + QLatin1String(")"));
|
|
||||||
ui->labelResultLength1->setToolTip(tr("Length can't be negative"));
|
|
||||||
|
|
||||||
CheckState();
|
|
||||||
}
|
|
||||||
|
|
||||||
QListWidgetItem *item = ui->listWidget->item(row);
|
QListWidgetItem *item = ui->listWidget->item(row);
|
||||||
SCASSERT(item != nullptr)
|
SCASSERT(item != nullptr)
|
||||||
|
@ -587,20 +575,16 @@ void DialogSplinePath::EvalLength2()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
labelEditFormula = ui->labelEditLength2;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditLength2F->toPlainText();
|
||||||
const qreal length2 = Eval(ui->plainTextEditLength2F->toPlainText(), flagLength2[row], ui->labelResultLength2,
|
formulaData.variables = data->DataVariables();
|
||||||
postfix, false);
|
formulaData.labelEditFormula = ui->labelEditLength2;
|
||||||
|
formulaData.labelResult = ui->labelResultLength2;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
if (length2 < 0)
|
Eval(formulaData, flagLength2[row]);
|
||||||
{
|
|
||||||
flagLength2[row] = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
ui->labelResultLength2->setText(tr("Error") + QLatin1String(" (") + postfix + QLatin1String(")"));
|
|
||||||
ui->labelResultLength2->setToolTip(tr("Length can't be negative"));
|
|
||||||
|
|
||||||
CheckState();
|
|
||||||
}
|
|
||||||
|
|
||||||
QListWidgetItem *item = ui->listWidget->item(row);
|
QListWidgetItem *item = ui->listWidget->item(row);
|
||||||
SCASSERT(item != nullptr)
|
SCASSERT(item != nullptr)
|
||||||
|
@ -641,7 +625,7 @@ void DialogSplinePath::currentPointChanged(int index)
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
||||||
ShowPointIssue(p.P().name());
|
ShowPointIssue(p.P().name());
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (not IsPathValid())
|
if (not IsPathValid())
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -652,7 +636,7 @@ void DialogSplinePath::currentPointChanged(int index)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
|
|
||||||
auto first = qvariant_cast<VSplinePoint>(ui->listWidget->item(0)->data(Qt::UserRole));
|
auto first = qvariant_cast<VSplinePoint>(ui->listWidget->item(0)->data(Qt::UserRole));
|
||||||
auto last = qvariant_cast<VSplinePoint>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
|
auto last = qvariant_cast<VSplinePoint>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
|
||||||
|
@ -758,7 +742,7 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p)
|
||||||
ui->toolButtonExprAngle1->setEnabled(false);
|
ui->toolButtonExprAngle1->setEnabled(false);
|
||||||
ui->labelResultAngle1->setText(emptyRes);
|
ui->labelResultAngle1->setText(emptyRes);
|
||||||
ui->labelResultAngle1->setToolTip(tr("Value"));
|
ui->labelResultAngle1->setToolTip(tr("Value"));
|
||||||
ChangeColor(ui->labelEditAngle1, okColor);
|
ChangeColor(ui->labelEditAngle1, OkColor(this));
|
||||||
ui->plainTextEditAngle1F->blockSignals(true);
|
ui->plainTextEditAngle1F->blockSignals(true);
|
||||||
ui->plainTextEditAngle1F->setPlainText(field);
|
ui->plainTextEditAngle1F->setPlainText(field);
|
||||||
ui->plainTextEditAngle1F->setEnabled(false);
|
ui->plainTextEditAngle1F->setEnabled(false);
|
||||||
|
@ -767,7 +751,7 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p)
|
||||||
ui->toolButtonExprLength1->setEnabled(false);
|
ui->toolButtonExprLength1->setEnabled(false);
|
||||||
ui->labelResultLength1->setText(emptyRes);
|
ui->labelResultLength1->setText(emptyRes);
|
||||||
ui->labelResultLength1->setToolTip(tr("Value"));
|
ui->labelResultLength1->setToolTip(tr("Value"));
|
||||||
ChangeColor(ui->labelEditLength1, okColor);
|
ChangeColor(ui->labelEditLength1, OkColor(this));
|
||||||
ui->plainTextEditLength1F->blockSignals(true);
|
ui->plainTextEditLength1F->blockSignals(true);
|
||||||
ui->plainTextEditLength1F->setPlainText(field);
|
ui->plainTextEditLength1F->setPlainText(field);
|
||||||
ui->plainTextEditLength1F->setEnabled(false);
|
ui->plainTextEditLength1F->setEnabled(false);
|
||||||
|
@ -795,7 +779,7 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p)
|
||||||
ui->toolButtonExprAngle2->setEnabled(false);
|
ui->toolButtonExprAngle2->setEnabled(false);
|
||||||
ui->labelResultAngle2->setText(emptyRes);
|
ui->labelResultAngle2->setText(emptyRes);
|
||||||
ui->labelResultAngle2->setToolTip(tr("Value"));
|
ui->labelResultAngle2->setToolTip(tr("Value"));
|
||||||
ChangeColor(ui->labelEditAngle2, okColor);
|
ChangeColor(ui->labelEditAngle2, OkColor(this));
|
||||||
ui->plainTextEditAngle2F->blockSignals(true);
|
ui->plainTextEditAngle2F->blockSignals(true);
|
||||||
ui->plainTextEditAngle2F->setPlainText(field);
|
ui->plainTextEditAngle2F->setPlainText(field);
|
||||||
ui->plainTextEditAngle2F->setEnabled(false);
|
ui->plainTextEditAngle2F->setEnabled(false);
|
||||||
|
@ -804,7 +788,7 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p)
|
||||||
ui->toolButtonExprLength2->setEnabled(false);
|
ui->toolButtonExprLength2->setEnabled(false);
|
||||||
ui->labelResultLength2->setText(emptyRes);
|
ui->labelResultLength2->setText(emptyRes);
|
||||||
ui->labelResultLength2->setToolTip(tr("Value"));
|
ui->labelResultLength2->setToolTip(tr("Value"));
|
||||||
ChangeColor(ui->labelEditLength2, okColor);
|
ChangeColor(ui->labelEditLength2, OkColor(this));
|
||||||
ui->plainTextEditLength2F->blockSignals(true);
|
ui->plainTextEditLength2F->blockSignals(true);
|
||||||
ui->plainTextEditLength2F->setPlainText(field);
|
ui->plainTextEditLength2F->setPlainText(field);
|
||||||
ui->plainTextEditLength2F->setEnabled(false);
|
ui->plainTextEditLength2F->setEnabled(false);
|
||||||
|
@ -930,3 +914,19 @@ void DialogSplinePath::ShowPointIssue(const QString &pName)
|
||||||
item->setText(pName + QLatin1String("(!)"));
|
item->setText(pName + QLatin1String("(!)"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogSplinePath::IsValid() const
|
||||||
|
{
|
||||||
|
bool fAngle1 = true, fAngle2 = true, fLength1 = true, fLength2 = true;
|
||||||
|
|
||||||
|
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
|
||||||
|
{
|
||||||
|
fAngle1 = fAngle1 && flagAngle1.at(i);
|
||||||
|
fAngle2 = fAngle2 && flagAngle2.at(i);
|
||||||
|
fLength1 = fLength1 && flagLength1.at(i);
|
||||||
|
fLength2 = fLength2 && flagLength2.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fAngle1 && fAngle2 && fLength1 && fLength2 && flagError;
|
||||||
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ class DialogSplinePath : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogSplinePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogSplinePath() override;
|
virtual ~DialogSplinePath() override;
|
||||||
|
|
||||||
VSplinePath GetPath() const;
|
VSplinePath GetPath() const;
|
||||||
|
@ -65,8 +65,8 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private slots:
|
private slots:
|
||||||
void PointChanged(int row);
|
void PointChanged(int row);
|
||||||
void currentPointChanged(int index);
|
void currentPointChanged(int index);
|
||||||
|
@ -107,6 +107,7 @@ private:
|
||||||
QVector<bool> flagAngle2;
|
QVector<bool> flagAngle2;
|
||||||
QVector<bool> flagLength1;
|
QVector<bool> flagLength1;
|
||||||
QVector<bool> flagLength2;
|
QVector<bool> flagLength2;
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
void EvalAngle1();
|
void EvalAngle1();
|
||||||
void EvalAngle2();
|
void EvalAngle2();
|
||||||
|
|
|
@ -77,8 +77,6 @@ template <class T> class QSharedPointer;
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(vDialog, "v.dialog")
|
Q_LOGGING_CATEGORY(vDialog, "v.dialog")
|
||||||
|
|
||||||
#define DIALOG_MAX_FORMULA_HEIGHT 80
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -153,32 +151,19 @@ bool DoubleCurve(const VPieceNode &firstNode, const VPieceNode &secondNode, cons
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogTool::DialogTool(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
data(data),
|
data(data),
|
||||||
isInitialized(false),
|
isInitialized(false),
|
||||||
flagName(true),
|
|
||||||
flagFormula(true),
|
|
||||||
flagError(true),
|
|
||||||
timerFormula(new QTimer(this)),
|
|
||||||
bOk(nullptr),
|
bOk(nullptr),
|
||||||
bApply(nullptr),
|
bApply(nullptr),
|
||||||
spinBoxAngle(nullptr),
|
|
||||||
plainTextEditFormula(nullptr),
|
|
||||||
labelResultCalculation(nullptr),
|
|
||||||
labelEditNamePoint(nullptr),
|
|
||||||
labelEditFormula(nullptr),
|
|
||||||
okColor(this->palette().color(QPalette::Active, QPalette::WindowText)),
|
|
||||||
errorColor(Qt::red),
|
|
||||||
associatedTool(nullptr),
|
associatedTool(nullptr),
|
||||||
toolId(toolId),
|
toolId(toolId),
|
||||||
prepare(false),
|
prepare(false),
|
||||||
pointName(),
|
|
||||||
number(0),
|
number(0),
|
||||||
vis(nullptr)
|
vis(nullptr)
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -226,6 +211,8 @@ void DialogTool::showEvent(QShowEvent *event)
|
||||||
|
|
||||||
isInitialized = true;//first show windows are held
|
isInitialized = true;//first show windows are held
|
||||||
ShowVisualization();
|
ShowVisualization();
|
||||||
|
|
||||||
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -261,13 +248,13 @@ void DialogTool::FillComboBoxPiecesList(QComboBox *box, const QVector<quint32> &
|
||||||
* @brief FillComboBoxPoints fill comboBox list of points
|
* @brief FillComboBoxPoints fill comboBox list of points
|
||||||
* @param box comboBox
|
* @param box comboBox
|
||||||
*/
|
*/
|
||||||
void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
|
void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule, quint32 ch1, quint32 ch2) const
|
||||||
{
|
{
|
||||||
FillCombo<VPointF>(box, GOType::Point, rule, ch1, ch2);
|
FillCombo<VPointF>(box, GOType::Point, rule, ch1, ch2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
|
void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, quint32 ch1, quint32 ch2) const
|
||||||
{
|
{
|
||||||
FillCombo<VAbstractCurve>(box, GOType::Arc, rule, ch1, ch2);
|
FillCombo<VAbstractCurve>(box, GOType::Arc, rule, ch1, ch2);
|
||||||
}
|
}
|
||||||
|
@ -448,43 +435,16 @@ void DialogTool::ChangeCurrentData(QComboBox *box, const QVariant &value) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit) const
|
|
||||||
{
|
|
||||||
SCASSERT(plainTextEdit != nullptr)
|
|
||||||
QTextCursor cursor = plainTextEdit->textCursor();
|
|
||||||
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
|
|
||||||
plainTextEdit->setTextCursor(cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
||||||
{
|
{
|
||||||
if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object))
|
const bool fitered = FilterObject(object, event);
|
||||||
|
if (fitered)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::KeyPress)
|
return fitered;
|
||||||
{
|
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
|
||||||
if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
|
||||||
{
|
|
||||||
if (qApp->Settings()->GetOsSeparator())
|
|
||||||
{
|
|
||||||
plainTextEdit->insertPlainText(QLocale().decimalPoint());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plainTextEdit->insertPlainText(QLocale::c().decimalPoint());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return QDialog::eventFilter(object, event);
|
||||||
// pass the event on to the parent class
|
|
||||||
return QDialog::eventFilter(object, event);
|
|
||||||
}
|
|
||||||
return false;// pass the event to the widget
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -831,146 +791,14 @@ bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const
|
||||||
return obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath;
|
return obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ValFormulaChanged handle change formula
|
|
||||||
* @param flag flag state of formula
|
|
||||||
* @param edit LineEdit
|
|
||||||
* @param timer timer of formula
|
|
||||||
*/
|
|
||||||
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer, const QString& postfix)
|
|
||||||
{
|
|
||||||
SCASSERT(edit != nullptr)
|
|
||||||
SCASSERT(timer != nullptr)
|
|
||||||
SCASSERT(labelEditFormula != nullptr)
|
|
||||||
SCASSERT(labelResultCalculation != nullptr)
|
|
||||||
if (edit->text().isEmpty())
|
|
||||||
{
|
|
||||||
flag = false;
|
|
||||||
CheckState();
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
if (postfix.isEmpty())
|
|
||||||
{
|
|
||||||
labelResultCalculation->setText(tr("Error"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
labelResultCalculation->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
}
|
|
||||||
labelResultCalculation->setToolTip(tr("Empty field"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
timer->start(1000);
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *timer, const QString& postfix)
|
|
||||||
{
|
|
||||||
SCASSERT(edit != nullptr)
|
|
||||||
SCASSERT(timer != nullptr)
|
|
||||||
SCASSERT(labelEditFormula != nullptr)
|
|
||||||
SCASSERT(labelResultCalculation != nullptr)
|
|
||||||
if (edit->toPlainText().isEmpty())
|
|
||||||
{
|
|
||||||
flag = false;
|
|
||||||
CheckState();
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
if (postfix.isEmpty())
|
|
||||||
{
|
|
||||||
labelResultCalculation->setText(tr("Error"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
labelResultCalculation->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
labelResultCalculation->setToolTip(tr("Empty field"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
timer->setSingleShot(true);
|
|
||||||
timer->start(300);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Eval evaluate formula and show result
|
* @brief Eval evaluate formula and show result
|
||||||
* @param text expresion that we parse
|
* @param formulaData options to control parsing
|
||||||
* @param flag flag state of eval formula
|
|
||||||
* @param label label for signal error
|
|
||||||
* @param postfix unit name
|
|
||||||
* @param checkZero true - if formula can't be equal zero
|
|
||||||
*/
|
*/
|
||||||
qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero,
|
qreal DialogTool::Eval(const FormulaData &formulaData, bool &flag)
|
||||||
bool checkLessThanZero)
|
|
||||||
{
|
{
|
||||||
SCASSERT(label != nullptr)
|
const qreal result = EvalToolFormula(this, formulaData, flag);
|
||||||
SCASSERT(labelEditFormula != nullptr)
|
|
||||||
|
|
||||||
qreal result = INT_MIN;//Value can be 0, so use max imposible value
|
|
||||||
|
|
||||||
if (text.isEmpty())
|
|
||||||
{
|
|
||||||
flag = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
label->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
label->setToolTip(tr("Empty field"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Translate to internal look.
|
|
||||||
QString formula = qApp->TrVars()->FormulaFromUser(text, qApp->Settings()->GetOsSeparator());
|
|
||||||
QScopedPointer<Calculator> cal(new Calculator());
|
|
||||||
result = cal->EvalFormula(data->DataVariables(), formula);
|
|
||||||
|
|
||||||
if (qIsInf(result) || qIsNaN(result))
|
|
||||||
{
|
|
||||||
flag = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
label->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
label->setToolTip(tr("Invalid result. Value is infinite or NaN. Please, check your calculations."));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if result equal 0
|
|
||||||
if (checkZero && qFuzzyIsNull(result))
|
|
||||||
{
|
|
||||||
flag = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
label->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
label->setToolTip(tr("Value can't be 0"));
|
|
||||||
}
|
|
||||||
else if (checkLessThanZero && result < 0)
|
|
||||||
{
|
|
||||||
flag = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
label->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
label->setToolTip(tr("Value can't be less than 0"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label->setText(qApp->LocaleToString(result) + QChar(QChar::Space) +postfix);
|
|
||||||
flag = true;
|
|
||||||
ChangeColor(labelEditFormula, okColor);
|
|
||||||
label->setToolTip(tr("Value"));
|
|
||||||
emit ToolTip(QString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (qmu::QmuParserError &e)
|
|
||||||
{
|
|
||||||
label->setText(tr("Error") + " (" + postfix + ")");
|
|
||||||
flag = false;
|
|
||||||
ChangeColor(labelEditFormula, Qt::red);
|
|
||||||
emit ToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
|
||||||
label->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
|
||||||
qDebug() << "\nMath parser error:\n"
|
|
||||||
<< "--------------------------------------\n"
|
|
||||||
<< "Message: " << e.GetMsg() << "\n"
|
|
||||||
<< "Expression: " << e.GetExpr() << "\n"
|
|
||||||
<< "--------------------------------------";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CheckState(); // Disable Ok and Apply buttons if something wrong.
|
CheckState(); // Disable Ok and Apply buttons if something wrong.
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1071,45 +899,6 @@ bool DialogTool::SetObject(const quint32 &id, QComboBox *box, const QString &too
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight)
|
|
||||||
{
|
|
||||||
SCASSERT(formula != nullptr)
|
|
||||||
SCASSERT(buttonGrowLength != nullptr)
|
|
||||||
|
|
||||||
const QTextCursor cursor = formula->textCursor();
|
|
||||||
|
|
||||||
//Before deploy ned to release dialog size
|
|
||||||
//I don't know why, but don't need to fixate again.
|
|
||||||
//A dialog will be lefted fixated. That's what we need.
|
|
||||||
setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
|
||||||
setMinimumSize(QSize(0, 0));
|
|
||||||
|
|
||||||
if (formula->height() < DIALOG_MAX_FORMULA_HEIGHT)
|
|
||||||
{
|
|
||||||
formula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
|
|
||||||
//Set icon from theme (internal for Windows system)
|
|
||||||
buttonGrowLength->setIcon(QIcon::fromTheme("go-next",
|
|
||||||
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
formula->setFixedHeight(formulaBaseHeight);
|
|
||||||
//Set icon from theme (internal for Windows system)
|
|
||||||
buttonGrowLength->setIcon(QIcon::fromTheme("go-down",
|
|
||||||
QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png")));
|
|
||||||
}
|
|
||||||
|
|
||||||
// I found that after change size of formula field, it was filed for angle formula, field for formula became black.
|
|
||||||
// This code prevent this.
|
|
||||||
setUpdatesEnabled(false);
|
|
||||||
repaint();
|
|
||||||
setUpdatesEnabled(true);
|
|
||||||
|
|
||||||
formula->setFocus();
|
|
||||||
formula->setTextCursor(cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief FillList fill combobox list
|
* @brief FillList fill combobox list
|
||||||
|
@ -1161,7 +950,7 @@ bool DialogTool::IsSpline(const QSharedPointer<VGObject> &obj) const
|
||||||
void DialogTool::CheckState()
|
void DialogTool::CheckState()
|
||||||
{
|
{
|
||||||
SCASSERT(bOk != nullptr)
|
SCASSERT(bOk != nullptr)
|
||||||
bOk->setEnabled(flagFormula && flagName && flagError);
|
bOk->setEnabled(IsValid());
|
||||||
// In case dialog hasn't apply button
|
// In case dialog hasn't apply button
|
||||||
if ( bApply != nullptr)
|
if ( bApply != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -1189,43 +978,6 @@ void DialogTool::SelectedObject(bool selected, quint32 object, quint32 tool)
|
||||||
Q_UNUSED(tool)
|
Q_UNUSED(tool)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief NamePointChanged check name of point
|
|
||||||
*/
|
|
||||||
void DialogTool::NamePointChanged()
|
|
||||||
{
|
|
||||||
SCASSERT(labelEditNamePoint != nullptr)
|
|
||||||
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
|
||||||
if (edit)
|
|
||||||
{
|
|
||||||
QString name = edit->text();
|
|
||||||
QRegularExpression rx(NameRegExp());
|
|
||||||
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) ||
|
|
||||||
rx.match(name).hasMatch() == false)
|
|
||||||
{
|
|
||||||
flagName = false;
|
|
||||||
ChangeColor(labelEditNamePoint, Qt::red);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
flagName = true;
|
|
||||||
ChangeColor(labelEditNamePoint, okColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CheckState();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogTool::ChangeColor(QWidget *widget, const QColor &color)
|
|
||||||
{
|
|
||||||
SCASSERT(widget != nullptr)
|
|
||||||
QPalette palette = widget->palette();
|
|
||||||
palette.setColor(QPalette::Active, widget->foregroundRole(), color);
|
|
||||||
palette.setColor(QPalette::Inactive, widget->foregroundRole(), color);
|
|
||||||
widget->setPalette(palette);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief DialogAccepted save data and emit signal about closed dialog.
|
* @brief DialogAccepted save data and emit signal about closed dialog.
|
||||||
|
@ -1252,120 +1004,6 @@ void DialogTool::DialogRejected()
|
||||||
emit DialogClosed(QDialog::Rejected);
|
emit DialogClosed(QDialog::Rejected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief formula check formula
|
|
||||||
*/
|
|
||||||
void DialogTool::FormulaChanged()
|
|
||||||
{
|
|
||||||
QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(sender());
|
|
||||||
if (edit)
|
|
||||||
{
|
|
||||||
ValFormulaChanged(flagFormula, edit, timerFormula);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogTool::FormulaChangedPlainText() //-V524
|
|
||||||
{
|
|
||||||
QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(sender());
|
|
||||||
if (edit)
|
|
||||||
{
|
|
||||||
ValFormulaChanged(flagFormula, edit, timerFormula);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowUp set angle value 90 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowUp()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(90);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowDown set angle value 270 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowDown()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(270);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowLeft set angle value 180 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowLeft()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(180);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowRight set angle value 0 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowRight()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowLeftUp set angle value 135 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowLeftUp()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(135);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowLeftDown set angle value 225 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowLeftDown()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(225);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowRightUp set angle value 45 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowRightUp()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(45);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief ArrowRightDown set angle value 315 degree
|
|
||||||
*/
|
|
||||||
void DialogTool::ArrowRightDown()
|
|
||||||
{
|
|
||||||
SCASSERT(spinBoxAngle != nullptr)
|
|
||||||
spinBoxAngle->setValue(315);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief EvalFormula evaluate formula
|
|
||||||
*/
|
|
||||||
void DialogTool::EvalFormula()
|
|
||||||
{
|
|
||||||
SCASSERT(plainTextEditFormula != nullptr)
|
|
||||||
SCASSERT(labelResultCalculation != nullptr)
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit());//Show unit in dialog lable (cm, mm or inch)
|
|
||||||
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
quint32 DialogTool::GetToolId() const
|
quint32 DialogTool::GetToolId() const
|
||||||
|
@ -1379,12 +1017,6 @@ void DialogTool::SetToolId(const quint32 &value)
|
||||||
toolId = value;
|
toolId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QString DialogTool::getPointName() const
|
|
||||||
{
|
|
||||||
return pointName;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogTool::ShowDialog(bool click)
|
void DialogTool::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
|
#include "../dialogtoolbox.h"
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ class DialogTool : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogTool(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogTool() override;
|
virtual ~DialogTool() override;
|
||||||
|
|
||||||
VAbstractTool* GetAssociatedTool();
|
VAbstractTool* GetAssociatedTool();
|
||||||
|
@ -90,8 +91,6 @@ public:
|
||||||
quint32 GetToolId() const;
|
quint32 GetToolId() const;
|
||||||
void SetToolId(const quint32 &value);
|
void SetToolId(const quint32 &value);
|
||||||
|
|
||||||
QString getPointName() const;
|
|
||||||
|
|
||||||
static void MoveListRowTop(QListWidget *list);
|
static void MoveListRowTop(QListWidget *list);
|
||||||
static void MoveListRowUp(QListWidget *list);
|
static void MoveListRowUp(QListWidget *list);
|
||||||
static void MoveListRowDown(QListWidget *list);
|
static void MoveListRowDown(QListWidget *list);
|
||||||
|
@ -114,32 +113,14 @@ signals:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||||
virtual void SelectedObject(bool selected, quint32 object, quint32 tool);
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool);
|
||||||
void NamePointChanged();
|
|
||||||
virtual void DialogAccepted();
|
virtual void DialogAccepted();
|
||||||
/**
|
/**
|
||||||
* @brief DialogApply save data and emit signal DialogApplied.
|
* @brief DialogApply save data and emit signal DialogApplied.
|
||||||
*/
|
*/
|
||||||
virtual void DialogApply();
|
virtual void DialogApply();
|
||||||
virtual void DialogRejected();
|
virtual void DialogRejected();
|
||||||
void FormulaChanged();
|
|
||||||
/**
|
|
||||||
* @brief FormulaChangedPlainText check formula (plain text editor editor)
|
|
||||||
*/
|
|
||||||
void FormulaChangedPlainText();
|
|
||||||
void ArrowUp();
|
|
||||||
void ArrowDown();
|
|
||||||
void ArrowLeft();
|
|
||||||
void ArrowRight();
|
|
||||||
void ArrowLeftUp();
|
|
||||||
void ArrowLeftDown();
|
|
||||||
void ArrowRightUp();
|
|
||||||
void ArrowRightDown();
|
|
||||||
virtual void EvalFormula();
|
|
||||||
|
|
||||||
virtual void PointNameChanged() {}
|
virtual void PointNameChanged() {}
|
||||||
protected:
|
protected:
|
||||||
Q_DISABLE_COPY(DialogTool)
|
|
||||||
|
|
||||||
/** @brief data container with data */
|
/** @brief data container with data */
|
||||||
// cppcheck-suppress duplInheritedMember
|
// cppcheck-suppress duplInheritedMember
|
||||||
const VContainer *data;
|
const VContainer *data;
|
||||||
|
@ -147,45 +128,12 @@ protected:
|
||||||
/** @brief isInitialized true if window is initialized */
|
/** @brief isInitialized true if window is initialized */
|
||||||
bool isInitialized;
|
bool isInitialized;
|
||||||
|
|
||||||
/** @brief flagName true if name is correct */
|
|
||||||
bool flagName;
|
|
||||||
|
|
||||||
/** @brief flagFormula true if formula correct */
|
|
||||||
bool flagFormula;
|
|
||||||
|
|
||||||
/** @brief flagError use this flag if for you do not enought @see flagName and @see flagFormula.
|
|
||||||
*
|
|
||||||
* In many cases you will need more flags fore checking if all data are valid.
|
|
||||||
* By default this flag is true.
|
|
||||||
*/
|
|
||||||
bool flagError;
|
|
||||||
|
|
||||||
/** @brief timerFormula timer for check formula */
|
|
||||||
QTimer *timerFormula;
|
|
||||||
|
|
||||||
/** @brief bOk button ok */
|
/** @brief bOk button ok */
|
||||||
QPushButton *bOk;
|
QPushButton *bOk;
|
||||||
|
|
||||||
/** @brief bApply button apply */
|
/** @brief bApply button apply */
|
||||||
QPushButton *bApply;
|
QPushButton *bApply;
|
||||||
|
|
||||||
/** @brief spinBoxAngle spinbox for angle */
|
|
||||||
QDoubleSpinBox *spinBoxAngle;
|
|
||||||
|
|
||||||
/** @brief plainTextEditFormula formula */
|
|
||||||
QPlainTextEdit *plainTextEditFormula;
|
|
||||||
|
|
||||||
/** @brief labelResultCalculation label with result of calculation */
|
|
||||||
QLabel *labelResultCalculation;
|
|
||||||
|
|
||||||
/** @brief labelEditNamePoint label used when need show wrong name of point */
|
|
||||||
QLabel *labelEditNamePoint;
|
|
||||||
|
|
||||||
/** @brief labelEditFormula label used when need show wrong formula */
|
|
||||||
QLabel *labelEditFormula;
|
|
||||||
|
|
||||||
const QColor okColor;
|
|
||||||
const QColor errorColor;
|
|
||||||
/**
|
/**
|
||||||
* @brief associatedTool vdrawtool associated with opened dialog.
|
* @brief associatedTool vdrawtool associated with opened dialog.
|
||||||
*/
|
*/
|
||||||
|
@ -195,9 +143,6 @@ protected:
|
||||||
/** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/
|
/** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/
|
||||||
bool prepare;
|
bool prepare;
|
||||||
|
|
||||||
/** @brief pointName name of point */
|
|
||||||
QString pointName;
|
|
||||||
|
|
||||||
/** @brief number number of handled objects */
|
/** @brief number number of handled objects */
|
||||||
qint32 number;
|
qint32 number;
|
||||||
|
|
||||||
|
@ -206,12 +151,16 @@ protected:
|
||||||
virtual void closeEvent ( QCloseEvent * event ) override;
|
virtual void closeEvent ( QCloseEvent * event ) override;
|
||||||
virtual void showEvent( QShowEvent *event ) override;
|
virtual void showEvent( QShowEvent *event ) override;
|
||||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
|
|
||||||
|
virtual bool IsValid() const =0;
|
||||||
|
virtual void CheckState();
|
||||||
|
|
||||||
void FillComboBoxPiecesList(QComboBox *box, const QVector<quint32> &list);
|
void FillComboBoxPiecesList(QComboBox *box, const QVector<quint32> &list);
|
||||||
void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
||||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
quint32 ch1 = NULL_ID, quint32 ch2 = NULL_ID) const;
|
||||||
void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
||||||
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
quint32 ch1 = NULL_ID, quint32 ch2 = NULL_ID) const;
|
||||||
void FillComboBoxSplines(QComboBox *box)const;
|
void FillComboBoxSplines(QComboBox *box)const;
|
||||||
void FillComboBoxSplinesPath(QComboBox *box)const;
|
void FillComboBoxSplinesPath(QComboBox *box)const;
|
||||||
void FillComboBoxCurves(QComboBox *box)const;
|
void FillComboBoxCurves(QComboBox *box)const;
|
||||||
|
@ -221,14 +170,10 @@ protected:
|
||||||
void FillComboBoxVCrossCurvesPoint(QComboBox *box) const;
|
void FillComboBoxVCrossCurvesPoint(QComboBox *box) const;
|
||||||
void FillComboBoxHCrossCurvesPoint(QComboBox *box) const;
|
void FillComboBoxHCrossCurvesPoint(QComboBox *box) const;
|
||||||
|
|
||||||
virtual void CheckState();
|
|
||||||
QString GetComboBoxCurrentData(const QComboBox *box, const QString &def)const;
|
QString GetComboBoxCurrentData(const QComboBox *box, const QString &def)const;
|
||||||
void ChangeCurrentData(QComboBox *box, const QVariant &value) const;
|
void ChangeCurrentData(QComboBox *box, const QVariant &value) const;
|
||||||
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer, const QString &postfix = QString());
|
qreal Eval(const FormulaData &formulaData, bool &flag);
|
||||||
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer,
|
|
||||||
const QString &postfix = QString());
|
|
||||||
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
|
|
||||||
bool checkZero = true, bool checkLessThanZero = false);
|
|
||||||
|
|
||||||
void setCurrentPointId(QComboBox *box, const quint32 &value,
|
void setCurrentPointId(QComboBox *box, const quint32 &value,
|
||||||
FillComboBox rule = FillComboBox::NoChildren,
|
FillComboBox rule = FillComboBox::NoChildren,
|
||||||
|
@ -246,10 +191,6 @@ protected:
|
||||||
T getCurrentCrossPoint(QComboBox *box) const;
|
T getCurrentCrossPoint(QComboBox *box) const;
|
||||||
|
|
||||||
bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip);
|
bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip);
|
||||||
void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void InitArrow(T *ui);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void InitOkCancelApply(T *ui);
|
void InitOkCancelApply(T *ui);
|
||||||
|
@ -257,23 +198,17 @@ protected:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void InitOkCancel(T *ui);
|
void InitOkCancel(T *ui);
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void InitFormulaUI(T *ui);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddVisualization();
|
void AddVisualization();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QVector<T> GetListInternals(const QListWidget *list) const;
|
QVector<T> GetListInternals(const QListWidget *list) const;
|
||||||
|
|
||||||
void ChangeColor(QWidget *widget, const QColor &color);
|
|
||||||
virtual void ShowVisualization() {}
|
virtual void ShowVisualization() {}
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() {}
|
virtual void SaveData() {}
|
||||||
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit) const;
|
|
||||||
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
|
||||||
quint32 DNumber(const QString &baseName) const;
|
quint32 DNumber(const QString &baseName) const;
|
||||||
|
|
||||||
static int FindNotExcludedNodeDown(QListWidget *listWidget, int candidate);
|
static int FindNotExcludedNodeDown(QListWidget *listWidget, int candidate);
|
||||||
|
@ -290,6 +225,7 @@ protected:
|
||||||
|
|
||||||
void InitNodeAngles(QComboBox *box);
|
void InitNodeAngles(QComboBox *box);
|
||||||
private:
|
private:
|
||||||
|
Q_DISABLE_COPY(DialogTool)
|
||||||
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -325,22 +261,6 @@ inline VAbstractTool *DialogTool::GetAssociatedTool()
|
||||||
return this->associatedTool;
|
return this->associatedTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
template <typename T>
|
|
||||||
inline void DialogTool::InitArrow(T *ui)
|
|
||||||
{
|
|
||||||
SCASSERT(ui != nullptr)
|
|
||||||
spinBoxAngle = ui->doubleSpinBoxAngle;
|
|
||||||
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, &DialogTool::ArrowDown);
|
|
||||||
connect(ui->toolButtonArrowUp, &QPushButton::clicked, this, &DialogTool::ArrowUp);
|
|
||||||
connect(ui->toolButtonArrowLeft, &QPushButton::clicked, this, &DialogTool::ArrowLeft);
|
|
||||||
connect(ui->toolButtonArrowRight, &QPushButton::clicked, this, &DialogTool::ArrowRight);
|
|
||||||
connect(ui->toolButtonArrowLeftUp, &QPushButton::clicked, this, &DialogTool::ArrowLeftUp);
|
|
||||||
connect(ui->toolButtonArrowLeftDown, &QPushButton::clicked, this, &DialogTool::ArrowLeftDown);
|
|
||||||
connect(ui->toolButtonArrowRightUp, &QPushButton::clicked, this, &DialogTool::ArrowRightUp);
|
|
||||||
connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this, &DialogTool::ArrowRightDown);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
/**
|
/**
|
||||||
|
@ -374,19 +294,6 @@ inline void DialogTool::InitOkCancel(T *ui)
|
||||||
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
template <typename T>
|
|
||||||
/**
|
|
||||||
* @brief InitFormulaUI initialise ui object for formula fild
|
|
||||||
* @param ui Dialog container
|
|
||||||
*/
|
|
||||||
inline void DialogTool::InitFormulaUI(T *ui)
|
|
||||||
{
|
|
||||||
labelResultCalculation = ui->labelResultCalculation;
|
|
||||||
plainTextEditFormula = ui->plainTextEditFormula;
|
|
||||||
labelEditFormula = ui->labelEditFormula;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void DialogTool::AddVisualization()
|
inline void DialogTool::AddVisualization()
|
||||||
|
|
|
@ -48,25 +48,31 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogTriangle::DialogTriangle(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle)
|
: DialogTool(data, toolId, parent),
|
||||||
|
ui(new Ui::DialogTriangle),
|
||||||
|
pointName(),
|
||||||
|
flagName(false),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
DialogTool::CheckState();
|
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxAxisP1);
|
FillComboBoxPoints(ui->comboBoxAxisP1);
|
||||||
FillComboBoxPoints(ui->comboBoxAxisP2);
|
FillComboBoxPoints(ui->comboBoxAxisP2);
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged);
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||||
|
CheckState();
|
||||||
|
});
|
||||||
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxFirstPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogTriangle::PointNameChanged);
|
this, &DialogTriangle::PointNameChanged);
|
||||||
connect(ui->comboBoxSecondPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxSecondPoint, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -189,7 +195,7 @@ void DialogTriangle::PointNameChanged()
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
|
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
|
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() < 3)//Need tree or more unique points for creation triangle
|
if (set.size() < 3)//Need tree or more unique points for creation triangle
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -198,7 +204,7 @@ void DialogTriangle::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
ChangeColor(ui->labelSecondPoint, color);
|
ChangeColor(ui->labelSecondPoint, color);
|
||||||
|
@ -235,7 +241,13 @@ void DialogTriangle::SetSecondPointId(const quint32 &value)
|
||||||
|
|
||||||
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
|
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setHypotenuseP2Id(value);
|
line->setHypotenuseP2Id(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogTriangle::GetPointName() const
|
||||||
|
{
|
||||||
|
return pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DialogTriangle : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogTriangle(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogTriangle() override;
|
virtual ~DialogTriangle() override;
|
||||||
|
|
||||||
quint32 GetAxisP1Id() const;
|
quint32 GetAxisP1Id() const;
|
||||||
|
@ -65,6 +65,7 @@ public:
|
||||||
quint32 GetSecondPointId() const;
|
quint32 GetSecondPointId() const;
|
||||||
void SetSecondPointId(const quint32 &value);
|
void SetSecondPointId(const quint32 &value);
|
||||||
|
|
||||||
|
QString GetPointName() const;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
@ -75,11 +76,23 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogTriangle)
|
Q_DISABLE_COPY(DialogTriangle)
|
||||||
|
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogTriangle *ui;
|
Ui::DialogTriangle *ui;
|
||||||
|
|
||||||
|
QString pointName;
|
||||||
|
|
||||||
|
bool flagName;
|
||||||
|
bool flagError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogTriangle::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGTRIANGLE_H
|
#endif // DIALOGTRIANGLE_H
|
||||||
|
|
|
@ -50,9 +50,16 @@
|
||||||
#include "ui_dialogtruedarts.h"
|
#include "ui_dialogtruedarts.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogTrueDarts::DialogTrueDarts(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogTrueDarts::DialogTrueDarts(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogTrueDarts), d1PointName(), d2PointName(), ch1(NULL_ID),
|
: DialogTool(data, toolId, parent),
|
||||||
ch2(NULL_ID), flagName1(true), flagName2(true)
|
ui(new Ui::DialogTrueDarts),
|
||||||
|
d1PointName(),
|
||||||
|
d2PointName(),
|
||||||
|
ch1(NULL_ID),
|
||||||
|
ch2(NULL_ID),
|
||||||
|
flagName1(true),
|
||||||
|
flagName2(true),
|
||||||
|
flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -65,7 +72,6 @@ DialogTrueDarts::DialogTrueDarts(const VContainer *data, const quint32 &toolId,
|
||||||
ui->lineEditSecondNewDartPoint->setText(name2);
|
ui->lineEditSecondNewDartPoint->setText(name2);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
CheckState();
|
|
||||||
|
|
||||||
FillComboBoxs(ch1, ch2);
|
FillComboBoxs(ch1, ch2);
|
||||||
|
|
||||||
|
@ -317,7 +323,7 @@ void DialogTrueDarts::PointNameChanged()
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint));
|
set.insert(getCurrentObjectId(ui->comboBoxSecondDartPoint));
|
||||||
set.insert(getCurrentObjectId(ui->comboBoxThirdDartPoint));
|
set.insert(getCurrentObjectId(ui->comboBoxThirdDartPoint));
|
||||||
|
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (set.size() != 5)
|
if (set.size() != 5)
|
||||||
{
|
{
|
||||||
flagError = false;
|
flagError = false;
|
||||||
|
@ -326,7 +332,7 @@ void DialogTrueDarts::PointNameChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstBasePoint, color);
|
ChangeColor(ui->labelFirstBasePoint, color);
|
||||||
ChangeColor(ui->labelSecondBasePoint, color);
|
ChangeColor(ui->labelSecondBasePoint, color);
|
||||||
|
@ -371,18 +377,6 @@ void DialogTrueDarts::SaveData()
|
||||||
points->RefreshGeometry();
|
points->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogTrueDarts::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr)
|
|
||||||
bOk->setEnabled(flagName1 && flagName2 && flagError);
|
|
||||||
// In case dialog hasn't apply button
|
|
||||||
if ( bApply != nullptr)
|
|
||||||
{
|
|
||||||
bApply->setEnabled(bOk->isEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogTrueDarts::NameChanged(QLabel *labelEditNamePoint, const QString &pointD1Name, const QString &pointD2Name,
|
void DialogTrueDarts::NameChanged(QLabel *labelEditNamePoint, const QString &pointD1Name, const QString &pointD2Name,
|
||||||
QLineEdit* secondPointName, bool &flagName)
|
QLineEdit* secondPointName, bool &flagName)
|
||||||
|
@ -424,11 +418,11 @@ void DialogTrueDarts::CheckName(QLineEdit *edit, QLabel *labelEditNamePoint, con
|
||||||
|| rx.match(name).hasMatch() == false)
|
|| rx.match(name).hasMatch() == false)
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(labelEditNamePoint, Qt::red);
|
ChangeColor(labelEditNamePoint, errorColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagName = true;
|
flagName = true;
|
||||||
ChangeColor(labelEditNamePoint, okColor);
|
ChangeColor(labelEditNamePoint, OkColor(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class DialogTrueDarts : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogTrueDarts(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogTrueDarts(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
~DialogTrueDarts();
|
~DialogTrueDarts();
|
||||||
|
|
||||||
QString GetFirstNewDartPointName();
|
QString GetFirstNewDartPointName();
|
||||||
|
@ -82,7 +82,7 @@ protected:
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void CheckState() final;
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogTrueDarts)
|
Q_DISABLE_COPY(DialogTrueDarts)
|
||||||
|
@ -96,6 +96,7 @@ private:
|
||||||
|
|
||||||
bool flagName1;
|
bool flagName1;
|
||||||
bool flagName2;
|
bool flagName2;
|
||||||
|
bool flagError;
|
||||||
|
|
||||||
void NameChanged(QLabel *labelEditNamePoint, const QString &pointD1Name, const QString &pointD2Name,
|
void NameChanged(QLabel *labelEditNamePoint, const QString &pointD1Name, const QString &pointD2Name,
|
||||||
QLineEdit *secondPointName, bool &flagName);
|
QLineEdit *secondPointName, bool &flagName);
|
||||||
|
@ -106,4 +107,10 @@ private:
|
||||||
QLineEdit *secondPointName, bool &flagName);
|
QLineEdit *secondPointName, bool &flagName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogTrueDarts::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName1 && flagName2 && flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGTRUEDARTS_H
|
#endif // DIALOGTRUEDARTS_H
|
||||||
|
|
|
@ -44,9 +44,17 @@
|
||||||
* @param data container with data
|
* @param data container with data
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogUnionDetails::DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogUnionDetails::DialogUnionDetails(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogUnionDetails), indexD1(0), indexD2(0), d1(NULL_ID), d2(NULL_ID),
|
: DialogTool(data, toolId, parent),
|
||||||
numberD(0), numberP(0), p1(NULL_ID), p2(NULL_ID)
|
ui(new Ui::DialogUnionDetails),
|
||||||
|
indexD1(0),
|
||||||
|
indexD2(0),
|
||||||
|
d1(NULL_ID),
|
||||||
|
d2(NULL_ID),
|
||||||
|
numberD(0),
|
||||||
|
numberP(0),
|
||||||
|
p1(NULL_ID),
|
||||||
|
p2(NULL_ID)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DialogUnionDetails : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogUnionDetails(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogUnionDetails() override;
|
virtual ~DialogUnionDetails() override;
|
||||||
|
|
||||||
quint32 getD1() const;
|
quint32 getD1() const;
|
||||||
|
@ -61,6 +61,8 @@ public:
|
||||||
bool RetainPieces() const;
|
bool RetainPieces() const;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
protected:
|
||||||
|
virtual bool IsValid() const final {return true;}
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogUnionDetails)
|
Q_DISABLE_COPY(DialogUnionDetails)
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "../../../visualization/path/vistoolduplicatedetail.h"
|
#include "../../../visualization/path/vistoolduplicatedetail.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogDuplicateDetail::DialogDuplicateDetail(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogDuplicateDetail::DialogDuplicateDetail(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogDuplicateDetail),
|
ui(new Ui::DialogDuplicateDetail),
|
||||||
m_idDetail(NULL_ID),
|
m_idDetail(NULL_ID),
|
||||||
|
|
|
@ -40,7 +40,7 @@ class DialogDuplicateDetail : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogDuplicateDetail(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
explicit DialogDuplicateDetail(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogDuplicateDetail();
|
virtual ~DialogDuplicateDetail();
|
||||||
|
|
||||||
quint32 Duplicate() const;
|
quint32 Duplicate() const;
|
||||||
|
@ -50,6 +50,8 @@ public:
|
||||||
virtual void ShowDialog(bool click) override;
|
virtual void ShowDialog(bool click) override;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
protected:
|
||||||
|
virtual bool IsValid() const final {return true;}
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogDuplicateDetail)
|
Q_DISABLE_COPY(DialogDuplicateDetail)
|
||||||
Ui::DialogDuplicateDetail *ui;
|
Ui::DialogDuplicateDetail *ui;
|
||||||
|
|
|
@ -35,7 +35,8 @@ DialogInsertNode::DialogInsertNode(const VContainer *data, quint32 toolId, QWidg
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogInsertNode),
|
ui(new Ui::DialogInsertNode),
|
||||||
m_node(),
|
m_node(),
|
||||||
m_flagItem(false)
|
m_flagItem(false),
|
||||||
|
m_flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
|
@ -162,26 +163,19 @@ void DialogInsertNode::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogInsertNode::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr);
|
|
||||||
bOk->setEnabled(m_flagItem && flagError);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogInsertNode::CheckPieces()
|
void DialogInsertNode::CheckPieces()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (ui->comboBoxPiece->count() <= 0 || ui->comboBoxPiece->currentIndex() == -1)
|
if (ui->comboBoxPiece->count() <= 0 || ui->comboBoxPiece->currentIndex() == -1)
|
||||||
{
|
{
|
||||||
flagError = false;
|
m_flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
m_flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelPiece, color);
|
ChangeColor(ui->labelPiece, color);
|
||||||
CheckState();
|
CheckState();
|
||||||
|
@ -190,8 +184,8 @@ void DialogInsertNode::CheckPieces()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogInsertNode::CheckItem()
|
void DialogInsertNode::CheckItem()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
m_flagItem ? color = okColor : color = errorColor;
|
m_flagItem ? color = OkColor(this) : color = errorColor;
|
||||||
ChangeColor(ui->labelItem, color);
|
ChangeColor(ui->labelItem, color);
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogInsertNode)
|
Q_DISABLE_COPY(DialogInsertNode)
|
||||||
|
@ -65,9 +65,16 @@ private:
|
||||||
|
|
||||||
VPieceNode m_node;
|
VPieceNode m_node;
|
||||||
bool m_flagItem;
|
bool m_flagItem;
|
||||||
|
bool m_flagError;
|
||||||
|
|
||||||
void CheckPieces();
|
void CheckPieces();
|
||||||
void CheckItem();
|
void CheckItem();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogInsertNode::IsValid() const
|
||||||
|
{
|
||||||
|
return m_flagItem && m_flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGINSERTNODE_H
|
#endif // DIALOGINSERTNODE_H
|
||||||
|
|
|
@ -68,7 +68,10 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
|
||||||
m_formulaBaseVisible(0),
|
m_formulaBaseVisible(0),
|
||||||
m_flagFormulaBefore(true),
|
m_flagFormulaBefore(true),
|
||||||
m_flagFormulaAfter(true),
|
m_flagFormulaAfter(true),
|
||||||
m_flagFormulaVisible(true)
|
m_flagFormulaVisible(true),
|
||||||
|
m_flagName(true),//We have default name of piece.
|
||||||
|
m_flagError(false),
|
||||||
|
m_flagFormula(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
|
@ -80,9 +83,7 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
|
||||||
|
|
||||||
EvalVisible();
|
EvalVisible();
|
||||||
|
|
||||||
flagName = true;//We have default name of piece.
|
m_flagError = PathIsValid();
|
||||||
flagError = PathIsValid();
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
vis = new VisToolPiecePath(data);
|
vis = new VisToolPiecePath(data);
|
||||||
|
|
||||||
|
@ -219,7 +220,7 @@ void DialogPiecePath::CheckState()
|
||||||
SCASSERT(bOk != nullptr);
|
SCASSERT(bOk != nullptr);
|
||||||
if (GetType() == PiecePathType::InternalPath)
|
if (GetType() == PiecePathType::InternalPath)
|
||||||
{
|
{
|
||||||
flagFormula = true;
|
m_flagFormula = true;
|
||||||
m_flagFormulaBefore = true;
|
m_flagFormulaBefore = true;
|
||||||
m_flagFormulaAfter = true;
|
m_flagFormulaAfter = true;
|
||||||
}
|
}
|
||||||
|
@ -228,17 +229,16 @@ void DialogPiecePath::CheckState()
|
||||||
m_flagFormulaVisible = true; // Works only for internal paths
|
m_flagFormulaVisible = true; // Works only for internal paths
|
||||||
if (not m_showMode)
|
if (not m_showMode)
|
||||||
{
|
{
|
||||||
flagFormula = true;
|
m_flagFormula = true;
|
||||||
m_flagFormulaBefore = true;
|
m_flagFormulaBefore = true;
|
||||||
m_flagFormulaAfter = true;
|
m_flagFormulaAfter = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bOk->setEnabled(flagName && flagError && flagFormula && m_flagFormulaBefore && m_flagFormulaAfter
|
bOk->setEnabled(IsValid());
|
||||||
&& m_flagFormulaVisible);
|
|
||||||
|
|
||||||
const int tabSeamAllowanceIndex = ui->tabWidget->indexOf(ui->tabSeamAllowance);
|
const int tabSeamAllowanceIndex = ui->tabWidget->indexOf(ui->tabSeamAllowance);
|
||||||
if (flagFormula && m_flagFormulaBefore && m_flagFormulaAfter)
|
if (m_flagFormula && m_flagFormulaBefore && m_flagFormulaAfter)
|
||||||
{
|
{
|
||||||
ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, QIcon());
|
ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, QIcon());
|
||||||
}
|
}
|
||||||
|
@ -391,13 +391,13 @@ void DialogPiecePath::NameChanged()
|
||||||
{
|
{
|
||||||
if (ui->lineEditName->text().isEmpty())
|
if (ui->lineEditName->text().isEmpty())
|
||||||
{
|
{
|
||||||
flagName = false;
|
m_flagName = false;
|
||||||
ChangeColor(ui->labelName, Qt::red);
|
ChangeColor(ui->labelName, errorColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagName = true;
|
m_flagName = true;
|
||||||
ChangeColor(ui->labelName, okColor);
|
ChangeColor(ui->labelName, OkColor(this));
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
@ -736,10 +736,16 @@ void DialogPiecePath::PassmarkShowSecondChanged(int state)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::EvalWidth()
|
void DialogPiecePath::EvalWidth()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditWidth;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditFormulaWidth->toPlainText();
|
||||||
const QString formula = ui->plainTextEditFormulaWidth->toPlainText();
|
formulaData.variables = data->DataVariables();
|
||||||
m_saWidth = Eval(formula, flagFormula, ui->labelResultWidth, postfix, false, true);
|
formulaData.labelEditFormula = ui->labelEditWidth;
|
||||||
|
formulaData.labelResult = ui->labelResultWidth;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
m_saWidth = Eval(formulaData, m_flagFormula);
|
||||||
|
|
||||||
if (m_saWidth >= 0)
|
if (m_saWidth >= 0)
|
||||||
{
|
{
|
||||||
|
@ -759,14 +765,18 @@ void DialogPiecePath::EvalWidth()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::EvalWidthBefore()
|
void DialogPiecePath::EvalWidthBefore()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditBefore;
|
|
||||||
if (ui->comboBoxNodes->count() > 0)
|
if (ui->comboBoxNodes->count() > 0)
|
||||||
{
|
{
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
FormulaData formulaData;
|
||||||
QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText();
|
formulaData.formula = ui->plainTextEditFormulaWidthBefore->toPlainText();
|
||||||
Eval(formula, m_flagFormulaBefore, ui->labelResultBefore, postfix, false, true);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditBefore;
|
||||||
|
formulaData.labelResult = ui->labelResultBefore;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
formula = GetFormulaSAWidthBefore();
|
const QString formula = GetFormulaSAWidthBefore();
|
||||||
if (formula != currentSeamAllowance)
|
if (formula != currentSeamAllowance)
|
||||||
{
|
{
|
||||||
ui->pushButtonDefBefore->setEnabled(true);
|
ui->pushButtonDefBefore->setEnabled(true);
|
||||||
|
@ -776,7 +786,7 @@ void DialogPiecePath::EvalWidthBefore()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChangeColor(labelEditFormula, okColor);
|
ChangeColor(ui->labelEditBefore, OkColor(this));
|
||||||
ui->labelResultBefore->setText(tr("<Empty>"));
|
ui->labelResultBefore->setText(tr("<Empty>"));
|
||||||
m_flagFormulaBefore = true;
|
m_flagFormulaBefore = true;
|
||||||
}
|
}
|
||||||
|
@ -785,14 +795,18 @@ void DialogPiecePath::EvalWidthBefore()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::EvalWidthAfter()
|
void DialogPiecePath::EvalWidthAfter()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditAfter;
|
|
||||||
if (ui->comboBoxNodes->count() > 0)
|
if (ui->comboBoxNodes->count() > 0)
|
||||||
{
|
{
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
FormulaData formulaData;
|
||||||
QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText();
|
formulaData.formula = ui->plainTextEditFormulaWidthAfter->toPlainText();
|
||||||
Eval(formula, m_flagFormulaAfter, ui->labelResultAfter, postfix, false, true);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditAfter;
|
||||||
|
formulaData.labelResult = ui->labelResultAfter;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
formula = GetFormulaSAWidthAfter();
|
const QString formula = GetFormulaSAWidthAfter();
|
||||||
if (formula != currentSeamAllowance)
|
if (formula != currentSeamAllowance)
|
||||||
{
|
{
|
||||||
ui->pushButtonDefAfter->setEnabled(true);
|
ui->pushButtonDefAfter->setEnabled(true);
|
||||||
|
@ -802,7 +816,7 @@ void DialogPiecePath::EvalWidthAfter()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChangeColor(labelEditFormula, okColor);
|
ChangeColor(ui->labelEditAfter, OkColor(this));
|
||||||
ui->labelResultAfter->setText(tr("<Empty>"));
|
ui->labelResultAfter->setText(tr("<Empty>"));
|
||||||
m_flagFormulaAfter = true;
|
m_flagFormulaAfter = true;
|
||||||
}
|
}
|
||||||
|
@ -811,9 +825,16 @@ void DialogPiecePath::EvalWidthAfter()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::EvalVisible()
|
void DialogPiecePath::EvalVisible()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditVisible;
|
FormulaData formulaData;
|
||||||
QString formula = ui->plainTextEditFormulaVisible->toPlainText();
|
formulaData.formula = ui->plainTextEditFormulaVisible->toPlainText();
|
||||||
Eval(formula, m_flagFormulaVisible, ui->labelResultVisible, QString(), false, true);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditVisible;
|
||||||
|
formulaData.labelResult = ui->labelResultVisible;
|
||||||
|
formulaData.postfix = QString();
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
Eval(formulaData, m_flagFormulaVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -870,63 +891,28 @@ void DialogPiecePath::FXVisible()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPiecePath::WidthChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditWidth;
|
|
||||||
labelResultCalculation = ui->labelResultWidth;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidth, m_timerWidth, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPiecePath::WidthBeforeChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditBefore;
|
|
||||||
labelResultCalculation = ui->labelResultBefore;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(m_flagFormulaBefore, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPiecePath::WidthAfterChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditAfter;
|
|
||||||
labelResultCalculation = ui->labelResultAfter;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(m_flagFormulaAfter, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPiecePath::VisibleChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditVisible;
|
|
||||||
labelResultCalculation = ui->labelResultVisible;
|
|
||||||
ValFormulaChanged(m_flagFormulaVisible, ui->plainTextEditFormulaVisible, m_timerVisible, QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::DeployWidthFormulaTextEdit()
|
void DialogPiecePath::DeployWidthFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaWidth, ui->pushButtonGrowWidth, m_formulaBaseWidth);
|
DeployFormula(this, ui->plainTextEditFormulaWidth, ui->pushButtonGrowWidth, m_formulaBaseWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::DeployWidthBeforeFormulaTextEdit()
|
void DialogPiecePath::DeployWidthBeforeFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaWidthBefore, ui->pushButtonGrowWidthBefore, m_formulaBaseWidthBefore);
|
DeployFormula(this, ui->plainTextEditFormulaWidthBefore, ui->pushButtonGrowWidthBefore, m_formulaBaseWidthBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::DeployWidthAfterFormulaTextEdit()
|
void DialogPiecePath::DeployWidthAfterFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaWidthAfter, ui->pushButtonGrowWidthAfter, m_formulaBaseWidthAfter);
|
DeployFormula(this, ui->plainTextEditFormulaWidthAfter, ui->pushButtonGrowWidthAfter, m_formulaBaseWidthAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::DeployVisibleFormulaTextEdit()
|
void DialogPiecePath::DeployVisibleFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
|
DeployFormula(this, ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -994,7 +980,6 @@ void DialogPiecePath::InitPathTab()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::InitSeamAllowanceTab()
|
void DialogPiecePath::InitSeamAllowanceTab()
|
||||||
{
|
{
|
||||||
plainTextEditFormula = ui->plainTextEditFormulaWidth;
|
|
||||||
this->m_formulaBaseWidth = ui->plainTextEditFormulaWidth->height();
|
this->m_formulaBaseWidth = ui->plainTextEditFormulaWidth->height();
|
||||||
this->m_formulaBaseWidthBefore = ui->plainTextEditFormulaWidthBefore->height();
|
this->m_formulaBaseWidthBefore = ui->plainTextEditFormulaWidthBefore->height();
|
||||||
this->m_formulaBaseWidthAfter = ui->plainTextEditFormulaWidthAfter->height();
|
this->m_formulaBaseWidthAfter = ui->plainTextEditFormulaWidthAfter->height();
|
||||||
|
@ -1003,6 +988,10 @@ void DialogPiecePath::InitSeamAllowanceTab()
|
||||||
ui->plainTextEditFormulaWidthBefore->installEventFilter(this);
|
ui->plainTextEditFormulaWidthBefore->installEventFilter(this);
|
||||||
ui->plainTextEditFormulaWidthAfter->installEventFilter(this);
|
ui->plainTextEditFormulaWidthAfter->installEventFilter(this);
|
||||||
|
|
||||||
|
m_timerWidth->setSingleShot(true);
|
||||||
|
m_timerWidthBefore->setSingleShot(true);
|
||||||
|
m_timerWidthAfter->setSingleShot(true);
|
||||||
|
|
||||||
connect(m_timerWidth, &QTimer::timeout, this, &DialogPiecePath::EvalWidth);
|
connect(m_timerWidth, &QTimer::timeout, this, &DialogPiecePath::EvalWidth);
|
||||||
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogPiecePath::EvalWidthBefore);
|
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogPiecePath::EvalWidthBefore);
|
||||||
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogPiecePath::EvalWidthAfter);
|
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogPiecePath::EvalWidthAfter);
|
||||||
|
@ -1026,11 +1015,20 @@ void DialogPiecePath::InitSeamAllowanceTab()
|
||||||
connect(ui->toolButtonExprBefore, &QPushButton::clicked, this, &DialogPiecePath::FXWidthBefore);
|
connect(ui->toolButtonExprBefore, &QPushButton::clicked, this, &DialogPiecePath::FXWidthBefore);
|
||||||
connect(ui->toolButtonExprAfter, &QPushButton::clicked, this, &DialogPiecePath::FXWidthAfter);
|
connect(ui->toolButtonExprAfter, &QPushButton::clicked, this, &DialogPiecePath::FXWidthAfter);
|
||||||
|
|
||||||
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, &DialogPiecePath::WidthChanged);
|
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this,
|
{
|
||||||
&DialogPiecePath::WidthBeforeChanged);
|
m_timerWidth->start(formulaTimerTimeout);
|
||||||
connect(ui->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this,
|
});
|
||||||
&DialogPiecePath::WidthAfterChanged);
|
|
||||||
|
connect(ui->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
m_timerWidthBefore->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
m_timerWidthAfter->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPiecePath::DeployWidthFormulaTextEdit);
|
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPiecePath::DeployWidthFormulaTextEdit);
|
||||||
connect(ui->pushButtonGrowWidthBefore, &QPushButton::clicked,
|
connect(ui->pushButtonGrowWidthBefore, &QPushButton::clicked,
|
||||||
|
@ -1061,9 +1059,14 @@ void DialogPiecePath::InitControlTab()
|
||||||
|
|
||||||
ui->plainTextEditFormulaVisible->installEventFilter(this);
|
ui->plainTextEditFormulaVisible->installEventFilter(this);
|
||||||
|
|
||||||
|
m_timerVisible->setSingleShot(true);
|
||||||
|
|
||||||
connect(m_timerVisible, &QTimer::timeout, this, &DialogPiecePath::EvalVisible);
|
connect(m_timerVisible, &QTimer::timeout, this, &DialogPiecePath::EvalVisible);
|
||||||
connect(ui->toolButtonExprVisible, &QPushButton::clicked, this, &DialogPiecePath::FXVisible);
|
connect(ui->toolButtonExprVisible, &QPushButton::clicked, this, &DialogPiecePath::FXVisible);
|
||||||
connect(ui->plainTextEditFormulaVisible, &QPlainTextEdit::textChanged, this, &DialogPiecePath::VisibleChanged);
|
connect(ui->plainTextEditFormulaVisible, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
m_timerVisible->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowVisible, &QPushButton::clicked, this,
|
connect(ui->pushButtonGrowVisible, &QPushButton::clicked, this,
|
||||||
&DialogPiecePath::DeployVisibleFormulaTextEdit);
|
&DialogPiecePath::DeployVisibleFormulaTextEdit);
|
||||||
}
|
}
|
||||||
|
@ -1492,7 +1495,7 @@ bool DialogPiecePath::PathIsValid() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPiecePath::ValidObjects(bool value)
|
void DialogPiecePath::ValidObjects(bool value)
|
||||||
{
|
{
|
||||||
flagError = value;
|
m_flagError = value;
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ protected:
|
||||||
virtual void CheckState() final;
|
virtual void CheckState() final;
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ShowContextMenu(const QPoint &pos);
|
void ShowContextMenu(const QPoint &pos);
|
||||||
|
@ -88,11 +89,6 @@ private slots:
|
||||||
void FXWidthAfter();
|
void FXWidthAfter();
|
||||||
void FXVisible();
|
void FXVisible();
|
||||||
|
|
||||||
void WidthChanged();
|
|
||||||
void WidthBeforeChanged();
|
|
||||||
void WidthAfterChanged();
|
|
||||||
void VisibleChanged();
|
|
||||||
|
|
||||||
void DeployWidthFormulaTextEdit();
|
void DeployWidthFormulaTextEdit();
|
||||||
void DeployWidthBeforeFormulaTextEdit();
|
void DeployWidthBeforeFormulaTextEdit();
|
||||||
void DeployWidthAfterFormulaTextEdit();
|
void DeployWidthAfterFormulaTextEdit();
|
||||||
|
@ -119,6 +115,9 @@ private:
|
||||||
bool m_flagFormulaBefore;
|
bool m_flagFormulaBefore;
|
||||||
bool m_flagFormulaAfter;
|
bool m_flagFormulaAfter;
|
||||||
bool m_flagFormulaVisible;
|
bool m_flagFormulaVisible;
|
||||||
|
bool m_flagName;
|
||||||
|
bool m_flagError;
|
||||||
|
bool m_flagFormula;
|
||||||
|
|
||||||
void InitPathTab();
|
void InitPathTab();
|
||||||
void InitSeamAllowanceTab();
|
void InitSeamAllowanceTab();
|
||||||
|
@ -165,6 +164,14 @@ private:
|
||||||
void RefreshPathList(const VPiecePath &path);
|
void RefreshPathList(const VPiecePath &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPiecePath::IsValid() const
|
||||||
|
{
|
||||||
|
return m_flagName && m_flagError && m_flagFormula && m_flagFormulaBefore && m_flagFormulaAfter
|
||||||
|
&& m_flagFormulaVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline bool DialogPiecePath::IsShowNotch() const
|
inline bool DialogPiecePath::IsShowNotch() const
|
||||||
{
|
{
|
||||||
return m_showMode && GetType() == PiecePathType::CustomSeamAllowance;
|
return m_showMode && GetType() == PiecePathType::CustomSeamAllowance;
|
||||||
|
|
|
@ -36,16 +36,14 @@ DialogPin::DialogPin(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogPin),
|
ui(new Ui::DialogPin),
|
||||||
m_showMode(false),
|
m_showMode(false),
|
||||||
m_flagPoint(false)
|
m_flagPoint(false),
|
||||||
|
m_flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxPoint);
|
FillComboBoxPoints(ui->comboBoxPoint);
|
||||||
|
|
||||||
flagError = false;
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->comboBoxPiece, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
|
connect(ui->comboBoxPiece, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
|
||||||
{
|
{
|
||||||
CheckPieces();
|
CheckPieces();
|
||||||
|
@ -143,13 +141,6 @@ void DialogPin::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPin::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr);
|
|
||||||
bOk->setEnabled(m_flagPoint && flagError);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPin::ShowVisualization()
|
void DialogPin::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -161,16 +152,16 @@ void DialogPin::CheckPieces()
|
||||||
{
|
{
|
||||||
if (not m_showMode)
|
if (not m_showMode)
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (ui->comboBoxPiece->count() <= 0 || ui->comboBoxPiece->currentIndex() == -1)
|
if (ui->comboBoxPiece->count() <= 0 || ui->comboBoxPiece->currentIndex() == -1)
|
||||||
{
|
{
|
||||||
flagError = false;
|
m_flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
m_flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelPiece, color);
|
ChangeColor(ui->labelPiece, color);
|
||||||
CheckState();
|
CheckState();
|
||||||
|
@ -180,11 +171,11 @@ void DialogPin::CheckPieces()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPin::CheckPoint()
|
void DialogPin::CheckPoint()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (ui->comboBoxPoint->currentIndex() != -1)
|
if (ui->comboBoxPoint->currentIndex() != -1)
|
||||||
{
|
{
|
||||||
m_flagPoint = true;
|
m_flagPoint = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,17 +57,24 @@ public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogPin)
|
Q_DISABLE_COPY(DialogPin)
|
||||||
Ui::DialogPin *ui;
|
Ui::DialogPin *ui;
|
||||||
bool m_showMode;
|
bool m_showMode;
|
||||||
bool m_flagPoint;
|
bool m_flagPoint;
|
||||||
|
bool m_flagError;
|
||||||
|
|
||||||
void CheckPieces();
|
void CheckPieces();
|
||||||
void CheckPoint();
|
void CheckPoint();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPin::IsValid() const
|
||||||
|
{
|
||||||
|
return m_flagPoint && m_flagError;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPIN_H
|
#endif // DIALOGPIN_H
|
||||||
|
|
|
@ -41,11 +41,6 @@ DialogPlaceLabel::DialogPlaceLabel(const VContainer *data, quint32 toolId, QWidg
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogPlaceLabel),
|
ui(new Ui::DialogPlaceLabel),
|
||||||
m_showMode(false),
|
m_showMode(false),
|
||||||
m_flagPoint(false),
|
|
||||||
m_flagWidth(false),
|
|
||||||
m_flagHeight(false),
|
|
||||||
m_flagAngle(false),
|
|
||||||
m_flagFormulaVisible(false),
|
|
||||||
m_formulaBaseHeightWidth(0),
|
m_formulaBaseHeightWidth(0),
|
||||||
m_formulaBaseHeightHeight(0),
|
m_formulaBaseHeightHeight(0),
|
||||||
m_formulaBaseHeightAngle(0),
|
m_formulaBaseHeightAngle(0),
|
||||||
|
@ -53,7 +48,13 @@ DialogPlaceLabel::DialogPlaceLabel(const VContainer *data, quint32 toolId, QWidg
|
||||||
timerAngle(new QTimer(this)),
|
timerAngle(new QTimer(this)),
|
||||||
timerWidth(new QTimer(this)),
|
timerWidth(new QTimer(this)),
|
||||||
timerHeight(new QTimer(this)),
|
timerHeight(new QTimer(this)),
|
||||||
m_timerVisible(new QTimer(this))
|
m_timerVisible(new QTimer(this)),
|
||||||
|
m_flagPoint(false),
|
||||||
|
m_flagWidth(false),
|
||||||
|
m_flagHeight(false),
|
||||||
|
m_flagAngle(false),
|
||||||
|
m_flagFormulaVisible(false),
|
||||||
|
m_flagError(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
|
@ -63,9 +64,6 @@ DialogPlaceLabel::DialogPlaceLabel(const VContainer *data, quint32 toolId, QWidg
|
||||||
|
|
||||||
EvalVisible();
|
EvalVisible();
|
||||||
|
|
||||||
flagError = false;
|
|
||||||
CheckState();
|
|
||||||
|
|
||||||
connect(ui->comboBoxPiece, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
|
connect(ui->comboBoxPiece, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
|
||||||
{
|
{
|
||||||
CheckPieces();
|
CheckPieces();
|
||||||
|
@ -255,9 +253,9 @@ void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
CheckPoint();
|
CheckPoint();
|
||||||
prepare = true;
|
prepare = true;
|
||||||
|
|
||||||
FormulaWidthChanged();
|
timerWidth->setSingleShot(formulaTimerTimeout);
|
||||||
FormulaHeightChanged();
|
timerHeight->setSingleShot(formulaTimerTimeout);
|
||||||
FormulaAngleChanged();
|
timerAngle->setSingleShot(formulaTimerTimeout);
|
||||||
|
|
||||||
this->setModal(true);
|
this->setModal(true);
|
||||||
this->show();
|
this->show();
|
||||||
|
@ -266,13 +264,6 @@ void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPlaceLabel::CheckState()
|
|
||||||
{
|
|
||||||
SCASSERT(bOk != nullptr);
|
|
||||||
bOk->setEnabled(m_flagPoint && flagError && m_flagWidth && m_flagHeight && m_flagAngle && m_flagFormulaVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::ShowVisualization()
|
void DialogPlaceLabel::ShowVisualization()
|
||||||
{
|
{
|
||||||
|
@ -295,93 +286,82 @@ void DialogPlaceLabel::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::DeployFormulaWidthEdit()
|
void DialogPlaceLabel::DeployFormulaWidthEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaWidth, ui->pushButtonGrowWidth, m_formulaBaseHeightWidth);
|
DeployFormula(this, ui->plainTextEditFormulaWidth, ui->pushButtonGrowWidth, m_formulaBaseHeightWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::DeployFormulaHeightEdit()
|
void DialogPlaceLabel::DeployFormulaHeightEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaHeight, ui->pushButtonGrowHeight, m_formulaBaseHeightHeight);
|
DeployFormula(this, ui->plainTextEditFormulaHeight, ui->pushButtonGrowHeight, m_formulaBaseHeightHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::DeployFormulaAngleEdit()
|
void DialogPlaceLabel::DeployFormulaAngleEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaAngle, ui->pushButtonGrowAngle, m_formulaBaseHeightAngle);
|
DeployFormula(this, ui->plainTextEditFormulaAngle, ui->pushButtonGrowAngle, m_formulaBaseHeightAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::DeployVisibleFormulaTextEdit()
|
void DialogPlaceLabel::DeployVisibleFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
|
DeployFormula(this, ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPlaceLabel::FormulaWidthChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditFormulaWidth;
|
|
||||||
labelResultCalculation = ui->labelResultCalculationWidth;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(m_flagWidth, ui->plainTextEditFormulaWidth, timerWidth, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPlaceLabel::FormulaHeightChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditFormulaHeight;
|
|
||||||
labelResultCalculation = ui->labelResultCalculationHeight;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(m_flagHeight, ui->plainTextEditFormulaHeight, timerHeight, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPlaceLabel::FormulaAngleChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditFormulaAngle;
|
|
||||||
labelResultCalculation = ui->labelResultCalculationAngle;
|
|
||||||
ValFormulaChanged(m_flagAngle, ui->plainTextEditFormulaAngle, timerAngle, degreeSymbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogPlaceLabel::VisibleChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = ui->labelEditVisible;
|
|
||||||
labelResultCalculation = ui->labelResultVisible;
|
|
||||||
ValFormulaChanged(m_flagFormulaVisible, ui->plainTextEditFormulaVisible, m_timerVisible, QString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::EvalWidth()
|
void DialogPlaceLabel::EvalWidth()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditFormulaWidth;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditFormulaWidth->toPlainText();
|
||||||
Eval(ui->plainTextEditFormulaWidth->toPlainText(), m_flagWidth, ui->labelResultCalculationWidth, postfix, true,
|
formulaData.variables = data->DataVariables();
|
||||||
true);
|
formulaData.labelEditFormula = ui->labelEditFormulaWidth;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculationWidth;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
Eval(formulaData, m_flagWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::EvalHeight()
|
void DialogPlaceLabel::EvalHeight()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditFormulaHeight;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = ui->plainTextEditFormulaHeight->toPlainText();
|
||||||
Eval(ui->plainTextEditFormulaHeight->toPlainText(), m_flagHeight, ui->labelResultCalculationHeight, postfix, true,
|
formulaData.variables = data->DataVariables();
|
||||||
true);
|
formulaData.labelEditFormula = ui->labelEditFormulaHeight;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculationHeight;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
Eval(formulaData, m_flagHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::EvalAngle()
|
void DialogPlaceLabel::EvalAngle()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditFormulaAngle;
|
FormulaData formulaData;
|
||||||
Eval(ui->plainTextEditFormulaAngle->toPlainText(), m_flagAngle, ui->labelResultCalculationAngle, degreeSymbol,
|
formulaData.formula = ui->plainTextEditFormulaAngle->toPlainText();
|
||||||
false);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditFormulaAngle;
|
||||||
|
formulaData.labelResult = ui->labelResultCalculationAngle;
|
||||||
|
formulaData.postfix = degreeSymbol;
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
|
||||||
|
Eval(formulaData, m_flagAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::EvalVisible()
|
void DialogPlaceLabel::EvalVisible()
|
||||||
{
|
{
|
||||||
labelEditFormula = ui->labelEditVisible;
|
FormulaData formulaData;
|
||||||
QString formula = ui->plainTextEditFormulaVisible->toPlainText();
|
formulaData.formula = ui->plainTextEditFormulaVisible->toPlainText();
|
||||||
Eval(formula, m_flagFormulaVisible, ui->labelResultVisible, QString(), false, true);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = ui->labelEditVisible;
|
||||||
|
formulaData.labelResult = ui->labelResultVisible;
|
||||||
|
formulaData.postfix = QString();
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
Eval(formulaData, m_flagFormulaVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -456,15 +436,29 @@ void DialogPlaceLabel::InitPlaceLabelTab()
|
||||||
connect(ui->toolButtonExprHeight, &QPushButton::clicked, this, &DialogPlaceLabel::FXHeight);
|
connect(ui->toolButtonExprHeight, &QPushButton::clicked, this, &DialogPlaceLabel::FXHeight);
|
||||||
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogPlaceLabel::FXAngle);
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogPlaceLabel::FXAngle);
|
||||||
|
|
||||||
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaWidthChanged);
|
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
connect(ui->plainTextEditFormulaHeight, &QPlainTextEdit::textChanged, this,
|
{
|
||||||
&DialogPlaceLabel::FormulaHeightChanged);
|
timerWidth->start(formulaTimerTimeout);
|
||||||
connect(ui->plainTextEditFormulaAngle, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaAngleChanged);
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditFormulaHeight, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerHeight->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ui->plainTextEditFormulaAngle, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
timerAngle->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaWidthEdit);
|
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaWidthEdit);
|
||||||
connect(ui->pushButtonGrowHeight, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaHeightEdit);
|
connect(ui->pushButtonGrowHeight, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaHeightEdit);
|
||||||
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaAngleEdit);
|
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaAngleEdit);
|
||||||
|
|
||||||
|
timerWidth->setSingleShot(true);
|
||||||
|
timerHeight->setSingleShot(true);
|
||||||
|
timerAngle->setSingleShot(true);
|
||||||
|
|
||||||
connect(timerWidth, &QTimer::timeout, this, &DialogPlaceLabel::EvalWidth);
|
connect(timerWidth, &QTimer::timeout, this, &DialogPlaceLabel::EvalWidth);
|
||||||
connect(timerHeight, &QTimer::timeout, this, &DialogPlaceLabel::EvalHeight);
|
connect(timerHeight, &QTimer::timeout, this, &DialogPlaceLabel::EvalHeight);
|
||||||
connect(timerAngle, &QTimer::timeout, this, &DialogPlaceLabel::EvalAngle);
|
connect(timerAngle, &QTimer::timeout, this, &DialogPlaceLabel::EvalAngle);
|
||||||
|
@ -477,9 +471,14 @@ void DialogPlaceLabel::InitControlTab()
|
||||||
|
|
||||||
ui->plainTextEditFormulaVisible->installEventFilter(this);
|
ui->plainTextEditFormulaVisible->installEventFilter(this);
|
||||||
|
|
||||||
|
m_timerVisible->setSingleShot(true);
|
||||||
|
|
||||||
connect(m_timerVisible, &QTimer::timeout, this, &DialogPlaceLabel::EvalVisible);
|
connect(m_timerVisible, &QTimer::timeout, this, &DialogPlaceLabel::EvalVisible);
|
||||||
connect(ui->toolButtonExprVisible, &QPushButton::clicked, this, &DialogPlaceLabel::FXVisible);
|
connect(ui->toolButtonExprVisible, &QPushButton::clicked, this, &DialogPlaceLabel::FXVisible);
|
||||||
connect(ui->plainTextEditFormulaVisible, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::VisibleChanged);
|
connect(ui->plainTextEditFormulaVisible, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
m_timerVisible->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
connect(ui->pushButtonGrowVisible, &QPushButton::clicked, this,
|
connect(ui->pushButtonGrowVisible, &QPushButton::clicked, this,
|
||||||
&DialogPlaceLabel::DeployVisibleFormulaTextEdit);
|
&DialogPlaceLabel::DeployVisibleFormulaTextEdit);
|
||||||
}
|
}
|
||||||
|
@ -503,16 +502,16 @@ void DialogPlaceLabel::CheckPieces()
|
||||||
{
|
{
|
||||||
if (not m_showMode)
|
if (not m_showMode)
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (ui->comboBoxPiece->count() <= 0 || ui->comboBoxPiece->currentIndex() == -1)
|
if (ui->comboBoxPiece->count() <= 0 || ui->comboBoxPiece->currentIndex() == -1)
|
||||||
{
|
{
|
||||||
flagError = false;
|
m_flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
m_flagError = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelPiece, color);
|
ChangeColor(ui->labelPiece, color);
|
||||||
CheckState();
|
CheckState();
|
||||||
|
@ -522,11 +521,11 @@ void DialogPlaceLabel::CheckPieces()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPlaceLabel::CheckPoint()
|
void DialogPlaceLabel::CheckPoint()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
if (ui->comboBoxPoint->currentIndex() != -1)
|
if (ui->comboBoxPoint->currentIndex() != -1)
|
||||||
{
|
{
|
||||||
m_flagPoint = true;
|
m_flagPoint = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,9 +74,9 @@ public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CheckState() final;
|
|
||||||
virtual void ShowVisualization() override;
|
virtual void ShowVisualization() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void DeployFormulaWidthEdit();
|
void DeployFormulaWidthEdit();
|
||||||
|
@ -84,11 +84,6 @@ private slots:
|
||||||
void DeployFormulaAngleEdit();
|
void DeployFormulaAngleEdit();
|
||||||
void DeployVisibleFormulaTextEdit();
|
void DeployVisibleFormulaTextEdit();
|
||||||
|
|
||||||
void FormulaWidthChanged();
|
|
||||||
void FormulaHeightChanged();
|
|
||||||
void FormulaAngleChanged();
|
|
||||||
void VisibleChanged();
|
|
||||||
|
|
||||||
void EvalWidth();
|
void EvalWidth();
|
||||||
void EvalHeight();
|
void EvalHeight();
|
||||||
void EvalAngle();
|
void EvalAngle();
|
||||||
|
@ -103,11 +98,6 @@ private:
|
||||||
Q_DISABLE_COPY(DialogPlaceLabel)
|
Q_DISABLE_COPY(DialogPlaceLabel)
|
||||||
Ui::DialogPlaceLabel *ui;
|
Ui::DialogPlaceLabel *ui;
|
||||||
bool m_showMode;
|
bool m_showMode;
|
||||||
bool m_flagPoint;
|
|
||||||
bool m_flagWidth;
|
|
||||||
bool m_flagHeight;
|
|
||||||
bool m_flagAngle;
|
|
||||||
bool m_flagFormulaVisible;
|
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int m_formulaBaseHeightWidth;
|
int m_formulaBaseHeightWidth;
|
||||||
|
@ -120,6 +110,13 @@ private:
|
||||||
QTimer *timerHeight;
|
QTimer *timerHeight;
|
||||||
QTimer *m_timerVisible;
|
QTimer *m_timerVisible;
|
||||||
|
|
||||||
|
bool m_flagPoint;
|
||||||
|
bool m_flagWidth;
|
||||||
|
bool m_flagHeight;
|
||||||
|
bool m_flagAngle;
|
||||||
|
bool m_flagFormulaVisible;
|
||||||
|
bool m_flagError;
|
||||||
|
|
||||||
void InitPlaceLabelTab();
|
void InitPlaceLabelTab();
|
||||||
void InitControlTab();
|
void InitControlTab();
|
||||||
|
|
||||||
|
@ -129,4 +126,10 @@ private:
|
||||||
void CheckPoint();
|
void CheckPoint();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogPlaceLabel::IsValid() const
|
||||||
|
{
|
||||||
|
return m_flagPoint && m_flagError && m_flagWidth && m_flagHeight && m_flagAngle && m_flagFormulaVisible;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGPLACELABEL_H
|
#endif // DIALOGPLACELABEL_H
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "../../support/dialogeditlabel.h"
|
#include "../../support/dialogeditlabel.h"
|
||||||
#include "../../../tools/vtoolseamallowance.h"
|
#include "../../../tools/vtoolseamallowance.h"
|
||||||
#include "../vgeometry/vplacelabelitem.h"
|
#include "../vgeometry/vplacelabelitem.h"
|
||||||
|
#include "../../dialogtoolbox.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@ -77,7 +78,7 @@ QString GetFormulaFromUser(QPlainTextEdit *textEdit)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const VAbstractPattern *doc, const quint32 &toolId,
|
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const VAbstractPattern *doc, quint32 toolId,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: DialogSeamAllowance(data, toolId, parent)
|
: DialogSeamAllowance(data, toolId, parent)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +87,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const VAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogSeamAllowance),
|
ui(new Ui::DialogSeamAllowance),
|
||||||
uiTabPaths(new Ui::TabPaths),
|
uiTabPaths(new Ui::TabPaths),
|
||||||
|
@ -114,6 +115,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
|
||||||
flagFormulaBefore(true),
|
flagFormulaBefore(true),
|
||||||
flagFormulaAfter(true),
|
flagFormulaAfter(true),
|
||||||
flagMainPathIsValid(true),
|
flagMainPathIsValid(true),
|
||||||
|
flagName(true), //We have default name of piece.
|
||||||
|
flagFormula(false),
|
||||||
m_bAddMode(true),
|
m_bAddMode(true),
|
||||||
m_dialog(),
|
m_dialog(),
|
||||||
m_visSpecialPoints(),
|
m_visSpecialPoints(),
|
||||||
|
@ -128,9 +131,9 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
|
||||||
m_formulaBaseWidth(0),
|
m_formulaBaseWidth(0),
|
||||||
m_formulaBaseWidthBefore(0),
|
m_formulaBaseWidthBefore(0),
|
||||||
m_formulaBaseWidthAfter(0),
|
m_formulaBaseWidthAfter(0),
|
||||||
m_timerWidth(nullptr),
|
m_timerWidth(new QTimer(this)),
|
||||||
m_timerWidthBefore(nullptr),
|
m_timerWidthBefore(new QTimer(this)),
|
||||||
m_timerWidthAfter(nullptr),
|
m_timerWidthAfter(new QTimer(this)),
|
||||||
m_saWidth(0),
|
m_saWidth(0),
|
||||||
m_templateLines(),
|
m_templateLines(),
|
||||||
m_undoStack(),
|
m_undoStack(),
|
||||||
|
@ -153,10 +156,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
|
||||||
InitPassmarksTab();
|
InitPassmarksTab();
|
||||||
InitPlaceLabelsTab();
|
InitPlaceLabelsTab();
|
||||||
|
|
||||||
flagName = true;//We have default name of piece.
|
ChangeColor(uiTabPaths->labelEditName, OkColor(this));
|
||||||
ChangeColor(uiTabPaths->labelEditName, okColor);
|
|
||||||
flagMainPathIsValid = MainPathIsValid();
|
flagMainPathIsValid = MainPathIsValid();
|
||||||
CheckState();
|
|
||||||
|
|
||||||
m_ftb->SetCurrentIndex(TabOrder::Paths);// Show always first tab active on start.
|
m_ftb->SetCurrentIndex(TabOrder::Paths);// Show always first tab active on start.
|
||||||
}
|
}
|
||||||
|
@ -177,6 +178,14 @@ DialogSeamAllowance::~DialogSeamAllowance()
|
||||||
delete uiTabLabels;
|
delete uiTabLabels;
|
||||||
delete uiTabPaths;
|
delete uiTabPaths;
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
|
for (auto &command : m_undoStack)
|
||||||
|
{
|
||||||
|
if (not command.isNull())
|
||||||
|
{
|
||||||
|
delete command;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -308,8 +317,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
||||||
uiTabPaths->checkBoxBuiltIn->setChecked(piece.IsSeamAllowanceBuiltIn());
|
uiTabPaths->checkBoxBuiltIn->setChecked(piece.IsSeamAllowanceBuiltIn());
|
||||||
uiTabPaths->lineEditName->setText(piece.GetName());
|
uiTabPaths->lineEditName->setText(piece.GetName());
|
||||||
|
|
||||||
const QString width = qApp->TrVars()->FormulaToUser(piece.GetFormulaSAWidth(), qApp->Settings()->GetOsSeparator());
|
uiTabPaths->plainTextEditFormulaWidth->setPlainText(
|
||||||
uiTabPaths->plainTextEditFormulaWidth->setPlainText(width);
|
qApp->TrVars()->FormulaToUser(piece.GetFormulaSAWidth(), qApp->Settings()->GetOsSeparator()));
|
||||||
m_saWidth = piece.GetSAWidth();
|
m_saWidth = piece.GetSAWidth();
|
||||||
|
|
||||||
const VPieceLabelData &ppData = piece.GetPatternPieceData();
|
const VPieceLabelData &ppData = piece.GetPatternPieceData();
|
||||||
|
@ -471,9 +480,7 @@ void DialogSeamAllowance::SaveData()
|
||||||
void DialogSeamAllowance::CheckState()
|
void DialogSeamAllowance::CheckState()
|
||||||
{
|
{
|
||||||
SCASSERT(bOk != nullptr);
|
SCASSERT(bOk != nullptr);
|
||||||
bOk->setEnabled(flagName && flagMainPathIsValid && flagFormula && flagFormulaBefore && flagFormulaAfter
|
bOk->setEnabled(IsValid());
|
||||||
&& (flagGFormulas || flagGPin) && flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle
|
|
||||||
&& (flagPLFormulas || flagPPin));
|
|
||||||
// In case dialog hasn't apply button
|
// In case dialog hasn't apply button
|
||||||
if ( bApply != nullptr && applyAllowed)
|
if ( bApply != nullptr && applyAllowed)
|
||||||
{
|
{
|
||||||
|
@ -581,12 +588,12 @@ void DialogSeamAllowance::NameDetailChanged()
|
||||||
if (edit->text().isEmpty())
|
if (edit->text().isEmpty())
|
||||||
{
|
{
|
||||||
flagName = false;
|
flagName = false;
|
||||||
ChangeColor(uiTabPaths->labelEditName, Qt::red);
|
ChangeColor(uiTabPaths->labelEditName, errorColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagName = true;
|
flagName = true;
|
||||||
ChangeColor(uiTabPaths->labelEditName, okColor);
|
ChangeColor(uiTabPaths->labelEditName, OkColor(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckState();
|
CheckState();
|
||||||
|
@ -811,9 +818,9 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
|
||||||
newLabel.SetLabelType(type);
|
newLabel.SetLabelType(type);
|
||||||
m_newPlaceLabels.insert(labelId, newLabel);
|
m_newPlaceLabels.insert(labelId, newLabel);
|
||||||
|
|
||||||
SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(toolId, currentLabel, newLabel,
|
QPointer<VUndoCommand> saveCommand =
|
||||||
qApp->getCurrentDocument(),
|
new SavePlaceLabelOptions(toolId, currentLabel, newLabel, qApp->getCurrentDocument(),
|
||||||
const_cast<VContainer *>(data), labelId);
|
const_cast<VContainer *>(data), labelId);
|
||||||
m_undoStack.append(saveCommand);
|
m_undoStack.append(saveCommand);
|
||||||
UpdateCurrentPlaceLabelRecords();
|
UpdateCurrentPlaceLabelRecords();
|
||||||
};
|
};
|
||||||
|
@ -1270,10 +1277,9 @@ void DialogSeamAllowance::PathDialogClosed(int result)
|
||||||
VPiecePath newPath = dialogTool->GetPiecePath();
|
VPiecePath newPath = dialogTool->GetPiecePath();
|
||||||
m_newPaths.insert(dialogTool->GetToolId(), newPath);
|
m_newPaths.insert(dialogTool->GetToolId(), newPath);
|
||||||
|
|
||||||
SavePiecePathOptions *saveCommand = new SavePiecePathOptions(toolId, currentPath, newPath,
|
QPointer<VUndoCommand> saveCommand =
|
||||||
qApp->getCurrentDocument(),
|
new SavePiecePathOptions(toolId, currentPath, newPath, qApp->getCurrentDocument(),
|
||||||
const_cast<VContainer *>(data),
|
const_cast<VContainer *>(data), dialogTool->GetToolId());
|
||||||
dialogTool->GetToolId());
|
|
||||||
m_undoStack.append(saveCommand);
|
m_undoStack.append(saveCommand);
|
||||||
UpdateCurrentCustomSARecord();
|
UpdateCurrentCustomSARecord();
|
||||||
UpdateCurrentInternalPathRecord();
|
UpdateCurrentInternalPathRecord();
|
||||||
|
@ -1323,10 +1329,9 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result)
|
||||||
|
|
||||||
m_newPlaceLabels.insert(dialogTool->GetToolId(), newLabel);
|
m_newPlaceLabels.insert(dialogTool->GetToolId(), newLabel);
|
||||||
|
|
||||||
SavePlaceLabelOptions *saveCommand = new SavePlaceLabelOptions(toolId, currentLabel, newLabel,
|
QPointer<VUndoCommand> saveCommand =
|
||||||
qApp->getCurrentDocument(),
|
new SavePlaceLabelOptions(toolId, currentLabel, newLabel, qApp->getCurrentDocument(),
|
||||||
const_cast<VContainer *>(data),
|
const_cast<VContainer *>(data), dialogTool->GetToolId());
|
||||||
dialogTool->GetToolId());
|
|
||||||
m_undoStack.append(saveCommand);
|
m_undoStack.append(saveCommand);
|
||||||
UpdateCurrentPlaceLabelRecords();
|
UpdateCurrentPlaceLabelRecords();
|
||||||
}
|
}
|
||||||
|
@ -1576,13 +1581,13 @@ void DialogSeamAllowance::UpdateGrainlineValues()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qsVal.setNum(dVal, 'f', 2);
|
qsVal.setNum(dVal, 'f', 2);
|
||||||
ChangeColor(plbText, okColor);
|
ChangeColor(plbText, OkColor(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (qmu::QmuParserError &e)
|
catch (qmu::QmuParserError &e)
|
||||||
{
|
{
|
||||||
qsVal = tr("Error");
|
qsVal = tr("Error");
|
||||||
not flagGPin ? ChangeColor(plbText, Qt::red) : ChangeColor(plbText, okColor);
|
not flagGPin ? ChangeColor(plbText, errorColor) : ChangeColor(plbText, OkColor(this));
|
||||||
bFormulasOK[i] = false;
|
bFormulasOK[i] = false;
|
||||||
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
||||||
}
|
}
|
||||||
|
@ -1658,13 +1663,13 @@ void DialogSeamAllowance::UpdateDetailLabelValues()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qsVal.setNum(dVal, 'f', 2);
|
qsVal.setNum(dVal, 'f', 2);
|
||||||
ChangeColor(plbText, okColor);
|
ChangeColor(plbText, OkColor(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (qmu::QmuParserError &e)
|
catch (qmu::QmuParserError &e)
|
||||||
{
|
{
|
||||||
qsVal = tr("Error");
|
qsVal = tr("Error");
|
||||||
not flagDPin ? ChangeColor(plbText, Qt::red) : ChangeColor(plbText, okColor);
|
not flagDPin ? ChangeColor(plbText, errorColor) : ChangeColor(plbText, OkColor(this));
|
||||||
bFormulasOK[i] = false;
|
bFormulasOK[i] = false;
|
||||||
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
||||||
}
|
}
|
||||||
|
@ -1743,13 +1748,13 @@ void DialogSeamAllowance::UpdatePatternLabelValues()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qsVal.setNum(dVal, 'f', 2);
|
qsVal.setNum(dVal, 'f', 2);
|
||||||
ChangeColor(plbText, okColor);
|
ChangeColor(plbText, OkColor(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (qmu::QmuParserError &e)
|
catch (qmu::QmuParserError &e)
|
||||||
{
|
{
|
||||||
qsVal = tr("Error");
|
qsVal = tr("Error");
|
||||||
not flagPPin ? ChangeColor(plbText, Qt::red) : ChangeColor(plbText, okColor);
|
not flagPPin ? ChangeColor(plbText, errorColor) : ChangeColor(plbText, OkColor(this));
|
||||||
bFormulasOK[i] = false;
|
bFormulasOK[i] = false;
|
||||||
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
plbVal->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
||||||
}
|
}
|
||||||
|
@ -1997,49 +2002,51 @@ void DialogSeamAllowance::EditPLFormula()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployGrainlineRotation()
|
void DialogSeamAllowance::DeployGrainlineRotation()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabGrainline->lineEditRotFormula, uiTabGrainline->pushButtonShowRot, m_iRotBaseHeight);
|
DeployFormula(this, uiTabGrainline->lineEditRotFormula, uiTabGrainline->pushButtonShowRot, m_iRotBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployGrainlineLength()
|
void DialogSeamAllowance::DeployGrainlineLength()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabGrainline->lineEditLenFormula, uiTabGrainline->pushButtonShowLen, m_iLenBaseHeight);
|
DeployFormula(this,uiTabGrainline->lineEditLenFormula, uiTabGrainline->pushButtonShowLen, m_iLenBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployDLWidth()
|
void DialogSeamAllowance::DeployDLWidth()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabLabels->lineEditDLWidthFormula, uiTabLabels->pushButtonShowDLWidth, m_DLWidthBaseHeight);
|
DeployFormula(this, uiTabLabels->lineEditDLWidthFormula, uiTabLabels->pushButtonShowDLWidth, m_DLWidthBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployDLHeight()
|
void DialogSeamAllowance::DeployDLHeight()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabLabels->lineEditDLHeightFormula, uiTabLabels->pushButtonShowDLHeight, m_DLHeightBaseHeight);
|
DeployFormula(this, uiTabLabels->lineEditDLHeightFormula, uiTabLabels->pushButtonShowDLHeight,
|
||||||
|
m_DLHeightBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployDLAngle()
|
void DialogSeamAllowance::DeployDLAngle()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabLabels->lineEditDLAngleFormula, uiTabLabels->pushButtonShowDLAngle, m_DLAngleBaseHeight);
|
DeployFormula(this, uiTabLabels->lineEditDLAngleFormula, uiTabLabels->pushButtonShowDLAngle, m_DLAngleBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployPLWidth()
|
void DialogSeamAllowance::DeployPLWidth()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabLabels->lineEditPLWidthFormula, uiTabLabels->pushButtonShowPLWidth, m_PLWidthBaseHeight);
|
DeployFormula(this, uiTabLabels->lineEditPLWidthFormula, uiTabLabels->pushButtonShowPLWidth, m_PLWidthBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployPLHeight()
|
void DialogSeamAllowance::DeployPLHeight()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabLabels->lineEditPLHeightFormula, uiTabLabels->pushButtonShowPLHeight, m_PLHeightBaseHeight);
|
DeployFormula(this, uiTabLabels->lineEditPLHeightFormula, uiTabLabels->pushButtonShowPLHeight,
|
||||||
|
m_PLHeightBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployPLAngle()
|
void DialogSeamAllowance::DeployPLAngle()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabLabels->lineEditPLAngleFormula, uiTabLabels->pushButtonShowPLAngle, m_PLAngleBaseHeight);
|
DeployFormula(this, uiTabLabels->lineEditPLAngleFormula, uiTabLabels->pushButtonShowPLAngle, m_PLAngleBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2064,10 +2071,16 @@ void DialogSeamAllowance::ResetLabelsWarning()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::EvalWidth()
|
void DialogSeamAllowance::EvalWidth()
|
||||||
{
|
{
|
||||||
labelEditFormula = uiTabPaths->labelEditWidth;
|
FormulaData formulaData;
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
formulaData.formula = uiTabPaths->plainTextEditFormulaWidth->toPlainText();
|
||||||
const QString formula = uiTabPaths->plainTextEditFormulaWidth->toPlainText();
|
formulaData.variables = data->DataVariables();
|
||||||
m_saWidth = Eval(formula, flagFormula, uiTabPaths->labelResultWidth, postfix, false, true);
|
formulaData.labelEditFormula = uiTabPaths->labelEditWidth;
|
||||||
|
formulaData.labelResult = uiTabPaths->labelResultWidth;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
m_saWidth = Eval(formulaData, flagFormula);
|
||||||
|
|
||||||
if (m_saWidth >= 0)
|
if (m_saWidth >= 0)
|
||||||
{
|
{
|
||||||
|
@ -2089,12 +2102,18 @@ void DialogSeamAllowance::EvalWidthBefore()
|
||||||
{
|
{
|
||||||
if (uiTabPaths->checkBoxSeams->isChecked())
|
if (uiTabPaths->checkBoxSeams->isChecked())
|
||||||
{
|
{
|
||||||
labelEditFormula = uiTabPaths->labelEditBefore;
|
|
||||||
if (uiTabPaths->comboBoxNodes->count() > 0)
|
if (uiTabPaths->comboBoxNodes->count() > 0)
|
||||||
{
|
{
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
FormulaData formulaData;
|
||||||
const QString formula = uiTabPaths->plainTextEditFormulaWidthBefore->toPlainText();
|
formulaData.formula = uiTabPaths->plainTextEditFormulaWidthBefore->toPlainText();
|
||||||
Eval(formula, flagFormulaBefore, uiTabPaths->labelResultBefore, postfix, false, true);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = uiTabPaths->labelEditBefore;
|
||||||
|
formulaData.labelResult = uiTabPaths->labelResultBefore;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormulaBefore);
|
||||||
|
|
||||||
const QString formulaSABefore = GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore);
|
const QString formulaSABefore = GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore);
|
||||||
UpdateNodeSABefore(formulaSABefore);
|
UpdateNodeSABefore(formulaSABefore);
|
||||||
|
@ -2102,7 +2121,7 @@ void DialogSeamAllowance::EvalWidthBefore()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChangeColor(labelEditFormula, okColor);
|
ChangeColor(uiTabPaths->labelEditBefore, OkColor(this));
|
||||||
uiTabPaths->labelResultBefore->setText(tr("<Empty>"));
|
uiTabPaths->labelResultBefore->setText(tr("<Empty>"));
|
||||||
flagFormulaBefore = true;
|
flagFormulaBefore = true;
|
||||||
}
|
}
|
||||||
|
@ -2114,12 +2133,18 @@ void DialogSeamAllowance::EvalWidthAfter()
|
||||||
{
|
{
|
||||||
if (uiTabPaths->checkBoxSeams->isChecked())
|
if (uiTabPaths->checkBoxSeams->isChecked())
|
||||||
{
|
{
|
||||||
labelEditFormula = uiTabPaths->labelEditAfter;
|
|
||||||
if (uiTabPaths->comboBoxNodes->count() > 0)
|
if (uiTabPaths->comboBoxNodes->count() > 0)
|
||||||
{
|
{
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
FormulaData formulaData;
|
||||||
const QString formula = uiTabPaths->plainTextEditFormulaWidthAfter->toPlainText();
|
formulaData.formula = uiTabPaths->plainTextEditFormulaWidthAfter->toPlainText();
|
||||||
Eval(formula, flagFormulaAfter, uiTabPaths->labelResultAfter, postfix, false, true);
|
formulaData.variables = data->DataVariables();
|
||||||
|
formulaData.labelEditFormula = uiTabPaths->labelEditAfter;
|
||||||
|
formulaData.labelResult = uiTabPaths->labelResultAfter;
|
||||||
|
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||||
|
formulaData.checkZero = false;
|
||||||
|
formulaData.checkLessThanZero = true;
|
||||||
|
|
||||||
|
Eval(formulaData, flagFormulaAfter);
|
||||||
|
|
||||||
const QString formulaSAAfter = GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter);
|
const QString formulaSAAfter = GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter);
|
||||||
UpdateNodeSAAfter(formulaSAAfter);
|
UpdateNodeSAAfter(formulaSAAfter);
|
||||||
|
@ -2127,7 +2152,7 @@ void DialogSeamAllowance::EvalWidthAfter()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChangeColor(labelEditFormula, okColor);
|
ChangeColor(uiTabPaths->labelEditAfter, OkColor(this));
|
||||||
uiTabPaths->labelResultAfter->setText(tr("<Empty>"));
|
uiTabPaths->labelResultAfter->setText(tr("<Empty>"));
|
||||||
flagFormulaAfter = true;
|
flagFormulaAfter = true;
|
||||||
}
|
}
|
||||||
|
@ -2137,7 +2162,7 @@ void DialogSeamAllowance::EvalWidthAfter()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::FXWidth()
|
void DialogSeamAllowance::FXWidth()
|
||||||
{
|
{
|
||||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||||
dialog->setWindowTitle(tr("Edit seam allowance width"));
|
dialog->setWindowTitle(tr("Edit seam allowance width"));
|
||||||
dialog->SetFormula(GetFormulaSAWidth());
|
dialog->SetFormula(GetFormulaSAWidth());
|
||||||
dialog->setCheckLessThanZero(true);
|
dialog->setCheckLessThanZero(true);
|
||||||
|
@ -2146,13 +2171,12 @@ void DialogSeamAllowance::FXWidth()
|
||||||
{
|
{
|
||||||
SetFormulaSAWidth(dialog->GetFormula());
|
SetFormulaSAWidth(dialog->GetFormula());
|
||||||
}
|
}
|
||||||
delete dialog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::FXWidthBefore()
|
void DialogSeamAllowance::FXWidthBefore()
|
||||||
{
|
{
|
||||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||||
dialog->setWindowTitle(tr("Edit seam allowance width before"));
|
dialog->setWindowTitle(tr("Edit seam allowance width before"));
|
||||||
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore));
|
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthBefore));
|
||||||
dialog->setCheckLessThanZero(true);
|
dialog->setCheckLessThanZero(true);
|
||||||
|
@ -2161,13 +2185,12 @@ void DialogSeamAllowance::FXWidthBefore()
|
||||||
{
|
{
|
||||||
SetCurrentSABefore(dialog->GetFormula());
|
SetCurrentSABefore(dialog->GetFormula());
|
||||||
}
|
}
|
||||||
delete dialog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::FXWidthAfter()
|
void DialogSeamAllowance::FXWidthAfter()
|
||||||
{
|
{
|
||||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||||
dialog->setWindowTitle(tr("Edit seam allowance width after"));
|
dialog->setWindowTitle(tr("Edit seam allowance width after"));
|
||||||
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter));
|
dialog->SetFormula(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidthAfter));
|
||||||
dialog->setCheckLessThanZero(true);
|
dialog->setCheckLessThanZero(true);
|
||||||
|
@ -2176,79 +2199,45 @@ void DialogSeamAllowance::FXWidthAfter()
|
||||||
{
|
{
|
||||||
SetCurrentSAAfter(dialog->GetFormula());
|
SetCurrentSAAfter(dialog->GetFormula());
|
||||||
}
|
}
|
||||||
delete dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSeamAllowance::WidthChanged()
|
|
||||||
{
|
|
||||||
labelEditFormula = uiTabPaths->labelEditWidth;
|
|
||||||
labelResultCalculation = uiTabPaths->labelResultWidth;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagFormula, uiTabPaths->plainTextEditFormulaWidth, m_timerWidth, postfix);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSeamAllowance::WidthBeforeChanged()
|
|
||||||
{
|
|
||||||
if (uiTabPaths->checkBoxSeams->isChecked())
|
|
||||||
{
|
|
||||||
labelEditFormula = uiTabPaths->labelEditBefore;
|
|
||||||
labelResultCalculation = uiTabPaths->labelResultBefore;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagFormulaBefore, uiTabPaths->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void DialogSeamAllowance::WidthAfterChanged()
|
|
||||||
{
|
|
||||||
if (uiTabPaths->checkBoxSeams->isChecked())
|
|
||||||
{
|
|
||||||
labelEditFormula = uiTabPaths->labelEditAfter;
|
|
||||||
labelResultCalculation = uiTabPaths->labelResultAfter;
|
|
||||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
|
||||||
ValFormulaChanged(flagFormulaAfter, uiTabPaths->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployWidthFormulaTextEdit()
|
void DialogSeamAllowance::DeployWidthFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabPaths->plainTextEditFormulaWidth, uiTabPaths->pushButtonGrowWidth, m_formulaBaseWidth);
|
DeployFormula(this, uiTabPaths->plainTextEditFormulaWidth, uiTabPaths->pushButtonGrowWidth, m_formulaBaseWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit()
|
void DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabPaths->plainTextEditFormulaWidthBefore, uiTabPaths->pushButtonGrowWidthBefore,
|
DeployFormula(this, uiTabPaths->plainTextEditFormulaWidthBefore, uiTabPaths->pushButtonGrowWidthBefore,
|
||||||
m_formulaBaseWidthBefore);
|
m_formulaBaseWidthBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DeployWidthAfterFormulaTextEdit()
|
void DialogSeamAllowance::DeployWidthAfterFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(uiTabPaths->plainTextEditFormulaWidthAfter, uiTabPaths->pushButtonGrowWidthAfter,
|
DeployFormula(this, uiTabPaths->plainTextEditFormulaWidthAfter, uiTabPaths->pushButtonGrowWidthAfter,
|
||||||
m_formulaBaseWidthAfter);
|
m_formulaBaseWidthAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::GrainlinePinPointChanged()
|
void DialogSeamAllowance::GrainlinePinPointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
const quint32 topPinId = getCurrentObjectId(uiTabGrainline->comboBoxGrainlineTopPin);
|
const quint32 topPinId = getCurrentObjectId(uiTabGrainline->comboBoxGrainlineTopPin);
|
||||||
const quint32 bottomPinId = getCurrentObjectId(uiTabGrainline->comboBoxGrainlineBottomPin);
|
const quint32 bottomPinId = getCurrentObjectId(uiTabGrainline->comboBoxGrainlineBottomPin);
|
||||||
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
||||||
{
|
{
|
||||||
flagGPin = true;
|
flagGPin = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
|
|
||||||
ResetGrainlineWarning();
|
ResetGrainlineWarning();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagGPin = false;
|
flagGPin = false;
|
||||||
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor;
|
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor;
|
||||||
|
|
||||||
if (not flagGFormulas && not flagGPin)
|
if (not flagGFormulas && not flagGPin)
|
||||||
{
|
{
|
||||||
|
@ -2265,13 +2254,13 @@ void DialogSeamAllowance::GrainlinePinPointChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::DetailPinPointChanged()
|
void DialogSeamAllowance::DetailPinPointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
const quint32 topPinId = getCurrentObjectId(uiTabLabels->comboBoxDLTopLeftPin);
|
const quint32 topPinId = getCurrentObjectId(uiTabLabels->comboBoxDLTopLeftPin);
|
||||||
const quint32 bottomPinId = getCurrentObjectId(uiTabLabels->comboBoxDLBottomRightPin);
|
const quint32 bottomPinId = getCurrentObjectId(uiTabLabels->comboBoxDLBottomRightPin);
|
||||||
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
||||||
{
|
{
|
||||||
flagDPin = true;
|
flagDPin = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
|
|
||||||
if (flagPPin)
|
if (flagPPin)
|
||||||
{
|
{
|
||||||
|
@ -2282,7 +2271,7 @@ void DialogSeamAllowance::DetailPinPointChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagDPin = false;
|
flagDPin = false;
|
||||||
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor;
|
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor;
|
||||||
|
|
||||||
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*');
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*');
|
||||||
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
||||||
|
@ -2299,13 +2288,13 @@ void DialogSeamAllowance::DetailPinPointChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::PatternPinPointChanged()
|
void DialogSeamAllowance::PatternPinPointChanged()
|
||||||
{
|
{
|
||||||
QColor color = okColor;
|
QColor color;
|
||||||
const quint32 topPinId = getCurrentObjectId(uiTabLabels->comboBoxPLTopLeftPin);
|
const quint32 topPinId = getCurrentObjectId(uiTabLabels->comboBoxPLTopLeftPin);
|
||||||
const quint32 bottomPinId = getCurrentObjectId(uiTabLabels->comboBoxPLBottomRightPin);
|
const quint32 bottomPinId = getCurrentObjectId(uiTabLabels->comboBoxPLBottomRightPin);
|
||||||
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
if (topPinId != NULL_ID && bottomPinId != NULL_ID && topPinId != bottomPinId)
|
||||||
{
|
{
|
||||||
flagPPin = true;
|
flagPPin = true;
|
||||||
color = okColor;
|
color = OkColor(this);
|
||||||
|
|
||||||
if (flagDPin)
|
if (flagDPin)
|
||||||
{
|
{
|
||||||
|
@ -2316,7 +2305,7 @@ void DialogSeamAllowance::PatternPinPointChanged()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagPPin = false;
|
flagPPin = false;
|
||||||
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = okColor : color = errorColor;
|
topPinId == NULL_ID && bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor;
|
||||||
|
|
||||||
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*');
|
m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*');
|
||||||
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
||||||
|
@ -2765,7 +2754,6 @@ void DialogSeamAllowance::InitMainPathTab()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSeamAllowance::InitSeamAllowanceTab()
|
void DialogSeamAllowance::InitSeamAllowanceTab()
|
||||||
{
|
{
|
||||||
plainTextEditFormula = uiTabPaths->plainTextEditFormulaWidth;
|
|
||||||
this->m_formulaBaseWidth = uiTabPaths->plainTextEditFormulaWidth->height();
|
this->m_formulaBaseWidth = uiTabPaths->plainTextEditFormulaWidth->height();
|
||||||
this->m_formulaBaseWidthBefore = uiTabPaths->plainTextEditFormulaWidthBefore->height();
|
this->m_formulaBaseWidthBefore = uiTabPaths->plainTextEditFormulaWidthBefore->height();
|
||||||
this->m_formulaBaseWidthAfter = uiTabPaths->plainTextEditFormulaWidthAfter->height();
|
this->m_formulaBaseWidthAfter = uiTabPaths->plainTextEditFormulaWidthAfter->height();
|
||||||
|
@ -2774,13 +2762,13 @@ void DialogSeamAllowance::InitSeamAllowanceTab()
|
||||||
uiTabPaths->plainTextEditFormulaWidthBefore->installEventFilter(this);
|
uiTabPaths->plainTextEditFormulaWidthBefore->installEventFilter(this);
|
||||||
uiTabPaths->plainTextEditFormulaWidthAfter->installEventFilter(this);
|
uiTabPaths->plainTextEditFormulaWidthAfter->installEventFilter(this);
|
||||||
|
|
||||||
m_timerWidth = new QTimer(this);
|
m_timerWidth->setSingleShot(true);
|
||||||
connect(m_timerWidth, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidth);
|
connect(m_timerWidth, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidth);
|
||||||
|
|
||||||
m_timerWidthBefore = new QTimer(this);
|
m_timerWidthBefore->setSingleShot(true);
|
||||||
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthBefore);
|
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthBefore);
|
||||||
|
|
||||||
m_timerWidthAfter = new QTimer(this);
|
m_timerWidthAfter->setSingleShot(true);
|
||||||
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthAfter);
|
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthAfter);
|
||||||
|
|
||||||
connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
|
connect(uiTabPaths->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
|
||||||
|
@ -2818,12 +2806,20 @@ void DialogSeamAllowance::InitSeamAllowanceTab()
|
||||||
connect(uiTabPaths->toolButtonExprBefore, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthBefore);
|
connect(uiTabPaths->toolButtonExprBefore, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthBefore);
|
||||||
connect(uiTabPaths->toolButtonExprAfter, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthAfter);
|
connect(uiTabPaths->toolButtonExprAfter, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthAfter);
|
||||||
|
|
||||||
connect(uiTabPaths->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this,
|
connect(uiTabPaths->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
&DialogSeamAllowance::WidthChanged);
|
{
|
||||||
connect(uiTabPaths->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this,
|
m_timerWidth->start(formulaTimerTimeout);
|
||||||
&DialogSeamAllowance::WidthBeforeChanged);
|
});
|
||||||
connect(uiTabPaths->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this,
|
|
||||||
&DialogSeamAllowance::WidthAfterChanged);
|
connect(uiTabPaths->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
m_timerWidthBefore->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(uiTabPaths->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
|
{
|
||||||
|
m_timerWidthAfter->start(formulaTimerTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
connect(uiTabPaths->pushButtonGrowWidth, &QPushButton::clicked, this,
|
connect(uiTabPaths->pushButtonGrowWidth, &QPushButton::clicked, this,
|
||||||
&DialogSeamAllowance::DeployWidthFormulaTextEdit);
|
&DialogSeamAllowance::DeployWidthFormulaTextEdit);
|
||||||
|
@ -3077,7 +3073,7 @@ QString DialogSeamAllowance::GetFormulaSAWidth() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<QUndoCommand *> &DialogSeamAllowance::UndoStack()
|
QVector<QPointer<VUndoCommand>> &DialogSeamAllowance::UndoStack()
|
||||||
{
|
{
|
||||||
return m_undoStack;
|
return m_undoStack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,16 +49,16 @@ namespace Ui
|
||||||
class VisPieceSpecialPoints;
|
class VisPieceSpecialPoints;
|
||||||
class FancyTabBar;
|
class FancyTabBar;
|
||||||
class VPlaceLabelItem;
|
class VPlaceLabelItem;
|
||||||
class QUndoCommand;
|
class VUndoCommand;
|
||||||
|
|
||||||
class DialogSeamAllowance : public DialogTool
|
class DialogSeamAllowance : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogSeamAllowance(const VContainer *data, const VAbstractPattern *doc, const quint32 &toolId,
|
DialogSeamAllowance(const VContainer *data, const VAbstractPattern *doc, quint32 toolId,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
DialogSeamAllowance(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogSeamAllowance(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogSeamAllowance();
|
virtual ~DialogSeamAllowance();
|
||||||
|
|
||||||
void EnableApply(bool enable);
|
void EnableApply(bool enable);
|
||||||
|
@ -68,7 +68,7 @@ public:
|
||||||
|
|
||||||
QString GetFormulaSAWidth() const;
|
QString GetFormulaSAWidth() const;
|
||||||
|
|
||||||
QVector<QUndoCommand*> &UndoStack();
|
QVector<QPointer<VUndoCommand> > &UndoStack();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
|
@ -81,6 +81,7 @@ protected:
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual void showEvent( QShowEvent *event ) override;
|
virtual void showEvent( QShowEvent *event ) override;
|
||||||
virtual void resizeEvent(QResizeEvent *event) override;
|
virtual void resizeEvent(QResizeEvent *event) override;
|
||||||
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void NameDetailChanged();
|
void NameDetailChanged();
|
||||||
|
@ -143,10 +144,6 @@ private slots:
|
||||||
void FXWidthBefore();
|
void FXWidthBefore();
|
||||||
void FXWidthAfter();
|
void FXWidthAfter();
|
||||||
|
|
||||||
void WidthChanged();
|
|
||||||
void WidthBeforeChanged();
|
|
||||||
void WidthAfterChanged();
|
|
||||||
|
|
||||||
void DeployWidthFormulaTextEdit();
|
void DeployWidthFormulaTextEdit();
|
||||||
void DeployWidthBeforeFormulaTextEdit();
|
void DeployWidthBeforeFormulaTextEdit();
|
||||||
void DeployWidthAfterFormulaTextEdit();
|
void DeployWidthAfterFormulaTextEdit();
|
||||||
|
@ -190,6 +187,8 @@ private:
|
||||||
bool flagFormulaBefore;
|
bool flagFormulaBefore;
|
||||||
bool flagFormulaAfter;
|
bool flagFormulaAfter;
|
||||||
bool flagMainPathIsValid;
|
bool flagMainPathIsValid;
|
||||||
|
bool flagName;
|
||||||
|
bool flagFormula;
|
||||||
bool m_bAddMode;
|
bool m_bAddMode;
|
||||||
|
|
||||||
QPointer<DialogTool> m_dialog;
|
QPointer<DialogTool> m_dialog;
|
||||||
|
@ -214,7 +213,7 @@ private:
|
||||||
|
|
||||||
QVector<VLabelTemplateLine> m_templateLines;
|
QVector<VLabelTemplateLine> m_templateLines;
|
||||||
|
|
||||||
QVector<QUndoCommand*> m_undoStack;
|
QVector<QPointer<VUndoCommand>> m_undoStack;
|
||||||
QHash<quint32, VPlaceLabelItem> m_newPlaceLabels;
|
QHash<quint32, VPlaceLabelItem> m_newPlaceLabels;
|
||||||
QHash<quint32, VPiecePath> m_newPaths;
|
QHash<quint32, VPiecePath> m_newPaths;
|
||||||
|
|
||||||
|
@ -282,4 +281,12 @@ private:
|
||||||
void EnablePatternLabelFormulaControls(bool enable);
|
void EnablePatternLabelFormulaControls(bool enable);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool DialogSeamAllowance::IsValid() const
|
||||||
|
{
|
||||||
|
return flagName && flagMainPathIsValid && flagFormula && flagFormulaBefore && flagFormulaAfter
|
||||||
|
&& (flagGFormulas || flagGPin) && flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle
|
||||||
|
&& (flagPLFormulas || flagPPin);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIALOGSEAMALLOWANCE_H
|
#endif // DIALOGSEAMALLOWANCE_H
|
||||||
|
|
|
@ -101,7 +101,7 @@ VToolCutArc* VToolCutArc::Create(const QPointer<DialogTool> &dialog, VMainGraphi
|
||||||
VToolCutArcInitData initData;
|
VToolCutArcInitData initData;
|
||||||
initData.formula = dialogTool->GetFormula();
|
initData.formula = dialogTool->GetFormula();
|
||||||
initData.arcId = dialogTool->getArcId();
|
initData.arcId = dialogTool->getArcId();
|
||||||
initData.name = dialogTool->getPointName();
|
initData.name = dialogTool->GetPointName();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
@ -205,7 +205,7 @@ void VToolCutArc::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepende
|
||||||
AddDependence(oldDependencies, curveCutId);
|
AddDependence(oldDependencies, curveCutId);
|
||||||
AddDependence(newDependencies, dialogTool->getArcId());
|
AddDependence(newDependencies, dialogTool->getArcId());
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||||
doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId()));
|
doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId()));
|
||||||
}
|
}
|
||||||
|
@ -283,5 +283,6 @@ QString VToolCutArc::MakeToolTip() const
|
||||||
return toolTip;
|
return toolTip;
|
||||||
};
|
};
|
||||||
|
|
||||||
return ArcToolTip(ArcToolTip("<table>", ar1, QChar('1')), ar2, QChar('2')) + QLatin1String("</table>");
|
return ArcToolTip(ArcToolTip(QStringLiteral("<table>"), ar1, QChar('1')), ar2, QChar('2')) +
|
||||||
|
QStringLiteral("</table>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer<DialogTool> &dialog, VMain
|
||||||
VToolCutSplineInitData initData;
|
VToolCutSplineInitData initData;
|
||||||
initData.formula = dialogTool->GetFormula();
|
initData.formula = dialogTool->GetFormula();
|
||||||
initData.splineId = dialogTool->getSplineId();
|
initData.splineId = dialogTool->getSplineId();
|
||||||
initData.name = dialogTool->getPointName();
|
initData.name = dialogTool->GetPointName();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
@ -204,7 +204,7 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
|
||||||
AddDependence(oldDependencies, curveCutId);
|
AddDependence(oldDependencies, curveCutId);
|
||||||
AddDependence(newDependencies, dialogTool->getSplineId());
|
AddDependence(newDependencies, dialogTool->getSplineId());
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||||
doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId()));
|
doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const QPointer<DialogTool> &dialo
|
||||||
VToolCutSplinePathInitData initData;
|
VToolCutSplinePathInitData initData;
|
||||||
initData.formula = dialogTool->GetFormula();
|
initData.formula = dialogTool->GetFormula();
|
||||||
initData.splinePathId = dialogTool->getSplinePathId();
|
initData.splinePathId = dialogTool->getSplinePathId();
|
||||||
initData.name = dialogTool->getPointName();
|
initData.name = dialogTool->GetPointName();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
@ -295,7 +295,7 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList<quint32> &old
|
||||||
AddDependence(oldDependencies, curveCutId);
|
AddDependence(oldDependencies, curveCutId);
|
||||||
AddDependence(newDependencies, dialogTool->getSplinePathId());
|
AddDependence(newDependencies, dialogTool->getSplinePathId());
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||||
doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId()));
|
doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
|
||||||
AddDependence(newDependencies, dialogTool->GetFirstPointId());
|
AddDependence(newDependencies, dialogTool->GetFirstPointId());
|
||||||
AddDependence(newDependencies, dialogTool->GetSecondPointId());
|
AddDependence(newDependencies, dialogTool->GetSecondPointId());
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||||
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
|
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
|
||||||
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
|
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
|
||||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||||
|
@ -164,8 +164,8 @@ QString VToolAlongLine::MakeToolTip() const
|
||||||
.arg(qApp->fromPixel(curLine.length()))
|
.arg(qApp->fromPixel(curLine.length()))
|
||||||
.arg(UnitsToStr(qApp->patternUnit(), true), tr("Angle"))
|
.arg(UnitsToStr(qApp->patternUnit(), true), tr("Angle"))
|
||||||
.arg(curLine.angle())
|
.arg(curLine.angle())
|
||||||
.arg(QString("%1->%2").arg(basePoint->name(), current->name()),
|
.arg(QStringLiteral("%1->%2").arg(basePoint->name(), current->name()),
|
||||||
QString("%1->%2").arg(current->name(), secondPoint->name()))
|
QStringLiteral("%1->%2").arg(current->name(), secondPoint->name()))
|
||||||
.arg(qApp->fromPixel(curToSecond.length()))
|
.arg(qApp->fromPixel(curToSecond.length()))
|
||||||
.arg(tr("Label"), current->name());
|
.arg(tr("Label"), current->name());
|
||||||
return toolTip;
|
return toolTip;
|
||||||
|
@ -230,7 +230,7 @@ VToolAlongLine* VToolAlongLine::Create(const QPointer<DialogTool> &dialog, VMain
|
||||||
initData.secondPointId = dialogTool->GetSecondPointId();
|
initData.secondPointId = dialogTool->GetSecondPointId();
|
||||||
initData.typeLine = dialogTool->GetTypeLine();
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
initData.lineColor = dialogTool->GetLineColor();
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
initData.name = dialogTool->getPointName();
|
initData.name = dialogTool->GetPointName();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
|
|
@ -146,7 +146,7 @@ VToolBisector* VToolBisector::Create(const QPointer<DialogTool> &dialog, VMainGr
|
||||||
initData.thirdPointId = dialogTool->GetThirdPointId();
|
initData.thirdPointId = dialogTool->GetThirdPointId();
|
||||||
initData.typeLine = dialogTool->GetTypeLine();
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
initData.lineColor = dialogTool->GetLineColor();
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
initData.name = dialogTool->getPointName();
|
initData.name = dialogTool->GetPointName();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
@ -254,7 +254,7 @@ void VToolBisector::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepen
|
||||||
AddDependence(newDependencies, dialogTool->GetSecondPointId());
|
AddDependence(newDependencies, dialogTool->GetSecondPointId());
|
||||||
AddDependence(newDependencies, dialogTool->GetThirdPointId());
|
AddDependence(newDependencies, dialogTool->GetThirdPointId());
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||||
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
|
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
|
||||||
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
|
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
|
||||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||||
|
|
|
@ -112,7 +112,7 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const QPointer<DialogTo
|
||||||
initData.curveId = dialogTool->getCurveId();
|
initData.curveId = dialogTool->getCurveId();
|
||||||
initData.typeLine = dialogTool->GetTypeLine();
|
initData.typeLine = dialogTool->GetTypeLine();
|
||||||
initData.lineColor = dialogTool->GetLineColor();
|
initData.lineColor = dialogTool->GetLineColor();
|
||||||
initData.name = dialogTool->getPointName();
|
initData.name = dialogTool->GetPointName();
|
||||||
initData.scene = scene;
|
initData.scene = scene;
|
||||||
initData.doc = doc;
|
initData.doc = doc;
|
||||||
initData.data = data;
|
initData.data = data;
|
||||||
|
@ -255,7 +255,7 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement, QList<quint32>
|
||||||
AddDependence(newDependencies, dialogTool->GetBasePointId());
|
AddDependence(newDependencies, dialogTool->GetBasePointId());
|
||||||
AddDependence(newDependencies, dialogTool->getCurveId());
|
AddDependence(newDependencies, dialogTool->getCurveId());
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||||
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
|
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
|
||||||
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
|
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
|
||||||
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
|
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
|
||||||
|
@ -346,7 +346,7 @@ void VToolCurveIntersectAxis::InitArc(VContainer *data, qreal segLength, const V
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLength, const VPointF *p, quint32 curveId,
|
void VToolCurveIntersectAxis::InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId,
|
||||||
VContainer *data)
|
VContainer *data)
|
||||||
{
|
{
|
||||||
switch(curveType)
|
switch(curveType)
|
||||||
|
|
|
@ -101,8 +101,7 @@ private:
|
||||||
|
|
||||||
template <class Item>
|
template <class Item>
|
||||||
static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
|
static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
|
||||||
static void InitSegments(const GOType &curveType, qreal segLength, const VPointF *p, quint32 curveId,
|
static void InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, VContainer *data);
|
||||||
VContainer *data);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLCURVEINTERSECTAXIS_H
|
#endif // VTOOLCURVEINTERSECTAXIS_H
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user