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
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2016-10-04 16:34:37 +02:00
|
|
|
**
|
|
|
|
** 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>
|
2020-03-24 16:31:32 +01:00
|
|
|
#include <QCompleter>
|
2016-10-04 16:34:37 +02:00
|
|
|
#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"
|
2020-01-16 18:20:55 +01:00
|
|
|
#include "../vmisc/compatibility.h"
|
2016-10-04 16:34:37 +02:00
|
|
|
#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),
|
2019-02-11 12:25:27 +01:00
|
|
|
timerAngle(new QTimer(this)),
|
|
|
|
timerRotationAngle(new QTimer(this)),
|
|
|
|
timerLength(new QTimer(this)),
|
2016-10-04 16:34:37 +02:00
|
|
|
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(),
|
2019-02-11 12:25:27 +01:00
|
|
|
optionalRotationOrigin(false),
|
|
|
|
flagAngle(false),
|
|
|
|
flagRotationAngle(false),
|
|
|
|
flagLength(false),
|
2020-03-18 13:45:47 +01:00
|
|
|
flagName(true),
|
|
|
|
flagGroupName(true)
|
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());
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
timerAngle->setSingleShot(true);
|
2016-10-04 16:34:37 +02:00
|
|
|
connect(timerAngle, &QTimer::timeout, this, &DialogMove::EvalAngle);
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
timerRotationAngle->setSingleShot(true);
|
2017-11-13 18:39:11 +01:00
|
|
|
connect(timerRotationAngle, &QTimer::timeout, this, &DialogMove::EvalRotationAngle);
|
|
|
|
|
2019-02-11 12:25:27 +01:00
|
|
|
timerLength->setSingleShot(true);
|
2016-10-04 16:34:37 +02:00
|
|
|
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
|
|
|
connect(ui->lineEditSuffix, &QLineEdit::textChanged, this, &DialogMove::SuffixChanged);
|
2020-03-18 13:45:47 +01:00
|
|
|
connect(ui->lineEditVisibilityGroup, &QLineEdit::textChanged, this, &DialogMove::GroupNameChanged);
|
2016-10-04 16:34:37 +02:00
|
|
|
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);
|
2019-02-11 12:25:27 +01:00
|
|
|
connect(ui->plainTextEditAngle, &QPlainTextEdit::textChanged, this, [this]()
|
|
|
|
{
|
|
|
|
timerAngle->start(formulaTimerTimeout);
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->plainTextEditRotationAngle, &QPlainTextEdit::textChanged, this, [this]()
|
|
|
|
{
|
|
|
|
timerRotationAngle->start(formulaTimerTimeout);
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, [this]()
|
|
|
|
{
|
|
|
|
timerLength->start(formulaTimerTimeout);
|
|
|
|
});
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
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);
|
2020-10-28 13:09:56 +01:00
|
|
|
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
|
|
|
SetTabStopDistance(ui->plainTextEditToolNotes);
|
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
|
|
|
|
{
|
2020-01-16 18:20:55 +01:00
|
|
|
return ConvertToVector(objects);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
2020-03-18 13:45:47 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogMove::GetVisibilityGroupName() const
|
|
|
|
{
|
|
|
|
return ui->lineEditVisibilityGroup->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetVisibilityGroupName(const QString &name)
|
|
|
|
{
|
|
|
|
ui->lineEditVisibilityGroup->setText(name.isEmpty() ? tr("Rotation") : name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogMove::HasLinkedVisibilityGroup() const
|
|
|
|
{
|
|
|
|
return ui->groupBoxVisibilityGroup->isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetHasLinkedVisibilityGroup(bool linked)
|
|
|
|
{
|
|
|
|
ui->groupBoxVisibilityGroup->setChecked(linked);
|
|
|
|
}
|
|
|
|
|
2020-03-24 16:31:32 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetVisibilityGroupTags(const QStringList &tags)
|
|
|
|
{
|
|
|
|
ui->lineEditGroupTags->setText(tags.join(", "));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QStringList DialogMove::GetVisibilityGroupTags() const
|
|
|
|
{
|
|
|
|
return ui->lineEditGroupTags->text().split(',');
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetGroupCategories(const QStringList &categories)
|
|
|
|
{
|
|
|
|
m_groupTags = categories;
|
|
|
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
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)
|
2020-01-16 18:20:55 +01:00
|
|
|
operation->SetObjects(ConvertToVector(objects));
|
2016-10-04 16:34:37 +02:00
|
|
|
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()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
DeployFormula(this, ui->plainTextEditAngle, ui->pushButtonGrowAngle, formulaBaseHeightAngle);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::DeployRotationAngleTextEdit()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
DeployFormula(this, ui->plainTextEditRotationAngle, ui->pushButtonGrowRotationAngle, formulaBaseHeightRotationAngle);
|
2017-11-13 18:39:11 +01:00
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::DeployLengthTextEdit()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
DeployFormula(this, ui->plainTextEditLength, ui->pushButtonGrowLength, formulaBaseHeightLength);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
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());
|
2020-10-15 17:05:21 +02:00
|
|
|
dialog->setPostfix(UnitsToStr(qApp->patternUnits(), 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;
|
2019-02-11 12:25:27 +01:00
|
|
|
ChangeColor(ui->labelSuffix, errorColor);
|
2016-10-04 16:34:37 +02:00
|
|
|
CheckState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_suffix != suffix)
|
|
|
|
{
|
|
|
|
QRegularExpression rx(NameRegExp());
|
2018-09-18 15:38:16 +02:00
|
|
|
const QStringList uniqueNames = data->AllUniqueNames();
|
2018-04-03 13:36:38 +02:00
|
|
|
for (auto &uniqueName : uniqueNames)
|
2016-10-04 16:34:37 +02:00
|
|
|
{
|
2018-04-03 13:36:38 +02:00
|
|
|
const QString name = uniqueName + suffix;
|
2016-10-04 16:34:37 +02:00
|
|
|
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
|
|
|
|
{
|
|
|
|
flagName = false;
|
2019-02-11 12:25:27 +01:00
|
|
|
ChangeColor(ui->labelSuffix, errorColor);
|
2016-10-04 16:34:37 +02:00
|
|
|
CheckState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flagName = true;
|
2019-02-11 12:25:27 +01:00
|
|
|
ChangeColor(ui->labelSuffix, OkColor(this));
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2020-03-18 13:45:47 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::GroupNameChanged()
|
|
|
|
{
|
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
|
|
|
if (edit)
|
|
|
|
{
|
|
|
|
const QString name = edit->text();
|
|
|
|
if (name.isEmpty())
|
|
|
|
{
|
|
|
|
flagGroupName = false;
|
|
|
|
ChangeColor(ui->labelGroupName, errorColor);
|
|
|
|
CheckState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
flagGroupName = true;
|
|
|
|
ChangeColor(ui->labelGroupName, OkColor(this));
|
|
|
|
}
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
2020-01-16 18:20:55 +01:00
|
|
|
operation->SetObjects(ConvertToVector(objects));
|
2016-10-04 16:34:37 +02:00
|
|
|
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();
|
2020-03-24 16:31:32 +01:00
|
|
|
|
|
|
|
QStringList groupTags = ui->lineEditGroupTags->text().split(',');
|
|
|
|
for (auto &tag : groupTags)
|
|
|
|
{
|
|
|
|
tag = tag.trimmed();
|
|
|
|
if (not m_groupTags.contains(tag))
|
|
|
|
{
|
|
|
|
m_groupTags.append(tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->lineEditGroupTags->SetCompletion(m_groupTags);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
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()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
FormulaData formulaData;
|
|
|
|
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);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
|
|
|
|
2017-11-13 18:39:11 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::EvalRotationAngle()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
FormulaData formulaData;
|
|
|
|
formulaData.formula = ui->plainTextEditRotationAngle->toPlainText();
|
|
|
|
formulaData.variables = data->DataVariables();
|
|
|
|
formulaData.labelEditFormula = ui->labelEditRotationAngle;
|
|
|
|
formulaData.labelResult = ui->labelResultRotationAngle;
|
|
|
|
formulaData.postfix = degreeSymbol;
|
|
|
|
formulaData.checkZero = false;
|
|
|
|
|
|
|
|
Eval(formulaData, flagRotationAngle);
|
2017-11-13 18:39:11 +01:00
|
|
|
}
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::EvalLength()
|
|
|
|
{
|
2019-02-11 12:25:27 +01:00
|
|
|
FormulaData formulaData;
|
|
|
|
formulaData.formula = ui->plainTextEditLength->toPlainText();
|
|
|
|
formulaData.variables = data->DataVariables();
|
|
|
|
formulaData.labelEditFormula = ui->labelEditLength;
|
|
|
|
formulaData.labelResult = ui->labelResultLength;
|
2020-10-15 17:05:21 +02:00
|
|
|
formulaData.postfix = UnitsToStr(qApp->patternUnits(), true);
|
2019-02-11 12:25:27 +01:00
|
|
|
|
|
|
|
Eval(formulaData, flagLength);
|
2016-10-04 16:34:37 +02:00
|
|
|
}
|
2020-10-28 13:09:56 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogMove::SetNotes(const QString ¬es)
|
|
|
|
{
|
|
|
|
ui->plainTextEditToolNotes->setPlainText(notes);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogMove::GetNotes() const
|
|
|
|
{
|
|
|
|
return ui->plainTextEditToolNotes->toPlainText();
|
|
|
|
}
|