#|

Fast Window

Note: This is an example file showing concepts of the Integration Kit. The code itself is not supported and will never be supported.
|#


(in-package :EXAMPLES)
(use-package :OLI)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(sd-defdialog 'fast_win
  :dialog-title "Fast Window"
  :variables
  '((CURR-DR-MODE)
    (CURR_VP :value-type :viewport
	     :title "Viewport"
	     :initial-value (first (sd-inq-vp-names)))
    (CURR_PART :value-type :part
	       :modifies nil
	       :face-part-allowed t :wire-part-allowed t
	       :title "Part"
	       :prompt-text "Specify PART.")
    (START_IT :value-type :boolean
	      :title "Start"
	      :after-input (switch-on)))
  :local-functions
  '((switch-on ()
     (unless
      (sd-inq-vp-exists-p "Fast")
      (sd-call-cmds (create_vp
		     :name "Fast"
		     :background_color :rgb (sd-inq-vp-bg-color curr_vp) :done
		     :corner_1 7,86 :corner_2 572,501))
      (sd-call-cmds (set_show "Fast"
			      :3dgeo_mixed :off
			      :3dgeo_part_transparency :off
			      :3dgeo_part_reflectance :off
			      :3dgeo_face_transparency :off
			      :3dgeo_face_reflectance :off))
      (sd-call-cmds (add_to_vp_drawlist "Fast" curr_part))
      (sd-set-vp-camera "Fast" (sd-inq-vp-camera curr_vp))
      (setf curr-dr-mode (sd-inq-dynamic-redraw-mode))
      (sd-set-dynamic-redraw-mode :edged)))
    (switch-off ()
      (when
      (sd-inq-vp-exists-p "Fast")
      (sd-set-dynamic-redraw-mode curr-dr-mode)
      (sd-set-vp-camera curr_vp (sd-inq-vp-camera "Fast"))
      (sd-call-cmds (delete_vp "Fast"))))
    )
  :ok-action '(switch-off)
  :cancel-action '(switch-off)
  :exception '(switch-off))

;;