1

Topic: Functional Cross-Reference in PDF

This feature makes cross-references in the PDF export of QElectroTech clickable, allowing users to jump directly to the corresponding locations in the circuit diagram. The feature was developed with the help of ChatGPT and has not been tested yet.
Note:
I dont know how to compile so i hope someone can do it. Feedback and testing are welcome.

2

Re: Functional Cross-Reference in PDF

Tried the code with Debian GNU/Linux stable and Qt 5.15.8

There was a Warning about deprecated calls (fixed that) and an Errror:

(...)/QET/sources/print/projectprintwindow.cpp:798: Fehler: cannot ‘dynamic_cast’ ‘item’ (of type ‘class QGraphicsItem*’) to type ‘class DiagramTextItem*’ (target is not pointer or reference to complete type)
../../sources/print/projectprintwindow.cpp: In member function ‘void ProjectPrintWindow::addPdfLinks(QPainter*, Diagram*)’:
../../sources/print/projectprintwindow.cpp:798:29: error: cannot ‘dynamic_cast’ ‘item’ (of type ‘class QGraphicsItem*’) to type ‘class DiagramTextItem*’ (target is not pointer or reference to complete type)
  798 |         if (auto textItem = dynamic_cast<DiagramTextItem *>(item)) {
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

removed the double #include "projectprintwindow.h", too.

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 !

3

Re: Functional Cross-Reference in PDF

so you already fixed the error or do i have to do that with chatgpt? Chatgpt already gave me 2 different types of solutions. if u already fixed it, was there the function given?

4

Re: Functional Cross-Reference in PDF

Laß uns zu Deutsch wechseln ... liegt uns beiden wahrscheinlich besser!  nomicons/wink

Die Warnungen habe ich behoben.
Der Fehler ist immer noch drin!

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 !

5

Re: Functional Cross-Reference in PDF

Habe auch mal die Funktion "void ProjectPrintWindow::addPdfLinks" geleert und nur eine qInfo()-Ausgabe eingefügt.

Die Funktion wird nicht aufgerufen!
Nicht beim Ausdruck in PDF und auch nicht beim PDF-Export.

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 !

6

Re: Functional Cross-Reference in PDF

Ja auf jeden Fall nomicons/grin ich wusste nicht ob es hier im Code-Bereich evtl anders gehandhabt wird.

Chatgpt hat mir 2 Lösungsvorschläge gegeben. Ich habe beide einmal eingearbeitet.

V1:
Ich sollte den Teil hinzufügen, muss allerdings evtl noch angepasst werden.
#include "diagramtextitem.h"  // Falls dies die Datei ist, in der DiagramTextItem definiert ist

V2:

Die Zeile
if (auto textItem = dynamic_cast<DiagramTextItem *>(item)) {

gegen diese
if (auto textItem = qgraphicsitem_cast<DiagramTextItem *>(item)) {

ausgetauscht.

7 (edited by Kellermorph 2025-03-11 20:06:11)

Re: Functional Cross-Reference in PDF

plc-user wrote:

Habe auch mal die Funktion "void ProjectPrintWindow::addPdfLinks" geleert und nur eine qInfo()-Ausgabe eingefügt.

Die Funktion wird nicht aufgerufen!
Nicht beim Ausdruck in PDF und auch nicht beim PDF-Export.

ok kann ich als nächstes nach gucken. Sollen wir erst gucken, ob durch die Änderungen in der vorherigen Nachricht der Fehler entfällt?

Allerdings sollte diese, wenn ich es richtig verstanden habe, wenn dann beim Ausdruck kommen, da ich in der Datei gearbeitet habe.

8

Re: Functional Cross-Reference in PDF

Die Funktion wird deshalb nicht aufgerufen, weil sie in der if (fit_page) nur im else-Zweig aufgerufen wird, aber die if-Bedingung (fit_page) erfüllt ist!

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

Re: Functional Cross-Reference in PDF

Beide Varianten können nicht funktionieren, weil:

/home/ich/Projekte/c_c++/QET/sources/print/projectprintwindow.cpp:720: Fehler: ‘class DiagramTextItem’ has no member named ‘isCrossReference’
../../sources/print/projectprintwindow.cpp: In member function ‘void ProjectPrintWindow::addPdfLinks(QPainter*, Diagram*)’:
../../sources/print/projectprintwindow.cpp:720:39: error: ‘class DiagramTextItem’ has no member named ‘isCrossReference’
  720 |                         if (textItem->isCrossReference()) {
      |                                       ^~~~~~~~~~~~~~~~


Vielleicht solltest Du doch mal versuchen, selber zu kompilieren:
Es macht nur begrenzt Spaß, für andere einen Code zu compilieren, der von einer "Intelligenz" entworfen wurde, die die Rahmenbedingungen von QET nicht zu kennen scheint!

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 !

10

Re: Functional Cross-Reference in PDF

Ok dann werde ich mich einmal schlau machen, wie ich das selbst kompilieren kann und ich werde versuchen die Funktion zu testen.

11

Re: Functional Cross-Reference in PDF

Bevor Du Dir an den XRef-Texten einen Wolf suchst...

Schau' Dir mal eine qet-Datei im Texteditor an:
Die Verlinkungen hängen nicht am Text, sondern an separaten Tags "link_uuid" der Referenz der Referenz-Elemente.

Einen Ausschnitt gibt's im Anhang.

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 !

12 (edited by plc-user 2025-03-12 15:47:39)

Re: Functional Cross-Reference in PDF

Auch, wenn Du den Text als Link markierst und den Text als Ziel-Adresse definieren kannst:
Das Ziel muss auch wissen, daß es Ziel ist, soweit ich PDFs richtig verstanden habe!

Bei HTML und LaTeX ist es jedenfalls auch so, daß es eine Stelle gibt, die den Link enthält und ein Sprungziel, wohin verlinkt ist.


Ergänzung:
Wenn ein Verweis auf eine andere Seite im Schaltplan geht, was meist die Regel ist, müsste das Dokument also (mindestens) zweimal komplett durch alle Seiten durchgegangen werden, um alle Verweise und Sprung-Ziele einzufügen.
Wie ich das sehe, ist diese Stelle beim Ausdruck im Ablauf zu spät, weil hier jede Seite nur einmal verarbeitet wird.
Es müßte also eine Vorverarbeitung mit zwei Durchgängen eingefügt werden, wenn PDF als Ausgabe gewählt wurde.

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 !

13

Re: Functional Cross-Reference in PDF

Ok schon mal danke für die Hilfe. Aber als aller erstes muss ich mich erst noch mit dem kompilieren auseinander setzen und wie das alles geht. bis jetzt klappt es noch nicht so ganz. Ich werde mich die Tage, wenn ich Zeit haben sollte nochmal dran wagen.

14

Re: Functional Cross-Reference in PDF

Kellermorph wrote:

Ok schon mal danke für die Hilfe. Aber als aller erstes muss ich mich erst noch mit dem kompilieren auseinander setzen und wie das alles geht. bis jetzt klappt es noch nicht so ganz. Ich werde mich die Tage, wenn ich Zeit haben sollte nochmal dran wagen.

Hallo Kellermorph!

Try elevatormind's Qt6-cmake branch, no need KF5/KF6 libs, so it is more easy for you for compil it, you just need Qt6 libs, and you don't need sqlite3.dev for this test.
SQlite3.dev dependency it's only for exporting project databse to an sqlite file.

BTW don't use qmake but Cmake! because elevatormind forgot to update .pro in Qt6-cmake branch!

BTW,if you want to use qmake use this patch to disable sqlite3 dependency in qelectrotech.pro to generate makefiles, if you have porblems for install Sqlite3.dependency, it's only optionnal....
And off  course add new path for news: *.cpp,*.h ; *.ui files which was added recently by elevatormind in this source code branch.

--- qelectrotech.pro
+++ qelectrotech.pro
@@ -61,7 +61,7 @@ DEFINES += QET_ALLOW_OVERRIDE_CD_OPTION
DEFINES += QET_ALLOW_OVERRIDE_DD_OPTION
 
#comment the line below to disable the project database export
-DEFINES += QET_EXPORT_PROJECT_DB
+#DEFINES += QET_EXPORT_PROJECT_DB
 
# warn on *any* usage of deprecated APIs
#DEFINES += QT_DEPRECATED_WARNINGS
@@ -257,7 +257,7 @@ TARGET = qelectrotech
 
# Ajustement des bibliotheques utilisees lors de l'edition des liens
unix:QMAKE_LIBS_THREAD -= -lpthread
-unix|win32: PKGCONFIG += sqlite3
+#unix|win32: PKGCONFIG += sqlite3
 
# Enable C++17
QMAKE_CXXFLAGS += -std=c++17

Well, on that note, I'm going back to bed, my health is very fragile at the moment, and I need to rest!
Don't be surprised if you see me less these days!
I also have to undergo a many numbers of health checkups....

PS : Search "showme" functions in the source code and you'll understand better how interactivity works in QET when you click on the report folios, master and slave links, etc...

Best regards,
Laurent

"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 !

15

Re: Functional Cross-Reference in PDF

All the best for your health, Laurent!

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 !

16 (edited by Kellermorph 2025-03-14 23:01:31)

Re: Functional Cross-Reference in PDF

Hi Laurent auch von mir gute besserung.

Das komplette kompelieren war mir für den jetzigen Zeitpunkt noch zu kompliziert / aufwendig mich da rein zu fuchsen. Mit 2 kleinen Kindern und Kleingewerbe gründen hat man leider nicht so viel zeit zur Verfügung.
Deshalb habe ich mich darauf konzentriert eine Übergangslösung zu schaffen. Ich hoffe die kann auch jemand anderem behilflich sein.
Ich habe ein Appimage erstellt.
Das Programm sucht die Querverweise in der PDF ab und verlinkt dort dann die Seite, die er findet. Beispiel bei 22.7 verlinkt das Programm auf S. 22. Das Manko hierbei ist, dass man jetzt keine Sprünge in dem Schaltplan haben darf. Man kann oben den Querverweistyp auswählen. Bei Seite.Spalte nutzt man X.X und bei Seite.Zeile.Spalte nutzt man X.X.X. Allerdings habe ich nur X.X getestet, da meine Querverweise so aussehen. Ich hoffe das Programm kann für einige Leute nützlich sein, da im Forum bereits des öfteren die Frage nach Querverweise in der PDF kam.
Ich habe im Anhang das Appimage + den Quellcode in einer .zip.

Translate:
Hi Laurent, get well soon from me too.

The complete compiling was still too complicated / time-consuming for me to get to grips with at the moment. Unfortunately, with 2 small children and starting a small business, you don't have that much time available.
That's why I concentrated on creating a temporary solution. I hope this can also be helpful to someone else.
I created an app image.
The program searches the cross-references in the PDF and then links to the page it finds. For example, at 22.7 the program links to p. 22. The drawback here is that you can't have any jumps in the circuit diagram. You can select the cross-reference type at the top. For page.column use X.X and for page.row.column use X.X.X. However, I have only tested X.X, as my cross-references look like this. I hope the program can be useful for some people, as the question about cross-references in the PDF has often been asked in the forum.
I have attached the app image + the source code in a .zip.

Translated with DeepL.com (free version)

17

Re: Functional Cross-Reference in PDF

Verdammt die Datei ist zu groß zum Uploaden. Sie ist 70mb groß. Habt ihr eine Alternative, wie ich euch die zukommen lassen kann?

Translate:
Damn the file is too big to upload. It is 70mb in size. Do you have an alternative how I can send it to you?

18

Re: Functional Cross-Reference in PDF

Im günstigsten Fall hast Du einen github-Account, auf dem Du Sourcecode und Releases veröffentlichst.
Dann kann sich jeder den Quellcode anschauen, weiter verbessern, PullRequests erstellen, etc. pp.

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 !

19

Re: Functional Cross-Reference in PDF

Einen Github Account zu machen ist kein Problem, auch wenn ich keine Ahnung habe, was eine PullRequests ist. Wie ist das mit den Abhänigkeiten? Ich habe extra ein Appimage gewählt, damit alle Abhänigkeiten direkt vorhanden sind. Für die Leute, die sich dort rum treiben, sollte es aber kein Problem sein die passenden Abhänigkeiten zu laden oder?

20

Re: Functional Cross-Reference in PDF

Git ist eine Versions-Verwaltung für Quellcode und github ist ein Onlinedienst zur gemeinschaftlichen Versionsverwaltung für Softwareprojekte.
Quelle: Wikipedia

Dort stellst Du primär den Quellcode nebst einer Beschreibung Deiner Anwendung zur Verfügung.

Wenn es Abhängigkeiten gibt, müssen die natürlich irgendwie ersichtlich sein: "RTFM" geht nur, wenn es auch "FM" gibt!

Dort können auch Releases veröffentlicht werden, die als Binärpakete (in Deinem Fall ein AppImage) verfügbar sind.

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 !

21

Re: Functional Cross-Reference in PDF

@Kellermorph I just made a little hack and change "increase g_pun_attachment_upload_max_size" key to max 200MB instead of 20MB, you could share it here if you want. nomicons/wink

Off course think to compress your file before upload it here!

"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 !

22 (edited by Kellermorph 2025-03-15 09:51:48)

Re: Functional Cross-Reference in PDF

Thanks Laurent.
That is much easyer for me. i upload it here.
If you or PLC-User still want a Github upload i will do it but it has to wait till next week.

Edit:
Theres still this Message:
Warning! The following errors must be corrected before your message can be posted:
The selected file was too large to upload. The server didn't allow the upload.

The File is .zip

23

Re: Functional Cross-Reference in PDF

Lade doch erstmal nur den Quellcode inklusive einer kurzen Beschreibung in einem Post hoch.
Damit können wir doch schon mal anfangen...

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 !

24

Re: Functional Cross-Reference in PDF

Erforderliche Python-Pakete:

PyMuPDF (wird über fitz importiert) → Verarbeitung von PDF-Dateien
tkinter → Grafische Benutzeroberfläche (GUI)
re → Reguläre Ausdrücke für die Querverweis-Suche
os → Dateiverwaltung und Pfade
sys → Zugriff auf Systemvariablen

Reicht das erstmal oder braucht ihr noch mehr Infos?

25

Re: Functional Cross-Reference in PDF

@Kellermorph: Please retry I forgot to Refresh hooks in attachments plugin....I'm tired!!!

"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 !