From ece5024156e2b35bbfd31b73639b73fff3386b47 Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 15 Aug 2013 23:39:00 +0300 Subject: [PATCH] Add history window --- Valentina.pro | 11 +- container/calculator.h | 5 + container/vcontainer.cpp | 32 ++++- container/vcontainer.h | 10 +- container/vpointf.cpp | 22 +-- container/vpointf.h | 5 +- cursor.qrc | 1 - cursor/spoint_cursor.png | Bin 1264 -> 0 bytes dialogs/dialoghistory.cpp | 248 ++++++++++++++++++++++++++++++++ dialogs/dialoghistory.h | 41 ++++++ dialogs/dialoghistory.ui | 99 +++++++++++++ dialogs/dialogincrements.cpp | 2 +- dialogs/dialoglineintersect.cpp | 4 +- dialogs/dialogtool.h | 4 +- icon.qrc | 3 +- icon/32x32/history.png | Bin 0 -> 3639 bytes icon/32x32/put_after.png | Bin 0 -> 520 bytes icon/32x32/spoint.png | Bin 1764 -> 0 bytes mainwindow.cpp | 159 ++++++++------------ mainwindow.h | 27 +--- mainwindow.ui | 143 ++++++++---------- options.h | 18 +++ tools/vabstracttool.cpp | 42 +++++- tools/vabstracttool.h | 4 + tools/vtoolalongline.cpp | 3 +- tools/vtoolarc.cpp | 18 ++- tools/vtoolarc.h | 1 + tools/vtoolbisector.cpp | 4 +- tools/vtoolendline.cpp | 4 +- tools/vtoolline.cpp | 18 ++- tools/vtoolline.h | 1 + tools/vtoollineintersect.cpp | 2 +- tools/vtoolnormal.cpp | 2 +- tools/vtoolpoint.cpp | 16 ++- tools/vtoolpoint.h | 1 + tools/vtoolshoulderpoint.cpp | 2 +- tools/vtoolsinglepoint.cpp | 9 +- tools/vtoolsinglepoint.h | 1 + tools/vtoolspline.cpp | 18 ++- tools/vtoolspline.h | 1 + tools/vtoolsplinepath.cpp | 18 ++- tools/vtoolsplinepath.h | 1 + xml/vdomdocument.cpp | 122 +++++++++------- xml/vdomdocument.h | 22 ++- xml/vtoolrecord.cpp | 32 +++++ xml/vtoolrecord.h | 32 +++++ 46 files changed, 888 insertions(+), 320 deletions(-) delete mode 100644 cursor/spoint_cursor.png create mode 100644 dialogs/dialoghistory.cpp create mode 100644 dialogs/dialoghistory.h create mode 100644 dialogs/dialoghistory.ui create mode 100644 icon/32x32/history.png create mode 100644 icon/32x32/put_after.png delete mode 100644 icon/32x32/spoint.png create mode 100644 xml/vtoolrecord.cpp create mode 100644 xml/vtoolrecord.h diff --git a/Valentina.pro b/Valentina.pro index 2497e8fe2..24f758038 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -56,7 +56,9 @@ SOURCES += main.cpp\ dialogs/dialogsplinepath.cpp \ widgets/vmaingraphicsscene.cpp \ widgets/vmaingraphicsview.cpp \ - tools/vdatatool.cpp + tools/vdatatool.cpp \ + xml/vtoolrecord.cpp \ + dialogs/dialoghistory.cpp HEADERS += mainwindow.h \ widgets/vmaingraphicsscene.h \ @@ -103,7 +105,9 @@ HEADERS += mainwindow.h \ tools/vtoolsplinepath.h \ dialogs/dialogsplinepath.h \ widgets/vmaingraphicsview.h \ - tools/vdatatool.h + tools/vdatatool.h \ + xml/vtoolrecord.h \ + dialogs/dialoghistory.h FORMS += mainwindow.ui \ dialogs/dialogsinglepoint.ui \ @@ -117,7 +121,8 @@ FORMS += mainwindow.ui \ dialogs/dialoglineintersect.ui \ dialogs/dialogspline.ui \ dialogs/dialogarc.ui \ - dialogs/dialogsplinepath.ui + dialogs/dialogsplinepath.ui \ + dialogs/dialoghistory.ui RESOURCES += \ icon.qrc \ diff --git a/container/calculator.h b/container/calculator.h index 2ae1f3c01..fe0e024ad 100644 --- a/container/calculator.h +++ b/container/calculator.h @@ -1,11 +1,16 @@ #ifndef CALCULATOR_H #define CALCULATOR_H +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include #include #include #include #include +#pragma GCC diagnostic pop #include "vcontainer.h" /** diff --git a/container/vcontainer.cpp b/container/vcontainer.cpp index 453caebc7..ca5af747c 100644 --- a/container/vcontainer.cpp +++ b/container/vcontainer.cpp @@ -3,13 +3,33 @@ #include "../options.h" +qint64 VContainer::_id = 0; + VContainer::VContainer(){ - _id = 0; SetSize(500); SetGrowth(1760); CreateManTableIGroup (); } +const VContainer &VContainer::operator =(const VContainer &data){ + setData(data); + return *this; +} + +void VContainer::setData(const VContainer &data){ + base = *data.DataBase(); + points = *data.DataPoints(); + standartTable = *data.DataStandartTable(); + incrementTable = *data.DataIncrementTable(); + lengthLines = *data.DataLengthLines(); + lineArcs = *data.DataLengthArcs(); + splines = *data.DataSplines(); + lengthSplines = *data.DataLengthSplines(); + arcs = *data.DataArcs(); + lengthArcs = *data.DataLengthArcs(); + splinePaths = *data.DataSplinePaths(); +} + template val VContainer::GetObject(const QMap &obj, key id)const{ if(obj.contains(id)){ @@ -151,17 +171,21 @@ qreal VContainer::GetValueIncrementTableRow(const QString& name) const{ void VContainer::Clear(){ _id = 0; - points.clear(); standartTable.clear(); incrementTable.clear(); lengthLines.clear(); - splines.clear(); - arcs.clear(); lengthArcs.clear(); lineArcs.clear(); + ClearObject(); CreateManTableIGroup (); } +void VContainer::ClearObject(){ + points.clear(); + splines.clear(); + arcs.clear(); +} + void VContainer::ClearIncrementTable(){ incrementTable.clear(); } diff --git a/container/vcontainer.h b/container/vcontainer.h index 8afe7e81d..c0c85411e 100644 --- a/container/vcontainer.h +++ b/container/vcontainer.h @@ -1,13 +1,16 @@ #ifndef VCONTAINER_H #define VCONTAINER_H +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" #include #include +#pragma GCC diagnostic pop #include "vpointf.h" #include "vstandarttablecell.h" #include "vincrementtablerow.h" -#pragma GCC diagnostic warning "-Weffc++" #include "../geometry/vspline.h" #include "../geometry/varc.h" #include "../geometry/vsplinepath.h" @@ -22,6 +25,8 @@ public: * @brief VContainer */ VContainer(); + const VContainer &operator=(const VContainer &data); + void setData(const VContainer &data); /** * @brief GetPoint * @param id @@ -63,6 +68,7 @@ public: qreal GetValueStandartTableCell(const QString& name) const; qreal GetValueIncrementTableRow(const QString& name) const; void Clear(); + void ClearObject(); void ClearIncrementTable(); void ClearLengthLines(); void ClearLengthSplines(); @@ -89,7 +95,7 @@ public: const QMap *DataSplinePaths() const; void UpdateId(qint64 newId); private: - qint64 _id; + static qint64 _id; QMap base; QMap points; QMap standartTable; diff --git a/container/vpointf.cpp b/container/vpointf.cpp index b93297c35..11c4ec646 100644 --- a/container/vpointf.cpp +++ b/container/vpointf.cpp @@ -1,26 +1,14 @@ #include "vpointf.h" -VPointF::VPointF(){ - _mx = 0; - _my = 0; - this->_x = 0; - this->_y = 0; +VPointF::VPointF():_name(QString()), _mx(0), _my(0), _x(0), _y(0){ } -VPointF::VPointF ( const VPointF & point ){ - _name = point.name(); - _mx = point.mx(); - _my = point.my(); - this->_x = point.x(); - this->_y = point.y(); +VPointF::VPointF ( const VPointF & point ):_name(point.name()), _mx(point.mx()), _my(point.my()), + _x(point.x()), _y(point.y()){ } -VPointF::VPointF (qreal x, qreal y , QString name, qreal mx, qreal my){ - _name = name; - _mx = mx; - _my = my; - this->_x = x; - this->_y = y; +VPointF::VPointF (qreal x, qreal y , QString name, qreal mx, qreal my):_name(name), _mx(mx), _my(my), _x(x), + _y(y){ } VPointF::~VPointF(){ diff --git a/container/vpointf.h b/container/vpointf.h index 6a7302350..d07915124 100644 --- a/container/vpointf.h +++ b/container/vpointf.h @@ -1,10 +1,13 @@ #ifndef VPOINTF_H #define VPOINTF_H +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" #include #include -#pragma GCC diagnostic warning "-Weffc++" +#pragma GCC diagnostic pop class VPointF { diff --git a/cursor.qrc b/cursor.qrc index 3d19a93e9..ab84498f9 100644 --- a/cursor.qrc +++ b/cursor.qrc @@ -1,6 +1,5 @@ - cursor/spoint_cursor.png cursor/endline_cursor.png cursor/line_cursor.png cursor/alongline_cursor.png diff --git a/cursor/spoint_cursor.png b/cursor/spoint_cursor.png deleted file mode 100644 index 6aaeb759ef717e05277d1ebce1d93378940f7fd3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1264 zcmVVl&|00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-3I{@DmvaRe4qdT06}y` zSad^gZEa<4bO1wAML|?gQaT`KWG!lNWoICEF)lD5D0OpbZf77#N=G0{P(?=|b~Z98 zEFf`pVQgu1c_2L?IWP*aMOc#n00b~eL_t(Y$HiA|NLyDJeopR)tjP~~SUGs*926n6kw6?Y` z+U<6#sHh+!I&-Ya%gf8}0HEC5TuNM@n3zavUJ(F9Q3L=4gF*6mJfziXk(Za}aXOt> zl78~a%E~(cNDu^Kj1d6xdcD2L&Z|kB$g&Kg9psmnmrpl0H@A4b-jZWExq5naFvh5) zq=b5Vdoz;8d15Gv0stT)XfzsFtya|3)T}2BcE)zDHe)RQtQOMM)dj{F*=#l{C@9b; zjdPXn#9)j;6h#mb#>U1%>Uv*aA4?kSiNQHXAP^w8+fAHvxZQ44S63fR^1V*1h9C%# zWf=ficXu}cpscLy=waUra?Ux32t*V&qq(^`0I(Dl6+LsLS1oaU4n+#(NilV?|GLh5i zWZT=@yBv>m9(O(>f+R@*0K473KOU>9s^a||0BJOu_!V=xT>HLGqobp2-<&Io0*yu! z?`W#9dU|^H)lv%!3+cjzdW0k4^s7H!gw+Ke7-LvNt!#TZ8~3mDR6u27Hw{AvW3*RLZQ4YNS-AvQL{Ad*2~AOH+> z{+2EUQY3In{dE2qfO&d)nkFYFD;y5Tz+oCjBoYGWGPo=u7L7tyIR1VR06<95>ac8> zg3+ko5!~S5;DD-nhr@B`E_v=;A?9cQfId}+bh8l)^D9t@AtuR?BndL##+m2xBn^@f zXC02WPCjizW`+r|C`X#f0FzMsetupUi(this); + bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted); + FillTable(); + InitialTable(); + connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked); + connect(this, &DialogHistory::ShowHistoryTool, doc, &VDomDocument::ShowHistoryTool); + connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); + connect(doc, &VDomDocument::haveChange, this, &DialogHistory::UpdateHistory); + connect(doc, &VDomDocument::ChangedActivDraw, this, &DialogHistory::UpdateHistory); + ShowPoint(); +} + +DialogHistory::~DialogHistory(){ + delete ui; +} + +void DialogHistory::DialogAccepted(){ + QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); + qint64 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, false); + emit DialogClosed(QDialog::Accepted); +} + +void DialogHistory::cellClicked(int row, int column){ + if(column == 0){ + 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")); + qint64 id = qvariant_cast(item->data(Qt::UserRole)); + disconnect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); + doc->setCursor(id); + connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor); + } else { + QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); + qint64 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, false); + + cursorToolRecordRow = row; + item = ui->tableWidget->item(cursorToolRecordRow, 0); + id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, true); + } +} + +void DialogHistory::ChangedCursor(qint64 id){ + for(qint32 i = 0; i< ui->tableWidget->rowCount(); ++i){ + QTableWidgetItem *item = ui->tableWidget->item(i, 0); + qint64 rId = qvariant_cast(item->data(Qt::UserRole)); + if(rId == id){ + QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0); + oldCursorItem->setIcon(QIcon()); + cursorRow = i; + item->setIcon(QIcon("://icon/32x32/put_after.png")); + } + } +} + +void DialogHistory::UpdateHistory(){ + FillTable(); + InitialTable(); +} + +void DialogHistory::FillTable(){ + ui->tableWidget->clear(); + QVector *history = doc->getHistory(); + qint32 currentRow = -1; + qint32 count = 0; + ui->tableWidget->setRowCount(history->size()); + for(qint32 i = 0; i< history->size(); ++i){ + VToolRecord tool = history->at(i); + if(tool.getNameDraw() != doc->GetNameActivDraw()){ + continue; + } + currentRow++; + + QTableWidgetItem *item = new QTableWidgetItem(QString()); + item->setTextAlignment(Qt::AlignHCenter); + item->setData(Qt::UserRole, tool.getId()); + ui->tableWidget->setItem(currentRow, 0, item); + + QString historyRecord = Record(tool); + item = new QTableWidgetItem(historyRecord); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setFlags(item->flags() ^ Qt::ItemIsEditable); + ui->tableWidget->setItem(currentRow, 1, item); + ++count; + } + ui->tableWidget->setRowCount(count); + if(history->size()>0){ + cursorRow = currentRow; + QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + item->setIcon(QIcon("://icon/32x32/put_after.png")); + } + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->resizeRowsToContents(); + ui->tableWidget->verticalHeader()->setDefaultSectionSize(20); +} + +QString DialogHistory::Record(const VToolRecord &tool){ + QString record = QString(); + qint64 basePointId = 0; + qint64 secondPointId = 0; + qint64 firstPointId = 0; + qint64 thirdPointId = 0; + qint64 p1Line1 = 0; + qint64 p2Line1 = 0; + qint64 p1Line2 = 0; + qint64 p2Line2 = 0; + QDomElement domElement; + switch( tool.getTypeTool() ){ + case Tools::ArrowTool: + break; + case Tools::SinglePointTool: + record = QString("%1 - Базова точка").arg(data->GetPoint(tool.getId()).name()); + break; + case Tools::EndLineTool: + domElement = doc->elementById(QString().setNum(tool.getId())); + if(domElement.isElement()){ + basePointId = domElement.attribute("basePoint", "").toLongLong(); + } + record = QString("%1_%2 - Відрізок з точки %1 до точки %2").arg(data->GetPoint(basePointId).name(), + data->GetPoint(tool.getId()).name()); + break; + case Tools::LineTool: + domElement = doc->elementById(QString().setNum(tool.getId())); + if(domElement.isElement()){ + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + record = QString("%1_%2 - Лінія з точки %1 до точки %2").arg(data->GetPoint(firstPointId).name(), + data->GetPoint(secondPointId).name()); + break; + case Tools::AlongLineTool: + domElement = doc->elementById(QString().setNum(tool.getId())); + if(domElement.isElement()){ + basePointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + record = QString("%3 - Точка на відрізку %1_%2").arg(data->GetPoint(basePointId).name(), + data->GetPoint(secondPointId).name(), + data->GetPoint(tool.getId()).name()); + break; + case Tools::ShoulderPointTool: + record = QString("%1 - Плечева точка").arg(data->GetPoint(tool.getId()).name()); + break; + case Tools::NormalTool: + domElement = doc->elementById(QString().setNum(tool.getId())); + if(domElement.isElement()){ + basePointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + record = QString("%3 - Перпендикуляр до відрузку %1_%2").arg(data->GetPoint(basePointId).name(), + data->GetPoint(secondPointId).name(), + data->GetPoint(tool.getId()).name()); + break; + case Tools::BisectorTool: + domElement = doc->elementById(QString().setNum(tool.getId())); + if(domElement.isElement()){ + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + basePointId = domElement.attribute("secondPoint", "").toLongLong(); + thirdPointId = domElement.attribute("thirdPoint", "").toLongLong(); + } + record = QString("%4 - Бісектриса кута %1_%2_%3").arg(data->GetPoint(firstPointId).name(), + data->GetPoint(basePointId).name(), + data->GetPoint(thirdPointId).name(), + data->GetPoint(tool.getId()).name()); + break; + case Tools::LineIntersectTool: + domElement = doc->elementById(QString().setNum(tool.getId())); + if(domElement.isElement()){ + p1Line1 = domElement.attribute("p1Line1", "").toLongLong(); + p2Line1 = domElement.attribute("p2Line1", "").toLongLong(); + p1Line2 = domElement.attribute("p1Line2", "").toLongLong(); + p2Line2 = domElement.attribute("p2Line2", "").toLongLong(); + } + record = QString("%5 - Точка перетину відрузку %1_%2 і %3_%4").arg(data->GetPoint(p1Line1).name(), + data->GetPoint(p2Line1).name(), + data->GetPoint(p1Line2).name(), + data->GetPoint(p2Line2).name(), + data->GetPoint(tool.getId()).name()); + break; + case Tools::SplineTool:{ + VSpline spl = data->GetSpline(tool.getId()); + record = QString("Сплайн %1_%2").arg(data->GetPoint(spl.GetP1()).name(), + data->GetPoint(spl.GetP4()).name()); + } + break; + case Tools::ArcTool:{ + VArc arc = data->GetArc(tool.getId()); + record = QString("Дуга з центром в точці %1").arg(data->GetPoint(arc.GetCenter()).name()); + } + break; + case Tools::SplinePathTool:{ + VSplinePath splPath = data->GetSplinePath(tool.getId()); + QVector points = splPath.GetSplinePath(); + if(points.size() != 0 ){ + record = QString("Шлях сплайну %1").arg(data->GetPoint(points[0].P()).name()); + for(qint32 i = 1; i< points.size(); ++i){ + QString name = QString("_%1").arg(data->GetPoint(points[i].P()).name()); + record.append(name); + } + } + } + break; + } + return record; +} + +void DialogHistory::InitialTable(){ + ui->tableWidget->setSortingEnabled(false); + ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(" ")); + ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Інструмент")); +} + +void DialogHistory::ShowPoint(){ + QVector *history = doc->getHistory(); + if(history->size()>0){ + QTableWidgetItem *item = ui->tableWidget->item(0, 1); + item->setSelected(true); + cursorToolRecordRow = 0; + item = ui->tableWidget->item(0, 0); + qint64 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, true); + } +} + + +void DialogHistory::closeEvent(QCloseEvent *event){ + QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); + qint64 id = qvariant_cast(item->data(Qt::UserRole)); + emit ShowHistoryTool(id, Qt::green, false); + DialogTool::closeEvent(event); +} diff --git a/dialogs/dialoghistory.h b/dialogs/dialoghistory.h new file mode 100644 index 000000000..a702889e3 --- /dev/null +++ b/dialogs/dialoghistory.h @@ -0,0 +1,41 @@ +#ifndef DIALOGHISTORY_H +#define DIALOGHISTORY_H + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#include "dialogtool.h" +#include "../xml/vdomdocument.h" +#pragma GCC diagnostic pop + +namespace Ui { +class DialogHistory; +} + +class DialogHistory : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent = 0); + virtual ~DialogHistory(); +public slots: + virtual void DialogAccepted(); + void cellClicked(int row, int column); + void ChangedCursor(qint64 id); + void UpdateHistory(); +signals: + void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); +protected: + virtual void closeEvent ( QCloseEvent * event ); +private: + Ui::DialogHistory *ui; + VDomDocument *doc; + qint32 cursorRow; + qint32 cursorToolRecordRow; + void FillTable(); + QString Record(const VToolRecord &tool); + void InitialTable(); + void ShowPoint(); +}; + +#endif // DIALOGHISTORY_H diff --git a/dialogs/dialoghistory.ui b/dialogs/dialoghistory.ui new file mode 100644 index 000000000..65a499875 --- /dev/null +++ b/dialogs/dialoghistory.ui @@ -0,0 +1,99 @@ + + + DialogHistory + + + Qt::NonModal + + + + 0 + 0 + 488 + 420 + + + + Dialog + + + + + + true + + + true + + + false + + + true + + + false + + + false + + + + + + + + + Інструмент + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DialogHistory + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogHistory + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/dialogs/dialogincrements.cpp b/dialogs/dialogincrements.cpp index 96bf4ca00..c0dcc0ad5 100644 --- a/dialogs/dialogincrements.cpp +++ b/dialogs/dialogincrements.cpp @@ -40,11 +40,11 @@ void DialogIncrements::FillStandartTable(){ const QMap *standartTable = data->DataStandartTable(); qint32 currentRow = -1; QMapIterator i(*standartTable); + ui->tableWidgetStandart->setRowCount ( standartTable->size() ); while (i.hasNext()) { i.next(); VStandartTableCell cell = i.value(); currentRow++; - ui->tableWidgetStandart->setRowCount ( standartTable->size() ); QTableWidgetItem *item = new QTableWidgetItem(QString(i.key())); item->setTextAlignment(Qt::AlignHCenter); diff --git a/dialogs/dialoglineintersect.cpp b/dialogs/dialoglineintersect.cpp index 3e0a9a9a8..f5fdae2dc 100644 --- a/dialogs/dialoglineintersect.cpp +++ b/dialogs/dialoglineintersect.cpp @@ -127,8 +127,8 @@ bool DialogLineIntersect::CheckIntersecion(){ VPointF p1L2 = data->GetPoint(p1Line2); VPointF p2L2 = data->GetPoint(p2Line2); - QLineF line1(p1L1, p2L1); - QLineF line2(p1L2, p2L2); + QLineF line1(p1L1.toQPointF(), p2L1.toQPointF()); + QLineF line2(p1L2.toQPointF(), p2L2.toQPointF()); QPointF fPoint; QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){ diff --git a/dialogs/dialogtool.h b/dialogs/dialogtool.h index dc9b184c9..1e57cb6fe 100644 --- a/dialogs/dialogtool.h +++ b/dialogs/dialogtool.h @@ -62,8 +62,8 @@ protected: QRadioButton *radioButtonStandartTable; QRadioButton *radioButtonIncrements; QRadioButton *radioButtonLengthLine; - void closeEvent ( QCloseEvent * event ); - void showEvent( QShowEvent *event ); + virtual void closeEvent ( QCloseEvent * event ); + virtual void showEvent( QShowEvent *event ); void FillComboBoxPoints(QComboBox *box, const qint64 &id = 0)const; void FillComboBoxTypeLine(QComboBox *box) const; virtual void CheckState(); diff --git a/icon.qrc b/icon.qrc index 467aa830d..a627cf202 100644 --- a/icon.qrc +++ b/icon.qrc @@ -3,7 +3,6 @@ icon/64x64/icon64x64.png icon/32x32/draw.png icon/32x32/kontur.png - icon/32x32/spoint.png icon/32x32/arrow_cursor.png icon/32x32/new_draw.png icon/32x32/option_draw.png @@ -29,5 +28,7 @@ icon/32x32/arc.png icon/24x24/putHereLeft.png icon/32x32/splinePath.png + icon/32x32/history.png + icon/32x32/put_after.png diff --git a/icon/32x32/history.png b/icon/32x32/history.png new file mode 100644 index 0000000000000000000000000000000000000000..fb64439429ba3ecf4a504cbd37e89f188036e142 GIT binary patch literal 3639 zcmV-74#@F|P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000AGNklP+7QQVTek8DvdjIMPiGX*pP+9P{BmD z7KFNFXc0^)Qin+GmZj<+kb!_2HHm~6P>Pbuk)gyXxc-sGdGFrS!M?Y)`|92o(jLju z@x4CB-}^n^bKbk2h!DpvU;BRLL7^}awU;@4di9&Hz8sH}ua}s%na@vr`uS&(dpED& z7>k=PHh?e;`RVEpk$Zi~WZZOkohA731-`y`=kd>784zLNO#1Ci=EGC%(Fcm@iD5Q2HoBf@czBrQ^Z}v; ztprg*;m?21ZRU3ufHU0zAer~h4pDkgXV!o)Xhm~0JILDmkpxm5;XHU0YGdA7y#?*>x_(ySl`u5 zj2Lm_C_*!e4S;MmYfqldW}N|;7*hi6{4D5TpjEDAQJaMBq;T2CZTqn13J)% zjvgF`1t9Jv5R}q~W?*n|(E33TaIpWR>m>A}7zmZL)Xn{~v$I33RzpPaeV;@kK~UYr zvt@7bW(sW{ayZX{2I7?~7s&q?9$hCm zYM}7Xqx!o8sm4}%pyx;cl&S$D6uJWNJa6dY6+||tU zyi>pckOEG==qd*s2ST9p4fR;Ft?OMt6o6W@B!5NT4PUoC9RL^Myv;V)Q3e12002ov JPDHLkV1k@g+$I13 literal 0 HcmV?d00001 diff --git a/icon/32x32/put_after.png b/icon/32x32/put_after.png new file mode 100644 index 0000000000000000000000000000000000000000..69e5776830b45d16f5a4c7a40812ebaefc0ead03 GIT binary patch literal 520 zcmV+j0{8uiP)yJ#b3 zqy=qsCujskn_9SN6Be1$^SPM^F}$mHQYQjGI1HT2ob%1hH|Nad9RC;>Pzhrb2l$g z#T?x=Ch!Taa zfkHt;OiN8}X?QM@C9;ZF*{FbpZhb0|NyG1qTNQ32bbAadCbL2?`4f3=Itq z4-XI#5fT#<6jD-FNl8o>7Z^iBMNm*uO-)Z{XK86_d1YsGR8?C^N>4{fO>A(0P*PfG zZGTNqR&H~IdVY&;b%{HVbbOF;d5n31lz)esU14iWO;Txc zgoclxS6*sgX?Bm9r(k7knWV2LE;LVBVWqFOSzKOWV`N!qZ(L($Bqu1ZyT2?pIWIm! zCo3#lU}3w)$U0I~HAqPT0|NsE1qBBO2MGxa4Gj+w5fc>^Q&m-0Sy@$9R>;uLD={zB z+SuIU-ykC)cGS+Q!h$qOkI@8AfYk6=_n%x`=#b?IO{3jR)Oi(^L0`yM58_gg$w^_C?7xz20J(nw_6;oRS9}4oTm*PH*Y%)DEk= zr{)JweE!k&bx1E;%(evxTCf^tmzw~aq#344)QXi#u~rp!Nj2XYY_}n3&ivK<;RSTGjUXcB zaxRxES8BqNbXsk&E!|nN8OIiR1DZ-#i@Uj8JP_N7mn$M+$E9ht$+oa$Gc_&pds!kA zS&L!k&-hU+wq2=-`T+rcWybvNECe}RQHF?wLuY$?5u|4ejpd3}FzNKy#!0JLJLQBp zI-AObpJQiw5ETr=TY>E|Ao?$jtBoepl_5J61VCi%4chZLtW?MqFdEw~S9n6#tu<=L zCZHh2;Ja%96ybH5tPbXgH;EA)c(x{x#$UuSKQNHXT3TA<@CF($7hAi)!a4`1Zb5k} zO^^UUV1>NiXtc-_Dt?Zd=!+4J#iG9jhD_rC*!oAM{883uH0lZ%!FF=Rwtne^Uazx5 zPMX0!(vAU#*3!DTPr_%DqaWcU>Hfjze!_1GMtaT%;^mrv zIuQ5So8k3P4{&nxzt!LGZ)|{V_x64U464k2VPNGj+{^UC#{}tn8bDG1mfwH&|4=wn zO_%l$xYvh)fmrIVKQ>8UDE0;mV1ZaDyqh6}r2@+ywZla{{FB)9`P|!~wddg%kxZ2- z74ly1hgiE3kM5o8oJ_2Qqe2} z#3=PLk?;fuPqmZtcoOv9OPWq5U99)h1$S^kmSw#kRr?*q@3VtPHj6g^0000jc( diff --git a/mainwindow.cpp b/mainwindow.cpp index c557d5bf7..1144ce2cb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -21,7 +21,6 @@ #include "tools/vtoolarc.h" #include "tools/vtoolsplinepath.h" #pragma GCC diagnostic warning "-Weffc++" -#include "options.h" #include "geometry/vspline.h" MainWindow::MainWindow(QWidget *parent) : @@ -40,11 +39,8 @@ MainWindow::MainWindow(QWidget *parent) : QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); policy.setHorizontalStretch(12); view->setSizePolicy(policy); - //view->setMinimumSize(800, 600); connect(scene, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); - connect(ui->toolButtonSinglePoint, &QToolButton::clicked, this, - &MainWindow::ToolSinglePoint); helpLabel = new QLabel("Створіть новий файл для початку роботи."); ui->statusBar->addWidget(helpLabel); @@ -58,30 +54,21 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::ActionOpen); connect(ui->actionNew, &QAction::triggered, this, &MainWindow::ActionNew); connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable); - connect(ui->toolButtonEndLine, &QToolButton::clicked, this, - &MainWindow::ToolEndLine); - connect(ui->toolButtonLine, &QToolButton::clicked, this, - &MainWindow::ToolLine); - connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, - &MainWindow::ToolAlongLine); - connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this, - &MainWindow::ToolShoulderPoint); - connect(ui->toolButtonNormal, &QToolButton::clicked, this, - &MainWindow::ToolNormal); - connect(ui->toolButtonBisector, &QToolButton::clicked, this, - &MainWindow::ToolBisector); - connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this, - &MainWindow::ToolLineIntersect); - connect(ui->toolButtonSpline, &QToolButton::clicked, this, - &MainWindow::ToolSpline); - connect(ui->toolButtonArc, &QToolButton::clicked, this, - &MainWindow::ToolArc); - connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, - &MainWindow::ToolSplinePath); + connect(ui->actionHistory, &QAction::triggered, this, &MainWindow::ActionHistory); + connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine); + connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine); + connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, &MainWindow::ToolAlongLine); + connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this, &MainWindow::ToolShoulderPoint); + connect(ui->toolButtonNormal, &QToolButton::clicked, this, &MainWindow::ToolNormal); + connect(ui->toolButtonBisector, &QToolButton::clicked, this, &MainWindow::ToolBisector); + connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this, &MainWindow::ToolLineIntersect); + connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline); + connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc); + connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath); data = new VContainer; - doc = new VDomDocument(data); + doc = new VDomDocument(data, comboBoxDraws); doc->CreateEmptyFile(); connect(doc, &VDomDocument::haveChange, this, &MainWindow::haveChange); @@ -123,13 +110,28 @@ void MainWindow::ActionNewDraw(){ qCritical()<<"Помилка створення креслення з ім'ям"<addItem(nameDraw, true); + disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::currentDrawChanged); + comboBoxDraws->addItem(nameDraw); index = comboBoxDraws->findText(nameDraw); if ( index != -1 ) { // -1 for not found comboBoxDraws->setCurrentIndex(index); + currentDrawChanged( index ); } + connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::currentDrawChanged); + data->ClearObject(); + //Create single point + qint64 id = data->AddPoint(VPointF((10+comboBoxDraws->count()*5)*PrintDPI/25.4, 10*PrintDPI/25.4, "А", 5, + 10)); + VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui); + scene->addItem(spoint); + connect(spoint, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + QMap* tools = doc->getTools(); + tools->insert(id, spoint); + VAbstractTool::AddRecord(id, Tools::SinglePointTool, doc); + SetEnableTool(true); SetEnableWidgets(true); - SetEnableTool(false); } void MainWindow::OptionDraw(){ @@ -186,49 +188,6 @@ void MainWindow::SetToolButton(bool checked, Tools::Enum t, const QString &curso } } -/* - * Інструмет базова точка креслення. - */ -void MainWindow::ToolSinglePoint(bool checked){ - if(checked){ - CanselTool(); - tool = Tools::SinglePointTool; - QPixmap pixmap(":/cursor/spoint_cursor.png"); - QCursor cur(pixmap, 2, 3); - view->setCursor(cur); - helpLabel->setText("Виберіть розташування для точки."); - dialogSinglePoint = new DialogSinglePoint(data); - //покажемо вікно як тільки буде вибрано місце розташування для точки - connect(scene, &VMainGraphicsScene::mousePress, dialogSinglePoint, - &DialogSinglePoint::mousePress); - connect(dialogSinglePoint, &DialogSinglePoint::DialogClosed, this, - &MainWindow::ClosedDialogSinglePoint); - } else { //не даємо користувачу зняти виділення кнопки - ui->toolButtonSinglePoint->setChecked(true); - } -} - -void MainWindow::ClosedDialogSinglePoint(int result){ - if(result == QDialog::Accepted){ - QPointF point = dialogSinglePoint->getPoint(); - QString name = dialogSinglePoint->getName(); - - qint64 id = data->AddPoint(VPointF(point.x(), point.y(), name, 5, 10)); - VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui); - scene->addItem(spoint); - connect(spoint, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - QMap* tools = doc->getTools(); - tools->insert(id, spoint); - ArrowTool(); - ui->toolButtonSinglePoint->setEnabled(false); - qint32 index = comboBoxDraws->currentIndex(); - comboBoxDraws->setItemData(index, false); - ui->actionSave->setEnabled(true); - SetEnableTool(true); - } - ArrowTool(); -} - void MainWindow::ToolEndLine(bool checked){ SetToolButton(checked, Tools::EndLineTool, ":/cursor/endline_cursor.png", dialogEndLine, &MainWindow::ClosedDialogEndLine); @@ -423,25 +382,22 @@ void MainWindow::ToolBarDraws(){ ui->toolBarDraws->addAction(ui->actionTable); ui->actionTable->setEnabled(false); + + ui->toolBarDraws->addAction(ui->actionHistory); + ui->actionHistory->setEnabled(false); } void MainWindow::currentDrawChanged( int index ){ if(index != -1) { - bool status = qvariant_cast(comboBoxDraws->itemData(index)); - ui->toolButtonSinglePoint->setEnabled(status); - if(ui->toolButtonSinglePoint->isEnabled() == false){ - SetEnableTool(true); - } else { - SetEnableTool(false); - } + doc->setCurrentData(); doc->ChangeActivDraw(comboBoxDraws->itemText(index)); } } void MainWindow::mouseMove(QPointF scenePos){ QString string = QString("%1, %2") - .arg((qint32)(scenePos.x()/PrintDPI*25.4)) - .arg((qint32)(scenePos.y()/PrintDPI*25.4)); + .arg(static_cast(scenePos.x()/PrintDPI*25.4)) + .arg(static_cast(scenePos.y()/PrintDPI*25.4)); mouseCoordinate->setText(string); } @@ -452,9 +408,7 @@ void MainWindow::CanselTool(){ ui->actionArrowTool->setChecked(false); break; case Tools::SinglePointTool: - //Знищимо діалогове вікно. - delete dialogSinglePoint; - ui->toolButtonSinglePoint->setChecked(false); + //Nothing to do here because we can't create this tool from main window. break; case Tools::EndLineTool: dialogEndLine.clear(); @@ -611,30 +565,22 @@ void MainWindow::ActionOpen(){ QFile file(fileName); if(file.open(QIODevice::ReadOnly)){ if(doc->setContent(&file)){ - scene->clear(); - comboBoxDraws->clear(); -// ui->toolButtonSinglePoint->setEnabled(true); disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), this, &MainWindow::currentDrawChanged); - doc->Parse(Document::FullParse, scene, comboBoxDraws); + doc->Parse(Document::FullParse, scene); connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), this, &MainWindow::currentDrawChanged); - ui->actionSave->setEnabled(true); - ui->actionSaveAs->setEnabled(true); - ui->actionTable->setEnabled(true); QString nameDraw = doc->GetNameActivDraw(); qint32 index = comboBoxDraws->findText(nameDraw); if ( index != -1 ) { // -1 for not found comboBoxDraws->setCurrentIndex(index); } - if(comboBoxDraws->count() == 1){ - if(ui->toolButtonSinglePoint->isEnabled()==false){ - SetEnableTool(true); - } else { - SetEnableTool(false); - } + if(comboBoxDraws->count() > 0){ + SetEnableTool(true); + } else { + SetEnableTool(false); } - + SetEnableWidgets(true); } file.close(); } @@ -649,7 +595,6 @@ void MainWindow::ActionNew(){ CanselTool(); comboBoxDraws->clear(); fileName.clear(); - ui->toolButtonSinglePoint->setEnabled(true); ui->actionOptionDraw->setEnabled(false); ui->actionSave->setEnabled(false); SetEnableTool(false); @@ -677,12 +622,12 @@ void MainWindow::SetEnableWidgets(bool enable){ ui->actionSaveAs->setEnabled(enable); ui->actionDraw->setEnabled(enable); ui->actionDetails->setEnabled(enable); - ui->toolButtonSinglePoint->setEnabled(enable); ui->actionOptionDraw->setEnabled(enable); if(enable == true && !fileName.isEmpty()){ ui->actionSave->setEnabled(enable); } ui->actionTable->setEnabled(enable); + ui->actionHistory->setEnabled(enable); } void MainWindow::ActionTable(bool checked){ @@ -702,6 +647,24 @@ void MainWindow::ClosedActionTable(){ delete dialogTable; } +void MainWindow::ActionHistory(bool checked){ + if(checked){ + dialogHistory = new DialogHistory(data, doc, this); + dialogHistory->setWindowFlags(Qt::Window); + connect(dialogHistory, &DialogHistory::DialogClosed, this, + &MainWindow::ClosedActionHistory); + dialogHistory->show(); + } else { + ui->actionHistory->setChecked(true); + dialogHistory->activateWindow(); + } +} + +void MainWindow::ClosedActionHistory(){ + ui->actionHistory->setChecked(false); + delete dialogHistory; +} + void MainWindow::SetEnableTool(bool enable){ ui->toolButtonEndLine->setEnabled(enable); ui->toolButtonLine->setEnabled(enable); diff --git a/mainwindow.h b/mainwindow.h index 394bce36d..e504ea8bd 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -12,7 +12,6 @@ #include "widgets/vmaingraphicsscene.h" #include "widgets/vmaingraphicsview.h" -#include "dialogs/dialogsinglepoint.h" #include "dialogs/dialogincrements.h" #include "dialogs/dialogline.h" #include "dialogs/dialogalongline.h" @@ -24,33 +23,17 @@ #include "dialogs/dialogspline.h" #include "dialogs/dialogarc.h" #include "dialogs/dialogsplinepath.h" +#include "dialogs/dialoghistory.h" #include "tools/vtoolsinglepoint.h" #include "xml/vdomdocument.h" #pragma GCC diagnostic warning "-Weffc++" #include "container/vcontainer.h" +#include "options.h" namespace Ui { class MainWindow; } -namespace Tools{ - enum Enum - { - ArrowTool, - SinglePointTool, - EndLineTool, - LineTool, - AlongLineTool, - ShoulderPointTool, - NormalTool, - BisectorTool, - LineIntersectTool, - SplineTool, - ArcTool, - SplinePathTool - }; -} - class MainWindow : public QMainWindow { Q_OBJECT @@ -59,11 +42,9 @@ public: ~MainWindow(); public slots: void mouseMove(QPointF scenePos); - void ToolSinglePoint(bool checked); void ActionAroowTool(); void ActionDraw(bool checked); void ActionDetails(bool checked); - void ClosedDialogSinglePoint(int result); void ActionNewDraw(); void currentDrawChanged( int index ); void OptionDraw(); @@ -76,6 +57,8 @@ public slots: void ChangedGrowth(const QString & text); void ActionTable(bool checked); void ClosedActionTable(); + void ActionHistory(bool checked); + void ClosedActionHistory(); void ToolEndLine(bool checked); void ClosedDialogEndLine(int result); void ToolLine(bool checked); @@ -107,7 +90,6 @@ private: QLabel *helpLabel; VMainGraphicsView *view; bool isInitialized; - DialogSinglePoint *dialogSinglePoint; DialogIncrements *dialogTable; QSharedPointer dialogEndLine; QSharedPointer dialogLine; @@ -119,6 +101,7 @@ private: QSharedPointer dialogSpline; QSharedPointer dialogArc; QSharedPointer dialogSplinePath; + DialogHistory *dialogHistory; VDomDocument *doc; VContainer *data; QComboBox *comboBoxDraws; diff --git a/mainwindow.ui b/mainwindow.ui index f6c51cc42..408dce2de 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -51,81 +51,6 @@ Точка - - - - false - - - ... - - - - :/icon/32x32/segment.png:/icon/32x32/segment.png - - - - 32 - 32 - - - - true - - - - - - - false - - - ... - - - - :/icon/32x32/along_line.png:/icon/32x32/along_line.png - - - - 32 - 32 - - - - true - - - - - - - false - - - Точка - - - - - - Точка - - - - :/icon/32x32/spoint.png:/icon/32x32/spoint.png - - - - 32 - 32 - - - - true - - - @@ -172,7 +97,53 @@ - + + + + false + + + ... + + + + :/icon/32x32/segment.png:/icon/32x32/segment.png + + + + 32 + 32 + + + + true + + + + + + + false + + + ... + + + + :/icon/32x32/along_line.png:/icon/32x32/along_line.png + + + + 32 + 32 + + + + true + + + + false @@ -202,7 +173,7 @@ 0 0 - 1074 + 100 58 @@ -269,7 +240,7 @@ 0 0 - 1074 + 100 58 @@ -336,7 +307,7 @@ 0 0 - 1074 + 87 58 @@ -378,7 +349,7 @@ - + 10 @@ -600,6 +571,18 @@ Таблиці змінних + + + true + + + + :/icon/32x32/history.png:/icon/32x32/history.png + + + History + + diff --git a/options.h b/options.h index 1541e1b76..8bb658500 100644 --- a/options.h +++ b/options.h @@ -17,4 +17,22 @@ namespace Scene{ }; } +namespace Tools{ + enum Enum + { + ArrowTool, + SinglePointTool, + EndLineTool, + LineTool, + AlongLineTool, + ShoulderPointTool, + NormalTool, + BisectorTool, + LineIntersectTool, + SplineTool, + ArcTool, + SplinePathTool + }; +} + #endif // OPTIONS_H diff --git a/tools/vabstracttool.cpp b/tools/vabstracttool.cpp index b4ec0e299..c3841774a 100644 --- a/tools/vabstracttool.cpp +++ b/tools/vabstracttool.cpp @@ -4,9 +4,8 @@ #pragma GCC diagnostic pop VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent): - VDataTool(data, parent){ + VDataTool(data, parent), baseColor(Qt::black), currentColor(Qt::black){ this->doc = doc; - this->id = id; nameActivDraw = doc->GetNameActivDraw(); ignoreContextMenuEvent = false;//don't ignore context menu events; @@ -16,6 +15,7 @@ VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QOb connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange); connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); connect(this, &VAbstractTool::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree); + connect(this->doc, &VDomDocument::ShowTool, this, &VAbstractTool::ShowTool); } void VAbstractTool::ChangedNameDraw(const QString oldName, const QString newName){ @@ -32,6 +32,12 @@ void VAbstractTool::ChangedActivDraw(const QString newName){ } } +void VAbstractTool::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ + Q_UNUSED(id); + Q_UNUSED(color); + Q_UNUSED(enable); +} + void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value){ QDomAttr domAttr = doc->createAttribute(name); domAttr.setValue(QString().setNum(value)); @@ -63,10 +69,22 @@ void VAbstractTool::AddToCalculation(const QDomElement &domElement){ QDomElement calcElement; bool ok = doc->GetActivCalculationElement(calcElement); if(ok){ - calcElement.appendChild(domElement); + qint64 id = doc->getCursor(); + if(id <= 0){ + calcElement.appendChild(domElement); + } else { + QDomElement refElement = doc->elementById(QString().setNum(doc->getCursor())); + if(refElement.isElement()){ + calcElement.insertAfter(domElement,refElement); + doc->setCursor(0); + } else { + qCritical()<<"Не можу знайти елемент після якого потрібно вставляти."<< Q_FUNC_INFO; + } + } } else { qCritical()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO; } + emit toolhaveChange(); } const VContainer *VAbstractTool::getData()const{ @@ -79,3 +97,21 @@ void VAbstractTool::setData(const VContainer &value){ void VAbstractTool::setDialog(){ } + +void VAbstractTool::AddRecord(const qint64 id, Tools::Enum toolType, VDomDocument *doc){ + qint64 cursor = doc->getCursor(); + QVector *history = doc->getHistory(); + if(cursor <= 0){ + history->append(VToolRecord(id, toolType, doc->GetNameActivDraw())); + } else { + qint32 index = 0; + for(qint32 i = 0; isize(); ++i){ + VToolRecord rec = history->at(i); + if(rec.getId() == cursor){ + index = i; + break; + } + } + history->insert(index+1, VToolRecord(id, toolType, doc->GetNameActivDraw())); + } +} diff --git a/tools/vabstracttool.h b/tools/vabstracttool.h index 0c61abda1..43c4f49bc 100644 --- a/tools/vabstracttool.h +++ b/tools/vabstracttool.h @@ -23,11 +23,13 @@ public: VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0); virtual ~VAbstractTool(); virtual void setDialog(); + static void AddRecord(const qint64 id, Tools::Enum toolType, VDomDocument *doc); public slots: virtual void FullUpdateFromFile()=0; void ChangedNameDraw(const QString oldName, const QString newName); virtual void ChangedActivDraw(const QString newName); virtual void FullUpdateFromGui(int result)=0; + virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); signals: void toolhaveChange(); void ChoosedTool(qint64 id, Scene::Type type); @@ -37,6 +39,8 @@ protected: qint64 id; bool ignoreContextMenuEvent; QString nameActivDraw; + const Qt::GlobalColor baseColor; + Qt::GlobalColor currentColor; virtual void AddToFile()=0; void AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value); void AddAttribute(QDomElement &domElement, const QString &name, const qint32 &value); diff --git a/tools/vtoolalongline.cpp b/tools/vtoolalongline.cpp index 71b871955..09651c8d6 100644 --- a/tools/vtoolalongline.cpp +++ b/tools/vtoolalongline.cpp @@ -63,7 +63,6 @@ void VToolAlongLine::AddToFile(){ AddAttribute(domElement, "secondPoint", secondPointId); AddToCalculation(domElement); - emit toolhaveChange(); } void VToolAlongLine::setDialog(){ @@ -113,6 +112,7 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS tools->insert(id, tool); } } + VAbstractTool::AddRecord(id, Tools::AlongLineTool, doc); data->AddLine(firstPointId, id); data->AddLine(id, secondPointId); if(parse == Document::FullParse){ @@ -122,6 +122,7 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); QMap* tools = doc->getTools(); tools->insert(id,point); + } } } diff --git a/tools/vtoolarc.cpp b/tools/vtoolarc.cpp index b8ff1b3be..f064ee67c 100644 --- a/tools/vtoolarc.cpp +++ b/tools/vtoolarc.cpp @@ -76,6 +76,7 @@ void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &rad } } data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength()); + VAbstractTool::AddRecord(id, Tools::ArcTool, doc); if(parse == Document::FullParse){ VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); scene->addItem(toolArc); @@ -117,6 +118,18 @@ void VToolArc::ChangedActivDraw(const QString newName){ } } +void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ + if(id == this->id){ + if(enable == false){ + this->setPen(QPen(baseColor, widthHairLine)); + currentColor = baseColor; + } else { + this->setPen(QPen(color, widthHairLine)); + currentColor = color; + } + } +} + void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ ContextMenu(dialogArc, this, event); } @@ -133,7 +146,6 @@ void VToolArc::AddToFile(){ AddAttribute(domElement, "angle2", arc.GetFormulaF2()); AddToCalculation(domElement); - emit toolhaveChange(); } void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ @@ -145,12 +157,12 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthMainLine)); + this->setPen(QPen(currentColor, widthMainLine)); } void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(currentColor, widthHairLine)); } void VToolArc::RefreshGeometry(){ diff --git a/tools/vtoolarc.h b/tools/vtoolarc.h index 085f099e9..a9509f464 100644 --- a/tools/vtoolarc.h +++ b/tools/vtoolarc.h @@ -24,6 +24,7 @@ public slots: virtual void FullUpdateFromFile(); virtual void FullUpdateFromGui(int result); virtual void ChangedActivDraw(const QString newName); + virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile(); diff --git a/tools/vtoolbisector.cpp b/tools/vtoolbisector.cpp index 79e99b3d3..220c32582 100644 --- a/tools/vtoolbisector.cpp +++ b/tools/vtoolbisector.cpp @@ -81,6 +81,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6 } } data->AddLine(firstPointId, id); + VAbstractTool::AddRecord(id, Tools::BisectorTool, doc); if(parse == Document::FullParse){ VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, thirdPointId, @@ -88,7 +89,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6 scene->addItem(point); connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); QMap* tools = doc->getTools(); - tools->insert(id,point); + tools->insert(id,point); } } } @@ -142,5 +143,4 @@ void VToolBisector::AddToFile(){ AddAttribute(domElement, "thirdPoint", thirdPointId); AddToCalculation(domElement); - emit toolhaveChange(); } diff --git a/tools/vtoolendline.cpp b/tools/vtoolendline.cpp index b51af97d0..6a0e0c723 100644 --- a/tools/vtoolendline.cpp +++ b/tools/vtoolendline.cpp @@ -63,13 +63,14 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr } } data->AddLine(basePointId, id); + VAbstractTool::AddRecord(id, Tools::EndLineTool, doc); if(parse == Document::FullParse){ VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); QMap* tools = doc->getTools(); - tools->insert(id,point); + tools->insert(id,point); } } } @@ -120,6 +121,5 @@ void VToolEndLine::AddToFile(){ AddAttribute(domElement, "basePoint", basePointId); AddToCalculation(domElement); - emit toolhaveChange(); } diff --git a/tools/vtoolline.cpp b/tools/vtoolline.cpp index 09c870845..5abe6f6cf 100644 --- a/tools/vtoolline.cpp +++ b/tools/vtoolline.cpp @@ -43,6 +43,7 @@ void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 tool->VDataTool::setData(data); tools->insert(id, tool); } + VAbstractTool::AddRecord(id, Tools::LineTool, doc); if(parse == Document::FullParse){ qint64 id = data->getNextId(); VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation); @@ -76,6 +77,18 @@ void VToolLine::FullUpdateFromGui(int result){ dialogLine.clear(); } +void VToolLine::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ + if(id == this->id){ + if(enable == false){ + this->setPen(QPen(baseColor, widthHairLine)); + currentColor = baseColor; + } else { + this->setPen(QPen(color, widthHairLine)); + currentColor = color; + } + } +} + void VToolLine::ChangedActivDraw(const QString newName){ if(nameActivDraw == newName){ this->setPen(QPen(Qt::black, widthHairLine)); @@ -100,16 +113,15 @@ void VToolLine::AddToFile(){ AddAttribute(domElement, "secondPoint", secondPoint); AddToCalculation(domElement); - emit toolhaveChange(); } void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthMainLine)); + this->setPen(QPen(currentColor, widthMainLine)); } void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(currentColor, widthHairLine)); } diff --git a/tools/vtoolline.h b/tools/vtoolline.h index 7538a3efb..3c147ffa6 100644 --- a/tools/vtoolline.h +++ b/tools/vtoolline.h @@ -21,6 +21,7 @@ public slots: virtual void FullUpdateFromFile(); virtual void ChangedActivDraw(const QString newName); virtual void FullUpdateFromGui(int result); + virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile(); diff --git a/tools/vtoollineintersect.cpp b/tools/vtoollineintersect.cpp index 3828f0e62..ed3066193 100644 --- a/tools/vtoollineintersect.cpp +++ b/tools/vtoollineintersect.cpp @@ -67,6 +67,7 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const data->AddLine(id, p2Line1Id); data->AddLine(p1Line2Id, id); data->AddLine(id, p2Line2Id); + VAbstractTool::AddRecord(id, Tools::LineIntersectTool, doc); if(parse == Document::FullParse){ VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, @@ -126,5 +127,4 @@ void VToolLineIntersect::AddToFile(){ AddAttribute(domElement, "p2Line2", p2Line2); AddToCalculation(domElement); - emit toolhaveChange(); } diff --git a/tools/vtoolnormal.cpp b/tools/vtoolnormal.cpp index 6ffd829c6..3c9ff921b 100644 --- a/tools/vtoolnormal.cpp +++ b/tools/vtoolnormal.cpp @@ -63,6 +63,7 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 } } data->AddLine(firstPointId, id); + VAbstractTool::AddRecord(id, Tools::NormalTool, doc); if(parse == Document::FullParse){ VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId, typeCreation); @@ -132,5 +133,4 @@ void VToolNormal::AddToFile(){ AddAttribute(domElement, "secondPoint", secondPointId); AddToCalculation(domElement); - emit toolhaveChange(); } diff --git a/tools/vtoolpoint.cpp b/tools/vtoolpoint.cpp index 5ce6b2f44..5d2e684fb 100644 --- a/tools/vtoolpoint.cpp +++ b/tools/vtoolpoint.cpp @@ -169,6 +169,18 @@ void VToolPoint::ChangedActivDraw(const QString newName){ } } +void VToolPoint::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ + if(id == this->id){ + if(enable == false){ + this->setPen(QPen(baseColor, widthHairLine)); + currentColor = baseColor; + } else { + this->setPen(QPen(color, widthHairLine)); + currentColor = color; + } + } +} + void VToolPoint::RefreshGeometry(){ VPointF point = VAbstractTool::data.GetPoint(id); QRectF rec = QRectF(0, 0, radius*2, radius*2); @@ -194,12 +206,12 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthMainLine)); + this->setPen(QPen(currentColor, widthMainLine)); } void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(currentColor, widthHairLine)); } VToolPoint::~VToolPoint(){ diff --git a/tools/vtoolpoint.h b/tools/vtoolpoint.h index 46197f9ba..1d3d510ae 100644 --- a/tools/vtoolpoint.h +++ b/tools/vtoolpoint.h @@ -19,6 +19,7 @@ public slots: void NameChangePosition(const QPointF pos); virtual void ChangedActivDraw(const QString newName); virtual void FullUpdateFromGui(int result) = 0; + virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); protected: qreal radius; VGraphicsSimpleTextItem *namePoint; diff --git a/tools/vtoolshoulderpoint.cpp b/tools/vtoolshoulderpoint.cpp index e25bdb2c1..3c1aa57c9 100644 --- a/tools/vtoolshoulderpoint.cpp +++ b/tools/vtoolshoulderpoint.cpp @@ -91,6 +91,7 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const } data->AddLine(p1Line, id); data->AddLine(p2Line, id); + VAbstractTool::AddRecord(id, Tools::ShoulderPointTool, doc); if(parse == Document::FullParse){ VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, p1Line, p2Line, pShoulder, @@ -153,5 +154,4 @@ void VToolShoulderPoint::AddToFile(){ AddAttribute(domElement, "pShoulder", pShoulder); AddToCalculation(domElement); - emit toolhaveChange(); } diff --git a/tools/vtoolsinglepoint.cpp b/tools/vtoolsinglepoint.cpp index 77e8ef10b..4cd95f4a8 100644 --- a/tools/vtoolsinglepoint.cpp +++ b/tools/vtoolsinglepoint.cpp @@ -19,6 +19,14 @@ VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 } } +void VToolSinglePoint::setDialog(){ + Q_ASSERT(!dialogSinglePoint.isNull()); + if(!dialogSinglePoint.isNull()){ + VPointF p = VAbstractTool::data.GetPoint(id); + dialogSinglePoint->setData(p.name(), p.toQPointF()); + } +} + void VToolSinglePoint::AddToFile(){ VPointF point = VAbstractTool::data.GetPoint(id); QDomElement domElement = doc->createElement("point"); @@ -32,7 +40,6 @@ void VToolSinglePoint::AddToFile(){ AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); AddToCalculation(domElement); - emit toolhaveChange(); } QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value){ diff --git a/tools/vtoolsinglepoint.h b/tools/vtoolsinglepoint.h index db93b8055..d3262296c 100644 --- a/tools/vtoolsinglepoint.h +++ b/tools/vtoolsinglepoint.h @@ -12,6 +12,7 @@ class VToolSinglePoint : public VToolPoint public: VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation, QGraphicsItem * parent = 0 ); + virtual void setDialog(); public slots: virtual void FullUpdateFromFile(); virtual void FullUpdateFromGui(int result); diff --git a/tools/vtoolspline.cpp b/tools/vtoolspline.cpp index 71a29e80c..e52d9a4d8 100644 --- a/tools/vtoolspline.cpp +++ b/tools/vtoolspline.cpp @@ -81,6 +81,7 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c } } data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength()); + VAbstractTool::AddRecord(id, Tools::SplineTool, doc); if(parse == Document::FullParse){ VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation); scene->addItem(spl); @@ -167,7 +168,6 @@ void VToolSpline::AddToFile(){ AddAttribute(domElement, "kCurve", spl.GetKcurve()); AddToCalculation(domElement); - emit toolhaveChange(); } void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ @@ -179,12 +179,12 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ void VToolSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthMainLine)); + this->setPen(QPen(currentColor, widthMainLine)); } void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(currentColor, widthHairLine)); } void VToolSpline::RefreshGeometry(){ @@ -228,3 +228,15 @@ void VToolSpline::ChangedActivDraw(const QString newName){ VAbstractTool::ChangedActivDraw(newName); } } + +void VToolSpline::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ + if(id == this->id){ + if(enable == false){ + this->setPen(QPen(baseColor, widthHairLine)); + currentColor = baseColor; + } else { + this->setPen(QPen(color, widthHairLine)); + currentColor = color; + } + } +} diff --git a/tools/vtoolspline.h b/tools/vtoolspline.h index cc10142f2..6717ba75a 100644 --- a/tools/vtoolspline.h +++ b/tools/vtoolspline.h @@ -33,6 +33,7 @@ public slots: SplinePoint::Position position, const QPointF pos); virtual void ChangedActivDraw ( const QString newName ); + virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile (); diff --git a/tools/vtoolsplinepath.cpp b/tools/vtoolsplinepath.cpp index ada36ce4d..ef7248f25 100644 --- a/tools/vtoolsplinepath.cpp +++ b/tools/vtoolsplinepath.cpp @@ -67,6 +67,7 @@ void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGra } } data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength()); + VAbstractTool::AddRecord(id, Tools::SplinePathTool, doc); if(parse == Document::FullParse){ VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation); scene->addItem(spl); @@ -201,6 +202,18 @@ void VToolSplinePath::ChangedActivDraw(const QString newName){ } } +void VToolSplinePath::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ + if(id == this->id){ + if(enable == false){ + this->setPen(QPen(baseColor, widthHairLine)); + currentColor = baseColor; + } else { + this->setPen(QPen(color, widthHairLine)); + currentColor = color; + } + } +} + void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ ContextMenu(dialogSplinePath, this, event); } @@ -218,7 +231,6 @@ void VToolSplinePath::AddToFile(){ } AddToCalculation(domElement); - emit toolhaveChange(); } void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint){ @@ -241,12 +253,12 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ void VToolSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthMainLine)); + this->setPen(QPen(currentColor, widthMainLine)); } void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(currentColor, widthHairLine)); } void VToolSplinePath::RefreshGeometry(){ diff --git a/tools/vtoolsplinepath.h b/tools/vtoolsplinepath.h index e0913a426..6f77f3cc0 100644 --- a/tools/vtoolsplinepath.h +++ b/tools/vtoolsplinepath.h @@ -30,6 +30,7 @@ public slots: SplinePoint::Position position, const QPointF pos); virtual void ChangedActivDraw(const QString newName); + virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void AddToFile(); diff --git a/xml/vdomdocument.cpp b/xml/vdomdocument.cpp index abce69b77..64cdcdfe1 100644 --- a/xml/vdomdocument.cpp +++ b/xml/vdomdocument.cpp @@ -19,16 +19,20 @@ -VDomDocument::VDomDocument(VContainer *data) : QDomDocument() { +VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws) : QDomDocument(), cursor(0){ this->data = data; + this->comboBoxDraws = comboBoxDraws; } -VDomDocument::VDomDocument(const QString& name, VContainer *data) : QDomDocument(name) { +VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws) : QDomDocument(name), cursor(0) { this->data = data; + this->comboBoxDraws = comboBoxDraws; } -VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data) : QDomDocument(doctype){ +VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws) : QDomDocument(doctype), + cursor(0){ this->data = data; + this->comboBoxDraws = comboBoxDraws; } VDomDocument::~VDomDocument(){ @@ -132,17 +136,12 @@ bool VDomDocument::appendDraw(const QString& name){ return false; } -void VDomDocument::ChangeActivDraw(const QString& name){ +void VDomDocument::ChangeActivDraw(const QString& name, Document::Enum parse){ if(CheckNameDraw(name) == true){ this->nameActivDraw = name; - VMainGraphicsScene *scene = new VMainGraphicsScene(); - QDomElement domElement; - bool ok = GetActivDrawElement(domElement); - if(ok){ - ParseDrawElement(scene, domElement, Document::LiteParse); + if(parse == Document::FullParse){ + emit ChangedActivDraw(name); } - delete scene; - emit ChangedActivDraw(name); } } @@ -225,19 +224,20 @@ bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element } } -void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *scene, QComboBox *comboBoxDraws){ +void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *scene){ if(parse == Document::FullParse){ data->Clear(); nameActivDraw.clear(); scene->clear(); comboBoxDraws->clear(); tools.clear(); - } else { - data->ClearLengthLines(); - data->ClearLengthArcs(); - data->ClearLengthSplines(); - data->ClearLineArcs(); + cursor = 0; } + data->ClearLengthLines(); + data->ClearLengthArcs(); + data->ClearLengthSplines(); + data->ClearLineArcs(); + history.clear(); QDomElement rootElement = this->documentElement(); QDomNode domNode = rootElement.firstChild(); while(!domNode.isNull()){ @@ -251,7 +251,9 @@ void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *scene, QCombo } else { ChangeActivDraw(domElement.attribute("name")); } - AddNewDraw(domElement, comboBoxDraws); + comboBoxDraws->addItem(domElement.attribute("name")); + } else { + ChangeActivDraw(domElement.attribute("name"), Document::LiteParse); } ParseDrawElement(scene, domElement, parse); } @@ -268,6 +270,10 @@ QMap *VDomDocument::getTools(){ return &tools; } +QVector *VDomDocument::getHistory(){ + return &history; +} + void VDomDocument::ParseIncrementsElement(const QDomNode &node){ QDomNode domNode = node.firstChild(); while(!domNode.isNull()){ @@ -295,38 +301,6 @@ void VDomDocument::ParseIncrementsElement(const QDomNode &node){ } } -void VDomDocument::AddNewDraw(const QDomElement& node, QComboBox *comboBoxDraws)const{ - QString name = node.attribute("name"); - QDomNode domNode = node.firstChild(); - if(!domNode.isNull()){ - if(domNode.isElement()){ - QDomElement domElement = domNode.toElement(); - if(!domElement.isNull()){ - if(domElement.tagName() == "calculation"){ - QDomNode domCal = domElement.firstChild(); - if(!domCal.isNull()){ - if(domCal.isElement()){ - QDomElement domElementPoint = domCal.toElement(); - if(!domElementPoint.isNull()){ - if(domElementPoint.tagName() == "point"){ - if(domElementPoint.attribute("type","") == "single"){ - comboBoxDraws->addItem(name, false); - return; - } else { - comboBoxDraws->addItem(name, true); - return; - } - } - } - } - } - comboBoxDraws->addItem(name, true); - } - } - } - } -} - void VDomDocument::ParseDrawElement(VMainGraphicsScene *scene, const QDomNode& node, Document::Enum parse){ QDomNode domNode = node.firstChild(); @@ -335,6 +309,7 @@ void VDomDocument::ParseDrawElement(VMainGraphicsScene *scene, const QDomNode& n QDomElement domElement = domNode.toElement(); if(!domElement.isNull()){ if(domElement.tagName() == "calculation"){ + data->ClearObject(); ParseCalculationElement(scene, domElement, parse); } if(domElement.tagName() == "modeling"){ @@ -388,6 +363,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen my = domElement.attribute("my","").toDouble()*PrintDPI/25.4; data->UpdatePoint(id, VPointF(x, y, name, mx, my)); + VAbstractTool::AddRecord(id, Tools::SinglePointTool, this); if(parse != Document::FullParse){ VToolSinglePoint *spoint = qobject_cast(tools[id]); spoint->VDataTool::setData(data); @@ -397,7 +373,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen VToolSinglePoint *spoint = new VToolSinglePoint(this, data, id, Tool::FromFile); scene->addItem(spoint); connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - tools[id] = spoint; + tools[id] = spoint; } } return; @@ -568,10 +544,9 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement void VDomDocument::FullUpdateTree(){ VMainGraphicsScene *scene = new VMainGraphicsScene(); - QComboBox *comboBoxDraws = new QComboBox(); - Parse(Document::LiteParse, scene, comboBoxDraws ); + Parse(Document::LiteParse, scene); delete scene; - delete comboBoxDraws; + setCurrentData(); emit FullUpdateFromFile(); emit haveChange(); } @@ -579,3 +554,42 @@ void VDomDocument::FullUpdateTree(){ void VDomDocument::haveLiteChange(){ emit haveChange(); } + +void VDomDocument::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable){ + emit ShowTool(id, color, enable); +} + +qint64 VDomDocument::getCursor() const{ + return cursor; +} + +void VDomDocument::setCursor(const qint64 &value){ + cursor = value; + emit ChangedCursor(cursor); +} + +void VDomDocument::setCurrentData(){ + QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); + nameActivDraw = nameDraw; + qint64 id = 0; + if(history.size() == 0){ + return; + } + for(qint32 i = 0; i < history.size(); ++i){ + VToolRecord tool = history.at(i); + if(tool.getNameDraw() == nameDraw){ + id = tool.getId(); + } + } + if(id == 0){ + VToolRecord tool = history.at(history.size()-1); + id = tool.getId(); + if(id == 0){ + return; + } + } + if(tools.size() > 0){ + VDataTool *vTool = tools.value(id); + data->setData(vTool->getData()); + } +} diff --git a/xml/vdomdocument.h b/xml/vdomdocument.h index 349bf2492..1ffd955d5 100644 --- a/xml/vdomdocument.h +++ b/xml/vdomdocument.h @@ -10,6 +10,7 @@ #include "../widgets/vmaingraphicsscene.h" #include "../tools/vdatatool.h" #pragma GCC diagnostic warning "-Weffc++" +#include "vtoolrecord.h" namespace Document{ enum Enum @@ -23,13 +24,13 @@ class VDomDocument : public QObject, public QDomDocument { Q_OBJECT public: - VDomDocument(VContainer *data); - VDomDocument(const QString& name, VContainer *data); - VDomDocument(const QDomDocumentType& doctype, VContainer *data); + VDomDocument(VContainer *data,QComboBox *comboBoxDraws); + VDomDocument(const QString& name, VContainer *data,QComboBox *comboBoxDraws); + VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws); ~VDomDocument(); QDomElement elementById(const QString& id); void CreateEmptyFile(); - void ChangeActivDraw(const QString& name); + void ChangeActivDraw(const QString& name, Document::Enum parse = Document::FullParse); QString GetNameActivDraw() const; bool GetActivDrawElement(QDomElement &element); bool GetActivCalculationElement(QDomElement &element); @@ -37,21 +38,31 @@ public: bool GetActivPathsElement(QDomElement &element); bool appendDraw(const QString& name); void SetNameDraw(const QString& name); - void Parse(Document::Enum parse, VMainGraphicsScene *scene, QComboBox *comboBoxDraws); + void Parse(Document::Enum parse, VMainGraphicsScene *scene); QMap* getTools(); + QVector *getHistory(); + qint64 getCursor() const; + void setCursor(const qint64 &value); + void setCurrentData(); signals: void ChangedActivDraw(const QString newName); void ChangedNameDraw(const QString oldName, const QString newName); void FullUpdateFromFile(); void haveChange(); + void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); + void ChangedCursor(qint64 id); public slots: void FullUpdateTree(); void haveLiteChange(); + void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable); private: QMap map; QString nameActivDraw; VContainer *data; QMap tools; + QVector history; + qint64 cursor; + QComboBox *comboBoxDraws; bool find(QDomElement node, const QString& id); bool CheckNameDraw(const QString& name) const; void SetActivDraw(const QString& name); @@ -69,7 +80,6 @@ private: void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement, Document::Enum parse, const QString& type); void ParseIncrementsElement(const QDomNode& node); - void AddNewDraw(const QDomElement &node, QComboBox *comboBoxDraws)const; }; #endif // VDOMDOCUMENT_H diff --git a/xml/vtoolrecord.cpp b/xml/vtoolrecord.cpp new file mode 100644 index 000000000..9d7d26dc8 --- /dev/null +++ b/xml/vtoolrecord.cpp @@ -0,0 +1,32 @@ +#include "vtoolrecord.h" + +VToolRecord::VToolRecord():id(0), typeTool(Tools::ArrowTool), nameDraw(QString()){ +} + +VToolRecord::VToolRecord(const qint64 &id, const Tools::Enum &typeTool, const QString &nameDraw):id(id), + typeTool(typeTool), nameDraw(nameDraw){ +} + +QString VToolRecord::getNameDraw() const{ + return nameDraw; +} + +void VToolRecord::setNameDraw(const QString &value){ + nameDraw = value; +} + +Tools::Enum VToolRecord::getTypeTool() const{ + return typeTool; +} + +void VToolRecord::setTypeTool(const Tools::Enum &value){ + typeTool = value; +} + +qint64 VToolRecord::getId() const{ + return id; +} + +void VToolRecord::setId(const qint64 &value){ + id = value; +} diff --git a/xml/vtoolrecord.h b/xml/vtoolrecord.h new file mode 100644 index 000000000..4b7826be3 --- /dev/null +++ b/xml/vtoolrecord.h @@ -0,0 +1,32 @@ +#ifndef VTOOLRECORD_H +#define VTOOLRECORD_H + +#pragma GCC diagnostic ignored "-Weffc++" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#include +#include +#pragma GCC diagnostic warning "-Wsign-conversion" +#pragma GCC diagnostic warning "-Weffc++" +#include "../options.h" + +class VToolRecord +{ +public: + VToolRecord(); + VToolRecord(const qint64 &id, const Tools::Enum &typeTool, const QString &nameDraw); + qint64 getId() const; + void setId(const qint64 &value); + + Tools::Enum getTypeTool() const; + void setTypeTool(const Tools::Enum &value); + + QString getNameDraw() const; + void setNameDraw(const QString &value); + +private: + qint64 id; + Tools::Enum typeTool; + QString nameDraw; +}; + +#endif // VTOOLRECORD_H