[ADD] Omniflo: Untermenue Weichenbatterien (OMNI_WB_*, 16 DWGs aus data/omniflo/2D), im Weichen-Katalog als WeichenTyp Weichenbatterie

[CHANGE] Omniflo-Edit: angeklicktes Bauteil im Dialog vorgewaehlt, Filterwechsel Richtung/Schaltung waehlt das Gegenstueck
This commit is contained in:
Simon Hensch committed 2026-11-04 10:52:32 +01:00
1 parent 4a5a3da88a
commit 34202cf305
23 files changed
+1088 -483

No files matched your search

+193 -31
View File
@@ -123,6 +123,66 @@
)
;; --- Aehnlichkeit zweier ProfilTyp-Texte ---
;; Anzahl gleicher Zeichen an gleicher Position minus Laengendifferenz.
;; Gegenstuecke unterscheiden sich im Katalog nur in einzelnen Zeichen
;; ("45-L-" / "45-R-", "MIT M" / "MIT P", "L1S" / "R1S"), darum bewertet das
;; ohne schemaabhaengiges Zerlegen die passende Weiche am hoechsten.
;; Kein String auf einer Seite -> 0.
(defun omni:profil-aehnlichkeit (a b / la lb n)
(if (and (= (type a) 'STR) (= (type b) 'STR))
(progn
(setq la (vl-string->list a)
lb (vl-string->list b)
n 0)
(while (and la lb)
(if (= (car la) (car lb)) (setq n (1+ n)))
(setq la (cdr la) lb (cdr lb))
)
(- n (abs (- (strlen a) (strlen b))))
)
0
)
)
;; --- Vorwahl-Index fuer ein Dialog-Dropdown ---
;; ziel = Katalog-Eintrag, der vorgewaehlt werden soll (z.B. das per
;; Doppelklick bearbeitete Bauteil oder die bisherige Auswahl)
;; liste = aktuell angezeigte Eintraege
;; Rueckgabe: Index des Eintrags mit gleicher Sivasnr, sonst des Eintrags mit
;; dem aehnlichsten ProfilTyp (Gleichstand: erster); nil ohne Ziel/Liste.
(defun omni:vorwahl-index (ziel liste / nr profil i idx best wert)
(if (and ziel liste)
(progn
(setq nr (omni:sivasid-to-str (cdr (assoc "Sivasnr" ziel)))
i 0)
(if (/= nr "")
(foreach e liste
(if (and (null idx)
(= (omni:sivasid-to-str (cdr (assoc "Sivasnr" e))) nr))
(setq idx i))
(setq i (1+ i))
)
)
(if (null idx)
(progn
(setq profil (cdr (assoc "ProfilTyp" ziel))
i 0)
(foreach e liste
(setq wert (omni:profil-aehnlichkeit profil (cdr (assoc "ProfilTyp" e))))
(if (or (null best) (> wert best))
(setq best wert idx i))
(setq i (1+ i))
)
)
)
idx
)
)
)
;; --- Einzelnen Wert aus einem Eintrag lesen ---
;; eintrag = Assoziationsliste (Rueckgabe von omni:get-bogen etc.)
;; key = Schluesselname z.B. "Radius"
@@ -331,8 +391,9 @@
;; profiltyp = optionales Praefix zum Filtern des ProfilTyp-Textes,
;; z.B. "APB 60" oder "APB 110" (nil = keine Einschraenkung)
;; Rueckgabe: (eintrag hoehe drehung) oder nil bei Abbruch
;; Vorwahl: *omni-dlg-vorwahl* (von OMNI_EDIT gesetzt) wird vorgewaehlt.
(defun omni:bogen-dialog (winkel init-hoehe init-drehung profiltyp / dcl-pfad dat boegen-liste
profil-liste ergebnis dlg-hoehe profil)
profil-liste ergebnis dlg-hoehe profil idx)
(if (null *OMNI-BOEGEN*) (omni:load-data))
;; Defaults
@@ -387,13 +448,16 @@
(start_list "bogenart")
(mapcar 'add_list profil-liste)
(end_list)
(set_tile "bogenart" "0")
;; Beim Edit (OMNI_EDIT) das bearbeitete Bauteil vorwaehlen
(setq idx (omni:vorwahl-index *omni-dlg-vorwahl* boegen-liste))
(if (null idx) (setq idx 0))
(set_tile "bogenart" (itoa idx))
;; Hoehe initialisieren (Drehung erfolgt interaktiv nach dem Einfuegen)
(set_tile "val_hoehe" init-hoehe)
;; Startwerte anzeigen
(omni:bogen-dlg-update "0")
(omni:bogen-dlg-update (itoa idx))
;; Callback bei Dropdown-Aenderung
(action_tile "bogenart" "(omni:bogen-dlg-update $value)")
@@ -522,7 +586,11 @@
;; --- Dropdown mit gefilterter Liste neu befuellen ---
(defun omni:weichen-dlg-refresh ( / filter sch-f ri-f gefiltert profil-liste)
;; Die bisher angezeigte Weiche (*omni-dlg-weiche-akt*) bleibt gewaehlt, wenn sie
;; den Filter passiert; sonst wird ihr Gegenstueck (aehnlichster ProfilTyp)
;; gewaehlt - ein Klick auf "Rechts" macht aus 45-L-400/750 MIT M also
;; 45-R-400/750 MIT M statt des ersten Listeneintrags.
(defun omni:weichen-dlg-refresh ( / filter sch-f ri-f gefiltert profil-liste idx)
(setq filter (omni:weichen-get-filter))
(setq sch-f (car filter))
(setq ri-f (cadr filter))
@@ -536,11 +604,13 @@
(mapcar 'add_list profil-liste)
(end_list)
;; Ersten Eintrag anzeigen (falls vorhanden)
;; Bisherige Weiche bzw. ihr Gegenstueck anzeigen (falls vorhanden)
(if gefiltert
(progn
(set_tile "profiltyp" "0")
(omni:weichen-dlg-update "0")
(setq idx (omni:vorwahl-index *omni-dlg-weiche-akt* gefiltert))
(if (null idx) (setq idx 0))
(set_tile "profiltyp" (itoa idx))
(omni:weichen-dlg-update (itoa idx))
)
(progn
(set_tile "val_sivasnr" "---")
@@ -553,23 +623,29 @@
;; --- Detail-Felder im Weichen-Dialog aktualisieren ---
(defun omni:weichen-dlg-update (idx-str / idx eintrag wkl)
;; Fehlende Werte (null im Katalog, z.B. Weichenbatterien ohne KurvenWinkel/
;; Breite/Laenge) werden als "---" angezeigt.
(defun omni:weichen-dlg-update (idx-str / idx eintrag wkl br lg)
(setq idx (atoi idx-str))
(setq eintrag (nth idx *OMNI-DLG-WEICHEN*))
(if eintrag
(progn
;; Merken fuer den naechsten Filterwechsel (omni:weichen-dlg-refresh)
(setq *omni-dlg-weiche-akt* eintrag)
(set_tile "val_sivasnr"
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")))
(setq wkl (omni:val eintrag "KurvenWinkel"))
(set_tile "val_winkel"
(if (= (type wkl) 'INT) (strcat (itoa wkl) " Grad")
(strcat (rtos wkl 2 1) " Grad")
(cond
((= (type wkl) 'INT) (strcat (itoa wkl) " Grad"))
((numberp wkl) (strcat (rtos wkl 2 1) " Grad"))
(T "---")
)
)
(set_tile "val_breite"
(itoa (fix (omni:val eintrag "Breite"))))
(set_tile "val_laenge"
(itoa (fix (omni:val eintrag "Länge"))))
(setq br (omni:val eintrag "Breite"))
(setq lg (omni:val eintrag "Länge"))
(set_tile "val_breite" (if (numberp br) (itoa (fix br)) "---"))
(set_tile "val_laenge" (if (numberp lg) (itoa (fix lg)) "---"))
)
)
)
@@ -580,8 +656,10 @@
;; weichentyp = "Einzelweiche", "Doppelweiche", "Dreiwegeweiche" oder nil fuer alle
;; init-hoehe / init-drehung = Vorbelegung (optional, fuer Edit-Modus)
;; Rueckgabe: (eintrag hoehe drehung) oder nil bei Abbruch
;; Vorwahl: *omni-dlg-vorwahl* (von OMNI_EDIT gesetzt) wird vorgewaehlt, die
;; Filter Schaltung/Richtung stehen dann auf dessen Werten.
(defun omni:weichen-dialog (winkel weichentyp init-hoehe init-drehung breite / dcl-pfad dat basis-liste
profil-liste ergebnis dlg-hoehe)
ergebnis dlg-hoehe sch kr)
(if (null *OMNI-WEICHEN*) (omni:load-data))
;; Defaults
@@ -630,28 +708,33 @@
(setq *OMNI-DLG-WEICHEN-BASIS* basis-liste)
(setq *OMNI-DLG-WEICHEN* basis-liste)
;; ProfilTyp-Liste fuer Dropdown aufbauen
(setq profil-liste
(mapcar '(lambda (e) (cdr (assoc "ProfilTyp" e))) basis-liste))
;; DCL laden
(setq dcl-pfad (strcat (getenv "DXFM_DCL") "/omniflo_weichen.dcl"))
(setq dat (load_dialog dcl-pfad))
(if (not (new_dialog "omniflo_weichen" dat))
(progn (alert (ssg-text "omni-weiche-dialog-ladefehler")) nil)
(progn
;; Dropdown befuellen
(start_list "profiltyp")
(mapcar 'add_list profil-liste)
(end_list)
(set_tile "profiltyp" "0")
;; Beim Edit (OMNI_EDIT, *omni-dlg-vorwahl*) die Filter auf Schaltung/
;; Richtung des Bauteils stellen; ohne Vorwahl bleibt "Alle".
(setq *omni-dlg-weiche-akt* *omni-dlg-vorwahl*)
(if *omni-dlg-vorwahl*
(progn
(setq sch (cdr (assoc "Schaltungstyp" *omni-dlg-vorwahl*)))
(setq kr (omni:sivasid-to-str (cdr (assoc "KurvenRichtung" *omni-dlg-vorwahl*))))
(cond ((= sch "M") (set_tile "sch_m" "1"))
((= sch "P") (set_tile "sch_p" "1")))
(cond ((= kr "1") (set_tile "ri_links" "1"))
((= kr "2") (set_tile "ri_rechts" "1")))
)
)
;; Dropdown befuellen und Weiche waehlen (vorgewaehltes Bauteil bzw.
;; ohne Vorwahl der erste Eintrag)
(omni:weichen-dlg-refresh)
;; Hoehe initialisieren (Drehung erfolgt interaktiv nach dem Einfuegen)
(set_tile "val_hoehe" init-hoehe)
;; Startwerte anzeigen
(omni:weichen-dlg-update "0")
;; Callback bei Dropdown-Aenderung
(action_tile "profiltyp" "(omni:weichen-dlg-update $value)")
@@ -1129,8 +1212,11 @@
)
)
;; 4. Dialog oeffnen mit vorhandenen Werten
;; 4. Dialog oeffnen mit vorhandenen Werten; das bearbeitete Bauteil wird
;; ueber *omni-dlg-vorwahl* im Dropdown vorgewaehlt (danach zuruecksetzen,
;; damit die Menuebefehle wieder ohne Vorwahl starten).
(setq dlg-result nil)
(setq *omni-dlg-vorwahl* eintrag)
(cond
((= typ "bogen")
(setq winkel (cdr (assoc "KurvenWinkel" eintrag)))
@@ -1145,6 +1231,7 @@
(setq dlg-result (omni:weichen-dialog winkel weichentyp hoehe drehung nil))
)
)
(setq *omni-dlg-vorwahl* nil)
(if (null dlg-result)
(progn (princ (ssg-text "omni-abbruch")) (ssg-end) (exit))
@@ -1249,6 +1336,77 @@
(princ)
)
;; --- Omniflo / Weichenbatterien ---
;; Fertige Weichenbatterien, DWG = ARTINR (aktuell nur in data/omniflo/2D,
;; omni:omniflo-datei-finden faellt bei 3D darauf zurueck). Menuetexte (BESCHR)
;; und Nummern aus data/omniflo/weichenbatterien_artinr_quelle.dxf. Der
;; Doppelklick (OMNI_EDIT) findet sie im Weichen-Katalog omniflo_weichen.json
;; unter WeichenTyp "Weichenbatterie" (Richtung/Schaltung umstellbar).
(defun c:OMNI_WB_834372536 ()
(omni:insert-dxf "834372536" nil nil)
(princ)
)
(defun c:OMNI_WB_834372537 ()
(omni:insert-dxf "834372537" nil nil)
(princ)
)
(defun c:OMNI_WB_834372512 ()
(omni:insert-dxf "834372512" nil nil)
(princ)
)
(defun c:OMNI_WB_834372513 ()
(omni:insert-dxf "834372513" nil nil)
(princ)
)
(defun c:OMNI_WB_834372524 ()
(omni:insert-dxf "834372524" nil nil)
(princ)
)
(defun c:OMNI_WB_834372525 ()
(omni:insert-dxf "834372525" nil nil)
(princ)
)
(defun c:OMNI_WB_834372500 ()
(omni:insert-dxf "834372500" nil nil)
(princ)
)
(defun c:OMNI_WB_834372501 ()
(omni:insert-dxf "834372501" nil nil)
(princ)
)
(defun c:OMNI_WB_834372539 ()
(omni:insert-dxf "834372539" nil nil)
(princ)
)
(defun c:OMNI_WB_834372540 ()
(omni:insert-dxf "834372540" nil nil)
(princ)
)
(defun c:OMNI_WB_834372515 ()
(omni:insert-dxf "834372515" nil nil)
(princ)
)
(defun c:OMNI_WB_834372516 ()
(omni:insert-dxf "834372516" nil nil)
(princ)
)
(defun c:OMNI_WB_834372527 ()
(omni:insert-dxf "834372527" nil nil)
(princ)
)
(defun c:OMNI_WB_834372528 ()
(omni:insert-dxf "834372528" nil nil)
(princ)
)
(defun c:OMNI_WB_834372503 ()
(omni:insert-dxf "834372503" nil nil)
(princ)
)
(defun c:OMNI_WB_834372504 ()
(omni:insert-dxf "834372504" nil nil)
(princ)
)
@@ -1335,7 +1493,8 @@
;; profiltyp = Praefix zum Filtern des ProfilTyp, z.B. "AP 110" (nil = alle)
;; init-hoehe = Vorbelegung Hoehe (nil = Default aus cfg)
;; Rueckgabe: (eintrag hoehe nil) wie omni:bogen-dialog, oder nil bei Abbruch
(defun omni:ladeschleifen-dialog (profiltyp init-hoehe / liste dat ergebnis dlg-hoehe profil)
;; Vorwahl: *omni-dlg-vorwahl* (von OMNI_EDIT gesetzt) wird vorgewaehlt.
(defun omni:ladeschleifen-dialog (profiltyp init-hoehe / liste dat ergebnis dlg-hoehe profil idx)
(if (null *OMNI-LADESCHLEIFEN*) (omni:load-ladeschleifen))
(if (null init-hoehe) (setq init-hoehe (ssg-cfg-or "omniflo" "default_hoehe" "2000")))
@@ -1367,9 +1526,12 @@
(start_list "ladeschleife")
(mapcar '(lambda (e) (add_list (omni:sivasid-to-str (omni:val e "Beschreibung")))) liste)
(end_list)
(set_tile "ladeschleife" "0")
;; Beim Edit (OMNI_EDIT) das bearbeitete Bauteil vorwaehlen
(setq idx (omni:vorwahl-index *omni-dlg-vorwahl* liste))
(if (null idx) (setq idx 0))
(set_tile "ladeschleife" (itoa idx))
(set_tile "val_hoehe" init-hoehe)
(omni:ladeschleife-dlg-update "0")
(omni:ladeschleife-dlg-update (itoa idx))
(action_tile "ladeschleife" "(omni:ladeschleife-dlg-update $value)")
(action_tile "accept"