diff --git a/Lisp/SSG_LIB_Commands.lsp b/Lisp/SSG_LIB_Commands.lsp index 6b4d055..88caccd 100644 --- a/Lisp/SSG_LIB_Commands.lsp +++ b/Lisp/SSG_LIB_Commands.lsp @@ -340,6 +340,24 @@ (c:VARIOFOERDERER_EDIT) ) + ;; TRO-Marker (TRO_SYM_) -> TRO_EDIT (DCL-Dialog) + ;; Die Marker kommen aus sps_skel (lib/tro_annotate.py) und tragen die + ;; Attribute ID und TYPE. Modul bei Bedarf nachladen, damit der Doppelklick + ;; auch ohne vorherigen Menueaufruf funktioniert. + ((wcmatch bname "TRO_*") + (princ (ssg-textf "cmd-tro-bearbeiten" (list bname))) + (if (and (null *ssg-Tro_Edit-loaded*) (atoms-family 1 '("SSG-ENSURE"))) + (ssg-ensure "Tro_Edit") + ) + (if (atoms-family 1 '("C:TRO_EDIT")) + (c:TRO_EDIT) + (progn + (princ (ssg-textf "tro-edit-modul-fehlt" (list "Tro_Edit.lsp"))) + (command "_.EATTEDIT") + ) + ) + ) + ;; Omniflo-Bloecke -> OMNI_EDIT ;; Erkennung: TEILEART-Attribut vorhanden, AP110-Blockname oder rein numerisch ((progn diff --git a/Lisp/Tro_Edit.lsp b/Lisp/Tro_Edit.lsp new file mode 100644 index 0000000..5176e21 --- /dev/null +++ b/Lisp/Tro_Edit.lsp @@ -0,0 +1,193 @@ +;; ============================================================ +;; TRO_EDIT.LSP - TRO-Marker bearbeiten +;; +;; Bearbeitet die Attribute ID und TYPE eines TRO_*-Blocks. Die Marker +;; werden von sps_skel (lib/tro_annotate.py) in eine Kopie der Zeichnung +;; eingefuegt; ein Marker ist ein Block TRO_SYM_ mit den Attributen +;; ID, TYPE sichtbar +;; FB_BLOCK sichtbar (nur wenn mit --fb beschriftet) +;; ITEMS, CONFIDENCE, SEPARATORS unsichtbar, reine Daten +;; +;; Aufruf: +;; - Doppelklick auf den Marker -> ***DOUBLECLICK [INSERT] -> SSG_BLOCKEDIT +;; - EATTEDIT -> c:EATTEDIT -> SSG_BLOCKEDIT +;; - Menue SSG_LIB > TRO > Marker bearbeiten +;; - direkt: TRO_EDIT +;; Der Dispatcher SSG_BLOCKEDIT (SSG_LIB_Commands.lsp) leitet Blocknamen +;; "TRO_*" hierher. +;; +;; Die Auswahlliste der Typen kommt aus tro_types.lsp, die sps_skel mit +;; lib/tro_annotate.py --emit-lisp +;; nach DXFM_LISP schreibt. Fehlt die Datei, bleibt nur der aktuelle Typ des +;; Blocks in der Liste - der Dialog laeuft also weiter. +;; +;; Grenze: geaendert werden nur die Attribute. Die *Form* des Markers gehoert +;; zur Blockdefinition des Typs und FB_BLOCK ist aus dem Typ abgeleitet - +;; beides passt erst nach einem neuen Lauf von tro_annotate.py wieder. +;; +;; Setzt ssg_core.lsp (ssg-start/ssg-end, ssg-attrib-*) und ssg_lang.lsp voraus. +;; ============================================================ + +(setq *tro-block-prefix* "TRO_SYM_") + + +;; ------------------------------------------------------------ +;; Gueltige TRO-Typen laden (aus tro_types.lsp, erzeugt aus dem Katalog) +;; ------------------------------------------------------------ +(defun tro-typen-laden ( / datei) + (if (null *TRO-TYPES*) + (progn + (setq datei + (cond + ((and (boundp '*ssg-lisp-pfad*) *ssg-lisp-pfad* + (findfile (strcat *ssg-lisp-pfad* "/tro_types.lsp"))) + (strcat *ssg-lisp-pfad* "/tro_types.lsp")) + ((getenv "DXFM_LISP") + (findfile (strcat (vl-string-translate "\\" "/" (getenv "DXFM_LISP")) + "/tro_types.lsp"))) + (t (findfile "tro_types.lsp")) + ) + ) + (if datei (load datei)) + ) + ) + *TRO-TYPES* +) + + +;; ------------------------------------------------------------ +;; Position eines Elements in einer Liste (nil wenn nicht enthalten) +;; ------------------------------------------------------------ +(defun tro-index (item lst / i pos) + (setq i 0 pos nil) + (foreach x lst + (if (and (null pos) (= (strcase x) (strcase item))) (setq pos i)) + (setq i (1+ i)) + ) + pos +) + + +;; ------------------------------------------------------------ +;; Auswahlliste aufbauen: Katalogtypen, der aktuelle Typ immer enthalten +;; ------------------------------------------------------------ +(defun tro-typliste (aktueller / liste) + (setq liste (tro-typen-laden)) + (if (and aktueller (/= aktueller "") (null (tro-index aktueller liste))) + (setq liste (append liste (list aktueller))) + ) + (if liste liste (list (if aktueller aktueller ""))) +) + + +;; ------------------------------------------------------------ +;; C:TRO_EDIT - Dialog fuer einen TRO-Marker +;; ------------------------------------------------------------ +(defun c:TRO_EDIT ( / ss ent ed bname attribs + alt-id alt-type alt-fb + neu-id neu-type + liste idx dcl-pfad dat ergebnis) + + ;; Implied Selection VOR ssg-start pruefen (ssg-start hebt Selektion auf) + (setq ss (ssget "I")) + (if (and ss (= (sslength ss) 1) + (= (cdr (assoc 0 (entget (ssname ss 0)))) "INSERT")) + (setq ent (ssname ss 0)) + ) + + (ssg-start "TRO_EDIT" nil) + + ;; Marker auswaehlen (falls nicht vorselektiert) + (if (null ent) + (progn + (princ (ssg-text "cmd-block-auswaehlen")) + (setq ss (ssget ":S" '((0 . "INSERT")))) + (if ss (setq ent (ssname ss 0))) + ) + ) + (if (null ent) + (progn (princ (ssg-text "cmd-kein-block-ausgewaehlt")) (ssg-end) (exit)) + ) + + (setq ed (entget ent) + bname (cdr (assoc 2 ed))) + (if (not (wcmatch bname "TRO_*")) + (progn + (alert (ssg-textf "tro-edit-kein-tro" (list bname))) + (ssg-end) + (exit) + ) + ) + + ;; --- aktuelle Attribute lesen ---------------------------------------- + (setq attribs (ssg-attrib-read ent) + alt-id (cdr (assoc "ID" attribs)) + alt-type (cdr (assoc "TYPE" attribs)) + alt-fb (cdr (assoc "FB_BLOCK" attribs))) + + (if (null alt-id) + (progn + (alert (ssg-textf "tro-edit-kein-id-attribut" (list bname))) + (ssg-end) + (exit) + ) + ) + (if (null alt-type) (setq alt-type "")) + + ;; --- Dialog ----------------------------------------------------------- + (setq dcl-pfad (strcat (getenv "DXFM_DCL") "/tro_edit.dcl")) + (setq dat (load_dialog dcl-pfad)) + (if (not (new_dialog "tro_edit" dat)) + (progn + (alert (ssg-textf "tro-edit-dialog-fehlt" (list dcl-pfad))) + (ssg-end) + (exit) + ) + ) + + (setq liste (tro-typliste alt-type) + idx (tro-index alt-type liste)) + + (set_tile "blockname" (ssg-textf "tro-edit-block" (list bname))) + (set_tile "fb" (ssg-textf "tro-edit-fb" (list (if alt-fb alt-fb "-")))) + (set_tile "hinweis" (ssg-text "tro-edit-hinweis")) + (set_tile "id" alt-id) + (start_list "type") + (foreach typ liste (add_list typ)) + (end_list) + (set_tile "type" (itoa (if idx idx 0))) + + (setq neu-id alt-id neu-type alt-type) + (action_tile "id" "(setq neu-id (get_tile \"id\"))") + (action_tile "type" "(setq neu-type (nth (atoi (get_tile \"type\")) liste))") + (action_tile "accept" + (strcat "(setq neu-id (get_tile \"id\")" + " neu-type (nth (atoi (get_tile \"type\")) liste))" + "(done_dialog 1)")) + (action_tile "cancel" "(done_dialog 0)") + + (setq ergebnis (start_dialog)) + (unload_dialog dat) + + ;; --- zurueckschreiben ------------------------------------------------- + (if (= ergebnis 1) + (if (= (vl-string-trim " " neu-id) "") + (alert (ssg-text "tro-edit-id-leer")) + (progn + (ssg-attrib-set-on ent (list (cons "ID" neu-id) (cons "TYPE" neu-type))) + (entupd ent) + (princ (ssg-textf "tro-edit-gespeichert" (list neu-id neu-type))) + (if (/= neu-type alt-type) + (princ (ssg-text "tro-edit-typ-geaendert")) + ) + ) + ) + ) + + (ssg-end) + (princ) +) + + +(prompt "\nTro_Edit.lsp geladen - Befehl: TRO_EDIT") +(princ) diff --git a/Lisp/ssg_load.lsp b/Lisp/ssg_load.lsp index 08639c3..e268f2b 100644 --- a/Lisp/ssg_load.lsp +++ b/Lisp/ssg_load.lsp @@ -34,6 +34,7 @@ (load (strcat base-path "export.lsp") "export.lsp nicht gefunden") (load (strcat base-path "tests.lsp") "tests.lsp nicht gefunden") (load (strcat base-path "OmniModulInsert.lsp") "OmniModulInsert.lsp nicht gefunden") + (load (strcat base-path "Tro_Edit.lsp") "Tro_Edit.lsp nicht gefunden") (load (strcat base-path "SSG_LIB_Commands.lsp") "SSG_LIB_Commands.lsp nicht gefunden") (prompt "\nSSG-Bibliotheken geladen: ssg_core, ssg_lang, ssg_dbg, ssg_dialog, ssg_layer, KreiselInsert, VarioFoerderer, Gefaellestrecke, export, tests, OmniModulInsert, SSG_LIB_Commands") (princ) diff --git a/Lisp/tro_types.lsp b/Lisp/tro_types.lsp new file mode 100644 index 0000000..e6c7142 --- /dev/null +++ b/Lisp/tro_types.lsp @@ -0,0 +1,4 @@ +;; Automatisch erzeugt von lib/tro_annotate.py --emit-lisp +;; Quelle: TRO_CATALOG in lib/tro_catalog.py - nicht manuell aendern. +(setq *TRO-TYPES* (list "1Sep" "1Sep1Swi" "1Sep2Swi" "1Sep_SSCC" "Vario" "PinStore_Auto" "Vario_workStation" "EmptyCarrBuffer" "LoadingBoom" "2Sep1Swi")) +(princ) diff --git a/dcl/tro_edit.dcl b/dcl/tro_edit.dcl new file mode 100644 index 0000000..6e318bc --- /dev/null +++ b/dcl/tro_edit.dcl @@ -0,0 +1,43 @@ +// ============================================================ +// tro_edit.dcl - TRO-Marker bearbeiten +// Aendert ID und TYPE eines TRO_*-Blocks, den die Beschriftung +// aus sps_skel (lib/tro_annotate.py) eingefuegt hat. +// Aufruf ueber c:TRO_EDIT (Lisp/Tro_Edit.lsp). +// ============================================================ + +tro_edit : dialog { + label = "TRO bearbeiten"; + + : column { + + : text { + key = "blockname"; + label = ""; + } + + : edit_box { + key = "id"; + label = "TRO-Kennung:"; + edit_width = 30; + } + + : popup_list { + key = "type"; + label = "TRO-Typ:"; + width = 30; + } + + : text { + key = "fb"; + label = ""; + } + + : text { + key = "hinweis"; + label = ""; + } + + } + + ok_cancel; +} diff --git a/lang/de_DE.json b/lang/de_DE.json index 2934d33..b41044f 100644 --- a/lang/de_DE.json +++ b/lang/de_DE.json @@ -648,6 +648,17 @@ "vfl-kette-nur-ein-baustein": "\nAb dem gewaehlten Baustein wurde kein weiterer angeschlossener VF_n-Baustein gefunden - nichts zum Zusammenfuehren.", "vfl-kette-gefunden": "\n\nKette erkannt: %1 Baustein(e) werden zusammengefuehrt:", "vfl-kette-luecke-warnung": "\n\n WARNUNG: Nach '%1' wurde ein visuell nahes, aber nicht sauber verbundenes VF_n ('%2') gefunden (KS-Abstand %3 mm) - Kette wurde dort beendet, dieser und alle weiteren Bausteine bleiben unangetastet.", - "vfl-kette-fertig": "\n\n>>> Fertig: neuer Gesamt-Block '%1' aus %2 Baustein(en) erstellt." + "vfl-kette-fertig": "\n\n>>> Fertig: neuer Gesamt-Block '%1' aus %2 Baustein(en) erstellt.", + "cmd-tro-bearbeiten": "\nTRO-Marker bearbeiten: %1", + "tro-edit-kein-tro": "Block %1 ist kein TRO-Marker (erwartet TRO_*).", + "tro-edit-kein-id-attribut": "Block %1 hat kein Attribut ID - bitte neu beschriften lassen (tro_annotate.py).", + "tro-edit-dialog-fehlt": "Dialogdatei nicht gefunden:\n%1\nDXFM_DCL pruefen (setenv.bat).", + "tro-edit-modul-fehlt": "%1 nicht geladen - Attribute werden mit EATTEDIT bearbeitet.", + "tro-edit-block": "Block: %1", + "tro-edit-fb": "Funktionsbaustein: %1", + "tro-edit-hinweis": "Symbol und FB folgen erst beim naechsten Lauf von tro_annotate.py.", + "tro-edit-id-leer": "Die TRO-Kennung darf nicht leer sein - nichts geaendert.", + "tro-edit-gespeichert": "\nTRO gespeichert: ID = %1, TYP = %2", + "tro-edit-typ-geaendert": "\nTyp geaendert - tro_annotate.py neu laufen lassen, damit Symbol und FB passen." } } diff --git a/lang/en_GB.json b/lang/en_GB.json index c8659e7..32a7635 100644 --- a/lang/en_GB.json +++ b/lang/en_GB.json @@ -648,6 +648,17 @@ "vfl-kette-nur-ein-baustein": "\nNo further connected VF_n block was found from the selected block onward - nothing to merge.", "vfl-kette-gefunden": "\n\nChain detected: %1 block(s) will be merged:", "vfl-kette-luecke-warnung": "\n\n WARNING: after '%1' a visually close but not properly connected VF_n ('%2') was found (KS distance %3 mm) - the chain was ended there; this and all further blocks are left untouched.", - "vfl-kette-fertig": "\n\n>>> Done: new combined block '%1' created from %2 block(s)." + "vfl-kette-fertig": "\n\n>>> Done: new combined block '%1' created from %2 block(s).", + "cmd-tro-bearbeiten": "\nEdit TRO marker: %1", + "tro-edit-kein-tro": "Block %1 is not a TRO marker (expected TRO_*).", + "tro-edit-kein-id-attribut": "Block %1 has no ID attribute - please re-annotate (tro_annotate.py).", + "tro-edit-dialog-fehlt": "Dialog file not found:\n%1\nCheck DXFM_DCL (setenv.bat).", + "tro-edit-modul-fehlt": "%1 not loaded - editing attributes with EATTEDIT instead.", + "tro-edit-block": "Block: %1", + "tro-edit-fb": "Function block: %1", + "tro-edit-hinweis": "Symbol and FB follow on the next tro_annotate.py run.", + "tro-edit-id-leer": "The TRO id must not be empty - nothing changed.", + "tro-edit-gespeichert": "\nTRO saved: ID = %1, TYPE = %2", + "tro-edit-typ-geaendert": "\nType changed - re-run tro_annotate.py so symbol and FB match." } } diff --git a/menu/SSG_LIB.mnl b/menu/SSG_LIB.mnl index 1a7de34..0861d70 100644 --- a/menu/SSG_LIB.mnl +++ b/menu/SSG_LIB.mnl @@ -160,6 +160,8 @@ (ssg-ensure "export") (ssg-ensure "external_call") (ssg-ensure "OmniModulInsert") + ;; Tro_Edit wird nicht vorgeladen - der Dispatcher SSG_BLOCKEDIT und die + ;; Menuemakros holen es per (ssg-ensure "Tro_Edit") bei Bedarf nach. (ssg-ensure "SSG_LIB_Commands") ;; Menue einhaengen diff --git a/menu/SSG_LIB.mnu b/menu/SSG_LIB.mnu index e452131..5393672 100644 --- a/menu/SSG_LIB.mnu +++ b/menu/SSG_LIB.mnu @@ -125,6 +125,9 @@ [~APBW 110 R550/67,5 208x347]^C^C(ssg-ensure "OmniModulInsert") OMNI_APBW_R550_675_208 [<-~APBW 110 R550/67,5 58x497]^C^C(ssg-ensure "OmniModulInsert") OMNI_APBW_R550_675_58 [<-Element bearbeiten]^C^C(ssg-ensure "OmniModulInsert") OMNI_EDIT +[->TRO] +[Marker bearbeiten]^C^C(ssg-ensure "Tro_Edit") TRO_EDIT +[<-Bearbeiten (Auto)]^C^C(ssg-ensure "SSG_LIB_Commands") SSG_BLOCKEDIT [->Export] [Export Sivas]^C^C(ssg-ensure "count_sep_scan") ZAEHLE_SEP_SCAN (ssg-ensure "export") EXPORTSIVAS [<-Export CSV]^C^C(ssg-ensure "export") EXPORTCSV @@ -161,5 +164,6 @@ [Omniflo Element bearbeiten](ssg-ensure "OmniModulInsert") OMNI_EDIT [Gefaellestrecke bearbeiten](ssg-ensure "Gefaellestrecke") GEFAELLESTRECKE_EDIT [VarioFoerderer bearbeiten](ssg-ensure "VarioFoerderer") VARIOFOERDERER_EDIT +[TRO-Marker bearbeiten](ssg-ensure "Tro_Edit") TRO_EDIT [--] [SSG Bearbeiten (Auto)](ssg-ensure "SSG_LIB_Commands") SSG_BLOCKEDIT