mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
improvement: ajust size of grid-dots with zoom-factor
Introduced additional spinboxes in config-page for setting min- and max-size of grid-dots separately for diagram- and element-editor. That assures maximal flexibility for setting the grids. Don't want the grid-dots to change over zooming-levels? Set min- and max-values to the same number. Preset-values for all min-/max-values is "1". If the adjustable range of 1 to 5 is not sufficient, it can be easily adjusted. Only need feedback for this.
This commit is contained in:
@@ -227,9 +227,27 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
points << QPoint(gx, gy);
|
||||
}
|
||||
}
|
||||
pen.setWidth(settings.value(QStringLiteral("diagrameditor/grid_pointsize"), 1).toInt());
|
||||
|
||||
qreal zoom_factor = p->transform().m11();
|
||||
int minWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_min"), 1).toInt();
|
||||
int maxWidthPen = settings.value(QStringLiteral("diagrameditor/grid_pointsize_max"), 1).toInt();
|
||||
pen.setWidth(minWidthPen);
|
||||
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
||||
qreal stepZoom = (5.0 - 1.0) / maxWidthPen;
|
||||
for (int n=0; n<maxWidthPen; n++) {
|
||||
if ((zoom_factor > (1.0 + n * stepZoom)) && (zoom_factor <= (1.0 + (n+1) * stepZoom))) {
|
||||
int widthPen = minWidthPen + qRound(n * stepPen);
|
||||
pen.setWidth(widthPen);
|
||||
}
|
||||
}
|
||||
if (zoom_factor <= 1.0)
|
||||
pen.setWidth(minWidthPen);
|
||||
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
||||
pen.setWidth(maxWidthPen);
|
||||
|
||||
p -> setPen(pen);
|
||||
p -> drawPoints(points);
|
||||
if (zoom_factor > 0.5) // no grid below ... !
|
||||
p -> drawPoints(points);
|
||||
}
|
||||
|
||||
if (use_border_) border_and_titleblock.draw(p);
|
||||
|
||||
Reference in New Issue
Block a user