Skip to content

Commit

Permalink
update hairline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
qcad committed Oct 15, 2014
1 parent b8e5090 commit ec5abc9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 42 deletions.
17 changes: 1 addition & 16 deletions src/gui/RGraphicsSceneQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,12 @@ bool RGraphicsSceneQt::beginPath() {
}
}

//qDebug() << "screenBasedLinetypes: " << screenBasedLinetypes;
//qDebug() << "twoColorSelectedMode: " << twoColorSelectedMode;

if (draftMode || screenBasedLinetypes || twoColorSelectedMode) {
QPen localPen = currentPen;
//draftPen.setWidth(0);
if (twoColorSelectedMode) {
// fixed width for selected entities in two color selected mode:
localPen.setCosmetic(true);
localPen.setWidth(3);
//localPen.setStyle(Qt::CustomDashLine);
}
else {
if (draftMode) {
Expand All @@ -141,21 +136,11 @@ bool RGraphicsSceneQt::beginPath() {
currentPainterPath.setPen(currentPen);
}

// if (twoColorSelectedMode) {
// QBrush localBrush(Qt::BDiagPattern);
// QTransform t;
// t.scale(0.01, 0.01);
// localBrush.setTransform(t);
// currentPainterPath.setBrush(localBrush);
// }
// else {
currentPainterPath.setBrush(QBrush(Qt::NoBrush));
// }
currentPainterPath.setBrush(QBrush(Qt::NoBrush));
currentPainterPath.setPixelSizeHint(pixelSizeHint);

if (!exportToPreview) {
if (getEntity()->isSelected()) {
//setSelectedMode(true);
currentPainterPath.setSelected(true);
}
}
Expand Down
42 changes: 16 additions & 26 deletions src/gui/RGraphicsViewImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ void RGraphicsViewImage::paintEntity(QPainter* painter, REntity::Id id) {
}

QPen pen = path.getPen();
//QPen pen2(Qt::NoPen);
QBrush brush = path.getBrush();

if (pen.style() != Qt::NoPen) {
Expand All @@ -812,27 +811,28 @@ void RGraphicsViewImage::paintEntity(QPainter* painter, REntity::Id id) {
}
else {
if (isPrintPreview()) {
// print preview: optimize thin lines to 0 (1 pixel):
if (pen.widthF() * getFactor() / drawingScale < 1.5) {
pen.setWidth(0);
}
else {
if (hairlineMode) {
pen.setWidthF(0.05 / drawingScale);
if (!pen.isCosmetic()) {
// print preview: optimize thin lines to 0 (1 pixel):
if (pen.widthF() * getFactor() / drawingScale < 1.5) {
pen.setWidth(0);
}
else {
pen.setWidthF(pen.widthF() / drawingScale);
if (hairlineMode) {
pen.setWidthF(0.05 / drawingScale);
}
else {
pen.setWidthF(pen.widthF() / drawingScale);
}
}
}
}
else {
// for display, ignore drawing scale and optimize
// thin lines to 0:
if (pen.widthF() * getFactor() < 1.5 && !pen.isCosmetic()) {
pen.setWidth(0);
}
else {
//pen.setWidthF(pen.widthF());
if (!pen.isCosmetic()) {
// for display, ignore drawing scale and optimize
// thin lines to 0:
if (pen.widthF() * getFactor() < 1.5 && !pen.isCosmetic()) {
pen.setWidth(0);
}
}
}
}
Expand Down Expand Up @@ -913,11 +913,6 @@ void RGraphicsViewImage::paintEntity(QPainter* painter, REntity::Id id) {
// draw outline:
if (pen.style() != Qt::NoPen) {
painter->drawPath(path);
//if (pen2.style() != Qt::NoPen) {
// painter->setPen(pen2);
// painter->drawPath(path);
// painter->setPen(pen);
//}
}
}
else {
Expand All @@ -940,11 +935,6 @@ void RGraphicsViewImage::paintEntity(QPainter* painter, REntity::Id id) {
QLineF qLine(QPointF(line.startPoint.x, line.startPoint.y),
QPointF(line.endPoint.x, line.endPoint.y));
painter->drawLine(qLine);
// if (pen2.style() != Qt::NoPen) {
// painter->setPen(pen2);
// painter->drawLine(qLine);
// painter->setPen(pen);
// }
}
}
else {
Expand Down

0 comments on commit ec5abc9

Please sign in to comment.