From 11641de911118d9bb4208b13dbd44952e7b6471e Mon Sep 17 00:00:00 2001 From: dismine Date: Sat, 4 Oct 2014 09:37:19 +0300 Subject: [PATCH] Fixes for tools vizualizations. --HG-- branch : develop --- src/app/tools/drawTools/vabstractspline.cpp | 6 +++++- src/app/tools/drawTools/vabstractspline.h | 3 +++ src/app/tools/drawTools/vdrawtool.cpp | 2 +- src/app/tools/drawTools/vtoolline.cpp | 3 ++- src/app/tools/drawTools/vtoollinepoint.cpp | 1 + src/app/tools/drawTools/vtoolpoint.cpp | 4 +++- src/app/tools/drawTools/vtoolsinglepoint.cpp | 11 ++++++++++- src/app/tools/drawTools/vtoolspline.cpp | 4 ++++ src/app/tools/drawTools/vtoolspline.h | 7 ++++--- src/app/tools/vtooldetail.cpp | 2 +- src/app/visualization/vistoolline.cpp | 9 +++++++++ src/app/visualization/vistoolline.h | 3 +++ src/app/visualization/visualization.h | 2 +- src/app/widgets/vmaingraphicsview.cpp | 1 + .../widgets/vtooloptionspropertybrowser.cpp | 19 +++++++++++++------ 15 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp index b483a3cdb..72ed12980 100644 --- a/src/app/tools/drawTools/vabstractspline.cpp +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -39,6 +39,10 @@ VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QG ignoreFullUpdate = true; } +//--------------------------------------------------------------------------------------------------------------------- +VAbstractSpline::~VAbstractSpline() +{} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { @@ -175,7 +179,7 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event) switch (event->key()) { case Qt::Key_Delete: - DeleteTool(this); + DeleteTool(); break; default: break; diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h index 96ac5d289..2c39f033f 100644 --- a/src/app/tools/drawTools/vabstractspline.h +++ b/src/app/tools/drawTools/vabstractspline.h @@ -38,6 +38,7 @@ class VAbstractSpline:public VDrawTool, public QGraphicsPathItem Q_OBJECT public: VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr); + virtual ~VAbstractSpline(); static const QString TagName; virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual int type() const {return Type;} @@ -82,6 +83,8 @@ protected: virtual void keyReleaseEvent(QKeyEvent * event); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const; +private: + Q_DISABLE_COPY(VAbstractSpline) }; #endif // VABSTRACTSPLINE_H diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp index 8dbea68e3..e0f059c45 100644 --- a/src/app/tools/drawTools/vdrawtool.cpp +++ b/src/app/tools/drawTools/vdrawtool.cpp @@ -83,7 +83,7 @@ void VDrawTool::ChangedActivDraw(const QString &newName) { if (nameActivDraw == newName) { - currentColor = Qt::black; + currentColor = baseColor; } else { diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index 74a9b5ecc..94ec22533 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -239,6 +239,7 @@ void VToolLine::ChangedActivDraw(const QString &newName) { VDrawTool::ChangedActivDraw(newName); this->setEnabled(nameActivDraw == newName); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); } //--------------------------------------------------------------------------------------------------------------------- @@ -348,7 +349,7 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event) switch (event->key()) { case Qt::Key_Delete: - DeleteTool(this); + DeleteTool(); break; default: break; diff --git a/src/app/tools/drawTools/vtoollinepoint.cpp b/src/app/tools/drawTools/vtoollinepoint.cpp index 788fc9656..59fd9742d 100644 --- a/src/app/tools/drawTools/vtoollinepoint.cpp +++ b/src/app/tools/drawTools/vtoollinepoint.cpp @@ -65,6 +65,7 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName) { VToolPoint::ChangedActivDraw(newName); this->setEnabled(nameActivDraw == newName); + mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine))); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index e6d1d693a..9e71bb664 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -135,6 +135,8 @@ void VToolPoint::ChangedActivDraw(const QString &newName) VDrawTool::ChangedActivDraw(newName); this->setEnabled(nameActivDraw == newName); namePoint->setBrush(QBrush(currentColor)); + lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); } //--------------------------------------------------------------------------------------------------------------------- @@ -312,7 +314,7 @@ void VToolPoint::keyReleaseEvent(QKeyEvent *event) switch (event->key()) { case Qt::Key_Delete: - DeleteTool(this); + DeleteTool(); break; default: break; diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index 325fde6d1..a90ed60da 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -307,7 +307,16 @@ void VToolSinglePoint::FullUpdateFromFile() void VToolSinglePoint::ChangedActivDraw(const QString &newName) { VToolPoint::ChangedActivDraw(newName); - this->setEnabled(nameActivDraw == newName); + if (nameActivDraw == newName) + { + this->setEnabled(true); + setColorLabel(Qt::black); + } + else + { + this->setEnabled(false); + setColorLabel(Qt::gray); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 788a383ce..96eddc313 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -84,6 +84,10 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Sour } } +//--------------------------------------------------------------------------------------------------------------------- +VToolSpline::~VToolSpline() +{} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief setDialog set dialog when user want change tool option. diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h index a0c8faa33..214b14687 100644 --- a/src/app/tools/drawTools/vtoolspline.h +++ b/src/app/tools/drawTools/vtoolspline.h @@ -38,9 +38,9 @@ class VToolSpline:public VAbstractSpline { Q_OBJECT public: - - VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, - QGraphicsItem * parent = nullptr ); + VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + QGraphicsItem * parent = nullptr ); + virtual ~VToolSpline(); virtual void setDialog(); static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolSpline *Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1, @@ -64,6 +64,7 @@ protected: virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); private: + Q_DISABLE_COPY(VToolSpline) void RefreshGeometry (); }; diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index 32b60be4e..911e72894 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -362,7 +362,7 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event) switch (event->key()) { case Qt::Key_Delete: - DeleteTool(this); + DeleteTool(); break; default: break; diff --git a/src/app/visualization/vistoolline.cpp b/src/app/visualization/vistoolline.cpp index 3ce21c3f8..0b782c45d 100644 --- a/src/app/visualization/vistoolline.cpp +++ b/src/app/visualization/vistoolline.cpp @@ -64,3 +64,12 @@ void VisToolLine::setPoint2Id(const quint32 &value) { point2Id = value; } + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolLine::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style) +{ + SCASSERT (lineItem != nullptr); + + lineItem->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style)); + lineItem->setLine(line); +} diff --git a/src/app/visualization/vistoolline.h b/src/app/visualization/vistoolline.h index 48347dbe7..b46c1a49c 100644 --- a/src/app/visualization/vistoolline.h +++ b/src/app/visualization/vistoolline.h @@ -42,6 +42,9 @@ public: void setPoint2Id(const quint32 &value); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Vis::ToolLine)}; +protected: + virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, + Qt::PenStyle style = Qt::SolidLine); private: Q_DISABLE_COPY(VisToolLine) quint32 point2Id; diff --git a/src/app/visualization/visualization.h b/src/app/visualization/visualization.h index 4ec34e60e..49f02c674 100644 --- a/src/app/visualization/visualization.h +++ b/src/app/visualization/visualization.h @@ -74,7 +74,7 @@ protected: qreal FindVal(const QString &expression); void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style = Qt::SolidLine); - void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, + virtual void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style = Qt::SolidLine); template diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index 54fc0ff65..7ebf5e755 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -235,6 +235,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) if (list.at(i)->type() <= VSimpleCurve::Type && list.at(i)->type() > QGraphicsItem::UserType) { emit itemClicked(list.at(i)); + break; } } } diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index cea5ee35e..c10582fc3 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -297,12 +297,15 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) { - if (item != nullptr && item->isEnabled()==false) + if (item != nullptr) { - return; + if (item->isEnabled()==false) + { + return; + } } - if (currentItem == item) + if (currentItem == item && item != nullptr) { UpdateOptions(); return; @@ -312,10 +315,14 @@ void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) propertyToId.clear(); idToProperty.clear(); - VAbstractTool *previousTool = dynamic_cast(currentItem); - if (previousTool != nullptr) + + if (currentItem != nullptr) { - previousTool->ShowVisualization(false); // hide for previous tool + VAbstractTool *previousTool = dynamic_cast(currentItem); + if (previousTool != nullptr) + { + previousTool->ShowVisualization(false); // hide for previous tool + } } currentItem = item;