Topic: Decimal places in element-file

Hello everyone!

What do you think about limiting the numerical values to two decimal places when saving elements with element-editor?
The background to the question.
For example, the elements contain such values (excerpt):

x1="-1.77636e-15" y5="6.91313" x5="-1.77636e-15"
dth="5.4" height="0.64596"/>
dth="5.4" height="0.64596"/>
idth="3" height="3.87576"/>
dth="3" height="3.87576"/>
idth="3.6" height="1.93788"/>

Where do these many decimal places come from?
Several possibilities:
- from a conversion tool
- copy and paste from the clipboard
- ???

I can't edit the third decimal place at the latest in the element editor itself because all input fields are limited to two decimal places.
Using mouse and keyboard, I can only move the individual graphical elements by a minimum of 0.1.
This means I can't change the values in such detail with on-board tools anyway!
How far do I have to zoom in the element editor to see the difference between “0” and “-1.77636e-15”?
So why all these decimal places?

I have included two screenshots in the appendix to show that the differences are hardly noticeable in most cases - not even with the selected (rather small) example element.

It's not like I'm just asking the question here and waiting for someone else to do the work: I've already prepared something and would like to ask your opinion on the topic, whether you think it makes sense too!

Looking forward to your comments!

Best regards
  plc-user

Post's attachments

Attachment icon Bildschirmfoto_2025-02-01_001_before.png 107.55 kb, 5 downloads since 2025-02-01 

Attachment icon Bildschirmfoto_2025-02-01_002_after.png 107.26 kb, 4 downloads since 2025-02-01 

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 !

Re: Decimal places in element-file

I would agree with limiting it to 2 decimal places. I don't see any real benefit to that level of resolution in the element placement, and it bloats the XML file. Since you can't edit any more than 2 digits inside the element editor anyway, what need is there to store it in the XML.

Re: Decimal places in element-file

I remember we limited the primitives in the element editor to two decimal places, and Xavier even wrote a script to detect them and correct them.
https://download.qelectrotech.org/qet/s … dinates.sh

But I don't remember why now?....That was more than 15 years ago....

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."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 !

4 (edited by plc-user 2025-02-04 20:12:59)

Re: Decimal places in element-file

Salut Laurent !

With the help of that shell script, all occurrences of more than x decimal places (default: 5) are searched for in all elements in the current directory.

This raises questions for me:
- Who knows this script?
- Who uses this script?
- Is it also available for win?

I have extended the call a little to only count the elements in official common collection.
With original setting of 5 or more decimals:

$ ./detect_elements_bad_coordinates.sh | awk -F ":" '{ print $1 }' | sort | uniq | wc -l
1190
$ 

search for 4 or more decimals:

$ ./detect_elements_bad_coordinates.sh | awk -F ":" '{ print $1 }' | sort | uniq | wc -l
2004
$ 

If I then know which files are affected: How do I fix them?
Should I really go through the file(s) by hand in a text editor and change the values? Or use the element editor to click on each graphical part to edit?
It would be much more practical if this were done automatically in the background by the software I use to create the graphics!

The decimal places are already limited to two in the element editor, don't we want to be consistent and write only two decimal places to the file?

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 !

Re: Decimal places in element-file

Hallo plc-user,

I know Xavier, if he wrote this script in 2011 he must also have written another bash script to make batch corrections, unfortunately on my machine I haven't been able to find this file.
Forum search can't help me, sorry.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."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 !

Re: Decimal places in element-file

Salut Laurent !

The fact that someone sits down and writes a script to recognize decimal places in order to minimize them in another script means to me that he is not satisfied with the many decimal places either.

And if I can avoid having to do additional work with one or even two external scripts, then I'll do it!
From my point of view, the element editor itself must ensure that the element file is “clean” and “tidy”.

In any case, I couldn't read any fundamental rejection from your lines, Laurent.
And all other feedback so far is also in favor of limiting the decimal places... nomicons/wink

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 !

Re: Decimal places in element-file

Hallo plc-user!

I have mixed feelings when I see the post by Luf, who wants to make maybe 10 meters XXXXL plotter drawingof the medium-voltage system at the factory where he's doing his work placement. nomicons/wink


I have a colleague who did the same on a 3 meters plan, for the 5.5KV cells and other TGBT on our industrial site since 63KV distribution.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."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 !

Re: Decimal places in element-file

Salut Laurent,

scorpio810 wrote:

I have mixed feelings when I see the post by Luf, who wants to make maybe 10 meters XXXXL plotter drawingof the medium-voltage system at the factory where he's doing his work placement.

This seems to be a special application that has appeared for the first time in more than 15 years! Until a few days ago, such a size could not be exported at all with QET! Do you remember that we have just changed the maximum size of export files from 10,000 px to larger values?
No one has asked for larger values yet, have they?

scorpio810 wrote:

I have a colleague who did the same on a 3 meters plan, for the 5.5KV cells and other TGBT on our industrial site since 63KV distribution.

Is that still your colleague? I hope so: Then please ask him what he used to create or edit the elements for his project. If I follow your reasoning: It probably couldn't have been the element editor, as it has a limit of two decimal places.

We can also ask Luf how and with which tool he creates and edits his elements.
Maybe he reads here, too?
@Luf: Do you need more than two decimal places in elements for detailed drawings of your schematics, Luf? Then what tool do you use to edit your elements?

scorpio810 wrote:

I remember we limited the primitives in the element editor to two decimal places, (...)

I've “only” been working with QET and following this forum for six or seven years now, and I can't remember any request that someone couldn't draw their elements in sufficient detail because the decimal places in the element editor are limited to two. Do you know of such requests?

At the moment I still see no good reason not to limit the decimal places...!

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 !

9 (edited by bruce33 2025-02-09 10:49:30)

Re: Decimal places in element-file

Hello,

That's an interesting discussion.
Not being involved in the source code, I'm not sure I can't give any relevant advice.
Values such as "-1.77636e-15", "0.64596", "1.93788", etc. may come from scaled elements.
Floating-point values are not always accurate and may explain these values. This result can be obtained even when values are entered to two decimal places.
If the QET file were a binary format and not an XML file, would the recording of floating-point values have led to this discussion?

Re: Decimal places in element-file

In almost all cases, these many decimal places are caused by copy-and-paste in the element editor:
Depending on which parts and in which combination the parts are copied and pasted, the element editor inserts the content of the clipboard in strange positions.
The copy-and-paste function in the source code is complex and should be adapted by someone who understands more about Qt programming.
However, we can fix this by paying attention to it when saving.

A binary format of the element file would only disguise the problem...

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 !

Re: Decimal places in element-file

We need to ask ourselves some questions before:

[1]
Is this really a problem today, and slowly QET, or element editor, I don't know?
In 2015, yes with Qt 4 and no UUID, because computing power was very limited 32 bits, one core CPU, little RAM on setup, and QET launches took a very long time, even though there were far fewer symbols in the collection.
Maybe can be affect element editor in 2015 year's.
Since the upgrade to Qt 5X, Qt has been storing XML attributes as a lottery, which means we've had to do a lot of work to make QET faster.

[2]
Copying and pasting primitives from several elements is very useful and I've used it a lot to create new symbols from scratch.

[3]
As long as the clipboard copy doesn't involve rounding off the primitives pasted, there's no point in wasting time writing a batch script to correct the collection until the source of the problem has been found and solved...

[4]
QET_element_Scaler round primitives to two decimal when scaling, mirroring or flip the element?

DXf2elmt round primitives to two decimal when converting a large DXF into an element?


=============================================

BTW, One of the priorities that I think is essential would be this:

https://qelectrotech.org/forum/viewtopic.php?id=2486

And maybe add new type and drawning contact for start delay star triangle, like LADS2..., and pre-break contact disconnector ?

https://download.qelectrotech.org/qet/forum_img_2/lad2s.jpeg

https://download.qelectrotech.org/qet/forum_img_2/LAD2S.jpg
pre-break contact disconnector
https://download.qelectrotech.org/qet/forum_img_2/legrand_contact_sectionneur.jpeg

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."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 !

Re: Decimal places in element-file

The copy-and-paste function in the source code is complex and should be adapted by someone who understands more about Qt programming.

https://github.com/qelectrotech/qelectr … w.cpp#L204
https://github.com/qelectrotech/qelectr … e.cpp#L649

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."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 !

Re: Decimal places in element-file

Salut Laurent !

to point 1:
One more reason to limit the decimal places: The smaller the element file, the faster it can be loaded!
This is not about loading x thousand elements: We are talking about saving one single element from the element editor!

Point 2:
No discussion: copy-and-paste is important and must and will be kept!

Points 3 and 4:
What I said before: I don't want to have to rely on a second tool to keep the element files tidy! Even if it were my own tool. Let the element editor do that itself!

to “BTW”:
That's a different issue! Let's tick off one topic first!

And as I already wrote in the opening post:

plc-user wrote:

It's not like I'm just asking the question here and waiting for someone else to do the work

The code is ready to upload to github and create a PR!

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 !

Re: Decimal places in element-file

Thanks for the links, Laurent!

But we should open a new topc for that!

For now only this:
I have already tried to find a few places that seemed strange to me in terms of the result.

I noticed that the “bounding rect” is used for some functions. However, the “bounding rect” of individual parts is responsible for adding decimal places!

Try it yourself: Copy a rect with integer values for the position and paste it again: The rectangle appears at an integer position.
If a text on the left or right of the same rect is copied and pasted, the position is no longer an integer! And it also depends on font-size...
See the attached example.


EDIT:
Problem with paste-position is fixed in my latest PR at github!  nomicons/cool

Post's attachments

Attachment icon copy-and-paste-sample.elmt 1.44 kb, 8 downloads since 2025-02-09 

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 !