From 466bc980202601835496bae6e42bf4a63692c4bc Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 28 Feb 2014 14:58:37 +0200 Subject: [PATCH] Use inline functions instead of plain old #define macros. QPen set width in pixel, so need convert mm to pixel. --HG-- branch : develop --- src/options.h | 17 +++++++++++++---- src/tablewindow.cpp | 18 +++++++++--------- src/tools/drawTools/vdrawtool.h | 2 +- src/tools/drawTools/vtoolarc.cpp | 10 +++++----- src/tools/drawTools/vtoolcutarc.cpp | 4 ++-- src/tools/drawTools/vtoolcutspline.cpp | 4 ++-- src/tools/drawTools/vtoolcutsplinepath.cpp | 4 ++-- src/tools/drawTools/vtoolline.cpp | 10 +++++----- src/tools/drawTools/vtoollinepoint.cpp | 6 +++--- src/tools/drawTools/vtoolpoint.cpp | 14 +++++++------- src/tools/drawTools/vtoolsinglepoint.cpp | 2 +- src/tools/drawTools/vtoolspline.cpp | 10 +++++----- src/tools/drawTools/vtoolsplinepath.cpp | 10 +++++----- src/tools/nodeDetails/vnodearc.cpp | 6 +++--- src/tools/nodeDetails/vnodepoint.cpp | 6 +++--- src/tools/nodeDetails/vnodespline.cpp | 6 +++--- src/tools/nodeDetails/vnodesplinepath.cpp | 6 +++--- src/widgets/vcontrolpointspline.cpp | 12 ++++++------ src/widgets/vitem.cpp | 6 +++--- src/widgets/vsimplearc.cpp | 12 ++++++------ src/widgets/vsimplespline.cpp | 12 ++++++------ src/widgets/vsimplesplinepath.cpp | 4 ++-- 22 files changed, 95 insertions(+), 86 deletions(-) diff --git a/src/options.h b/src/options.h index 1c3a8770e..1d4176d0c 100644 --- a/src/options.h +++ b/src/options.h @@ -34,10 +34,19 @@ #define SceneSize 50000 -#define PrintDPI 96 -#define toPixel(mm) ((mm / 25.4) * PrintDPI) -#define toMM(pix) ((pix / PrintDPI) * 25.4) -#define widthMainLine 1.2 +#define PrintDPI 96.0 + +inline double toPixel(double mm) +{ + return (mm / 25.4) * PrintDPI; +} + +inline double toMM(double pix) +{ + return (pix / PrintDPI) * 25.4; +} + +#define widthMainLine 1.2 //mm #define widthHairLine widthMainLine/3 extern const QString translationsPath; diff --git a/src/tablewindow.cpp b/src/tablewindow.cpp index 28ad33a61..7215028ab 100644 --- a/src/tablewindow.cpp +++ b/src/tablewindow.cpp @@ -81,7 +81,7 @@ void TableWindow::AddPaper() shadowPaper->setBrush(QBrush(Qt::black)); tableScene->addItem(shadowPaper); paper = new QGraphicsRectItem(QRectF(x1, y1, x2, y2)); - paper->setPen(QPen(Qt::black, widthMainLine)); + paper->setPen(QPen(Qt::black, toPixel(widthMainLine))); paper->setBrush(QBrush(Qt::white)); tableScene->addItem(paper); qDebug()<rect().size().toSize(); @@ -220,22 +220,22 @@ void TableWindow::saveScene() case 1: //png paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); PngFile(name); - paper->setPen(QPen(Qt::black, widthMainLine)); + paper->setPen(QPen(Qt::black, toPixel(widthMainLine))); break; case 2: //pdf paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); PdfFile(name); - paper->setPen(QPen(Qt::black, widthMainLine)); + paper->setPen(QPen(Qt::black, toPixel(widthMainLine))); break; case 3: //eps paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); EpsFile(name); - paper->setPen(QPen(Qt::black, widthMainLine)); + paper->setPen(QPen(Qt::black, toPixel(widthMainLine))); break; case 4: //ps paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); PsFile(name); - paper->setPen(QPen(Qt::black, widthMainLine)); + paper->setPen(QPen(Qt::black, toPixel(widthMainLine))); break; default: qWarning() << "Bad file suffix"< list, int number) { VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(i) ); Q_CHECK_PTR(bitem); - bitem->setPen(QPen(Qt::black, widthMainLine)); + bitem->setPen(QPen(Qt::black, toPixel(widthMainLine))); listCollidingItems.removeAt(i); } } @@ -323,7 +323,7 @@ void TableWindow::itemColliding(QList list, int number) { VItem * bitem = qgraphicsitem_cast ( listCollidingItems.at(0) ); Q_CHECK_PTR(bitem); - bitem->setPen(QPen(Qt::black, widthMainLine)); + bitem->setPen(QPen(Qt::black, toPixel(widthMainLine))); listCollidingItems.clear(); collidingItems = true; } @@ -450,7 +450,7 @@ void TableWindow::PngFile(const QString &name) const QPainter painter(&image); painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); tableScene->render(&painter); image.save(name); @@ -474,7 +474,7 @@ void TableWindow::PdfFile(const QString &name) const } painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, toPixel(widthMainLine), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter.setBrush ( QBrush ( Qt::NoBrush ) ); tableScene->render(&painter); painter.end(); diff --git a/src/tools/drawTools/vdrawtool.h b/src/tools/drawTools/vdrawtool.h index 3e24c9b59..f85b9cab4 100644 --- a/src/tools/drawTools/vdrawtool.h +++ b/src/tools/drawTools/vdrawtool.h @@ -196,7 +196,7 @@ protected: { currentColor = color; } - item->setPen(QPen(currentColor, widthHairLine/factor)); + item->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); } } private: diff --git a/src/tools/drawTools/vtoolarc.cpp b/src/tools/drawTools/vtoolarc.cpp index 1bfdc066b..7f63bfa8d 100644 --- a/src/tools/drawTools/vtoolarc.cpp +++ b/src/tools/drawTools/vtoolarc.cpp @@ -42,7 +42,7 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::S path.addPath(arc->GetPath()); path.setFillRule( Qt::WindingFill ); this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine/factor)); + this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); @@ -156,7 +156,7 @@ void VToolArc::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); this->setAcceptHoverEvents (selectable); VDrawTool::ChangedActivDraw(newName); @@ -219,14 +219,14 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor)); } //cppcheck-suppress unusedFunction void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); } void VToolArc::RemoveReferens() @@ -279,7 +279,7 @@ void VToolArc::SaveDialog(QDomElement &domElement) void VToolArc::RefreshGeometry() { - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); const VArc *arc = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(arc->GetPath()); diff --git a/src/tools/drawTools/vtoolcutarc.cpp b/src/tools/drawTools/vtoolcutarc.cpp index bd75d9152..05588967a 100644 --- a/src/tools/drawTools/vtoolcutarc.cpp +++ b/src/tools/drawTools/vtoolcutarc.cpp @@ -193,8 +193,8 @@ void VToolCutArc::ChangedActivDraw(const QString &newName) secondArc->setFlag(QGraphicsItem::ItemIsSelectable, false); secondArc->setAcceptHoverEvents(false); } - firstArc->setPen(QPen(currentColor, widthHairLine/factor)); - secondArc->setPen(QPen(currentColor, widthHairLine/factor)); + firstArc->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); + secondArc->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); VToolPoint::ChangedActivDraw(newName); } diff --git a/src/tools/drawTools/vtoolcutspline.cpp b/src/tools/drawTools/vtoolcutspline.cpp index efa9ca3c6..b97a97e41 100644 --- a/src/tools/drawTools/vtoolcutspline.cpp +++ b/src/tools/drawTools/vtoolcutspline.cpp @@ -194,8 +194,8 @@ void VToolCutSpline::ChangedActivDraw(const QString &newName) secondSpline->setFlag(QGraphicsItem::ItemIsSelectable, false); secondSpline->setAcceptHoverEvents(false); } - firstSpline->setPen(QPen(currentColor, widthHairLine/factor)); - secondSpline->setPen(QPen(currentColor, widthHairLine/factor)); + firstSpline->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); + secondSpline->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); VToolPoint::ChangedActivDraw(newName); } diff --git a/src/tools/drawTools/vtoolcutsplinepath.cpp b/src/tools/drawTools/vtoolcutsplinepath.cpp index ae49c70c7..5a26815c2 100644 --- a/src/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/tools/drawTools/vtoolcutsplinepath.cpp @@ -275,8 +275,8 @@ void VToolCutSplinePath::ChangedActivDraw(const QString &newName) secondSpline->setFlag(QGraphicsItem::ItemIsSelectable, false); secondSpline->setAcceptHoverEvents(false); } - firstSpline->setPen(QPen(currentColor, widthHairLine/factor)); - secondSpline->setPen(QPen(currentColor, widthHairLine/factor)); + firstSpline->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); + secondSpline->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); VToolPoint::ChangedActivDraw(newName); } diff --git a/src/tools/drawTools/vtoolline.cpp b/src/tools/drawTools/vtoolline.cpp index c9fece4ca..e4723dc35 100644 --- a/src/tools/drawTools/vtoolline.cpp +++ b/src/tools/drawTools/vtoolline.cpp @@ -45,7 +45,7 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); - this->setPen(QPen(Qt::black, widthHairLine/factor, LineStyle())); + this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor, LineStyle())); if (typeCreation == Tool::FromGui) { @@ -143,7 +143,7 @@ void VToolLine::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle())); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle())); this->setAcceptHoverEvents (selectable); VDrawTool::ChangedActivDraw(newName); } @@ -178,13 +178,13 @@ void VToolLine::RefreshDataInFile() void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor, LineStyle())); + this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor, LineStyle())); } void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle())); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle())); } void VToolLine::RemoveReferens() @@ -246,5 +246,5 @@ void VToolLine::RefreshGeometry() const VPointF *first = VAbstractTool::data.GeometricObject(firstPoint); const VPointF *second = VAbstractTool::data.GeometricObject(secondPoint); this->setLine(QLineF(first->toQPointF(), second->toQPointF())); - this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle())); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle())); } diff --git a/src/tools/drawTools/vtoollinepoint.cpp b/src/tools/drawTools/vtoollinepoint.cpp index ff7d53dc4..e277335b5 100644 --- a/src/tools/drawTools/vtoollinepoint.cpp +++ b/src/tools/drawTools/vtoollinepoint.cpp @@ -39,7 +39,7 @@ VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 QPointF point1 = data->GeometricObject(basePointId)->toQPointF(); QPointF point2 = data->GeometricObject(id)->toQPointF(); mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); - mainLine->setPen(QPen(Qt::black, widthHairLine/factor, LineStyle())); + mainLine->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor, LineStyle())); mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); } @@ -53,13 +53,13 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName) { currentColor = Qt::gray; } - mainLine->setPen(QPen(currentColor, widthHairLine/factor, LineStyle())); + mainLine->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle())); VToolPoint::ChangedActivDraw(newName); } void VToolLinePoint::RefreshGeometry() { - mainLine->setPen(QPen(currentColor, widthHairLine/factor, LineStyle())); + mainLine->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle())); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); QPointF point = VDrawTool::data.GeometricObject(id)->toQPointF(); QPointF basePoint = VDrawTool::data.GeometricObject(basePointId)->toQPointF(); diff --git a/src/tools/drawTools/vtoolpoint.cpp b/src/tools/drawTools/vtoolpoint.cpp index 4baf9a1d6..7d618cd14 100644 --- a/src/tools/drawTools/vtoolpoint.cpp +++ b/src/tools/drawTools/vtoolpoint.cpp @@ -84,7 +84,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); this->setAcceptHoverEvents (selectable); namePoint->setFlag(QGraphicsItem::ItemIsMovable, selectable); @@ -92,7 +92,7 @@ void VToolPoint::ChangedActivDraw(const QString &newName) namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, selectable); namePoint->setBrush(QBrush(currentColor)); namePoint->setAcceptHoverEvents(selectable); - lineName->setPen(QPen(currentColor, widthHairLine/factor)); + lineName->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); VDrawTool::ChangedActivDraw(newName); } @@ -124,18 +124,18 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor)); } void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); } void VToolPoint::RefreshPointGeometry(const VPointF &point) { - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); QRectF rec = QRectF(0, 0, radius*2/factor, radius*2/factor); rec.translate(-rec.center().x(), -rec.center().y()); this->setRect(rec); @@ -161,11 +161,11 @@ void VToolPoint::RefreshLine() lineName->setLine(QLineF(p1, pRec - scenePos())); if (currentColor == Qt::gray) { - lineName->setPen(QPen(currentColor, widthHairLine/factor)); + lineName->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); } else { - lineName->setPen(QPen(Qt::black, widthHairLine/factor)); + lineName->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor)); } if (QLineF(p1, pRec - scenePos()).length() <= toPixel(4)) { diff --git a/src/tools/drawTools/vtoolsinglepoint.cpp b/src/tools/drawTools/vtoolsinglepoint.cpp index e56d7c3f8..22518d374 100644 --- a/src/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/tools/drawTools/vtoolsinglepoint.cpp @@ -150,7 +150,7 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement) void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) { namePoint->setBrush(color); - lineName->setPen(QPen(color, widthHairLine/factor)); + lineName->setPen(QPen(color, toPixel(widthHairLine)/factor)); } void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) diff --git a/src/tools/drawTools/vtoolspline.cpp b/src/tools/drawTools/vtoolspline.cpp index a8392d7ca..93987b272 100644 --- a/src/tools/drawTools/vtoolspline.cpp +++ b/src/tools/drawTools/vtoolspline.cpp @@ -44,7 +44,7 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const T path.addPath(spl->GetPath()); path.setFillRule( Qt::WindingFill ); this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine/factor)); + this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); @@ -227,13 +227,13 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor)); } void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); } void VToolSpline::RemoveReferens() @@ -309,7 +309,7 @@ void VToolSpline::SaveDialog(QDomElement &domElement) void VToolSpline::RefreshGeometry() { - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); const VSpline *spl = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(spl->GetPath()); @@ -348,7 +348,7 @@ void VToolSpline::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); this->setAcceptHoverEvents (selectable); emit setEnabledPoint(selectable); diff --git a/src/tools/drawTools/vtoolsplinepath.cpp b/src/tools/drawTools/vtoolsplinepath.cpp index d7f2dac6b..924a9091c 100644 --- a/src/tools/drawTools/vtoolsplinepath.cpp +++ b/src/tools/drawTools/vtoolsplinepath.cpp @@ -42,7 +42,7 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, path.addPath(splPath->GetPath()); path.setFillRule( Qt::WindingFill ); this->setPath(path); - this->setPen(QPen(Qt::black, widthHairLine/factor)); + this->setPen(QPen(Qt::black, toPixel(widthHairLine)/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); @@ -202,7 +202,7 @@ void VToolSplinePath::ChangedActivDraw(const QString &newName) selectable = false; currentColor = Qt::gray; } - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, selectable); this->setAcceptHoverEvents (selectable); emit setEnabledPoint(selectable); @@ -299,13 +299,13 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor)); } void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); } void VToolSplinePath::RemoveReferens() @@ -382,7 +382,7 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement) void VToolSplinePath::RefreshGeometry() { - this->setPen(QPen(currentColor, widthHairLine/factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor)); const VSplinePath *splPath = VAbstractTool::data.GeometricObject(id); QPainterPath path; path.addPath(splPath->GetPath()); diff --git a/src/tools/nodeDetails/vnodearc.cpp b/src/tools/nodeDetails/vnodearc.cpp index ebda652c1..84ff1a103 100644 --- a/src/tools/nodeDetails/vnodearc.cpp +++ b/src/tools/nodeDetails/vnodearc.cpp @@ -38,7 +38,7 @@ VNodeArc::VNodeArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, :VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); - this->setPen(QPen(baseColor, widthHairLine)); + this->setPen(QPen(baseColor, toPixel(widthHairLine))); if (typeCreation == Tool::FromGui) { @@ -129,13 +129,13 @@ void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); + this->setPen(QPen(currentColor, toPixel(widthMainLine))); } void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); + this->setPen(QPen(currentColor, toPixel(widthHairLine))); } void VNodeArc::RefreshGeometry() diff --git a/src/tools/nodeDetails/vnodepoint.cpp b/src/tools/nodeDetails/vnodepoint.cpp index d86fbccd8..e1f4ee241 100644 --- a/src/tools/nodeDetails/vnodepoint.cpp +++ b/src/tools/nodeDetails/vnodepoint.cpp @@ -43,7 +43,7 @@ VNodePoint::VNodePoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 id lineName = new QGraphicsLineItem(this); connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VNodePoint::NameChangePosition); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(Qt::black, toPixel(widthHairLine))); this->setBrush(QBrush(Qt::NoBrush)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setAcceptHoverEvents(true); @@ -146,13 +146,13 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); + this->setPen(QPen(currentColor, toPixel(widthMainLine))); } void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); + this->setPen(QPen(currentColor, toPixel(widthHairLine))); } diff --git a/src/tools/nodeDetails/vnodespline.cpp b/src/tools/nodeDetails/vnodespline.cpp index 7ec99d27b..6cb4d68a8 100644 --- a/src/tools/nodeDetails/vnodespline.cpp +++ b/src/tools/nodeDetails/vnodespline.cpp @@ -39,7 +39,7 @@ VNodeSpline::VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); - this->setPen(QPen(baseColor, widthHairLine)); + this->setPen(QPen(baseColor, toPixel(widthHairLine))); if (typeCreation == Tool::FromGui) { @@ -132,13 +132,13 @@ void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); + this->setPen(QPen(currentColor, toPixel(widthMainLine))); } void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); + this->setPen(QPen(currentColor, toPixel(widthHairLine))); } void VNodeSpline::RefreshGeometry() diff --git a/src/tools/nodeDetails/vnodesplinepath.cpp b/src/tools/nodeDetails/vnodesplinepath.cpp index 54dc91ea5..ed21d0bb4 100644 --- a/src/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/tools/nodeDetails/vnodesplinepath.cpp @@ -39,7 +39,7 @@ VNodeSplinePath::VNodeSplinePath(VDomDocument *doc, VContainer *data, qint64 id, :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); - this->setPen(QPen(baseColor, widthHairLine)); + this->setPen(QPen(baseColor, toPixel(widthHairLine))); if (typeCreation == Tool::FromGui) { @@ -136,13 +136,13 @@ void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine)); + this->setPen(QPen(currentColor, toPixel(widthMainLine))); } void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine)); + this->setPen(QPen(currentColor, toPixel(widthHairLine))); } void VNodeSplinePath::RefreshGeometry() diff --git a/src/widgets/vcontrolpointspline.cpp b/src/widgets/vcontrolpointspline.cpp index bf1dc0be8..a918bb943 100644 --- a/src/widgets/vcontrolpointspline.cpp +++ b/src/widgets/vcontrolpointspline.cpp @@ -40,7 +40,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint: QRectF rec = QRectF(0, 0, radius*2, radius*2); rec.translate(-rec.center().x(), -rec.center().y()); this->setRect(rec); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(Qt::black, toPixel(widthHairLine))); this->setBrush(QBrush(Qt::NoBrush)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true); @@ -51,20 +51,20 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint: QPointF p1, p2; VAbstractTool::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2); controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this); - controlLine->setPen(QPen(Qt::red, widthHairLine)); + controlLine->setPen(QPen(Qt::red, toPixel(widthHairLine))); controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); } void VControlPointSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthMainLine)); + this->setPen(QPen(Qt::black, toPixel(widthMainLine))); } void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(Qt::black, toPixel(widthHairLine))); } QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) @@ -93,14 +93,14 @@ void VControlPointSpline::setEnabledPoint(bool enable) { if (enable == true) { - this->setPen(QPen(Qt::black, widthHairLine)); + this->setPen(QPen(Qt::black, toPixel(widthHairLine))); this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setAcceptHoverEvents(true); } else { - this->setPen(QPen(Qt::gray, widthHairLine)); + this->setPen(QPen(Qt::gray, toPixel(widthHairLine))); this->setFlag(QGraphicsItem::ItemIsSelectable, false); this->setFlag(QGraphicsItem::ItemIsMovable, false); this->setAcceptHoverEvents(false); diff --git a/src/widgets/vitem.cpp b/src/widgets/vitem.cpp index f42b9a4d2..68dda487b 100644 --- a/src/widgets/vitem.cpp +++ b/src/widgets/vitem.cpp @@ -52,19 +52,19 @@ void VItem::checkItemChange() QRectF myrect = sceneBoundingRect(); if ( rect.contains( myrect )==true ) { - setPen(QPen(Qt::black, widthMainLine)); + setPen(QPen(Qt::black, toPixel(widthMainLine))); emit itemOut( numInOutList, false ); } else { - setPen(QPen(Qt::red, widthMainLine)); + setPen(QPen(Qt::red, toPixel(widthMainLine))); emit itemOut( numInOutList, true ); } QList list = QGraphicsItem::collidingItems (); if ( list.size() - 2 > 0 ) { list.append( this ); - setPen(QPen(Qt::red, widthMainLine)); + setPen(QPen(Qt::red, toPixel(widthMainLine))); emit itemColliding( list, 1 );//Detail intersect with other details. } else diff --git a/src/widgets/vsimplearc.cpp b/src/widgets/vsimplearc.cpp index b9151da3e..b5ed1cb4b 100644 --- a/src/widgets/vsimplearc.cpp +++ b/src/widgets/vsimplearc.cpp @@ -33,11 +33,11 @@ VSimpleArc::VSimpleArc(qint64 id, Qt::GlobalColor *currentColor, qreal *factor, { if (factor == 0) { - setPen(QPen(Qt::black, widthHairLine)); + setPen(QPen(Qt::black, toPixel(widthHairLine))); } else { - setPen(QPen(Qt::black, widthHairLine/ *factor)); + setPen(QPen(Qt::black, toPixel(widthHairLine)/ *factor)); } setFlag(QGraphicsItem::ItemIsSelectable, true); setAcceptHoverEvents(true); @@ -57,11 +57,11 @@ void VSimpleArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == 0) { - this->setPen(QPen(*currentColor, widthMainLine)); + this->setPen(QPen(*currentColor, toPixel(widthMainLine))); } else { - this->setPen(QPen(*currentColor, widthMainLine/ *factor)); + this->setPen(QPen(*currentColor, toPixel(widthMainLine)/ *factor)); } } @@ -70,10 +70,10 @@ void VSimpleArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == 0) { - this->setPen(QPen(*currentColor, widthHairLine)); + this->setPen(QPen(*currentColor, toPixel(widthHairLine))); } else { - this->setPen(QPen(*currentColor, widthHairLine/ *factor)); + this->setPen(QPen(*currentColor, toPixel(widthHairLine)/ *factor)); } } diff --git a/src/widgets/vsimplespline.cpp b/src/widgets/vsimplespline.cpp index c77be792a..a86d37364 100644 --- a/src/widgets/vsimplespline.cpp +++ b/src/widgets/vsimplespline.cpp @@ -34,11 +34,11 @@ VSimpleSpline::VSimpleSpline(qint64 id, Qt::GlobalColor *currentColor, qreal *fa { if (factor == 0) { - setPen(QPen(Qt::black, widthHairLine)); + setPen(QPen(Qt::black, toPixel(widthHairLine))); } else { - setPen(QPen(Qt::black, widthHairLine/ *factor)); + setPen(QPen(Qt::black, toPixel(widthHairLine)/ *factor)); } setFlag(QGraphicsItem::ItemIsSelectable, true); setAcceptHoverEvents(true); @@ -58,11 +58,11 @@ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == 0) { - this->setPen(QPen(*currentColor, widthMainLine)); + this->setPen(QPen(*currentColor, toPixel(widthMainLine))); } else { - this->setPen(QPen(*currentColor, widthMainLine/ *factor)); + this->setPen(QPen(*currentColor, toPixel(widthMainLine)/ *factor)); } } @@ -71,10 +71,10 @@ void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == 0) { - this->setPen(QPen(*currentColor, widthHairLine)); + this->setPen(QPen(*currentColor, toPixel(widthHairLine))); } else { - this->setPen(QPen(*currentColor, widthHairLine/ *factor)); + this->setPen(QPen(*currentColor, toPixel(widthHairLine)/ *factor)); } } diff --git a/src/widgets/vsimplesplinepath.cpp b/src/widgets/vsimplesplinepath.cpp index fb63883b4..b7dae6417 100644 --- a/src/widgets/vsimplesplinepath.cpp +++ b/src/widgets/vsimplesplinepath.cpp @@ -45,11 +45,11 @@ void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthMainLine/ *factor)); + this->setPen(QPen(currentColor, toPixel(widthMainLine)/ *factor)); } void VSimpleSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, widthHairLine/ *factor)); + this->setPen(QPen(currentColor, toPixel(widthHairLine)/ *factor)); }