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 dialogtool.cpp
|
2013-11-15 13:41:26 +01:00
|
|
|
|
** @author Roman Telezhinsky <dismine@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.
|
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
|
** <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-07-28 00:18:06 +02:00
|
|
|
|
#include "dialogtool.h"
|
2013-11-06 16:49:07 +01:00
|
|
|
|
#include "../container/calculator.h"
|
2013-07-28 00:18:06 +02:00
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
DialogTool::DialogTool(const VContainer *data, Draw::Draws mode, QWidget *parent)
|
|
|
|
|
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0),
|
|
|
|
|
spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
|
|
|
|
|
labelEditNamePoint(0), labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandartTable(0),
|
|
|
|
|
radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0),
|
|
|
|
|
idDetail(0), mode(mode)
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(data != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
timerFormula = new QTimer(this);
|
|
|
|
|
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::closeEvent(QCloseEvent *event)
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
DialogClosed(QDialog::Rejected);
|
|
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::showEvent(QShowEvent *event)
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
QDialog::showEvent( event );
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if ( event->spontaneous() )
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (isInitialized)
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-10-04 18:51:03 +02:00
|
|
|
|
isInitialized = true;//first show windows are held
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
|
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
|
box->clear();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
|
{
|
2013-10-04 13:32:42 +02:00
|
|
|
|
const QHash<qint64, VPointF> *points = data->DataPoints();
|
|
|
|
|
QHashIterator<qint64, VPointF> i(*points);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
while (i.hasNext())
|
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
|
i.next();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (i.key() != id)
|
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
|
VPointF point = i.value();
|
|
|
|
|
box->addItem(point.name(), i.key());
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (idDetail <= 0)
|
|
|
|
|
{
|
2013-10-04 18:51:03 +02:00
|
|
|
|
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
|
2013-09-10 14:29:06 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
VDetail det = data->GetDetail(idDetail);
|
2013-11-07 15:40:39 +01:00
|
|
|
|
for (ptrdiff_t i = 0; i< det.CountNode(); ++i)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
|
|
|
|
if (det[i].getTypeTool() == Tool::NodePoint ||
|
|
|
|
|
det[i].getTypeTool() == Tool::AlongLineTool ||
|
|
|
|
|
det[i].getTypeTool() == Tool::BisectorTool ||
|
|
|
|
|
det[i].getTypeTool() == Tool::EndLineTool ||
|
|
|
|
|
det[i].getTypeTool() == Tool::LineIntersectTool ||
|
|
|
|
|
det[i].getTypeTool() == Tool::NormalTool ||
|
|
|
|
|
det[i].getTypeTool() == Tool::PointOfContact ||
|
|
|
|
|
det[i].getTypeTool() == Tool::ShoulderPointTool)
|
|
|
|
|
{
|
|
|
|
|
if (det[i].getId() != id)
|
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
|
VPointF point = data->GetModelingPoint(det[i].getId());
|
|
|
|
|
box->addItem(point.name(), det[i].getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-13 18:48:36 +02:00
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
|
|
|
|
|
{
|
2013-10-14 14:57:04 +02:00
|
|
|
|
Q_ASSERT(box != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
QStringList list;
|
2013-10-04 18:51:03 +02:00
|
|
|
|
list<<tr("Line")<<tr("No line");
|
2013-07-28 00:18:06 +02:00
|
|
|
|
box->addItems(list);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
QString DialogTool::GetTypeLine(const QComboBox *box) const
|
|
|
|
|
{
|
|
|
|
|
if (box->currentText()==tr("Line"))
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
return QString("hair");
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
return QString("none");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
|
|
|
|
|
{
|
|
|
|
|
if (value == "hair")
|
|
|
|
|
{
|
2013-10-04 18:51:03 +02:00
|
|
|
|
qint32 index = box->findText(tr("Line"));
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
|
box->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (value == "none")
|
|
|
|
|
{
|
2013-10-04 18:51:03 +02:00
|
|
|
|
qint32 index = box->findText(tr("No line"));
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
|
box->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
|
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
|
qint32 index = box->findText(value);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
|
box->setCurrentIndex(index);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-10-18 12:03:01 +02:00
|
|
|
|
qWarning()<<tr("Can't find point by name")<<value;
|
2013-07-29 14:55:40 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ChangeCurrentData(QComboBox *box, const qint64 &value) const
|
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
|
qint32 index = box->findData(value);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
|
box->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::PutValHere(QLineEdit *lineEdit, QListWidget *listWidget)
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(lineEdit != 0);
|
|
|
|
|
Q_ASSERT(listWidget != 0);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
QListWidgetItem *item = listWidget->currentItem();
|
2013-10-14 18:18:08 +02:00
|
|
|
|
int pos = lineEdit->cursorPosition();
|
|
|
|
|
lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text()));
|
2013-10-04 18:51:03 +02:00
|
|
|
|
lineEdit->setFocus();
|
2013-10-14 18:18:08 +02:00
|
|
|
|
lineEdit->setCursorPosition(pos + item->text().size());
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(edit != 0);
|
|
|
|
|
Q_ASSERT(timer != 0);
|
|
|
|
|
Q_ASSERT(labelEditFormula != 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (edit->text().isEmpty())
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
flag = false;
|
|
|
|
|
CheckState();
|
2013-10-06 18:22:21 +02:00
|
|
|
|
QPalette palette = labelEditFormula->palette();
|
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
|
|
|
|
labelEditFormula->setPalette(palette);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
timer->start(1000);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label)
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(edit != 0);
|
|
|
|
|
Q_ASSERT(timer != 0);
|
|
|
|
|
Q_ASSERT(label != 0);
|
|
|
|
|
Q_ASSERT(labelEditFormula != 0);
|
2013-10-06 18:22:21 +02:00
|
|
|
|
QPalette palette = labelEditFormula->palette();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (edit->text().isEmpty())
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
flag = false;
|
2013-10-06 18:22:21 +02:00
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
Calculator cal(data);
|
|
|
|
|
QString errorMsg;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
qreal result = cal.eval(edit->text(), &errorMsg);
|
|
|
|
|
if (errorMsg.isEmpty() == false)
|
|
|
|
|
{
|
2013-10-04 18:51:03 +02:00
|
|
|
|
label->setText(tr("Error"));
|
2013-08-06 09:56:09 +02:00
|
|
|
|
flag = false;
|
2013-10-06 18:22:21 +02:00
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), Qt::red);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
label->setText(QString().setNum(result));
|
|
|
|
|
flag = true;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76));
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CheckState();
|
|
|
|
|
timer->stop();
|
2013-10-06 18:22:21 +02:00
|
|
|
|
labelEditFormula->setPalette(palette);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(box != 0);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
FillComboBoxPoints(box, id);
|
|
|
|
|
pointId = value;
|
|
|
|
|
ChangeCurrentData(box, value);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
qint64 DialogTool::getCurrentPointId(QComboBox *box) const
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(box != 0);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
qint32 index = box->currentIndex();
|
|
|
|
|
Q_ASSERT(index != -1);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (index != -1)
|
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
|
return qvariant_cast<qint64>(box->itemData(index));
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::CheckState()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(bOk != 0);
|
2013-09-12 15:25:24 +02:00
|
|
|
|
bOk->setEnabled(flagFormula && flagName);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-06 20:46:07 +01:00
|
|
|
|
void DialogTool::ChoosedObject(qint64 id, const Scene::Scenes &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
Q_UNUSED(id);
|
|
|
|
|
Q_UNUSED(type);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::NamePointChanged()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(labelEditNamePoint != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (edit)
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
QString name = edit->text();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (name.isEmpty() || name.contains(" "))
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
flagName = false;
|
2013-10-06 18:22:21 +02:00
|
|
|
|
QPalette palette = labelEditNamePoint->palette();
|
|
|
|
|
palette.setColor(labelEditNamePoint->foregroundRole(), Qt::red);
|
|
|
|
|
labelEditNamePoint->setPalette(palette);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
flagName = true;
|
2013-10-06 18:22:21 +02:00
|
|
|
|
QPalette palette = labelEditNamePoint->palette();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
palette.setColor(labelEditNamePoint->foregroundRole(), QColor(76, 76, 76));
|
2013-10-06 18:22:21 +02:00
|
|
|
|
labelEditNamePoint->setPalette(palette);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CheckState();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::DialogAccepted()
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
emit DialogClosed(QDialog::Accepted);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::DialogRejected()
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
emit DialogClosed(QDialog::Rejected);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::FormulaChanged()
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (edit)
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ValFormulaChanged(flagFormula, edit, timerFormula);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowUp()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(90);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowDown()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(270);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowLeft()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(180);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowRight()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(0);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowLeftUp()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(135);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowLeftDown()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(225);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowRightUp()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(45);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ArrowRightDown()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(spinBoxAngle != 0);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
spinBoxAngle->setValue(315);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::EvalFormula()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(lineEditFormula != 0);
|
|
|
|
|
Q_ASSERT(labelResultCalculation != 0);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::SizeGrowth()
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ShowVariable(data->DataBase());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::StandartTable()
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ShowVariable(data->DataStandartTable());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::LengthLines()
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ShowVariable(data->DataLengthLines());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::LengthArcs()
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
ShowVariable(data->DataLengthArcs());
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::LengthCurves()
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
ShowVariable(data->DataLengthSplines());
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::Increments()
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ShowVariable(data->DataIncrementTable());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::PutHere()
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
PutValHere(lineEditFormula, listWidget);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::PutVal(QListWidgetItem *item)
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(lineEditFormula != 0);
|
2013-10-14 18:18:08 +02:00
|
|
|
|
Q_ASSERT(item != 0);
|
|
|
|
|
int pos = lineEditFormula->cursorPosition();
|
|
|
|
|
lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(),
|
|
|
|
|
item->text()));
|
2013-10-04 18:51:03 +02:00
|
|
|
|
lineEditFormula->setFocus();
|
2013-10-14 18:18:08 +02:00
|
|
|
|
lineEditFormula->setCursorPosition(pos + item->text().size());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ValChenged(int row)
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(listWidget != 0);
|
|
|
|
|
Q_ASSERT(labelDescription != 0);
|
|
|
|
|
Q_ASSERT(radioButtonSizeGrowth != 0);
|
|
|
|
|
Q_ASSERT(radioButtonStandartTable != 0);
|
|
|
|
|
Q_ASSERT(radioButtonIncrements != 0);
|
|
|
|
|
Q_ASSERT(radioButtonLengthLine != 0);
|
|
|
|
|
Q_ASSERT(radioButtonLengthArc != 0);
|
|
|
|
|
Q_ASSERT(radioButtonLengthCurve != 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (listWidget->count() == 0)
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QListWidgetItem *item = listWidget->item( row );
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonSizeGrowth->isChecked())
|
|
|
|
|
{
|
|
|
|
|
if (item->text()=="Р")
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg(tr("Growth"));
|
2013-07-28 00:18:06 +02:00
|
|
|
|
labelDescription->setText(desc);
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (item->text()=="Сг")
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
|
2013-07-28 00:18:06 +02:00
|
|
|
|
labelDescription->setText(desc);
|
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
|
return;
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonStandartTable->isChecked())
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
VStandartTableCell stable = data->GetStandartTableCell(item->text());
|
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandartTableCell(item->text()))
|
|
|
|
|
.arg(stable.GetDescription());
|
|
|
|
|
labelDescription->setText(desc);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
return;
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonIncrements->isChecked())
|
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
|
VIncrementTableRow itable = data->GetIncrementTableRow(item->text());
|
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueIncrementTableRow(item->text()))
|
|
|
|
|
.arg(itable.getDescription());
|
|
|
|
|
labelDescription->setText(desc);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
return;
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonLengthLine->isChecked())
|
|
|
|
|
{
|
2013-07-29 14:55:40 +02:00
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text()))
|
2013-10-04 18:51:03 +02:00
|
|
|
|
.arg(tr("Line length"));
|
2013-07-29 14:55:40 +02:00
|
|
|
|
labelDescription->setText(desc);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
return;
|
2013-07-29 14:55:40 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonLengthArc->isChecked())
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthArc(item->text()))
|
|
|
|
|
.arg(tr("Arc length"));
|
|
|
|
|
labelDescription->setText(desc);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonLengthCurve->isChecked())
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLengthSpline(item->text()))
|
|
|
|
|
.arg(tr("Curve length"));
|
|
|
|
|
labelDescription->setText(desc);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::UpdateList()
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(radioButtonSizeGrowth != 0);
|
|
|
|
|
Q_ASSERT(radioButtonStandartTable != 0);
|
|
|
|
|
Q_ASSERT(radioButtonIncrements != 0);
|
|
|
|
|
Q_ASSERT(radioButtonLengthLine != 0);
|
|
|
|
|
Q_ASSERT(radioButtonLengthArc != 0);
|
|
|
|
|
Q_ASSERT(radioButtonLengthCurve != 0);
|
2013-10-13 17:31:42 +02:00
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonSizeGrowth->isChecked())
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ShowVariable(data->DataBase());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonStandartTable->isChecked())
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ShowVariable(data->DataStandartTable());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonIncrements->isChecked())
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ShowVariable(data->DataIncrementTable());
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonLengthLine->isChecked())
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
ShowVariable(data->DataLengthLines());
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonLengthArc->isChecked())
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
ShowVariable(data->DataLengthArcs());
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (radioButtonLengthCurve->isChecked())
|
|
|
|
|
{
|
2013-10-13 17:31:42 +02:00
|
|
|
|
ShowVariable(data->DataLengthSplines());
|
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
bool DialogTool::CheckObject(const qint64 &id)
|
|
|
|
|
{
|
|
|
|
|
if (mode == Draw::Calculation || idDetail == 0)
|
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
VDetail det = data->GetDetail(idDetail);
|
|
|
|
|
return det.Containes(id);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-20 12:26:02 +02:00
|
|
|
|
template <class key, class val>
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void DialogTool::ShowVariable(const QHash<key, val> *var)
|
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(listWidget != 0);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
|
|
|
|
listWidget->clear();
|
2013-10-13 13:04:26 +02:00
|
|
|
|
|
2013-10-04 13:32:42 +02:00
|
|
|
|
QHashIterator<key, val> i(*var);
|
2013-10-13 13:04:26 +02:00
|
|
|
|
QMap<key, val> map;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
while (i.hasNext())
|
|
|
|
|
{
|
2013-08-06 09:56:09 +02:00
|
|
|
|
i.next();
|
2013-10-13 13:04:26 +02:00
|
|
|
|
map.insert(i.key(), i.value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMapIterator<key, val> iMap(map);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
while (iMap.hasNext())
|
|
|
|
|
{
|
2013-10-13 13:04:26 +02:00
|
|
|
|
iMap.next();
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(iMap.key());
|
2013-08-06 09:56:09 +02:00
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
|
listWidget->addItem(item);
|
|
|
|
|
}
|
2013-10-13 13:04:26 +02:00
|
|
|
|
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
|
2013-10-15 11:26:47 +02:00
|
|
|
|
listWidget->setCurrentRow (0);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|