Hallo Re-searcher!
Lass mich auf Deutsch anfangen, Englisch ist weiter unten.
Worin liegt der Unterschied zwischen diesen beiden Code-Fragmenten für "diagram.cpp":
QPen point(Qt::black, 1);
p -> setPen(point);
und
pen.setWidth(settings.value(QStringLiteral("diagrameditor/grid_pointsize"), 1).toInt());
Ich sehe diese Unterschiede:
Im ersten Fragment wird eine hardcodierte "1" als Stiftbreite eingetragen und im zweiten wird eine Stiftbreite aus der Konfigurationsdatei geladen. Ist kein Wert in der Konfigurationsdatei vorhanden, wird eine "1" eingetragen.
Im Ergebnis steht in beiden Fällen eine "1" als Stiftbreite.
Einen Nachteil hat das erste Code-Fragment aber leider: Es wird eine möglicherweise vorgegebene Stiftfarbe hardcodiert durch "Qt::black" ersetzt!
Nun zur Datei "elementview.cpp".
und
pen.setWidth(settings.value(QStringLiteral("diagrameditor/grid_pointsize"), 1).toInt());
Im ersten Fall wird die Stiftbreite hardcodiert auf "5" gesetzt und im zweiten Fall auf den Wert aus der Konfigurationsdatei.
p -> drawLine(QLineF(gx - 0.8, gy, gx + 0.8, gy));
p -> drawLine(QLineF(gx, gy - 0.8, gx, gy + 0.8));
und
p -> drawLine(QLineF(gx - (pen.width()/4.0), gy, gx + (pen.width()/4.0), gy));
p -> drawLine(QLineF(gx, gy - (pen.width()/4.0), gx, gy + (pen.width()/4.0)));
Im ersten Fall wird die Linienlänge um von "-0.8" bis "+0.8" definiert und im zweiten Fall auf "Stiftbreite geteilt durch 4".
Für den Fall "Stiftbreite = 5" ist das Ergebnis identisch.
Zusammenfassung:
In einem Fall sind die Stiftbreiten hardcodiert und im zweiten Fall kommt die Stiftbreite aus der Konfigurationsdatei. Bei gleicher Einstellung für die Stiftbreite ist das Ergebnis auf dem Bildschirm das gleiche.
Seit ein paar Tagen ist die Raster-Punktgröße für den Schaltplaneditor und den Element-Editor sogar getrennt einstellbar, sodass man unterschiedliche Werte haben kann: Zum Beispiel "1" für den Schaltplaneditor und "5" für den Element-Editor, wie es in hardcodiertem Code der Fall wäre.
So ist Deine Idee mit anderer Punktgröße für das Raster in den Quellcode von QElectroTech gelangt, Re-searcher!
Die Ergänzung, daß es konfigurierbar ist, kann für die Benutzer nur von Vorteil sein.
Daß Du keine grafischen Artefakte siehst: Freue Dich doch!
Die fallen je nach Pixelgröße des Bildschirms optisch weniger auf!
Du hat einen UHD-Monitor, nicht wahr?
Ich hoffe, dass mit dieser Erklärung deutlich geworden ist, dass es ausdrücklich nicht darum geht, den Code-Vorschlag von jemandem nicht umzusetzen, sondern für uns und die Nutzer von QET eine gute Lösung zu haben!
Beste Grüße
plc-user
Online-Translator
Hello Re-searcher!
What is the difference between these two code fragments for "diagram.cpp":
QPen point(Qt::black, 1);
p -> setPen(point);
and
pen.setWidth(settings.value(QStringLiteral("diagrameditor/grid_pointsize"), 1).toInt());
I see these differences:
In the first fragment, a hardcoded "1" is entered as the pen width and in the second, a pen width is loaded from the configuration file. If there is no value in the configuration file, a "1" is entered.
The result in both cases is a "1" as the pen width.
Unfortunately, the first code fragment has one disadvantage: a possibly predefined pen color is hardcoded and replaced by "Qt::black"!
Now to the "elementview.cpp" file.
and
pen.setWidth(settings.value(QStringLiteral("diagrameditor/grid_pointsize"), 1).toInt());
In the first case, the pen width is hardcoded to "5" and in the second case to the value from the configuration file.
p -> drawLine(QLineF(gx - 0.8, gy, gx + 0.8, gy));
p -> drawLine(QLineF(gx, gy - 0.8, gx, gy + 0.8));
and
p -> drawLine(QLineF(gx - (pen.width()/4.0), gy, gx + (pen.width()/4.0), gy));
p -> drawLine(QLineF(gx, gy - (pen.width()/4.0), gx, gy + (pen.width()/4.0)));
In the first case, the line length is defined from "-0.8" to "+0.8" and in the second case to "pen width divided by 4".
In the case of "pen width == 5" (as in pen.setWidth(5)), the result is identical.
Summary:
In one case the pen widths are hardcoded and in the second case the pen width comes from the configuration file. With the same setting for the pen width, the result on the screen is the same.
Since a few days, the grid point size for the circuit diagram editor and the element editor can even be set separately, so that you can have different values: For example "1" for the schematic editor and "5" for the element editor, as would be the case in hardcoded code.
This is how your idea with a different point size for the grid got into the source code of QElectroTech, Re-searcher!
The addition that it is configurable can only be an advantage for users.
That you don't see any graphical artifacts: Rejoice!
Depending on the pixel size of the screen, they are less noticeable!
You have a UHD monitor, don't you?
I hope that this explanation has made it clear that it is explicitly not about not implementing someone's code proposal, but about having a good solution for us and the users of QET!
Best regards
plc-user
Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !