Use inline functions instead of plain old #define macros. QPen set width in

pixel, so need convert mm to pixel.

--HG--
branch : develop
This commit is contained in:
dismine 2014-02-28 14:58:37 +02:00
parent 95e02fc043
commit 466bc98020
22 changed files with 95 additions and 86 deletions

View File

@ -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;

View File

@ -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()<<paper->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"<<Q_FUNC_INFO;
@ -314,7 +314,7 @@ void TableWindow::itemColliding(QList<QGraphicsItem *> list, int number)
{
VItem * bitem = qgraphicsitem_cast<VItem *> ( 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<QGraphicsItem *> list, int number)
{
VItem * bitem = qgraphicsitem_cast<VItem *> ( 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();

View File

@ -196,7 +196,7 @@ protected:
{
currentColor = color;
}
item->setPen(QPen(currentColor, widthHairLine/factor));
item->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
}
}
private:

View File

@ -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<const VArc *>(id);
QPainterPath path;
path.addPath(arc->GetPath());

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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<const VPointF *>(firstPoint);
const VPointF *second = VAbstractTool::data.GeometricObject<const VPointF *>(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
this->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor, LineStyle()));
}

View File

@ -39,7 +39,7 @@ VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64
QPointF point1 = data->GeometricObject<const VPointF *>(basePointId)->toQPointF();
QPointF point2 = data->GeometricObject<const VPointF *>(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<const VPointF *>(id));
QPointF point = VDrawTool::data.GeometricObject<const VPointF *>(id)->toQPointF();
QPointF basePoint = VDrawTool::data.GeometricObject<const VPointF *>(basePointId)->toQPointF();

View File

@ -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))
{

View File

@ -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 )

View File

@ -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<const VSpline *>(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);

View File

@ -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<const VSplinePath *>(id);
QPainterPath path;
path.addPath(splPath->GetPath());

View File

@ -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()

View File

@ -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)));
}

View File

@ -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()

View File

@ -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()

View File

@ -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);

View File

@ -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<QGraphicsItem *> 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

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}