From aa7b2a411267c566b3d17bdb6d0a753bff2e534a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 7 Feb 2015 17:18:18 +0200 Subject: [PATCH] Use visualization for highlighting tool. --HG-- branch : feature --- src/app/dialogs/app/dialoghistory.cpp | 10 +++++----- src/app/dialogs/app/dialoghistory.h | 3 +-- src/app/tools/drawTools/vabstractspline.cpp | 5 ++--- src/app/tools/drawTools/vabstractspline.h | 2 +- src/app/tools/drawTools/vdrawtool.cpp | 4 +--- src/app/tools/drawTools/vdrawtool.h | 21 ++++++--------------- src/app/tools/drawTools/vtoolline.cpp | 5 ++--- src/app/tools/drawTools/vtoolline.h | 2 +- src/app/tools/drawTools/vtoolpoint.cpp | 5 ++--- src/app/tools/drawTools/vtoolpoint.h | 2 +- src/app/xml/vpattern.cpp | 5 ++--- src/app/xml/vpattern.h | 5 ++--- 12 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index 78b7c6d96..6e70e1b97 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -74,7 +74,7 @@ void DialogHistory::DialogAccepted() { QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); + emit ShowHistoryTool(id, false); emit DialogClosed(QDialog::Accepted); } @@ -103,12 +103,12 @@ void DialogHistory::cellClicked(int row, int column) { QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); + emit ShowHistoryTool(id, false); cursorToolRecordRow = row; item = ui->tableWidget->item(cursorToolRecordRow, 0); id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, true); + emit ShowHistoryTool(id, true); } } @@ -434,7 +434,7 @@ void DialogHistory::ShowPoint() cursorToolRecordRow = 0; item = ui->tableWidget->item(0, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, true); + emit ShowHistoryTool(id, true); } } @@ -466,6 +466,6 @@ void DialogHistory::closeEvent(QCloseEvent *event) { QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); + emit ShowHistoryTool(id, false); DialogTool::closeEvent(event); } diff --git a/src/app/dialogs/app/dialoghistory.h b/src/app/dialogs/app/dialoghistory.h index 20b18e6b6..c6d085bf2 100644 --- a/src/app/dialogs/app/dialoghistory.h +++ b/src/app/dialogs/app/dialoghistory.h @@ -63,10 +63,9 @@ signals: /** * @brief ShowHistoryTool signal change color of selected in records tool * @param id id of tool - * @param color new color of tool * @param enable true enable selection, false disable selection */ - void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); + void ShowHistoryTool(quint32 id, bool enable); protected: virtual void closeEvent ( QCloseEvent * event ); private: diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp index 385622c0c..f0d04dcab 100644 --- a/src/app/tools/drawTools/vabstractspline.cpp +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -96,12 +96,11 @@ void VAbstractSpline::ChangedActivDraw(const QString &newName) /** * @brief ShowTool highlight tool. * @param id object id in container - * @param color highlight color. * @param enable enable or disable highlight. */ -void VAbstractSpline::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VAbstractSpline::ShowTool(quint32 id, bool enable) { - ShowItem(this, id, color, enable); + ShowItem(this, id, enable); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h index b1e5cdd05..f9b314b73 100644 --- a/src/app/tools/drawTools/vabstractspline.h +++ b/src/app/tools/drawTools/vabstractspline.h @@ -78,7 +78,7 @@ protected: */ virtual void RefreshGeometry ()=0; virtual void ChangedActivDraw ( const QString &newName ); - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ShowTool(quint32 id, bool enable); virtual void SetFactor(qreal factor); virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp index 70b538e86..597399843 100644 --- a/src/app/tools/drawTools/vdrawtool.cpp +++ b/src/app/tools/drawTools/vdrawtool.cpp @@ -64,13 +64,11 @@ VDrawTool::~VDrawTool() /** * @brief ShowTool highlight tool. * @param id object id in container. - * @param color highlight color. * @param enable enable or disable highlight. */ -void VDrawTool::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VDrawTool::ShowTool(quint32 id, bool enable) { Q_UNUSED(id); - Q_UNUSED(color); Q_UNUSED(enable); } diff --git a/src/app/tools/drawTools/vdrawtool.h b/src/app/tools/drawTools/vdrawtool.h index 8a412a7b3..021387e20 100644 --- a/src/app/tools/drawTools/vdrawtool.h +++ b/src/app/tools/drawTools/vdrawtool.h @@ -63,7 +63,7 @@ public: virtual void SetLineColor(const QString &value); public slots: - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ShowTool(quint32 id, bool enable); virtual void ChangedActivDraw(const QString &newName) = 0; void ChangedNameDraw(const QString &oldName, const QString &newName); virtual void FullUpdateFromGuiOk(int result); @@ -161,24 +161,15 @@ protected: * @brief ShowItem highlight tool. * @param item tool. * @param id object id in container. - * @param color highlight color. * @param enable enable or disable highlight. */ - void ShowItem(Item *item, quint32 id, Qt::GlobalColor color, bool enable) + void ShowItem(Item *item, quint32 id, bool enable) { SCASSERT(item != nullptr); -// if (id == item->id) -// { -// if (enable == false) -// { -// currentColor = baseColor; -// } -// else -// { -// currentColor = color; -// } -// item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); -// } + if (id == item->id) + { + ShowVisualization(enable); + } } private: Q_DISABLE_COPY(VDrawTool) diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index 44806774d..797005bae 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -211,12 +211,11 @@ void VToolLine::FullUpdateFromFile() /** * @brief ShowTool highlight tool. * @param id object id in container - * @param color highlight color. * @param enable enable or disable highlight. */ -void VToolLine::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VToolLine::ShowTool(quint32 id, bool enable) { - ShowItem(this, id, color, enable); + ShowItem(this, id, enable); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolline.h b/src/app/tools/drawTools/vtoolline.h index 7b53530e4..17be7b9b4 100644 --- a/src/app/tools/drawTools/vtoolline.h +++ b/src/app/tools/drawTools/vtoolline.h @@ -65,7 +65,7 @@ public: public slots: virtual void FullUpdateFromFile(); virtual void ChangedActivDraw(const QString &newName); - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ShowTool(quint32 id, bool enable); virtual void SetFactor(qreal factor); void Disable(bool disable); protected: diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index 94e3a6abd..d082ddd20 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -139,12 +139,11 @@ void VToolPoint::ChangedActivDraw(const QString &newName) /** * @brief ShowTool highlight tool. * @param id object id in container. - * @param color highlight color. * @param enable enable or disable highlight. */ -void VToolPoint::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VToolPoint::ShowTool(quint32 id, bool enable) { - ShowItem(this, id, color, enable); + ShowItem(this, id, enable); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolpoint.h b/src/app/tools/drawTools/vtoolpoint.h index 8601e6c47..e0c0c52d5 100644 --- a/src/app/tools/drawTools/vtoolpoint.h +++ b/src/app/tools/drawTools/vtoolpoint.h @@ -54,7 +54,7 @@ public: public slots: void NameChangePosition(const QPointF &pos); virtual void ChangedActivDraw(const QString &newName); - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ShowTool(quint32 id, bool enable); virtual void SetFactor(qreal factor); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); void Disable(bool disable); diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 358c16176..a009a1ec3 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -857,12 +857,11 @@ void VPattern::haveLiteChange() /** * @brief ShowHistoryTool hightlight tool. * @param id tool id. - * @param color hightlight color. * @param enable enable or diasable hightlight. */ -void VPattern::ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable) +void VPattern::ShowHistoryTool(quint32 id, bool enable) { - emit ShowTool(id, color, enable); + emit ShowTool(id, enable); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 5642d2366..ea4db3e0b 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -197,10 +197,9 @@ signals: /** * @brief ShowTool highlight tool. * @param id tool id. - * @param color highlight color. * @param enable enable or disable highlight. */ - void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + void ShowTool(quint32 id, bool enable); /** * @brief ChangedCursor change cursor position. * @param id tool id. @@ -214,7 +213,7 @@ signals: public slots: void LiteParseTree(const Document &parse); void haveLiteChange(); - void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); + void ShowHistoryTool(quint32 id, bool enable); void NeedFullParsing(); void ClearScene(); protected: