Re: QET-Element to SVG

Just for the record:

diff --git a/toSVG.sh b/toSVG.sh
index 98101ca..976a899 100755
--- a/toSVG.sh
+++ b/toSVG.sh
@@ -3,9 +3,9 @@
# scales QET - Element-files in the directory from where it was called and
# all sub-dirs by the factor given here:
 
-Skalierung="1.0"
-SkalierProg="/home/ich/Projekte/c_c++/QET_ElementScaler/QET_ElementScaler"
-
+Skalierung="5.0"
+#SkalierProg="/home/ich/Projekte/c_c++/QET_ElementScaler/QET_ElementScaler"
+SkalierProg="/home/laurent/Qet_scripts/qelectrotech-elements/QET_ElementScaler"
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
@@ -16,7 +16,7 @@ for i in  `find . -name "*.elmt"` ; do
   echo "processing $i"
   # With the construct in curly brackets the file extension
   # is changed accordingly
-  "$SkalierProg" --toSVG -o "$i" > "${i%.elmt}.svg"
+  "$SkalierProg" --toSVG -o -F "$Skalierung" "$i" > "${i%.elmt}.svg"
   done
 
# blanks in filenames - back to original:
rsync -e ssh -av -W --delete-after --no-owner --no-g --chmod=g+w --progress  --exclude=''.*/ /home/laurent/Qet_scripts/qelectrotech-elements/qelectrotech-elements/  server:download.qelectrotech.org/qet/elements/
rsync -e ssh -av -W --delete-after --no-owner --no-g --chmod=g+w --progress --exclude='.*/'  /home/laurent/Qet_scripts/qelectrotech-element-contrib/qelectrotech-element-contrib/elements/   server:download.qelectrotech.org/qet/elements_contrib/

@plc-user: https://github.com/plc-user/QET_ElementScaler/pull/2

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Given a directory structure with QET elements and the SVG images derived from them.
Here is a script that goes through this directory structure and links all subdirectories and SVG files.
The links of the SVG files point to the corresponding QET element.

#!/bin/bash

# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

BaseDir="elemente"

for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo "<html><body>" > $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\">${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html
  done
  # html-Footer:
  echo "</body></html>" >> $d/index.html
  echo ""
done

# blanks in filenames - back to original:
IFS=$OFS
# DONE!

@Laurent:
In the context of writing the script, I noticed, that a scaling-factor of 5.0 will be in many cases too much!
But I will implement your idea of including the scaling-factor to the script on github!

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: QET-Element to SVG

@plc-user:

good work, thanks plc-user. nomicons/wink
Preview on remote, example:
https://download.qelectrotech.org/qet/e … index.html

ps: I changed scale factor to 2.0 instead of 5.0.

Post's attachments

Attachment icon PHP5online -svg_converter.zip 34.48 kb, 75 downloads since 2023-12-26 

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Benchmark scripts on my Debian workstation
8340 elements dans 1110 categories (soit 9450 fichiers)

Clean my local git repository:

cd qelectrotech-elements/
git clean -d -x -f
cd ..

Convert *.elmt to *.SVG:

time ./toSVG.sh

real    0m55,232s

Add index.html pages in all directory:

time ./toHTMLsh

real    0m47,843s

Ssh sync to remote:

time rsync -e ssh -av -W --delete-after --no-owner --no-g --chmod=g+w --progress  --exclude='.*/' /home/laurent/Qet_scripts/qelectrotech-elements/qelectrotech-elements/  server:download.qelectrotech.org/qet/elements/

real    0m30,741s

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Added the back button to the parent directory, to make navigation easier.


<a href="../index.html">Parent Directory </a><br>
#!/bin/bash
 
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

 
BaseDir="qelectrotech-elements"
 
for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo "<html><body>" > $d/index.html
  echo "<a href="../index.html">Parent Directory </a><br>"  > $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\">${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html
  done
  # html-Footer:
  echo "</body></html>" >> $d/index.html
  echo ""
done
 
# blanks in filenames - back to original:
IFS=$OFS
# DONE!

Edit: changed to

echo "<li><a href="../index.html">Parent Directory </a></li>"  > $d/index.html

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Added automatic download element file when you click on *.elmt link text.

- echo "<a href=\"$elmtdatei\">${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html
+echo "<a href=\"$elmtdatei\" download>${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br>" >> $d/index.html

Added return to history back button:

echo '<li><a href="../index.html">Parent Directory </a></li><br><br><li><button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--cta svelte-1gv5n3y cd17fc8d794774a44aa5bbe652ad93894-dom" onclick="history.back()">Back return</button></li><br>'  > $d/index.html

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

82 (edited by plc-user 2023-12-31 13:40:53)

Re: QET-Element to SVG

So macht OpenSource Spaß: Jeder gibt einen Teil seines Wissens / seiner Erfahrung dazu!

-----

This is how OpenSource is fun: Everyone contributes a part of their knowledge / experience!

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: QET-Element to SVG

Just for record:

#!/bin/bash
 
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

 
BaseDir="qelectrotech-elements"
 
for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo "<html><body>" > $d/index.html
  echo '<li><a href="../index.html">&larr;  Parent Directory </a></li><br><li><button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--cta svelte-1gv5n3y cd17fc8d794774a44aa5bbe652ad93894-dom" onclick="history.back()">Back return</button></li>'  >> $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\" download>${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br><br>" >> $d/index.html
  done
  # html-Footer:
  echo "<li><a href="../index.html">&larr;  Parent Directory </a></li><br><a href="#" class="btn btn-default">Back to top ↑</a>" >> $d/index.html
  echo "</body></html>" >> $d/index.html
  echo ""
done
 
# blanks in filenames - back to original:
IFS=$OFS
# DONE!

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Add a Scroll Back To Top Button.

#!/bin/bash
 
# to be able to process blanks in file names - remember original state:
OFS=$IFS
# set new:
IFS="
"

 
BaseDir="qelectrotech-elements"
 
for d in `find $BaseDir -type d | sort`; do
  echo "processing directory $d"
  # html-Header:
  echo '<!doctype html>
  <html>
<head>
<link href="/qet/to-top.css" rel='
stylesheet' type='text/css'>' > $d/index.html
  echo '<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>'  >> $d/index.html
  echo '<script src="/qet/to-top.js"></script>'  >> $d/index.html
  echo '<li><a href="../index.html">&larr;  Parent Directory </a></li><br><li><button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--cta svelte-1gv5n3y cd17fc8d794774a44aa5bbe652ad93894-dom" onclick="history.back()">Back return</button></li>'  >> $d/index.html
  # Unterverzeichnisse auflisten:
  for sd in `find $d -maxdepth 1 -type d | sort`; do
    if [[ "$d" == "$sd" ]] ; then
      continue
    fi
    echo "sub-dir: $sd"
    echo "<a href=\"`basename $sd`/index.html\">`basename $sd`</a><br>" >> $d/index.html
  done
  # SVG-Dateien auflisten:
  for f in  `find $d -maxdepth 1 -name "*.svg" | sort` ; do
    echo "file: `basename $f`"
    svgdatei=`basename $f`
    elmtdatei="${svgdatei%.svg}.elmt"
    echo "<a href=\"$elmtdatei\" download>${svgdatei%.svg}<br> <img src=\"$svgdatei\" /></a><br><br>" >> $d/index.html
  done
  # html-Footer:
  #echo "<li><a href="../index.html">&larr;  Parent Directory </a></li><br><a href="#" class="btn btn-default">Back to top ↑</a>" >> $d/index.html
  echo '<div id="scrollUp">
<a href="#top"><img src="/qet/to_top.png"/></a>
</div></body></html>'
>> $d/index.html
  echo ""
done
 
# blanks in filenames - back to original:
IFS=$OFS
# DONE!

If you have a website that has large pages, it may be useful to display a button to return to the top of the page.
It is a good idea to place the button at the bottom right.
The goal is that it is displayed once 200 pixels of page go down.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Hello everybody!

In this post https://qelectrotech.org/forum/viewtopi … 380#p19380 I asked the forum participants to try out the elements they use most often and give feedback on whether they are OK.
After eight weeks of waiting, I am a little surprised:
There was no feedback on the elements!

That can mean two things:
No one has checked them or there is nothing wrong with them.

In German, we have a saying:
To say nothing is to agree!

So I'll just say that the elements that I automatically updated to the current version are fine! Nevertheless, I will not release the pull-request myself:
The "four-eyes principle" should still be applied in my opinion.

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 !

Re: QET-Element to SVG

This is getting more and more interesting: Another ~500 views on this topic and still no feedback that one or the other element doesn't work.
It's not that I'm looking for special thanks or fishing for compliments: I asked for "proofreaders".
You didn't want it any other way: I will "release" the pull request with the changed elements after all.

As said before: To say nothing is to agree!

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 !

Re: QET-Element to SVG

Hallo plc-user,

do we need to add your patch?
https://qelectrotech.org/forum/viewtopi … 396#p19396


Best regards,
Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Salut Laurent!

In my opinion it's not a "must have", if we think about users who only need the official collection.
When we think about QET's long-standing users, that have elements created with earlier versions of QET with "input"-Elements inside, we should apply the patch.

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 !

Re: QET-Element to SVG

Hallo plc-user

I don't know what to make of it because just below it there's this:
#if TODO_LIST
#pragma message("@TODO remove in futur")
#endif
        //Keep compatibility TODO remove in futur
        setFont(QETApp::dynamicTextsItemFont(9));
    }

I'm going to wait for Joshua's opinion on this, I've just gone back to work part-time,
and my brain isn't in the code at the moment...  sorry.

Best regards,
Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

90 (edited by plc-user 2024-03-11 21:08:51)

Re: QET-Element to SVG

Salut Laurent,

as far as I understand this code fragment, this is the workaround for the font size of the old "input"-elements. I think that this code-fragment has become obsolete with my inserted part.
In my local QET version with which I opened and saved the ~4500 elements, this part of code was also active. It didn't do any harm!
But Joshua will know exactly!

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 !

Re: QET-Element to SVG

I also have viewed this topic multiple times
now I think I have found a use case for SVG export.

I only have one remark regarding the current export (or is it word) when I paste an SVG exported page WORD always shows the whole page.

I only need the part with the schematic and not the whole page.
Is this something that can be easily adapted?

Post's attachments

Schermafbeelding 2024-03-12 081456.png, 6.21 kb, 521 x 353
Schermafbeelding 2024-03-12 081456.png 6.21 kb, 45 downloads since 2024-03-12 

Always using the latest development version

92 (edited by plc-user 2024-03-12 22:04:01)

Re: QET-Element to SVG

Hello Lieven,

I guess you mix two different topics:
This thread is about a commandline-tool to convert QET-Elements to SVG.
The screenshot you sent is about export of QET-Schematics.
These are different topics. You should open a new thread in the English Forum...

But to answer your question:
M$-Office would not be my first choice when it comes to dealing with SVG-Graphics!
In my opinion it would be the last choice: only if nothing useful is available, but that's another point...  nomicons/wink

You are right:
When I export a QET-Schematic to SVG there is much free space right and below of the schematic!
It seems that the picture-size in the SVG-file isn't set correctly. Export to PNG shows the correct view!
So if you want to use the export in a word-processor then maybe PNG-export would be better...
Or you edit the SVG with Inkscape before importing to office: Here you can set the document-size to the contents
(Menu -> Document-Settings -> Button... see attachment)

EDIT:
From whatever reason the width and height of the SVG is calculated too big!
I tried some different folio-sizes and exported them to SVG: It seems to be a constant factor of 16/9 = 1.7777777

With this patch all exported SVGs had the correct width and height:

diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp
index a50c5147e..6588ecbc3 100644
--- a/sources/exportdialog.cpp
+++ b/sources/exportdialog.cpp
@@ -411,7 +411,7 @@ void ExportDialog::generateSvg(
        
        // "joue" la QPicture sur un QSvgGenerator
        QSvgGenerator svg_engine;
-       svg_engine.setSize(QSize(width, height));
+       svg_engine.setSize(QSize((width*9/16), (height*9/16)));
        svg_engine.setOutputDevice(&io_device);
        QPainter svg_painter(&svg_engine);
        picture.play(&svg_painter);

@Laurent and/or @Joshua:
Maybe one of you can check?

In the attachment you find a package with two SVGs:
one exported from original QET-Version and the other exported from my local QET-version with 9-16-patch

Best regards
  plc-user

Post's attachments

Bildschirmfoto_Inkscape_Document-Settings.jpg, 69.24 kb, 1192 x 589
Bildschirmfoto_Inkscape_Document-Settings.jpg 69.24 kb, 48 downloads since 2024-03-12 

Attachment icon SVG-export.tar.gz 9.53 kb, 53 downloads since 2024-03-12 

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: QET-Element to SVG

Hallo plc-user,

I think that we can publish it, please make a pull request for your two patchs.

Best regards,
Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

Salut Laurent!

Done!  nomicons/smile

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: QET-Element to SVG

However, I've noticed that the right and bottom borders are sometimes missing, depending on the software you use to open the SVG file,

Inkscape ok
Genview no
KolourPaint no

That 's strange...

Thanks plc-user. nomicons/wink

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: QET-Element to SVG

It seems that Pixel-Graphic-Software doesn't show the SVG right.
Gwenview and KolourPaint are originally made for Pixel-Graphics?

LibreOffice Draw and Firefox show the SVGs correctly!

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: QET-Element to SVG

Everything has been packaged, enjoy! nomicons/wink

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."