(in-package :custom) (use-package :oli) (defvar *structure-check-result* (list)) ;; REFRESH DIALOG (sd-defdialog 'refresh-structure-browser-part-check :dialog-title "Refresh structure browser part check" :toolbox-button t :precondition '(progn (check-structure) (sd-set-current-browser-view "PARTCHECK"))) ;; BROWSER CUSTOMIZATION/CONFIGURATION (sd-create-column-definition :check-result :title "Check result" :display-fnc 'display-structure-browser-check :applicable-fnc 'checkable-p :ui-accessible t :edit-fnc nil) (sd-create-browser-view "PARTCHECK" :tree-config '(:instance-name) :detail-config '(:contents-name :check-result) :title "Analyse") (defun checkable-p (node) (let ((sel-item (sd-pathname-to-obj (browsernode-objpath node)))) (when sel-item (sd-inq-part-p sel-item)))) (defun display-structure-browser-check (node) (unless *structure-check-result* (check-structure)) (when *structure-check-result* (let* ( (c-sysid (sd-inq-obj-contents-sysid (sd-pathname-to-obj (browsernode-objpath node)))) (node-check-result (assoc-sysid c-sysid *structure-check-result*))) (when node-check-result (getf node-check-result :check-result))))) (defun check-structure () (let* ( (cnt 0) (new-structure-check-result (list)) (all-items (inq-obj-tree-list (sd-pathname-to-obj "/"))) (all-items-length (if all-items (length all-items) 0))) (dolist (obj all-items) (progress-bar :percentage (* (/ 100 all-items-length) (incf cnt))) (when (sd-inq-part-p obj) (let ((item-found (first (member (sd-inq-obj-contents-sysid obj) *structure-check-result* :test #'check-for-sysid)))) (if item-found (if (string= (getf item-found :mod-time) (sd-inq-obj-mod-time-string obj)) (push item-found new-structure-check-result) (push (get-structure-check-item obj) new-structure-check-result)) (push (get-structure-check-item obj) new-structure-check-result))))) (progress-bar :finalize t) (progress-bar :finalize t) (setq *structure-check-result* new-structure-check-result))) (defun get-part-check-result (node) (let ( (check-result (list))) (display :clear :hide) (check_part :objects node :maximal_check t :voids t :knife_edges t :inexact_geo t :warnings t :check_it) (setq check-result (sd-get-text-control-value "OUTPUT-BOX-TX")) (display :clear :hide) (format nil "~{~a~^ ~}" (sd-string-split check-result (format nil "~a" #\Newline))))) ;; HELPER FUNCTIONS (defun assoc-sysid (sysid chck-res-lst) (dolist (chck-res chck-res-lst) (when (string= (getf chck-res :contents-sysid) sysid) (return-from assoc-sysid chck-res)))) (defun get-structure-check-item (obj) (list :mod-time (sd-inq-obj-mod-time-string obj) :contents-sysid (sd-inq-obj-contents-sysid obj) :check-result (get-part-check-result obj))) (defun check-for-sysid (sysid plst) (if (string= sysid (getf plst :contents-sysid)) plst nil)) (defun inq-obj-tree-list (obj) (cons obj (apply #'nconc (mapcar #'inq-obj-tree-list (sd-inq-obj-children obj))))) (defun sd-inq-obj-mod-time-string (object &optional attachment) (let ((modtime (sd-inq-obj-mod-time object attachment))) (format nil "~4,'0D~2,'0D~2,'0D~2,'0D~2,'0D~2,'0D" (getf modtime :year) (getf modtime :month) (getf modtime :day) (getf modtime :hour) (getf modtime :minutes) (getf modtime :seconds)))) (defun progress-bar (&key percentage finalize) (let ( (probe-struct (read-from-string (format nil "#s(frame2-ui::Probe frame2-ui::eventno 1 frame2-ui::currticks ~a frame2-ui::maxticks 100)" percentage)))) (if finalize (frame2-ui::hide-probe-display) (frame2-ui::update-probe-display probe-struct)))) (sd-set-current-browser-view "PARTCHECK")