2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file dialogsplinepath.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-08-09 08:49:34 +02:00
|
|
|
#include "dialogsplinepath.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QFont>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLatin1String>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QListWidgetItem>
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <Qt>
|
|
|
|
#include <new>
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
#include "../../tools/vabstracttool.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../visualization/visualization.h"
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../../visualization/path/vistoolsplinepath.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
2016-03-05 13:30:18 +01:00
|
|
|
#include "../qmuparser/qmuparsererror.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../support/dialogeditwrongformula.h"
|
|
|
|
#include "../vgeometry/../ifc/ifcdef.h"
|
|
|
|
#include "../vgeometry/vpointf.h"
|
|
|
|
#include "../vgeometry/vsplinepoint.h"
|
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vmisc/vcommonsettings.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2016-07-26 12:45:17 +02:00
|
|
|
#include "../vwidgets/vabstractmainwindow.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
|
|
|
#include "ui_dialogsplinepath.h"
|
|
|
|
#include "vtranslatevars.h"
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogSplinePath create dialog
|
|
|
|
* @param data container with data
|
|
|
|
* @param parent parent widget
|
|
|
|
*/
|
2014-07-29 14:19:11 +02:00
|
|
|
DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
2016-03-04 17:08:29 +01:00
|
|
|
: DialogTool(data, toolId, parent),
|
|
|
|
ui(new Ui::DialogSplinePath),
|
|
|
|
path(),
|
|
|
|
newDuplicate(-1),
|
|
|
|
formulaBaseHeightAngle1(0),
|
|
|
|
formulaBaseHeightAngle2(0),
|
|
|
|
formulaBaseHeightLength1(0),
|
|
|
|
formulaBaseHeightLength2(0),
|
|
|
|
flagAngle1(),
|
|
|
|
flagAngle2(),
|
|
|
|
flagLength1(),
|
|
|
|
flagLength2()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-09 08:49:34 +02:00
|
|
|
ui->setupUi(this);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
plainTextEditFormula = ui->plainTextEditAngle1F;
|
|
|
|
|
|
|
|
formulaBaseHeightAngle1 = ui->plainTextEditAngle1F->height();
|
|
|
|
formulaBaseHeightAngle2 = ui->plainTextEditAngle2F->height();
|
|
|
|
formulaBaseHeightLength1 = ui->plainTextEditLength1F->height();
|
|
|
|
formulaBaseHeightLength2 = ui->plainTextEditLength2F->height();
|
|
|
|
|
|
|
|
ui->plainTextEditAngle1F->installEventFilter(this);
|
|
|
|
ui->plainTextEditAngle2F->installEventFilter(this);
|
|
|
|
ui->plainTextEditLength1F->installEventFilter(this);
|
|
|
|
ui->plainTextEditLength2F->installEventFilter(this);
|
|
|
|
|
2014-09-07 18:51:22 +02:00
|
|
|
InitOkCancelApply(ui);
|
2014-02-14 16:16:43 +01:00
|
|
|
bOk->setEnabled(false);
|
2013-08-09 08:49:34 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
FillComboBoxPoints(ui->comboBoxPoint);
|
2015-02-02 12:10:02 +01:00
|
|
|
FillComboBoxLineColors(ui->comboBoxColor);
|
2017-05-16 12:07:53 +02:00
|
|
|
FillComboBoxTypeLine(ui->comboBoxPenStyle, CurvePenStylesPics());
|
2013-08-09 08:49:34 +02:00
|
|
|
|
2014-02-14 16:16:43 +01:00
|
|
|
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChanged);
|
2013-08-09 08:49:34 +02:00
|
|
|
connect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &DialogSplinePath::currentPointChanged);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
connect(ui->toolButtonExprAngle1, &QPushButton::clicked, this, &DialogSplinePath::FXAngle1);
|
|
|
|
connect(ui->toolButtonExprAngle2, &QPushButton::clicked, this, &DialogSplinePath::FXAngle2);
|
|
|
|
connect(ui->toolButtonExprLength1, &QPushButton::clicked, this, &DialogSplinePath::FXLength1);
|
|
|
|
connect(ui->toolButtonExprLength2, &QPushButton::clicked, this, &DialogSplinePath::FXLength2);
|
|
|
|
|
|
|
|
connect(ui->plainTextEditAngle1F, &QPlainTextEdit::textChanged, this, &DialogSplinePath::Angle1Changed);
|
|
|
|
connect(ui->plainTextEditAngle2F, &QPlainTextEdit::textChanged, this, &DialogSplinePath::Angle2Changed);
|
|
|
|
connect(ui->plainTextEditLength1F, &QPlainTextEdit::textChanged, this, &DialogSplinePath::Length1Changed);
|
|
|
|
connect(ui->plainTextEditLength2F, &QPlainTextEdit::textChanged, this, &DialogSplinePath::Length2Changed);
|
|
|
|
|
|
|
|
connect(ui->pushButtonGrowAngle1, &QPushButton::clicked, this, &DialogSplinePath::DeployAngle1TextEdit);
|
|
|
|
connect(ui->pushButtonGrowAngle2, &QPushButton::clicked, this, &DialogSplinePath::DeployAngle2TextEdit);
|
|
|
|
connect(ui->pushButtonGrowLength1, &QPushButton::clicked, this, &DialogSplinePath::DeployLength1TextEdit);
|
|
|
|
connect(ui->pushButtonGrowLength2, &QPushButton::clicked, this, &DialogSplinePath::DeployLength2TextEdit);
|
2014-09-07 18:51:22 +02:00
|
|
|
|
2015-05-21 21:24:31 +02:00
|
|
|
vis = new VisToolSplinePath(data);
|
2016-02-13 17:24:32 +01:00
|
|
|
auto path = qobject_cast<VisToolSplinePath *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(path != nullptr)
|
2016-02-13 17:24:32 +01:00
|
|
|
|
|
|
|
auto scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(scene != nullptr)
|
2016-02-13 17:24:32 +01:00
|
|
|
connect(scene, &VMainGraphicsScene::MouseLeftPressed, path, &VisToolSplinePath::MouseLeftPressed);
|
|
|
|
connect(scene, &VMainGraphicsScene::MouseLeftReleased, path, &VisToolSplinePath::MouseLeftReleased);
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2013-11-04 21:35:15 +01:00
|
|
|
DialogSplinePath::~DialogSplinePath()
|
|
|
|
{
|
2013-08-09 08:49:34 +02:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief SetPath set spline path
|
|
|
|
* @param value path
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSplinePath::SetPath(const VSplinePath &value)
|
|
|
|
{
|
2016-03-04 17:08:29 +01:00
|
|
|
flagAngle1.clear();
|
|
|
|
flagAngle2.clear();
|
|
|
|
flagLength1.clear();
|
|
|
|
flagLength2.clear();
|
|
|
|
|
2013-08-09 08:49:34 +02:00
|
|
|
this->path = value;
|
2014-09-07 18:51:22 +02:00
|
|
|
ui->listWidget->blockSignals(true);
|
2013-11-04 21:35:15 +01:00
|
|
|
ui->listWidget->clear();
|
2016-03-16 19:07:50 +01:00
|
|
|
for (qint32 i = 0; i < path.CountPoints(); ++i)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-03-04 17:08:29 +01:00
|
|
|
NewItem(path.at(i));
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
ui->listWidget->setFocus(Qt::OtherFocusReason);
|
2017-04-11 12:42:42 +02:00
|
|
|
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
|
2014-09-07 18:51:22 +02:00
|
|
|
|
2016-02-13 22:39:47 +01:00
|
|
|
auto visPath = qobject_cast<VisToolSplinePath *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(visPath != nullptr)
|
2014-09-07 18:51:22 +02:00
|
|
|
visPath->setPath(path);
|
|
|
|
ui->listWidget->blockSignals(false);
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString DialogSplinePath::GetPenStyle() const
|
|
|
|
{
|
|
|
|
return GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::SetPenStyle(const QString &value)
|
|
|
|
{
|
|
|
|
ChangeCurrentData(ui->comboBoxPenStyle, value);
|
|
|
|
}
|
|
|
|
|
2015-02-03 10:27:33 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
QString DialogSplinePath::GetColor() const
|
2015-02-03 10:27:33 +01:00
|
|
|
{
|
2016-10-17 13:53:46 +02:00
|
|
|
return GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack);
|
2015-02-03 10:27:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void DialogSplinePath::SetColor(const QString &value)
|
2015-02-03 10:27:33 +01:00
|
|
|
{
|
|
|
|
ChangeCurrentData(ui->comboBoxColor, value);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
|
|
|
* @param id id of point or detail
|
|
|
|
* @param type don't show this id in list
|
|
|
|
*/
|
2014-07-15 16:42:41 +02:00
|
|
|
void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
if (type == SceneObject::Point)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-02-16 13:00:56 +01:00
|
|
|
if (AllIds().contains(id))
|
2015-01-27 14:56:44 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
const auto point = data->GeometricObject<VPointF>(id);
|
|
|
|
VSplinePoint p;
|
|
|
|
p.SetP(*point);
|
|
|
|
NewItem(p);
|
2013-10-07 13:11:56 +02:00
|
|
|
emit ToolTip(tr("Select point of curve path"));
|
2014-09-07 18:51:22 +02:00
|
|
|
|
|
|
|
SavePath();
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2016-02-13 17:24:32 +01:00
|
|
|
auto visPath = qobject_cast<VisToolSplinePath *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(visPath != nullptr)
|
2014-09-07 18:51:22 +02:00
|
|
|
visPath->setPath(path);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2016-03-16 19:07:50 +01:00
|
|
|
if (path.CountPoints() == 1)
|
2014-09-07 18:51:22 +02:00
|
|
|
{
|
|
|
|
visPath->VisualMode(NULL_ID);
|
2016-07-26 12:45:17 +02:00
|
|
|
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(window != nullptr)
|
2016-07-26 12:45:17 +02:00
|
|
|
connect(visPath, &VisToolSplinePath::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
|
|
|
|
2014-09-07 18:51:22 +02:00
|
|
|
connect(visPath, &VisToolSplinePath::PathChanged, this, &DialogSplinePath::PathUpdated);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
visPath->RefreshGeometry();
|
|
|
|
}
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-03-04 17:08:29 +01:00
|
|
|
/**
|
|
|
|
* @brief SaveData Put dialog data in local variables
|
|
|
|
*/
|
2014-08-13 12:20:30 +02:00
|
|
|
void DialogSplinePath::SaveData()
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-02-16 13:00:56 +01:00
|
|
|
const quint32 d = path.GetDuplicate();//Save previous value
|
2014-09-07 18:51:22 +02:00
|
|
|
SavePath();
|
2016-02-16 13:00:56 +01:00
|
|
|
newDuplicate <= -1 ? path.SetDuplicate(d) : path.SetDuplicate(static_cast<quint32>(newDuplicate));
|
2014-09-07 18:51:22 +02:00
|
|
|
|
2016-02-13 22:39:47 +01:00
|
|
|
auto visPath = qobject_cast<VisToolSplinePath *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(visPath != nullptr)
|
2014-09-07 18:51:22 +02:00
|
|
|
visPath->setPath(path);
|
2016-02-13 22:39:47 +01:00
|
|
|
visPath->SetMode(Mode::Show);
|
2014-09-07 18:51:22 +02:00
|
|
|
visPath->RefreshGeometry();
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::CheckState()
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(bOk != nullptr)
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
bool fAngle1 = true, fAngle2 = true, fLength1 = true, fLength2 = true;
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(true);
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength1F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength2F->blockSignals(true);
|
|
|
|
DialogTool::closeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::DeployAngle1TextEdit()
|
|
|
|
{
|
|
|
|
DeployFormula(ui->plainTextEditAngle1F, ui->pushButtonGrowAngle1, formulaBaseHeightAngle1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::DeployAngle2TextEdit()
|
|
|
|
{
|
|
|
|
DeployFormula(ui->plainTextEditAngle2F, ui->pushButtonGrowAngle2, formulaBaseHeightAngle2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::DeployLength1TextEdit()
|
|
|
|
{
|
|
|
|
DeployFormula(ui->plainTextEditLength1F, ui->pushButtonGrowLength1, formulaBaseHeightLength1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::DeployLength2TextEdit()
|
|
|
|
{
|
|
|
|
DeployFormula(ui->plainTextEditLength2F, ui->pushButtonGrowLength2, formulaBaseHeightLength2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::Angle1Changed()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
if (row != 0)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-05 13:30:18 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
const QString angle1F = ui->plainTextEditAngle1F->toPlainText().replace("\n", " ");
|
|
|
|
const qreal angle1 = Visualization::FindVal(angle1F, data->PlainVariables());
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
p.SetAngle1(angle1, qApp->TrVars()->FormulaFromUser(angle1F, qApp->Settings()->GetOsSeparator()));
|
|
|
|
}
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
{
|
|
|
|
Q_UNUSED(e)
|
|
|
|
p.SetAngle1(angle1, angle1F);
|
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 14:22:24 +01:00
|
|
|
EvalAngle1();
|
2016-03-05 13:30:18 +01:00
|
|
|
|
|
|
|
if (row != ui->listWidget->count()-1)
|
|
|
|
{
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(true);
|
2016-05-23 17:23:39 +02:00
|
|
|
ui->plainTextEditAngle2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle2Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
2016-03-05 13:30:18 +01:00
|
|
|
EvalAngle2();
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(false);
|
|
|
|
}
|
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::Angle2Changed()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
if (row != ui->listWidget->count()-1)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-05 13:30:18 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
const QString angle2F = ui->plainTextEditAngle2F->toPlainText().replace("\n", " ");
|
|
|
|
const qreal angle2 = Visualization::FindVal(angle2F, data->PlainVariables());
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
p.SetAngle2(angle2, qApp->TrVars()->FormulaFromUser(angle2F, qApp->Settings()->GetOsSeparator()));
|
|
|
|
}
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
{
|
|
|
|
Q_UNUSED(e)
|
|
|
|
p.SetAngle2(angle2, angle2F);
|
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 14:22:24 +01:00
|
|
|
EvalAngle2();
|
2016-03-05 13:30:18 +01:00
|
|
|
|
|
|
|
if (row != 0)
|
|
|
|
{
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(true);
|
2016-05-23 17:23:39 +02:00
|
|
|
ui->plainTextEditAngle1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle1Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
2016-03-05 13:30:18 +01:00
|
|
|
EvalAngle1();
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(false);
|
|
|
|
}
|
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::Length1Changed()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
if (row != 0)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-05 13:30:18 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
const QString length1F = ui->plainTextEditLength1F->toPlainText().replace("\n", " ");
|
|
|
|
const qreal length1 = Visualization::FindLength(length1F, data->PlainVariables());
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
p.SetLength1(length1, qApp->TrVars()->FormulaFromUser(length1F, qApp->Settings()->GetOsSeparator()));
|
|
|
|
}
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
{
|
|
|
|
Q_UNUSED(e)
|
|
|
|
p.SetLength1(length1, length1F);
|
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
|
|
|
|
2016-03-05 14:22:24 +01:00
|
|
|
EvalLength1();
|
2016-03-05 13:30:18 +01:00
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::Length2Changed()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
if (row != ui->listWidget->count()-1)
|
|
|
|
{
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-05 13:30:18 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
const QString length2F = ui->plainTextEditLength2F->toPlainText().replace("\n", " ");
|
|
|
|
const qreal length2 = Visualization::FindLength(length2F, data->PlainVariables());
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
p.SetLength2(length2, qApp->TrVars()->FormulaFromUser(length2F, qApp->Settings()->GetOsSeparator()));
|
|
|
|
}
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
{
|
|
|
|
Q_UNUSED(e)
|
|
|
|
p.SetLength2(length2, length2F);
|
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
|
|
|
|
2016-03-05 14:22:24 +01:00
|
|
|
EvalLength2();
|
2016-03-05 13:30:18 +01:00
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::FXAngle1()
|
|
|
|
{
|
|
|
|
auto dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit first control point angle"));
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-05 16:27:07 +01:00
|
|
|
QString angle1F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditAngle1F->toPlainText().replace("\n", " "),
|
|
|
|
qApp->Settings()->GetOsSeparator());
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
dialog->SetFormula(angle1F);
|
2016-08-26 18:20:03 +02:00
|
|
|
dialog->setPostfix(degreeSymbol);
|
2016-03-04 17:08:29 +01:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
angle1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
|
2016-03-04 17:08:29 +01:00
|
|
|
// increase height if needed.
|
|
|
|
if (angle1F.length() > 80)
|
|
|
|
{
|
|
|
|
DeployAngle1TextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditAngle1F->setPlainText(angle1F);
|
|
|
|
MoveCursorToEnd(ui->plainTextEditAngle1F);
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::FXAngle2()
|
|
|
|
{
|
|
|
|
auto dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit second control point angle"));
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-05 16:27:07 +01:00
|
|
|
QString angle2F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditAngle2F->toPlainText().replace("\n", " "),
|
|
|
|
qApp->Settings()->GetOsSeparator());
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
dialog->SetFormula(angle2F);
|
2016-08-26 18:20:03 +02:00
|
|
|
dialog->setPostfix(degreeSymbol);
|
2016-03-04 17:08:29 +01:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
angle2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
|
2016-03-04 17:08:29 +01:00
|
|
|
// increase height if needed.
|
|
|
|
if (angle2F.length() > 80)
|
|
|
|
{
|
|
|
|
DeployAngle1TextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditAngle2F->setPlainText(angle2F);
|
|
|
|
MoveCursorToEnd(ui->plainTextEditAngle2F);
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::FXLength1()
|
|
|
|
{
|
|
|
|
auto dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit first control point length"));
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-05 16:27:07 +01:00
|
|
|
QString length1F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText().replace("\n", " "),
|
|
|
|
qApp->Settings()->GetOsSeparator());
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
dialog->SetFormula(length1F);
|
2017-07-02 13:34:36 +02:00
|
|
|
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
|
2016-03-04 17:08:29 +01:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
length1F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
|
2016-03-04 17:08:29 +01:00
|
|
|
// increase height if needed.
|
|
|
|
if (length1F.length() > 80)
|
|
|
|
{
|
|
|
|
DeployLength1TextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditLength1F->setPlainText(length1F);
|
|
|
|
MoveCursorToEnd(ui->plainTextEditLength1F);
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::FXLength2()
|
|
|
|
{
|
|
|
|
auto dialog = new DialogEditWrongFormula(data, toolId, this);
|
|
|
|
dialog->setWindowTitle(tr("Edit second control point length"));
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-05 16:27:07 +01:00
|
|
|
QString length2F = qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText().replace("\n", " "),
|
|
|
|
qApp->Settings()->GetOsSeparator());
|
2016-03-05 13:30:18 +01:00
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
dialog->SetFormula(length2F);
|
2017-07-02 13:34:36 +02:00
|
|
|
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
|
2016-03-04 17:08:29 +01:00
|
|
|
if (dialog->exec() == QDialog::Accepted)
|
|
|
|
{
|
2016-05-23 17:23:39 +02:00
|
|
|
length2F = qApp->TrVars()->FormulaToUser(dialog->GetFormula(), qApp->Settings()->GetOsSeparator());
|
2016-03-04 17:08:29 +01:00
|
|
|
// increase height if needed.
|
|
|
|
if (length2F.length() > 80)
|
|
|
|
{
|
|
|
|
DeployLength2TextEdit();
|
|
|
|
}
|
|
|
|
ui->plainTextEditLength2F->setPlainText(length2F);
|
|
|
|
MoveCursorToEnd(ui->plainTextEditLength2F);
|
|
|
|
}
|
|
|
|
delete dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::EvalAngle1()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
labelEditFormula = ui->labelEditAngle1;
|
|
|
|
Eval(ui->plainTextEditAngle1F->toPlainText(), flagAngle1[row], ui->labelResultAngle1, degreeSymbol, false);
|
|
|
|
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-04 17:08:29 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
|
|
|
|
|
|
|
ShowPointIssue(p.P().name());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::EvalAngle2()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
labelEditFormula = ui->labelEditAngle2;
|
|
|
|
Eval(ui->plainTextEditAngle2F->toPlainText(), flagAngle2[row], ui->labelResultAngle2, degreeSymbol, false);
|
|
|
|
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-04 17:08:29 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
|
|
|
|
|
|
|
ShowPointIssue(p.P().name());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::EvalLength1()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
labelEditFormula = ui->labelEditLength1;
|
2017-07-02 13:34:36 +02:00
|
|
|
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
2016-03-04 17:08:29 +01:00
|
|
|
const qreal length1 = Eval(ui->plainTextEditLength1F->toPlainText(), flagLength1[row], ui->labelResultLength1,
|
2016-08-26 18:33:54 +02:00
|
|
|
postfix, false);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
if (length1 < 0)
|
|
|
|
{
|
|
|
|
flagLength1[row] = false;
|
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2016-08-26 18:33:54 +02:00
|
|
|
ui->labelResultLength1->setText(tr("Error") + QLatin1String(" (") + postfix + QLatin1String(")"));
|
2016-03-04 17:08:29 +01:00
|
|
|
ui->labelResultLength1->setToolTip(tr("Length can't be negative"));
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-04 17:08:29 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
|
|
|
|
|
|
|
ShowPointIssue(p.P().name());
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::EvalLength2()
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
labelEditFormula = ui->labelEditLength2;
|
2017-07-02 13:34:36 +02:00
|
|
|
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
2016-03-04 17:08:29 +01:00
|
|
|
const qreal length2 = Eval(ui->plainTextEditLength2F->toPlainText(), flagLength2[row], ui->labelResultLength2,
|
2016-08-26 18:33:54 +02:00
|
|
|
postfix, false);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
if (length2 < 0)
|
|
|
|
{
|
|
|
|
flagLength2[row] = false;
|
|
|
|
ChangeColor(labelEditFormula, Qt::red);
|
2016-08-26 18:33:54 +02:00
|
|
|
ui->labelResultLength2->setText(tr("Error") + QLatin1String(" (") + postfix + QLatin1String(")"));
|
2016-03-04 17:08:29 +01:00
|
|
|
ui->labelResultLength2->setToolTip(tr("Length can't be negative"));
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-04 17:08:29 +01:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
|
|
|
|
|
|
|
ShowPointIssue(p.P().name());
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief PointChanged selected another point in list
|
|
|
|
* @param row number of row
|
|
|
|
*/
|
2014-02-14 16:16:43 +01:00
|
|
|
void DialogSplinePath::PointChanged(int row)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
if (ui->listWidget->count() == 0)
|
|
|
|
{
|
2013-08-09 08:49:34 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-03-05 13:30:18 +01:00
|
|
|
|
|
|
|
const auto p = qvariant_cast<VSplinePoint>(ui->listWidget->item(row)->data(Qt::UserRole));
|
|
|
|
DataPoint(p);
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief currentPointChanged changed point in combo box
|
|
|
|
* @param index index in list
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogSplinePath::currentPointChanged(int index)
|
|
|
|
{
|
2016-03-04 17:08:29 +01:00
|
|
|
const quint32 id = qvariant_cast<quint32>(ui->comboBoxPoint->itemData(index));
|
|
|
|
QListWidgetItem *item = ui->listWidget->item( ui->listWidget->currentRow() );
|
2013-08-09 08:49:34 +02:00
|
|
|
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
|
2016-03-05 13:30:18 +01:00
|
|
|
const auto point = data->GeometricObject<VPointF>(id);
|
2013-12-29 17:48:57 +01:00
|
|
|
p.SetP(*point);
|
2016-03-04 17:08:29 +01:00
|
|
|
DataPoint(p);
|
2013-08-09 08:49:34 +02:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(p));
|
2016-03-04 17:08:29 +01:00
|
|
|
ShowPointIssue(p.P().name());
|
2016-02-16 13:00:56 +01:00
|
|
|
|
|
|
|
QColor color = okColor;
|
|
|
|
if (not IsPathValid())
|
|
|
|
{
|
|
|
|
flagError = false;
|
|
|
|
color = errorColor;
|
|
|
|
|
|
|
|
ui->lineEditSplPathName->setText(tr("Invalid spline path"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flagError = true;
|
|
|
|
color = okColor;
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
2016-03-16 19:07:50 +01:00
|
|
|
if (first.P().id() == path.at(0).P().id() && last.P().id() == path.at(path.CountPoints()-1).P().id())
|
2016-02-16 13:00:56 +01:00
|
|
|
{
|
|
|
|
newDuplicate = -1;
|
2017-04-11 12:42:42 +02:00
|
|
|
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
|
2016-02-16 13:00:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VSplinePath newPath = ExtractPath();
|
|
|
|
|
|
|
|
if (not data->IsUnique(newPath.name()))
|
|
|
|
{
|
2016-05-03 18:50:37 +02:00
|
|
|
newDuplicate = static_cast<qint32>(DNumber(newPath.name()));
|
|
|
|
newPath.SetDuplicate(static_cast<quint32>(newDuplicate));
|
2016-02-16 13:00:56 +01:00
|
|
|
}
|
|
|
|
|
2017-04-11 12:42:42 +02:00
|
|
|
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name()));
|
2016-02-16 13:00:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ChangeColor(ui->labelName, color);
|
|
|
|
ChangeColor(ui->labelPoint, color);
|
|
|
|
CheckState();
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
|
2014-09-07 18:51:22 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::ShowDialog(bool click)
|
|
|
|
{
|
|
|
|
if (click == false)
|
|
|
|
{
|
2016-03-16 19:07:50 +01:00
|
|
|
if (path.CountPoints() >= 3)
|
2014-11-21 18:24:16 +01:00
|
|
|
{
|
|
|
|
emit ToolTip("");
|
2016-02-16 13:00:56 +01:00
|
|
|
|
|
|
|
if (not data->IsUnique(path.name()))
|
|
|
|
{
|
|
|
|
path.SetDuplicate(DNumber(path.name()));
|
|
|
|
}
|
|
|
|
|
2014-11-21 18:24:16 +01:00
|
|
|
DialogAccepted();
|
|
|
|
}
|
2014-09-07 18:51:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::PathUpdated(const VSplinePath &path)
|
|
|
|
{
|
|
|
|
SetPath(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::ShowVisualization()
|
|
|
|
{
|
2016-02-12 19:10:01 +01:00
|
|
|
AddVisualization<VisToolSplinePath>();
|
2014-09-07 18:51:22 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief NewItem add point to list
|
2016-03-04 17:08:29 +01:00
|
|
|
* @param point spline path point
|
2014-06-02 16:28:02 +02:00
|
|
|
*/
|
2016-03-04 17:08:29 +01:00
|
|
|
void DialogSplinePath::NewItem(const VSplinePoint &point)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2016-03-05 17:30:45 +01:00
|
|
|
flagAngle1.append(true);
|
|
|
|
flagLength1.append(true);
|
|
|
|
flagAngle2.append(true);
|
|
|
|
flagLength2.append(true);
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
auto item = new QListWidgetItem(point.P().name());
|
2013-08-09 08:49:34 +02:00
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
2016-03-04 17:08:29 +01:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(point));
|
|
|
|
|
2013-08-09 08:49:34 +02:00
|
|
|
ui->listWidget->addItem(item);
|
2014-02-14 16:16:43 +01:00
|
|
|
ui->listWidget->setCurrentItem(item);
|
|
|
|
if (ui->listWidget->count() >= 2)
|
|
|
|
{
|
|
|
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
|
|
|
bOk->setEnabled(true);
|
|
|
|
}
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
DataPoint(point);
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-02 16:28:02 +02:00
|
|
|
/**
|
|
|
|
* @brief dataPoint show data of point in fields
|
2016-03-04 17:08:29 +01:00
|
|
|
* @param p spline path point
|
2014-06-02 16:28:02 +02:00
|
|
|
*/
|
2016-03-04 17:08:29 +01:00
|
|
|
void DialogSplinePath::DataPoint(const VSplinePoint &p)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-09 10:43:01 +02:00
|
|
|
ui->comboBoxPoint->blockSignals(true);
|
2016-03-04 17:08:29 +01:00
|
|
|
ChangeCurrentData(ui->comboBoxPoint, p.P().id());
|
2014-08-09 10:43:01 +02:00
|
|
|
ui->comboBoxPoint->blockSignals(false);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
int row = ui->listWidget->currentRow();
|
2016-03-04 17:08:29 +01:00
|
|
|
const QString field = tr("Not used");
|
2016-03-05 13:30:18 +01:00
|
|
|
const QString emptyRes = QString("_");
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
if (row == 0)
|
|
|
|
{
|
2016-03-05 13:30:18 +01:00
|
|
|
ui->toolButtonExprAngle1->setEnabled(false);
|
|
|
|
ui->labelResultAngle1->setText(emptyRes);
|
|
|
|
ui->labelResultAngle1->setToolTip(tr("Value"));
|
|
|
|
ChangeColor(ui->labelEditAngle1, okColor);
|
2016-03-04 17:08:29 +01:00
|
|
|
ui->plainTextEditAngle1F->blockSignals(true);
|
|
|
|
ui->plainTextEditAngle1F->setPlainText(field);
|
|
|
|
ui->plainTextEditAngle1F->setEnabled(false);
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(false);
|
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
ui->toolButtonExprLength1->setEnabled(false);
|
|
|
|
ui->labelResultLength1->setText(emptyRes);
|
|
|
|
ui->labelResultLength1->setToolTip(tr("Value"));
|
|
|
|
ChangeColor(ui->labelEditLength1, okColor);
|
2016-03-04 17:08:29 +01:00
|
|
|
ui->plainTextEditLength1F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength1F->setPlainText(field);
|
|
|
|
ui->plainTextEditLength1F->setEnabled(false);
|
|
|
|
ui->plainTextEditLength1F->blockSignals(false);
|
2016-03-05 13:30:18 +01:00
|
|
|
|
|
|
|
ui->plainTextEditAngle2F->setEnabled(true);
|
|
|
|
ui->plainTextEditLength2F->setEnabled(true);
|
|
|
|
|
|
|
|
ui->toolButtonExprAngle2->setEnabled(true);
|
|
|
|
ui->toolButtonExprLength2->setEnabled(true);
|
|
|
|
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength2F->blockSignals(true);
|
2016-05-23 17:23:39 +02:00
|
|
|
ui->plainTextEditAngle2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle2Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
2016-03-05 13:30:18 +01:00
|
|
|
EvalAngle2();
|
2016-05-23 17:23:39 +02:00
|
|
|
ui->plainTextEditLength2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length2Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
2016-03-05 13:30:18 +01:00
|
|
|
EvalLength2();
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(false);
|
|
|
|
ui->plainTextEditLength2F->blockSignals(false);
|
2016-03-04 17:08:29 +01:00
|
|
|
}
|
|
|
|
else if (row == ui->listWidget->count()-1)
|
|
|
|
{
|
2016-03-05 13:30:18 +01:00
|
|
|
ui->toolButtonExprAngle2->setEnabled(false);
|
|
|
|
ui->labelResultAngle2->setText(emptyRes);
|
|
|
|
ui->labelResultAngle2->setToolTip(tr("Value"));
|
|
|
|
ChangeColor(ui->labelEditAngle2, okColor);
|
2016-03-04 17:08:29 +01:00
|
|
|
ui->plainTextEditAngle2F->blockSignals(true);
|
|
|
|
ui->plainTextEditAngle2F->setPlainText(field);
|
|
|
|
ui->plainTextEditAngle2F->setEnabled(false);
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(false);
|
|
|
|
|
2016-03-05 13:30:18 +01:00
|
|
|
ui->toolButtonExprLength2->setEnabled(false);
|
|
|
|
ui->labelResultLength2->setText(emptyRes);
|
|
|
|
ui->labelResultLength2->setToolTip(tr("Value"));
|
|
|
|
ChangeColor(ui->labelEditLength2, okColor);
|
2016-03-04 17:08:29 +01:00
|
|
|
ui->plainTextEditLength2F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength2F->setPlainText(field);
|
|
|
|
ui->plainTextEditLength2F->setEnabled(false);
|
|
|
|
ui->plainTextEditLength2F->blockSignals(false);
|
2016-03-05 13:30:18 +01:00
|
|
|
|
|
|
|
ui->plainTextEditAngle1F->setEnabled(true);
|
|
|
|
ui->plainTextEditLength1F->setEnabled(true);
|
|
|
|
|
|
|
|
ui->toolButtonExprAngle1->setEnabled(true);
|
|
|
|
ui->toolButtonExprLength1->setEnabled(true);
|
|
|
|
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength1F->blockSignals(true);
|
2016-05-23 17:23:39 +02:00
|
|
|
ui->plainTextEditAngle1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle1Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
2016-03-05 13:30:18 +01:00
|
|
|
EvalAngle1();
|
2016-05-23 17:23:39 +02:00
|
|
|
ui->plainTextEditLength1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length1Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
2016-03-05 13:30:18 +01:00
|
|
|
EvalLength1();
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(false);
|
|
|
|
ui->plainTextEditLength1F->blockSignals(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->toolButtonExprAngle1->setEnabled(true);
|
|
|
|
ui->toolButtonExprLength1->setEnabled(true);
|
|
|
|
ui->toolButtonExprAngle2->setEnabled(true);
|
|
|
|
ui->toolButtonExprLength2->setEnabled(true);
|
|
|
|
|
|
|
|
ui->plainTextEditAngle1F->setEnabled(true);
|
|
|
|
ui->plainTextEditLength1F->setEnabled(true);
|
|
|
|
ui->plainTextEditAngle2F->setEnabled(true);
|
|
|
|
ui->plainTextEditLength2F->setEnabled(true);
|
|
|
|
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength1F->blockSignals(true);
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(true);
|
|
|
|
ui->plainTextEditLength2F->blockSignals(true);
|
|
|
|
|
2016-05-23 17:23:39 +02:00
|
|
|
ui->plainTextEditAngle1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle1Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
|
|
|
ui->plainTextEditAngle2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Angle2Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
|
|
|
ui->plainTextEditLength1F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length1Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
|
|
|
ui->plainTextEditLength2F->setPlainText(qApp->TrVars()->FormulaToUser(p.Length2Formula(),
|
|
|
|
qApp->Settings()->GetOsSeparator()));
|
2016-03-05 13:30:18 +01:00
|
|
|
|
|
|
|
EvalAngle1();
|
|
|
|
EvalLength1();
|
|
|
|
EvalAngle2();
|
|
|
|
EvalLength2();
|
|
|
|
|
|
|
|
ui->plainTextEditAngle1F->blockSignals(false);
|
|
|
|
ui->plainTextEditLength1F->blockSignals(false);
|
|
|
|
ui->plainTextEditAngle2F->blockSignals(false);
|
|
|
|
ui->plainTextEditLength2F->blockSignals(false);
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-07 18:51:22 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::SavePath()
|
|
|
|
{
|
|
|
|
path.Clear();
|
2016-02-16 13:00:56 +01:00
|
|
|
path = ExtractPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSet<quint32> DialogSplinePath::AllIds() const
|
|
|
|
{
|
|
|
|
QSet<quint32> ids;
|
|
|
|
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
|
|
|
|
{
|
|
|
|
ids.insert(qvariant_cast<VSplinePoint>(ui->listWidget->item(i)->data(Qt::UserRole)).P().id());
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool DialogSplinePath::IsPathValid() const
|
|
|
|
{
|
2016-03-16 19:07:50 +01:00
|
|
|
if (path.CountPoints() < 3)
|
2016-02-16 13:00:56 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-16 19:07:50 +01:00
|
|
|
return (AllIds().size() == path.CountPoints());
|
2016-02-16 13:00:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSplinePath DialogSplinePath::ExtractPath() const
|
|
|
|
{
|
2016-03-04 17:08:29 +01:00
|
|
|
QVector<VSplinePoint> points;
|
2014-09-07 18:51:22 +02:00
|
|
|
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
|
|
|
|
{
|
2016-03-04 17:08:29 +01:00
|
|
|
points.append(qvariant_cast<VSplinePoint>(ui->listWidget->item(i)->data(Qt::UserRole)));
|
|
|
|
}
|
|
|
|
return VSplinePath(points);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSplinePath::ShowPointIssue(const QString &pName)
|
|
|
|
{
|
|
|
|
const int row = ui->listWidget->currentRow();
|
|
|
|
if (row == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = ui->listWidget->item(row);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(item != nullptr)
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
if (flagAngle1.at(row) && flagAngle2.at(row) && flagLength1.at(row) && flagLength2.at(row))
|
|
|
|
{
|
|
|
|
item->setText(pName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-20 10:39:15 +02:00
|
|
|
item->setText(pName + QLatin1String("(!)"));
|
2014-09-07 18:51:22 +02:00
|
|
|
}
|
|
|
|
}
|