mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
only calculate grid-point-size, when min != max
This commit is contained in:
@@ -186,7 +186,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
p -> drawRect(r);
|
||||
|
||||
if (draw_grid_) {
|
||||
/* Draw the point of the grid
|
||||
/* Draw the points of the grid
|
||||
* if background color is black,
|
||||
* then grid spots shall be white,
|
||||
* else they shall be black in color.
|
||||
@@ -232,19 +232,20 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
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 (minWidthPen != maxWidthPen) {
|
||||
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);
|
||||
}
|
||||
if (zoom_factor <= 1.0)
|
||||
pen.setWidth(minWidthPen);
|
||||
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
||||
pen.setWidth(maxWidthPen);
|
||||
|
||||
p -> setPen(pen);
|
||||
if (zoom_factor > 0.5) // no grid below ... !
|
||||
p -> drawPoints(points);
|
||||
|
||||
@@ -559,19 +559,20 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
|
||||
int minWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_min"), 1).toInt();
|
||||
int maxWidthPen = settings.value(QStringLiteral("elementeditor/grid_pointsize_max"), 1).toInt();
|
||||
pen.setWidth(minWidthPen);
|
||||
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
||||
qreal stepZoom = (25.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 (minWidthPen != maxWidthPen) {
|
||||
qreal stepPen = (maxWidthPen - minWidthPen) / (qreal)maxWidthPen;
|
||||
qreal stepZoom = (25.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);
|
||||
}
|
||||
if (zoom_factor <= 1.0)
|
||||
pen.setWidth(minWidthPen);
|
||||
else if (zoom_factor > (1.0 + stepZoom * maxWidthPen))
|
||||
pen.setWidth(maxWidthPen);
|
||||
|
||||
p -> setPen(pen);
|
||||
p -> setBrush(Qt::NoBrush);
|
||||
qreal limit_x = r.x() + r.width();
|
||||
|
||||
Reference in New Issue
Block a user