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 dialoghistory.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-08-15 22:39:00 +02:00
|
|
|
#include "dialoghistory.h"
|
|
|
|
#include "ui_dialoghistory.h"
|
2014-02-21 14:04:39 +01:00
|
|
|
#include "../../geometry/varc.h"
|
|
|
|
#include "../../geometry/vspline.h"
|
|
|
|
#include "../../geometry/vsplinepath.h"
|
|
|
|
#include "../../tools/vabstracttool.h"
|
|
|
|
#include "../../tools/drawTools/vtoolcutspline.h"
|
|
|
|
#include "../../tools/drawTools/vtoolcutsplinepath.h"
|
|
|
|
#include "../../tools/drawTools/vtoolcutarc.h"
|
2013-09-12 16:18:31 +02:00
|
|
|
#include <QDebug>
|
2013-11-21 13:05:26 +01:00
|
|
|
#include <QPushButton>
|
2013-08-15 22:39:00 +02:00
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
|
2013-12-21 12:36:51 +01:00
|
|
|
:DialogTool(data, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0),
|
2013-11-04 21:35:15 +01:00
|
|
|
cursorToolRecordRow(0)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
ui->setupUi(this);
|
|
|
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
|
|
|
connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted);
|
|
|
|
FillTable();
|
|
|
|
InitialTable();
|
|
|
|
connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked);
|
2014-02-25 15:02:09 +01:00
|
|
|
connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool);
|
|
|
|
connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor);
|
|
|
|
connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory);
|
|
|
|
connect(doc, &VPattern::ChangedActivDraw, this, &DialogHistory::UpdateHistory);
|
2013-08-15 22:39:00 +02:00
|
|
|
ShowPoint();
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
DialogHistory::~DialogHistory()
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogHistory::DialogAccepted()
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
2013-08-15 22:39:00 +02:00
|
|
|
emit ShowHistoryTool(id, Qt::green, false);
|
|
|
|
emit DialogClosed(QDialog::Accepted);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogHistory::cellClicked(int row, int column)
|
|
|
|
{
|
|
|
|
if (column == 0)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
|
|
|
|
item->setIcon(QIcon());
|
|
|
|
|
|
|
|
item = ui->tableWidget->item(row, 0);
|
|
|
|
cursorRow = row;
|
|
|
|
item->setIcon(QIcon("://icon/32x32/put_after.png"));
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
2014-02-25 15:02:09 +01:00
|
|
|
disconnect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor);
|
2013-08-15 22:39:00 +02:00
|
|
|
doc->setCursor(id);
|
2014-02-25 15:02:09 +01:00
|
|
|
connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
2013-08-15 22:39:00 +02:00
|
|
|
emit ShowHistoryTool(id, Qt::green, false);
|
|
|
|
|
|
|
|
cursorToolRecordRow = row;
|
|
|
|
item = ui->tableWidget->item(cursorToolRecordRow, 0);
|
2014-02-25 15:40:24 +01:00
|
|
|
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
2013-08-15 22:39:00 +02:00
|
|
|
emit ShowHistoryTool(id, Qt::green, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-25 15:40:24 +01:00
|
|
|
void DialogHistory::ChangedCursor(quint32 id)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
for (qint32 i = 0; i< ui->tableWidget->rowCount(); ++i)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QTableWidgetItem *item = ui->tableWidget->item(i, 0);
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 rId = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
2013-11-04 21:35:15 +01:00
|
|
|
if (rId == id)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0);
|
|
|
|
oldCursorItem->setIcon(QIcon());
|
|
|
|
cursorRow = i;
|
|
|
|
item->setIcon(QIcon("://icon/32x32/put_after.png"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogHistory::UpdateHistory()
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
FillTable();
|
|
|
|
InitialTable();
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogHistory::FillTable()
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
ui->tableWidget->clear();
|
2014-03-02 19:32:54 +01:00
|
|
|
const QVector<VToolRecord> *history = doc->getHistory();
|
|
|
|
Q_CHECK_PTR(history);
|
2013-08-15 22:39:00 +02:00
|
|
|
qint32 currentRow = -1;
|
|
|
|
qint32 count = 0;
|
|
|
|
ui->tableWidget->setRowCount(history->size());
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i< history->size(); ++i)
|
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const VToolRecord tool = history->at(i);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (tool.getNameDraw() != doc->GetNameActivDraw())
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
continue;
|
|
|
|
}
|
2014-03-02 19:32:54 +01:00
|
|
|
const QString historyRecord = Record(tool);
|
|
|
|
if (historyRecord.isEmpty() ==false)
|
|
|
|
{
|
|
|
|
currentRow++;
|
2013-08-15 22:39:00 +02:00
|
|
|
|
2014-03-02 19:32:54 +01:00
|
|
|
{
|
|
|
|
QTableWidgetItem *item = new QTableWidgetItem(QString());
|
|
|
|
item->setTextAlignment(Qt::AlignHCenter);
|
|
|
|
item->setData(Qt::UserRole, tool.getId());
|
|
|
|
ui->tableWidget->setItem(currentRow, 0, item);
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
|
2014-03-02 19:32:54 +01:00
|
|
|
QTableWidgetItem *item = new QTableWidgetItem(historyRecord);
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
|
|
|
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
|
|
|
|
ui->tableWidget->setItem(currentRow, 1, item);
|
|
|
|
++count;
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
ui->tableWidget->setRowCount(count);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (history->size()>0)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
cursorRow = currentRow;
|
|
|
|
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
|
2014-03-02 19:32:54 +01:00
|
|
|
Q_CHECK_PTR(item);
|
2013-08-15 22:39:00 +02:00
|
|
|
item->setIcon(QIcon("://icon/32x32/put_after.png"));
|
|
|
|
}
|
|
|
|
ui->tableWidget->resizeColumnsToContents();
|
|
|
|
ui->tableWidget->resizeRowsToContents();
|
|
|
|
ui->tableWidget->verticalHeader()->setDefaultSectionSize(20);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QString DialogHistory::Record(const VToolRecord &tool)
|
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const QDomElement domElement = doc->elementById(QString().setNum(tool.getId()));
|
|
|
|
if (domElement.isElement() == false)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
qWarning()<<"Can't find element by id"<<Q_FUNC_INFO;
|
|
|
|
return QString(tr("Can't create record."));
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
switch ( tool.getTypeTool() )
|
2013-12-29 17:48:57 +01:00
|
|
|
{
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::ArrowTool:
|
2014-03-02 19:32:54 +01:00
|
|
|
Q_UNREACHABLE();
|
|
|
|
break;
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::SinglePointTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const QString name = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%1 - Base point")).arg(name);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::EndLineTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
|
|
|
|
const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::LineTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
|
|
|
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
|
|
|
return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::AlongLineTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
|
|
|
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::ShoulderPointTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const QString name = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%1 - Point of shoulder")).arg(name);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::NormalTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
|
|
|
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::BisectorTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const quint32 thirdPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0");
|
|
|
|
const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
|
|
|
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
|
|
|
const QString thirdPointIdName = data->GeometricObject<const VPointF *>(thirdPointId)->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, secondPointIdName,
|
|
|
|
thirdPointIdName, toolIdName);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::LineIntersectTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 p1Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0");
|
|
|
|
const quint32 p2Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0");
|
|
|
|
const quint32 p1Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0");
|
|
|
|
const quint32 p2Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0");
|
|
|
|
const QString p1Line1Name = data->GeometricObject<const VPointF *>(p1Line1)->name();
|
|
|
|
const QString p2Line1Name = data->GeometricObject<const VPointF *>(p2Line1)->name();
|
|
|
|
const QString p1Line2Name = data->GeometricObject<const VPointF *>(p1Line2)->name();
|
|
|
|
const QString p2Line2Name = data->GeometricObject<const VPointF *>(p2Line2)->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(p1Line1Name, p2Line1Name,
|
|
|
|
p1Line2Name, p2Line2Name,
|
|
|
|
toolIdName);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::SplineTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const VSpline *spl = data->GeometricObject<const VSpline *>(tool.getId());
|
|
|
|
Q_CHECK_PTR(spl);
|
|
|
|
const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
|
|
|
|
const QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name();
|
|
|
|
return QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name);
|
2013-10-18 12:03:01 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::ArcTool:
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const VArc *arc = data->GeometricObject<const VArc *>(tool.getId());
|
|
|
|
Q_CHECK_PTR(arc);
|
|
|
|
const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
|
|
|
|
return QString(tr("Arc with center in point %1")).arg(arcCenterName);
|
2013-10-18 20:20:54 +02:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::SplinePathTool:
|
2014-01-18 11:02:24 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(tool.getId());
|
|
|
|
Q_CHECK_PTR(splPath);
|
|
|
|
const QVector<VSplinePoint> points = splPath->GetSplinePath();
|
|
|
|
QString record;
|
|
|
|
if (points.size() != 0 )
|
|
|
|
{
|
|
|
|
const QString pName = data->GeometricObject<const VPointF *>(points.at(0).P().id())->name();
|
|
|
|
record = QString(tr("Curve point %1")).arg(pName);
|
2014-03-06 16:35:24 +01:00
|
|
|
if (points.size() > 1)
|
2014-03-02 19:32:54 +01:00
|
|
|
{
|
|
|
|
const QString pName = data->GeometricObject<const VPointF *>(points.last().P().id())->name();
|
|
|
|
record.append(QString("_%1").arg(pName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
|
|
|
|
return QString(tr("Can't create record."));
|
|
|
|
}
|
|
|
|
return record;
|
2014-01-18 11:02:24 +01:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::PointOfContact:
|
2014-01-08 15:05:32 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 center = doc->GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
|
|
|
|
const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
|
|
|
const QString centerName = data->GeometricObject<const VPointF *>(center)->name();
|
|
|
|
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg(
|
|
|
|
centerName, firstPointIdName, secondPointIdName, toolIdName);
|
2014-01-08 15:05:32 +01:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::Height:
|
2013-12-24 10:58:23 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
|
|
|
|
const quint32 p1LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
|
|
|
|
const quint32 p2LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
|
|
|
|
const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
|
|
|
|
const QString p1LineIdName = data->GeometricObject<const VPointF *>(p1LineId)->name();
|
|
|
|
const QString p2LineIdName = data->GeometricObject<const VPointF *>(p2LineId)->name();
|
|
|
|
return QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg(basePointIdName,
|
|
|
|
p1LineIdName,
|
|
|
|
p2LineIdName);
|
2013-12-24 10:58:23 +01:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::Triangle:
|
2014-03-02 19:32:54 +01:00
|
|
|
{
|
|
|
|
const quint32 axisP1Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0");
|
|
|
|
const quint32 axisP2Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0");
|
|
|
|
const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const QString axisP1IdName = data->GeometricObject<const VPointF *>(axisP1Id)->name();
|
|
|
|
const QString axisP2IdName = data->GeometricObject<const VPointF *>(axisP2Id)->name();
|
|
|
|
const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
|
|
|
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
|
|
|
return QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(axisP1IdName, axisP2IdName,
|
|
|
|
firstPointIdName, secondPointIdName);
|
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::PointOfIntersection:
|
2014-03-02 19:32:54 +01:00
|
|
|
{
|
|
|
|
const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
|
|
|
|
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%1 - point of intersection %2 and %3")).arg(toolIdName, firstPointIdName,
|
|
|
|
secondPointIdName);
|
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::CutArcTool:
|
2014-03-02 19:32:54 +01:00
|
|
|
{
|
|
|
|
const quint32 arcId = doc->GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
|
|
|
|
const VArc *arc = data->GeometricObject<const VArc *>(arcId);
|
|
|
|
Q_CHECK_PTR(arc);
|
|
|
|
const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
return QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName);
|
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::CutSplineTool:
|
2013-12-24 10:58:23 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 splineId = doc->GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
|
|
|
|
const VSpline *spl = data->GeometricObject<const VSpline *>(splineId);
|
|
|
|
Q_CHECK_PTR(spl);
|
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
|
|
|
|
const QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name();
|
|
|
|
return QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name);
|
2013-12-24 10:58:23 +01:00
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::CutSplinePathTool:
|
2013-12-24 10:58:23 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const quint32 splinePathId = doc->GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
|
|
|
|
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
|
|
|
|
Q_CHECK_PTR(splPath);
|
|
|
|
const QVector<VSplinePoint> points = splPath->GetSplinePath();
|
|
|
|
QString record;
|
|
|
|
if (points.size() != 0 )
|
2013-12-24 10:58:23 +01:00
|
|
|
{
|
2014-03-02 19:32:54 +01:00
|
|
|
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
|
|
|
|
const QString pName = data->GeometricObject<const VPointF *>(points.at(0).P().id())->name();
|
|
|
|
record = QString(tr("%1 - cut curve path %2")).arg(toolIdName, pName);
|
|
|
|
if (points.size() > 1)
|
|
|
|
{
|
|
|
|
const QString pName = data->GeometricObject<const VPointF *>(points.last().P().id())->name();
|
|
|
|
const QString name = QString("_%1").arg(pName);
|
|
|
|
record.append(name);
|
|
|
|
}
|
2013-12-24 10:58:23 +01:00
|
|
|
}
|
2014-03-02 19:32:54 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
|
|
|
|
return QString(tr("Can't create record."));
|
|
|
|
}
|
|
|
|
return record;
|
2013-12-24 10:58:23 +01:00
|
|
|
}
|
2014-03-02 19:32:54 +01:00
|
|
|
//Because "history" not only show history of pattern, but help restore current data for each pattern's
|
|
|
|
//piece, we need add record about details and nodes, but don't show them.
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::DetailTool:
|
2014-03-02 19:32:54 +01:00
|
|
|
break;
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::UnionDetails:
|
2014-03-02 19:32:54 +01:00
|
|
|
break;
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::NodeArc:
|
2014-03-02 19:32:54 +01:00
|
|
|
break;
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::NodePoint:
|
2014-03-02 19:32:54 +01:00
|
|
|
break;
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::NodeSpline:
|
2014-03-02 19:32:54 +01:00
|
|
|
break;
|
2014-03-11 12:43:24 +01:00
|
|
|
case Valentina::NodeSplinePath:
|
2014-03-02 19:32:54 +01:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-26 05:39:07 +01:00
|
|
|
qWarning()<<"Got wrong tool type. Ignore.";
|
2014-03-02 19:32:54 +01:00
|
|
|
break;
|
2013-12-24 10:58:23 +01:00
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2014-03-02 19:32:54 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
qWarning()<<e.ErrorMessage()<<Q_FUNC_INFO;
|
|
|
|
return QString(tr("Can't create record."));
|
|
|
|
}
|
|
|
|
return QString();
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogHistory::InitialTable()
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
ui->tableWidget->setSortingEnabled(false);
|
|
|
|
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" "));
|
2013-10-04 18:51:03 +02:00
|
|
|
ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Tool")));
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogHistory::ShowPoint()
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QVector<VToolRecord> *history = doc->getHistory();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (history->size()>0)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QTableWidgetItem *item = ui->tableWidget->item(0, 1);
|
|
|
|
item->setSelected(true);
|
|
|
|
cursorToolRecordRow = 0;
|
|
|
|
item = ui->tableWidget->item(0, 0);
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
2013-08-15 22:39:00 +02:00
|
|
|
emit ShowHistoryTool(id, Qt::green, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void DialogHistory::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
2013-08-15 22:39:00 +02:00
|
|
|
emit ShowHistoryTool(id, Qt::green, false);
|
|
|
|
DialogTool::closeEvent(event);
|
|
|
|
}
|