; #|

Annotation Object Creation - Additional Examples

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 :create-objects)
(use-package :oli)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Begin of page;;
;; 
;; example how to use the function sd-am-create-standard-view
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(sd-defdialog 'am_create_some_views_example
 :dialog-title "Create Views"
 :precondition
 '(if (and (sd-am-inq-drawing-no) (sd-am-inq-curr-view-set))
      :ok
    (values :error "Please create a drawing and create/set viewset first.")
    )
 :mutual-exclusion '(all_views three_views)
 :variables
 '(("First Angle Projection")
   (all_views   :value-type :boolean :toggle-type :wide-toggle)
   (three_views :value-type :boolean :toggle-type :wide-toggle)
   ) ;; end variables
 :ok-action
 '(let (par-view v-right v-left)
    ;; prepare a sheet
    (sd-call-cmds (progn
		    (AM_SHEET_CREATE :frame-type "None")
		    (AM_FRAME_MOVE 100,100)))
    (setf par-view (getf (sd-am-create-standard-view "FRONT" 100,100) :view-name))
    (setf v-right  (getf (sd-am-create-standard-view "RIGHT_SIDE" :to_left  par-view) :view-name))
    (sd-am-create-standard-view "TOP"     :below par-view)
    (when all_views
      (setf v-left   (getf (sd-am-create-standard-view "LEFT_SIDE"  :to_right par-view) :view-name))
      (sd-am-create-standard-view "BOTTOM"  :above par-view)
      (sd-am-create-standard-view "BACK"    :to_right v-left)
      )
    (sd-call-cmds (docu_vp "SolidDesigner Annotation" :fit_vp))
    ) ;; end let
 ) ;; end sd-defdialog 'am_create_some_views_example

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Begin of page;;
;; 
;; example how to use the function sd-am-create-section-view
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(sd-defdialog 'am_create_section_views_example
 :dialog-title "Create Section"
 :precondition
 '(if (and (sd-am-inq-drawing-no) (sd-am-inq-curr-view-set))
      :ok
    (values :error "Please create a drawing and create/set viewset first.")
    )
 :variables
 '(
   (parent_view_type
    :title "Std. View"
    :range ("FRONT" "BACK" "LEFT_SIDE" "RIGHT_SIDE" "TOP" "BOTTOM" 
	    "FRONT_TOP_LEFT" "FRONT_TOP_RIGHT" "BACK_TOP_LEFT" "BACK_TOP_RIGHT" 
	    "FRONT_BOTTOM_LEFT" "FRONT_BOTTOM_RIGHT" "BACK_BOTTOM_LEFT" "BACK_BOTTOM_RIGHT")
    ) ;; end parent_view_type
   (rel_position
    :title "Position"
    :range ( :ABOVE :BELOW :TO_RIGHT :TO_LEFT)
    ) ;; end rel_position
   ) ;; end variables
 :ok-action
 '(let (par-view)
    ;; prepare a sheet
    (sd-call-cmds (progn
		    (AM_SHEET_CREATE :frame-type "None")
		    (AM_FRAME_MOVE 125,150)))
    (setf par-view (getf (sd-am-create-standard-view parent_view_type -125,50) :view-name))
    (sd-call-cmds (am_view_update :update_amount 3 :view-name par-view))
    (sd-am-create-section-view par-view '(-170,50 -120,50 -120,70 -70,70) rel_position par-view)
    (sd-call-cmds (docu_vp "SolidDesigner Annotation" :fit_vp))
    ) ;; end let
 ) ;; end sd-defdialog 'am_create_section_views_example

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Begin of page;;
;; 
;; example how to use the sd-am-create- functions
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(sd-defdialog 'am_create_label_example
 :dialog-title "Create Label"
 :precondition
 '(if (and (sd-am-inq-drawing-no) (sd-am-inq-curr-view-set))
      :ok
    (values :error "Please create a drawing and create/set viewset first.")
    )
 :variables
 '(("Owner")
   (type
      :range ((:current-frame :label "current Frame")
	      (:current-sheet :label "current Sheet")
	      (:2dview :label "2d View")
	      (:sketch :label "sketch"))
      :initial-value :current-sheet
      :after-input (if (or (equal type :2dview) (equal type :sketch))
		       (progn
			 (sd-set-variable-status 'owner :enable t)
			 (setq owner nil))
		     (progn
		       (sd-set-variable-status 'owner :enable nil)
		       (setq owner " ")))
      :size :third
   )
   (owner 
      :value-type :docupart
      :initial-enable nil
      :initial-value " "
      :size :third
   )
   ("Label")
   (x
      :title "x Pos"
      :value-type :integer
      :initial-value 0
   )
   (y
      :title "y Pos"
      :value-type :integer
      :initial-value 0
   )
   (logo
      :value-type :filename
      :direction :input
      :initial-value (list "cclogo.mi")
      :initialPattern "*.mi"
   )
   (text
      :value-type :string
      :initial-value "SolidDesigner Annotation"
   )
 ) ;; end variables
 :ok-action
 '(let ()
    ;; misc methods used to draw the sides of the box
    (sd-am-create-geo-straight :2pos 
			       (list (gpnt2d (- x 45) (+ y 25)) (gpnt2d (+ x 45) (+ y 25)))
			       :owner_type type :owner owner)
    (sd-am-create-geo-straight :horizontal 
			       (list (gpnt2d (- x 45) (- y 25)) 90)
			       :owner_type type :owner owner)
    (sd-am-create-geo-straight :vertical 
			       (list (gpnt2d (- x 50) (- y 20)) 40)
			       :owner_type type :owner owner)
    (sd-am-create-geo-straight :angle 
			       (list (gpnt2d (+ x 50) (- y 20)) 90 40)
			       :owner_type type :owner owner)

    ;; draw four arcs for the 'corners'
    (sd-am-create-geo-circular :arc_center
			       (list (gpnt2d (- x 45) (+ y 20))  (gpnt2d (- x 45) (+ y 25))  (gpnt2d (- x 50) (+ y 20))
				     (gpnt2d (+ x 45) (+ y 20))  (gpnt2d (+ x 50) (+ y 20))  (gpnt2d (+ x 45) (+ y 25))
				     (gpnt2d (+ x 45) (- y 20))  (gpnt2d (+ x 45) (- y 25))  (gpnt2d (+ x 50) (- y 20))
				     (gpnt2d (- x 45) (- y 20))  (gpnt2d (- x 50) (- y 20))  (gpnt2d (- x 45) (- y 25))
			       )
			       :owner_type type :owner owner)

    ;; load the specified sketch
    (sd-am-load-sketch :file_name (first logo)
		       :position (gpnt2d x y)
		       :adjust :middle_middle
		       :owner_type type :owner owner)
    
    ;; create text string within the given owner
    (sd-am-create-text :text text
		       :position (gpnt2d (- x 30) (- y 20))
		       :owner_type type :owner owner)

  ) ;; end let
) ;; end sd-defdialog 'am_create_label_example


;  END of Example