2016-10-04 16:34:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogmove.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 30 9, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-10-04 16:34:37 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 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 "dialogmove.h"
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QLineF>
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <QRegularExpressionMatch>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <Qt>
|
|
|
|
#include <new>
|
|
|
|
|
|
|
|
#include "../../visualization/visualization.h"
|
|
|
|
#include "../../visualization/line/operation/vistoolmove.h"
|
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
|
|
|
#include "../qmuparser/qmudef.h"
|
|
|
|
#include "../support/dialogeditwrongformula.h"
|
|
|
|
#include "../vgeometry/vpointf.h"
|
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vmisc/vcommonsettings.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
|
|
|
#include "../vpatterndb/vtranslatevars.h"
|
|
|
|
#include "../vwidgets/vabstractmainwindow.h"
|
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
2018-01-05 21:01:35 +01:00
|
|
|
#include "../vwidgets/vmaingraphicsview.h"
|
2016-10-04 16:34:37 +02:00
|
|
|
#include "ui_dialogmove.h"
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
|
|
|
|
: DialogTool(data, toolId, parent),
|
|
|
|
ui(new Ui::DialogMove),
|
|
|
|
flagAngle(false),
|
2017-11-13 18:39:11 +01:00
|
|
|
flagRotationAngle(false),
|
2016-10-04 16:34:37 +02:00
|
|
|
flagLength(false),
|
|
|
|
timerAngle(nullptr),
|
2017-11-13 18:39:11 +01:00
|
|
|
timerRotationAngle(nullptr),
|
2016-10-04 16:34:37 +02:00
|
|
|
timerLength(nullptr),
|
|
|
|
formulaAngle(),
|
2017-11-13 18:39:11 +01:00
|
|
|
formulaRotationAngle(),
|
2016-10-04 16:34:37 +02:00
|
|
|
formulaLength(),
|
|
|
|
formulaBaseHeightAngle(0),
|
2017-11-13 18:39:11 +01:00
|
|
|
formulaBaseHeightRotationAngle(0),
|
2016-10-04 16:34:37 +02:00
|
|
|
formulaBaseHeightLength(0),
|
|
|
|
objects(),
|
|
|
|
stage1(true),
|
2017-11-13 18:39:11 +01:00
|
|
|
stage2(false),
|
2017-11-17 11:28:57 +01:00
|
|
|
m_suffix(),
|
|
|
|
optionalRotationOrigin(false)
|
2016-10-04 16:34:37 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
|
|
|
|
ui->plainTextEditAngle->installEventFilter(this);
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
this->formulaBaseHeightRotationAngle = ui->plainTextEditRotationAngle->height();
|
|
|
|
ui->plainTextEditRotationAngle->installEventFilter(this);
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
this->formulaBaseHeightLength = ui->plainTextEditLength->height();
|
|
|
|
ui->plainTextEditLength->installEventFilter(this);
|
|
|
|
|
|
|
|
ui->lineEditSuffix->setText(qApp->getCurrentDocument()->GenerateSuffix());
|
|
|
|
|
|
|
|
timerAngle = new QTimer(this);
|
|
|
|
connect(timerAngle, &QTimer::timeout, this, &DialogMove::EvalAngle);
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
timerRotationAngle = new QTimer(this);
|
|
|
|
connect(timerRotationAngle, &QTimer::timeout, this, &DialogMove::EvalRotationAngle);
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
timerLength = new QTimer(this);
|
|
|
|
connect(timerLength, &QTimer::timeout, this, &DialogMove::EvalLength);
|
|
|
|
|
|
|
|
InitOkCancelApply(ui);
|
|
|
|
|
2017-11-17 11:28:57 +01:00
|
|
|
FillComboBoxPoints(ui->comboBoxRotationOriginPoint);
|
|
|
|
|
|
|
|
ui->comboBoxRotationOriginPoint->blockSignals(true);
|
|
|
|
ui->comboBoxRotationOriginPoint->addItem(tr("Center point"), NULL_ID);
|
|
|
|
ui->comboBoxRotationOriginPoint->blockSignals(false);
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
flagName = true;
|
|
|
|
CheckState();
|
|
|
|
|
|
|
|
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogMove::SuffixChanged);
|
|
|
|
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogMove::FXAngle);
|
2017-11-13 18:39:11 +01:00
|
|
|
connect(ui->toolButtonExprRotationAngle, &QPushButton::clicked, this, &DialogMove::FXRotationAngle);
|
2016-10-04 16:34:37 +02:00
|
|
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogMove::FXLength);
|
|
|
|
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, &DialogMove::AngleChanged);
|
2017-11-13 18:39:11 +01:00
|
|
|
connect(ui->plainTextEditRotationAngle, &QPlainTextEdit::textChanged, this, &DialogMove::RotationAngleChanged);
|
2016-10-04 16:34:37 +02:00
|
|
|
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, &DialogMove::LengthChanged);
|
|
|
|
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogMove::DeployAngleTextEdit);
|
2017-11-13 18:39:11 +01:00
|
|
|
connect(ui->pushButtonGrowRotationAngle, &QPushButton::clicked, this, &DialogMove::DeployRotationAngleTextEdit);
|
2016-10-04 16:34:37 +02:00
|
|
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
|
|
|
|
|
|
|
|
vis = new VisToolMove(data);
|
2017-11-17 11:28:57 +01:00
|
|
|
|
|
|
|
SetRotationOrigPointId(NULL_ID);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogMove::~DialogMove()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogMove::GetAngle() const
|
|
|
|
{
|
|
|
|
return qApp->TrVars()->TryFormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetAngle(const QString &value)
|
|
|
|
{
|
|
|
|
formulaAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formulaAngle.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployAngleTextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditAngle->setPlainText(formulaAngle);
|
|
|
|
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(operation != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
operation->SetAngle(formulaAngle);
|
|
|
|
|
|
|
|
MoveCursorToEnd(ui->plainTextEditAngle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogMove::GetLength() const
|
|
|
|
{
|
|
|
|
return qApp->TrVars()->TryFormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetLength(const QString &value)
|
|
|
|
{
|
|
|
|
formulaLength = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formulaLength.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployLengthTextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditLength->setPlainText(formulaLength);
|
|
|
|
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(operation != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
operation->SetLength(formulaLength);
|
|
|
|
|
|
|
|
MoveCursorToEnd(ui->plainTextEditLength);
|
|
|
|
}
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogMove::GetRotationAngle() const
|
|
|
|
{
|
|
|
|
return qApp->TrVars()->TryFormulaFromUser(formulaRotationAngle, qApp->Settings()->GetOsSeparator());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetRotationAngle(const QString &value)
|
|
|
|
{
|
|
|
|
formulaRotationAngle = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator());
|
|
|
|
// increase height if needed.
|
|
|
|
if (formulaRotationAngle.length() > 80)
|
|
|
|
{
|
|
|
|
this->DeployAngleTextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditRotationAngle->setPlainText(formulaRotationAngle);
|
|
|
|
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
|
|
|
SCASSERT(operation != nullptr)
|
|
|
|
operation->SetRotationAngle(formulaRotationAngle);
|
|
|
|
|
|
|
|
MoveCursorToEnd(ui->plainTextEditRotationAngle);
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogMove::GetSuffix() const
|
|
|
|
{
|
|
|
|
return m_suffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetSuffix(const QString &value)
|
|
|
|
{
|
|
|
|
m_suffix = value;
|
|
|
|
ui->lineEditSuffix->setText(value);
|
|
|
|
}
|
|
|
|
|
2017-11-17 11:28:57 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 DialogMove::GetRotationOrigPointId() const
|
|
|
|
{
|
|
|
|
return getCurrentObjectId(ui->comboBoxRotationOriginPoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetRotationOrigPointId(const quint32 &value)
|
|
|
|
{
|
|
|
|
ChangeCurrentData(ui->comboBoxRotationOriginPoint, value);
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
|
|
|
SCASSERT(operation != nullptr)
|
|
|
|
operation->SetRotationOriginPointId(value);
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<quint32> DialogMove::GetObjects() const
|
|
|
|
{
|
|
|
|
return objects.toVector();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::ShowDialog(bool click)
|
|
|
|
{
|
|
|
|
if (stage1 && not click)
|
|
|
|
{
|
|
|
|
if (objects.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
stage1 = false;
|
|
|
|
prepare = true;
|
|
|
|
|
|
|
|
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(scene != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
scene->clearSelection();
|
|
|
|
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(operation != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
operation->SetObjects(objects.toVector());
|
|
|
|
operation->VisualMode();
|
|
|
|
|
|
|
|
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(window != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
connect(operation, &VisToolMove::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
|
|
|
|
|
|
|
scene->ToggleArcSelection(false);
|
2016-12-20 16:08:28 +01:00
|
|
|
scene->ToggleElArcSelection(false);
|
2016-10-04 16:34:37 +02:00
|
|
|
scene->ToggleSplineSelection(false);
|
|
|
|
scene->ToggleSplinePathSelection(false);
|
|
|
|
|
|
|
|
scene->ToggleArcHover(false);
|
2016-12-20 16:08:28 +01:00
|
|
|
scene->ToggleElArcHover(false);
|
2016-10-04 16:34:37 +02:00
|
|
|
scene->ToggleSplineHover(false);
|
|
|
|
scene->ToggleSplinePathHover(false);
|
2018-01-05 21:01:35 +01:00
|
|
|
|
|
|
|
qApp->getSceneView()->AllowRubberBand(false);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
2017-11-13 18:39:11 +01:00
|
|
|
else if (not stage2 && not stage1 && prepare && click)
|
2016-10-04 16:34:37 +02:00
|
|
|
{
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(operation != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
|
|
|
|
if (operation->LengthValue() > 0)
|
|
|
|
{
|
2017-11-13 18:39:11 +01:00
|
|
|
formulaAngle = qApp->TrVars()->FormulaToUser(operation->Angle(), qApp->Settings()->GetOsSeparator());
|
|
|
|
formulaLength = qApp->TrVars()->FormulaToUser(operation->Length(), qApp->Settings()->GetOsSeparator());
|
|
|
|
operation->SetAngle(formulaAngle);
|
|
|
|
operation->SetLength(formulaLength);
|
|
|
|
operation->RefreshGeometry();
|
|
|
|
emit ToolTip(operation->CurrentToolTip());
|
|
|
|
stage2 = true;
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
}
|
2017-11-13 18:39:11 +01:00
|
|
|
else if (not stage1 && stage2 && prepare && click)
|
|
|
|
{
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
|
|
|
SCASSERT(operation != nullptr)
|
|
|
|
|
2017-11-17 11:28:57 +01:00
|
|
|
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
|
|
|
|
{
|
|
|
|
if (not optionalRotationOrigin)
|
|
|
|
{
|
|
|
|
operation->SetRotationOriginPointId(NULL_ID);
|
2018-03-14 15:01:24 +01:00
|
|
|
SetObject(NULL_ID, ui->comboBoxRotationOriginPoint, QString());
|
2017-11-17 11:28:57 +01:00
|
|
|
operation->RefreshGeometry();
|
|
|
|
}
|
|
|
|
optionalRotationOrigin = false; // Handled, next click on empty filed will disable selection
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetAngle(qApp->TrVars()->FormulaFromUser(formulaAngle, qApp->Settings()->GetOsSeparator()));
|
|
|
|
SetLength(qApp->TrVars()->FormulaFromUser(formulaLength, qApp->Settings()->GetOsSeparator()));
|
|
|
|
SetRotationAngle(operation->RotationAngle());
|
|
|
|
setModal(true);
|
2018-03-14 15:01:24 +01:00
|
|
|
emit ToolTip(QString());
|
2017-11-17 11:28:57 +01:00
|
|
|
timerAngle->start();
|
|
|
|
timerRotationAngle->start();
|
|
|
|
timerLength->start();
|
|
|
|
show();
|
|
|
|
}
|
2017-11-13 18:39:11 +01:00
|
|
|
}
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::ChosenObject(quint32 id, const SceneObject &type)
|
|
|
|
{
|
2017-11-17 11:28:57 +01:00
|
|
|
if (not stage1 && stage2 && prepare)// After first choose we ignore all objects
|
|
|
|
{
|
|
|
|
if (type == SceneObject::Point && QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
|
|
|
|
{
|
2018-03-14 15:01:24 +01:00
|
|
|
if (SetObject(id, ui->comboBoxRotationOriginPoint, QString()))
|
2017-11-17 11:28:57 +01:00
|
|
|
{
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
|
|
|
SCASSERT(operation != nullptr)
|
|
|
|
|
|
|
|
operation->SetRotationOriginPointId(id);
|
|
|
|
operation->RefreshGeometry();
|
|
|
|
optionalRotationOrigin = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool)
|
|
|
|
{
|
|
|
|
Q_UNUSED(tool)
|
|
|
|
if (stage1)
|
|
|
|
{
|
|
|
|
if (selected)
|
|
|
|
{
|
|
|
|
if (not objects.contains(object))
|
|
|
|
{
|
|
|
|
objects.append(object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
objects.removeOne(object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::DeployAngleTextEdit()
|
|
|
|
{
|
|
|
|
DeployFormula(ui->plainTextEditAngle, ui->pushButtonGrowAngle, formulaBaseHeightAngle);
|
|
|
|
}
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::DeployRotationAngleTextEdit()
|
|
|
|
{
|
|
|
|
DeployFormula(ui->plainTextEditRotationAngle, ui->pushButtonGrowRotationAngle, formulaBaseHeightRotationAngle);
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::DeployLengthTextEdit()
|
|
|
|
{
|
|
|
|
DeployFormula(ui->plainTextEditLength, ui->pushButtonGrowLength, formulaBaseHeightLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::AngleChanged()
|
|
|
|
{
|
|
|
|
labelEditFormula = ui->labelEditAngle;
|
|
|
|
labelResultCalculation = ui->labelResultAngle;
|
|
|
|
ValFormulaChanged(flagAngle, ui->plainTextEditAngle, timerAngle, degreeSymbol);
|
|
|
|
}
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::RotationAngleChanged()
|
|
|
|
{
|
|
|
|
labelEditFormula = ui->labelEditRotationAngle;
|
|
|
|
labelResultCalculation = ui->labelResultRotationAngle;
|
|
|
|
ValFormulaChanged(flagRotationAngle, ui->plainTextEditRotationAngle, timerRotationAngle, degreeSymbol);
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::LengthChanged()
|
|
|
|
{
|
|
|
|
labelEditFormula = ui->labelEditLength;
|
|
|
|
labelResultCalculation = ui->labelResultLength;
|
|
|
|
ValFormulaChanged(flagLength, ui->plainTextEditLength, timerLength, degreeSymbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::FXAngle()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit angle"));
|
|
|
|
dialog->SetFormula(GetAngle());
|
|
|
|
dialog->setPostfix(degreeSymbol);
|
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetAngle(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::FXRotationAngle()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit rotation angle"));
|
|
|
|
dialog->SetFormula(GetRotationAngle());
|
|
|
|
dialog->setPostfix(degreeSymbol);
|
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetRotationAngle(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::FXLength()
|
|
|
|
{
|
|
|
|
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit length"));
|
|
|
|
dialog->SetFormula(GetLength());
|
2017-07-02 13:34:36 +02:00
|
|
|
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
|
2016-10-04 16:34:37 +02:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
SetLength(dialog->GetFormula());
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SuffixChanged()
|
|
|
|
{
|
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
|
|
|
if (edit)
|
|
|
|
{
|
|
|
|
const QString suffix = edit->text();
|
|
|
|
if (suffix.isEmpty())
|
|
|
|
{
|
|
|
|
flagName = false;
|
|
|
|
ChangeColor(ui->labelSuffix, Qt::red);
|
|
|
|
CheckState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_suffix != suffix)
|
|
|
|
{
|
|
|
|
QRegularExpression rx(NameRegExp());
|
2017-03-23 09:25:46 +01:00
|
|
|
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
2016-10-04 16:34:37 +02:00
|
|
|
for (int i=0; i < uniqueNames.size(); ++i)
|
|
|
|
{
|
|
|
|
const QString name = uniqueNames.at(i) + suffix;
|
|
|
|
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
|
|
|
{
|
|
|
|
flagName = false;
|
|
|
|
ChangeColor(ui->labelSuffix, Qt::red);
|
|
|
|
CheckState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flagName = true;
|
|
|
|
ChangeColor(ui->labelSuffix, okColor);
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::CheckState()
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(bOk != nullptr)
|
2017-11-13 18:39:11 +01:00
|
|
|
bOk->setEnabled(flagAngle && flagRotationAngle && flagLength && flagName);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(bApply != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
bApply->setEnabled(bOk->isEnabled());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::ShowVisualization()
|
|
|
|
{
|
|
|
|
AddVisualization<VisToolMove>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SaveData()
|
|
|
|
{
|
|
|
|
m_suffix = ui->lineEditSuffix->text();
|
|
|
|
formulaAngle = ui->plainTextEditAngle->toPlainText();
|
2017-11-13 18:39:11 +01:00
|
|
|
formulaRotationAngle = ui->plainTextEditRotationAngle->toPlainText();
|
2016-10-04 16:34:37 +02:00
|
|
|
formulaLength = ui->plainTextEditLength->toPlainText();
|
|
|
|
|
|
|
|
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(operation != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
|
|
|
|
operation->SetObjects(objects.toVector());
|
|
|
|
operation->SetAngle(formulaAngle);
|
|
|
|
operation->SetLength(formulaLength);
|
2017-11-13 18:39:11 +01:00
|
|
|
operation->SetRotationAngle(formulaRotationAngle);
|
2017-11-17 11:28:57 +01:00
|
|
|
operation->SetRotationOriginPointId(GetRotationOrigPointId());
|
2016-10-04 16:34:37 +02:00
|
|
|
operation->RefreshGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
ui->plainTextEditAngle->blockSignals(true);
|
2017-11-13 18:39:11 +01:00
|
|
|
ui->plainTextEditRotationAngle->blockSignals(true);
|
2016-10-04 16:34:37 +02:00
|
|
|
ui->plainTextEditLength->blockSignals(true);
|
|
|
|
DialogTool::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::EvalAngle()
|
|
|
|
{
|
|
|
|
labelEditFormula = ui->labelEditAngle;
|
|
|
|
Eval(ui->plainTextEditAngle->toPlainText(), flagAngle, ui->labelResultAngle, degreeSymbol, false);
|
|
|
|
}
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::EvalRotationAngle()
|
|
|
|
{
|
|
|
|
labelEditFormula = ui->labelEditRotationAngle;
|
|
|
|
Eval(ui->plainTextEditRotationAngle->toPlainText(), flagRotationAngle, ui->labelResultRotationAngle, degreeSymbol,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::EvalLength()
|
|
|
|
{
|
|
|
|
labelEditFormula = ui->labelEditLength;
|
2017-07-02 13:34:36 +02:00
|
|
|
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
2016-10-04 16:34:37 +02:00
|
|
|
Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
|
|
|
|
}
|