Topic: QElectroTech Element Updater

this topic will report progress of QElectroTech Element Updater
started at the request of plc-user

De-Backer wrote:
Joshua wrote:
De-Backer wrote:

if this isn't too hard I can do this, Joshua/plc-user
this is an opportunity to learn the file format.

Of course you can, they will be very helpful in future to convert old element to new svg element.

I have started the work:
https://github.com/De-Backer/QElectroTe … nt_Updater
this will not be done in 123.

here i show the usefulness of exception
the error is an uppercase X

Add mainwindow loading

note: error at line 134 hotspot_X => hotspot_x
to demonstrate the excepts
eg debug:
_____________________________________________________________
!! exception !! 83 QElectroTech_Element_Updater/src/element/loadelement.cpp
value:  "hotspot_X"
hotspot_x:
unknown value
!! exception !! 143 QElectroTech_Element_Updater/src/gui/mainwindow.cpp
_____________________________________________________

https://github.com/De-Backer/QElectroTe … 44df993df2

more info will follow..

2 (edited by De-Backer 2021-01-01 18:02:08)

Re: QElectroTech Element Updater

update:
QElectroTech_Element_Updater found an error in the XML of an Element
https://git.tuxfamily.org/qet/qet.git/c … 707e4d7a68
bug from  2010-05-20

it uses QXmlStreamReader

QXmlStreamReader is a well-formed XML 1.0 parser that does not include external parsed entities. As long as no error occurs, the application code can thus be assured that the data provided by the stream reader satisfies the W3C's criteria for well-formed XML. For example, you can be certain that all tags are indeed nested and closed properly, that references to internal entities have been replaced with the correct replacement text, and that attributes have been normalized or added according to the internal subset of the DTD.

the program is still far from its original goal but starting to yield.

elements count : 7156
"nr of version 0.3 :" 406
"nr of version 0.4 :" 684
"nr of version 0.5 :" 2145
"nr of version 0.22 :" 1
"nr of version 0.51 :" 574
"nr of version 0.60 :" 103
"nr of version 0.61 :" 1
"nr of version 0.70 :" 1253
"nr of version 0.80 :" 1989

Re: QElectroTech Element Updater

QT had me good with my *#$%*
I tried to create and Element Class, lots of error message
now it appears that Element already exists for QT:
https://doc.qt.io/qt-5/qpainterpath-element.html
I will have to rename Element class.

But I seem to be making progress.

Load Element      => ok
Convert Element   => ToDo
Element           => rename
Safe Element      => Wip

Re: QElectroTech Element Updater

test file

<?xml version="1.0" encoding="UTF-8"?>
<definition>
    <uuid uuid="{00000000-0000-0000-0000-000000000000}"/>
    <names/>
    <kindInformations/>
    <elementInformations/>
    <informations></informations>
    <description>
        <!--line-->
        <!--rect-->
        <!--circle-->
        <!--ellipse-->
        <!--polygon-->
        <!--arc-->
        <!--dynamic_text-->
        <!--terminal-->
    </description>
</definition>

5 (edited by De-Backer 2021-01-05 00:27:09)

Re: QElectroTech Element Updater

from:

<definition width="130" hotspot_y="76" version="0.80" type="element" hotspot_x="65" height="170" link_type="master">
    <uuid uuid="{3429b359-dffd-4205-b4f5-5122286dfabc}"/>
    <names>
        <name lang="nl">test_element_norm</name>
    </names>
    <kindInformations>
        <kindInformation name="type" show="1">coil</kindInformation>
    </kindInformations>
    <elementInformations>
        <elementInformation name="manufacturer_reference" show="1"></elementInformation>
        <elementInformation name="description" show="1"></elementInformation>
        <elementInformation name="supplier" show="1"></elementInformation>
        <elementInformation name="machine_manufacturer_reference" show="1"></elementInformation>
        <elementInformation name="comment" show="1"></elementInformation>
        <elementInformation name="plant" show="1"></elementInformation>
        <elementInformation name="quantity" show="1"></elementInformation>
        <elementInformation name="unity" show="1"></elementInformation>
        <elementInformation name="manufacturer" show="1"></elementInformation>
        <elementInformation name="designation" show="1"></elementInformation>
        <elementInformation name="label" show="1">etiket</elementInformation>
    </elementInformations>
    <informations>info auteur</informations>
    <description>
        <line antialias="false" x2="30" x1="-40" style="line-style:normal;line-weight:normal;filling:none;color:black" end2="none" y1="-40" y2="-40" end1="none" length2="1.5" length1="1.5"/>
        <rect antialias="false" width="70" style="line-style:normal;line-weight:normal;filling:none;color:black" rx="0" y="-30" x="-40" height="30" ry="0"/>
        <circle antialias="false" diameter="40" style="line-style:normal;line-weight:normal;filling:none;color:black" y="-10" x="-60"/>
        <polygon y3="50" antialias="false" x2="60" x1="0" style="line-style:normal;line-weight:normal;filling:none;color:black" y6="10" x5="0" y5="10" y1="10" y2="10" y4="10" x3="60" x4="0" x6="0"/>
        <polygon y3="60" antialias="false" x2="30" x1="-25" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="50" y2="50" y4="60" closed="false" x3="60" x4="60"/>
        <text color="#000000" rotation="0" y="85" x="-45" text="T" font="Sans Serif,9,-1,5,50,0,0,0,0,0"/>
        <arc antialias="true" width="65" start="90" angle="90" style="line-style:normal;line-weight:normal;filling:none;color:black" y="75" x="-15" height="30"/>
        <dynamic_text z="8" rotation="0" Valignment="AlignTop" text_from="ElementInfo" uuid="{655686e9-d968-4a16-91a1-80252e014460}" y="-80" frame="false" x="-20" Halignment="AlignLeft" font="Sans Serif,9,-1,5,0,0,0,0,0,0,normal" text_width="-1">
            <text>etiket</text>
            <info_name>label</info_name>
        </dynamic_text>
        <terminal uuid="{9ac8e678-fd84-4a77-b3bd-3d8e1dc426fe}" orientation="n" y="-70" name="term" x="-55"/>
    </description>
</definition>

convertelement:

<?xml version="1.0" encoding="UTF-8"?>
<definition height="170" hotspot_x="65" hotspot_y="76" link_type="master" type="element" version="0.80" width="130">
    <uuid uuid="{3429b359-dffd-4205-b4f5-5122286dfabc}"/>
    <names>
        <name lang="nl">test_element_norm</name>
    </names>
    <kindInformations>
        <kindInformation name="type" show="1">coil</kindInformation>
    </kindInformations>
    <elementInformations>
        <elementInformation name="comment" show="1"></elementInformation>
        <elementInformation name="description" show="1"></elementInformation>
        <elementInformation name="designation" show="1"></elementInformation>
        <elementInformation name="label" show="1">etiket</elementInformation>
        <elementInformation name="machine_manufacturer_reference" show="1"></elementInformation>
        <elementInformation name="manufacturer" show="1"></elementInformation>
        <elementInformation name="manufacturer_reference" show="1"></elementInformation>
        <elementInformation name="plant" show="1"></elementInformation>
        <elementInformation name="quantity" show="1"></elementInformation>
        <elementInformation name="supplier" show="1"></elementInformation>
        <elementInformation name="unity" show="1"></elementInformation>
    </elementInformations>
    <informations>info auteur</informations>
    <description>
        <!--line-->
        <line antialias="false" end1="none" end2="none" length1="1.5" length2="1.5" style="line-style:normal;line-weight:normal;filling:none;color:black" x1="-40" x2="30" y1="-40" y2="-40"/>
        <!--rect-->
        <rect antialias="false" height="30" style="line-style:normal;line-weight:normal;filling:none;color:black" width="70" x="-40" y="-30"/>
        <!--circle-->
        <circle antialias="false" diameter="40" style="line-style:normal;line-weight:normal;filling:none;color:black" x="-60" y="-10"/>
        <!--ellipse-->
        <!--polygon-->
        <polygon antialias="false" closed="" style="line-style:normal;line-weight:normal;filling:none;color:black" x1="0" x2="60" x3="60" x4="0" x5="0" x6="0" y1="10" y2="10" y3="50" y4="10" y5="10" y6="10"/>
        <polygon antialias="false" closed="false" style="line-style:normal;line-weight:normal;filling:none;color:black" x1="-25" x2="30" x3="60" x4="60" y1="50" y2="50" y3="60" y4="60"/>
        <!--arc-->
        <arc angle="90" antialias="true" height="30" start="90" style="line-style:normal;line-weight:normal;filling:none;color:black" width="65" x="-15" y="75"/>
        <!--dynamic_text-->
        <dynamic_text Halignment="AlignLeft" Valignment="AlignTop" font="Sans Serif,9,-1,5,0,0,0,0,0,0,normal" frame="false" info_name="label" rotation="0" text="etiket" text_from="ElementInfo" text_width="-1" uuid="{655686e9-d968-4a16-91a1-80252e014460}" x="-20" y="-80" z="8"/>
        <!--terminal-->
        <terminal nameHidden="" number="0" orientation="n" terminalname="term" x="-55" y="-70"/>
    </description>
</definition>

ok it still contains errors, but i'm making progress.

<terminal uuid="{9ac8e678-fd84-4a77-b3bd-3d8e1dc426fe}" orientation="n" y="-70" name="term" x="-55"/>
<terminal nameHidden="" number="0" orientation="n" terminalname="term" x="-55" y="-70"/>

Re: QElectroTech Element Updater

all Attribute  are now sorted this is useful for git diff
the unnecessary Attribute have been removed
terminal uuid ok

<definition width="70" version="0.3" hotspot_x="49" hotspot_y="15" height="30" type="element" ic="true" orientation="dyyy"
link_type="previous_report">
<uuid uuid="{F549BEFB-F0CF-44ED-A948-F6F796BFB421}"/><names>
        <name lang="ru">Предыдущая страница</name>
        <name lang="ar">الصفحة السابقة</name>
        <name lang="de">Vorherige Folie</name>
        <name lang="el">Προηγούμενη σελίδα</name>
        <name lang="en">Coming arrow</name>
        <name lang="it">Foglio precedente</name>
        <name lang="fr">Folio précédent</name>
        <name lang="pl">Wejście adresowe</name>
        <name lang="es">folio anterior</name>
        <name lang="cs">Předchozí list</name>
        <name lang="nl">Referentie Vorig</name>
    </names>
    <informations>Author: The QElectroTech team
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
    <description>
        <polygon x4="-1" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-1" y2="4" x2="-1" y3="0" x3="9" y4="-4"/>
        <line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="9" y2="0" x2="12"/>
        <input x="-44" y="0" size="9" rotate="true" text="/"/>
        <terminal x="13" y="0" nameHidden="0" number="" name="" orientation="e"/>
    </description>
</definition>
<?xml version="1.0" encoding="UTF-8"?>
<!--note: this is still in the testing phase!-->
<definition height="30" hotspot_x="49" hotspot_y="15" link_type="previous_report" type="element" version="0.80" width="70">
    <uuid uuid="{f549befb-f0cf-44ed-a948-f6f796bfb421}"/>
    <names>
        <name lang="ar">الصفحة السابقة</name>
        <name lang="cs">Předchozí list</name>
        <name lang="de">Vorherige Folie</name>
        <name lang="el">Προηγούμενη σελίδα</name>
        <name lang="en">Coming arrow</name>
        <name lang="es">folio anterior</name>
        <name lang="fr">Folio précédent</name>
        <name lang="it">Foglio precedente</name>
        <name lang="nl">Referentie Vorig</name>
        <name lang="pl">Wejście adresowe</name>
        <name lang="ru">Предыдущая страница</name>
    </names>
    <kindInformations/>
    <elementInformations/>
    <informations>Author: The QElectroTech team
License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
    <description>
        <!--line-->
        <line antialias="false" end1="none" end2="none" length1="1.5" length2="1.5" style="line-style:normal;line-weight:normal;filling:none;color:black" x1="9" x2="12" y1="0" y2="0"/>
        <!--rect-->
        <!--circle-->
        <!--ellipse-->
        <!--polygon-->
        <polygon antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" x1="-1" x2="-1" x3="9" x4="-1" y1="-4" y2="4" y3="0" y4="-4"/>
        <!--arc-->
        <!--dynamic_text-->
        <!--terminal-->
        <terminal name="" orientation="e" uuid="{12456c15-b18f-441f-a087-c10e0c9bac66}" x="13" y="0"/>
    </description>
</definition>
<!--note: this is still in the testing phase!-->

some feedbacks would be appreciated
i seem to be missing the uptodate doc.

7 (edited by Joshua 2021-01-06 19:59:28)

Re: QElectroTech Element Updater

Great nomicons/smile

De-Backer wrote:

all Attribute  are now sorted

By the past the attribute was sorted in qet. It was used to check if an element was changed or not by checking the string of the xml.
But Qt changed the way how work the dom xml writer, and the attributes was never write in the same order.
So from this change, we can't check if element was changed or not even if attributes wasn't changed.
This is why we have an 'element definition' uuid. Uuid is much much better for qet (not for git diff).


When you think you've finished your work, I've some ideas to test (if you want to code it of course).

Développeur QElectroTech

8 (edited by De-Backer 2021-01-06 23:44:41)

Re: QElectroTech Element Updater

Joshua wrote:

But Qt changed the way how work the dom xml writer, and the attributes was never write in the same order.

yes i know that from librepcb.


well, i just need to write unit tests but for the rest I am far done.

Re: QElectroTech Element Updater

I am now on <input> (see Element texts item) editing to dynamic_text
but I don't seem to find the Z value in QET code
qet/sources/qetgraphicsitem/element.cpp line 851

<dynamic_text x="3" z="1"

can you give me a hint?

Re: QElectroTech Element Updater

De-Backer wrote:

I am now on <input> (see Element texts item) editing to dynamic_text
but I don't seem to find the Z value in QET code
qet/sources/qetgraphicsitem/element.cpp line 851

<dynamic_text x="3" z="1"

can you give me a hint?

is he stacking order

qreal QGraphicsItem::zValue() const
Returns the Z-value of the item. The Z-value affects the stacking order of sibling (neighboring) items.

Re: QElectroTech Element Updater

https://github.com/qelectrotech/qelectr … nt_Updater

Re: QElectroTech Element Updater

De-Backer wrote:

I am now on <input> (see Element texts item) editing to dynamic_text
but I don't seem to find the Z value in QET code

Because they doesn't exist. The Z value was added very late in QElectroTech (in the 0.7 if I remember well) and in the case of the text,
the text is a child of an element and the Qt doc say :

An item's children are stacked on top of the parent, and sibling items are stacked by insertion order (i.e., in the same order that they were either added to the scene, or added to the same parent). If you add item A, and then B, then B will be on top of A. If you then add C, the items' stacking order will be A, then B, then C.

So for the text we not need to set the Zvalue, because the text will always follow the zvalue of the parent element and it's what we need for element text.

Développeur QElectroTech

Re: QElectroTech Element Updater

remove Zvalue for dynamic_text and Others?
the element (is the parent) has the Zvalue in the project, and that (Zvalue) does not belong is the lib(element).

Another note, I am still working on it but are there any sources of information? (of the file structure)

see
https://github.com/De-Backer/QElectroTe … its/master
the tests are used,i saw a bug in the x y was an int and had to be double.
so first I made a test (which stated that x y is int and had to be double)
run test=> test stated that x y is int and must be double => ok works
then the code fixed and the test running =>ok