home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / SUPPORT2.LIB / DDSELECT.LSP < prev    next >
Encoding:
Text File  |  1992-09-08  |  8.5 KB  |  257 lines

  1. ;;;----------------------------------------------------------------------------
  2. ;;;   DDSELECT.LSP  ¬⌐Ñ╗ 0.5
  3. ;;;
  4. ;;;   ¬⌐┼v (C) 1991-1992  Autodesk ñ╜Ñq
  5. ;;;
  6. ;;;   Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  7. ;;;   ¡∞½h :
  8. ;;;
  9. ;;;   1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  10. ;;;   2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  11. ;;;
  12. ;;;   Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  13. ;;;   Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  14. ;;;
  15. ;;;
  16. ;;;----------------------------------------------------------------------------
  17. ;;;
  18. ;;;
  19. ;;; ===========================================================================
  20. ;;; ===================== load-time error checking ============================
  21. ;;;
  22.  
  23.   (defun ai_abort (app msg)
  24.      (defun *error* (s)
  25.         (if old_error (setq *error* old_error))
  26.         (princ)
  27.      )
  28.      (if msg
  29.        (alert (strcat " └│Ñ╬╡{ªí┐∙╗~: "
  30.                       app
  31.                       " \n\n  "
  32.                       msg
  33.                       "  \n"
  34.               )
  35.        )
  36.      )
  37.      (exit)
  38.   )
  39.  
  40. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  41. ;;; and then try to load it.
  42. ;;;
  43. ;;; If it can't be found or it can't be loaded, then abort the
  44. ;;; loading of this file immediately, preserving the (autoload)
  45. ;;; stub function.
  46.  
  47.   (cond
  48.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  49.  
  50.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  51.         (ai_abort "DDSELECT"
  52.                   (strcat "ºΣñú¿∞íuAI_UTILS.LSPív└╔«╫;"
  53.                           "\n  ╜╨└╦¼díusupportívÑ╪┐²íC")))
  54.  
  55.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  56.         (ai_abort "DDSELECT" "╡L¬k╕ⁿñJíuAI_UTILS.LSPív└╔«╫"))
  57.   )
  58.  
  59.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  60.       (ai_abort "DDSELECT" nil)         ; a Nil <msg> supresses
  61.   )                                    ; ai_abort's alert box dialog.
  62.  
  63. ;;; ==================== end load-time operations ===========================
  64.  
  65. ;;;----------------------------------------------------------------------------
  66. ;;; The main routine.
  67. ;;;----------------------------------------------------------------------------
  68. (defun c:ddselect( /
  69.                    cmd             draw_size       set_default     x2
  70.                    dcl_id          ent_sort        set_sort        x_pickbox
  71.                    globals         sortents        y_pickbox       undo_init
  72.                    sortents_init   ddselect_main
  73.                    do_setvars      pickboxsize     x1
  74.                    pickfirst_init  pickadd_init    pickdrag_init
  75.                    pickauto_init   pickboxsize_init
  76.                  )
  77.   ;;
  78.   ;; Pass an integer and draw a square of that size in the pickboxsize
  79.   ;; image tile.
  80.   ;;
  81.   (defun draw_size (intsize)
  82.     (setq x1 (- (/ x_pickbox 2) (1+ intsize) ))
  83.     (setq x2 (+ (/ x_pickbox 2) (1+ intsize) ))
  84.     (setq y1 (- (/ y_pickbox 2) (1+ intsize) ))
  85.     (setq y2 (+ (/ y_pickbox 2) (1+ intsize) ))
  86.     (start_image "pickbox_image")
  87.     (fill_image 0 0 x_pickbox y_pickbox -2)  ; -2 is the graphics screen color
  88.     (vector_image x1 y1 x2 y1 -1)            ; -1 is the cursor color
  89.     (vector_image x2 y1 x2 y2 -1)
  90.     (vector_image x2 y2 x1 y2 -1)
  91.     (vector_image x1 y2 x1 y1 -1)
  92.     (end_image)
  93.   )
  94.   ;;
  95.   ;; Set the SORTENTS system variable to selected setting.
  96.   ;;
  97.   (defun set_sort()
  98.     (setq sortents 0)             ; initialise to 0.
  99.     (if (= "1" (get_tile "sort_obj_sel"))
  100.       (setq sortents (logior sortents 1))
  101.     )
  102.     (if (= "1" (get_tile "sort_obj_snap"))
  103.       (setq sortents (logior sortents 2))
  104.     )
  105.     (if (= "1" (get_tile "sort_redraws"))
  106.       (setq sortents (logior sortents 4))
  107.     )
  108.     (if (= "1" (get_tile "sort_slide"))
  109.       (setq sortents (logior sortents 8))
  110.     )
  111.     (if (= "1" (get_tile "sort_regens"))
  112.       (setq sortents (logior sortents 16))
  113.     )
  114.     (if (= "1" (get_tile "sort_plot"))
  115.       (setq sortents (logior sortents 32))
  116.     )
  117.     (if (= "1" (get_tile "sort_post"))
  118.       (setq sortents (logior sortents 64))
  119.     )
  120.     (setq sortents sortents)
  121.   )
  122.   ;;
  123.   ;;  The entity sort dialogue.
  124.   ;;
  125.   (defun ent_sort()
  126.     (if (not (new_dialog "sortents" dcl_id)) (exit))
  127.     ;; Display current settings.
  128.     (if (= 1 (logand 1 sortents)) (set_tile "sort_obj_sel" "1"))
  129.     (if (= 2 (logand 2 sortents)) (set_tile "sort_obj_snap" "1"))
  130.     (if (= 4 (logand 4 sortents)) (set_tile "sort_redraws" "1"))
  131.     (if (= 8 (logand 8 sortents)) (set_tile "sort_slide" "1"))
  132.     (if (= 16 (logand 16 sortents)) (set_tile "sort_regens" "1"))
  133.     (if (= 32 (logand 32 sortents)) (set_tile "sort_plot" "1"))
  134.     (if (= 64 (logand 64 sortents)) (set_tile "sort_post" "1"))
  135.  
  136.     (action_tile "accept" "(set_sort)(done_dialog)")
  137.     (start_dialog)
  138.   )
  139.   ;;
  140.   ;;  If OK, set all setvars to selected values.
  141.   ;;
  142.   (defun do_setvars()
  143.     (if (/= pickfirst_init (get_tile "pickfirst"))
  144.       (setvar "pickfirst" (atoi (get_tile "pickfirst")))
  145.     )
  146.     (if (/= pickadd_init (get_tile "pickadd"))
  147.       (setvar "pickadd" (abs (- 1 (atoi (get_tile "pickadd")))))
  148.     )
  149.     (if (/= pickdrag_init (get_tile "pickdrag"))
  150.       (setvar "pickdrag" (atoi (get_tile "pickdrag")))
  151.     )
  152.     (if (/= pickauto_init (get_tile "pickauto"))
  153.       (setvar "pickauto" (atoi (get_tile "pickauto")))
  154.     )
  155.     (if (/= pickboxsize_init pickboxsize)
  156.       (setvar "pickbox" (1+ pickboxsize))
  157.     )
  158.     ; Also set the sortents sysvar, if it has been modified.
  159.     (if (/= sortents sortents_init)
  160.       (setvar "sortents" sortents)
  161.     )
  162.   )
  163.   ;;
  164.   ;;  Set all toggles to default mode.
  165.   ;;
  166.   (defun set_default()
  167.     (set_tile "pickfirst" "1")
  168.     (set_tile "pickadd" "0")         ; label is titled opposite to the setvar.
  169.     (set_tile "pickdrag" "0")
  170.     (set_tile "pickauto" "1")
  171.   )
  172.   ;;
  173.   ;; Put up the dialogue.
  174.   ;;
  175.   (defun ddselect_main()
  176.  
  177.     (if (not (new_dialog "ddselect" dcl_id)) (exit))
  178.  
  179.     ;; Get the value of the SORTENTS system variable.
  180.     (setq sortents_init (getvar "sortents")
  181.           sortents     sortents_init
  182.     )
  183.  
  184.     ;; The pickbox variable must be within 1 - 20 for display within the image
  185.     ;; tile.  The pickbox variable will only be updated if the user moves
  186.     ;; the slider bar (0 - 19).
  187.     (setq pickboxsize (1- (getvar "pickbox")))
  188.     (if (< 19 pickboxsize) (setq pickboxsize 19))
  189.     (if (> 0 pickboxsize) (setq pickboxsize 0))
  190.     (setq pickboxsize_init pickboxsize)
  191.  
  192.     ;; Get current settings of variables.
  193.     (set_tile "pickfirst" (setq pickfirst_init (itoa (getvar "pickfirst"))))
  194.     (set_tile "pickadd"
  195.               (setq pickadd_init (itoa (abs (- 1 (getvar "pickadd"))))))
  196.     (set_tile "pickdrag" (setq pickdrag_init (itoa (getvar "pickdrag"))))
  197.     (set_tile "pickauto" (setq pickauto_init (itoa (getvar "pickauto"))))
  198.  
  199.     (set_tile "pickbox_slider" (itoa pickboxsize))
  200.  
  201.     (setq x_pickbox (dimx_tile "pickbox_image"))
  202.     (setq y_pickbox (dimy_tile "pickbox_image"))
  203.  
  204.     (draw_size pickboxsize)
  205.  
  206.     (action_tile "default_mode" "(set_default)")
  207.  
  208.     (action_tile "pickbox_slider"
  209.                  "(draw_size (setq pickboxsize (atoi $value)))")
  210.     (action_tile "ent_sort" "(ent_sort)")
  211.     (action_tile "help" "(acad_helpdlg \"acad.hlp\" \"ddselect\")")
  212.     (action_tile "accept" "(do_setvars)(done_dialog)")
  213.  
  214.     (start_dialog)
  215.   )
  216.  
  217.   ;; Set up error function.
  218.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  219.         old_error  *error*            ; save current error function
  220.         *error* ai_error              ; new error function
  221.   )
  222.  
  223.   (setvar "cmdecho" 0)
  224.  
  225.   (cond
  226.      (  (not (ai_transd)))                        ; transparent OK
  227.      (  (not (ai_acadapp)))                       ; ACADAPP.EXP xloaded?
  228.      (  (not (setq dcl_id (ai_dcl "ddselect"))))  ; is .DCL file loaded?
  229.  
  230.      (t (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  231.                  (/= 8 (logand 8 (getvar "cmdactive")))
  232.             )
  233.          (ai_undo_push)
  234.         )
  235.  
  236.         (ddselect_main)                          ; proceed!
  237.  
  238.         (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  239.                  (/= 8 (logand 8 (getvar "cmdactive")))
  240.             )
  241.          (ai_undo_pop)
  242.         )
  243.  
  244.      )
  245.   )
  246.  
  247.   (setq *error* old_error)
  248.   (setvar "cmdecho" old_cmd)
  249.   (princ)
  250. )
  251.  
  252. ;;;----------------------------------------------------------------------------
  253. (princ "  íuDDSELECTívñw╕ⁿñJíC")
  254. (princ)
  255.  
  256.  
  257.