| 1 |
;;; |
| 2 |
;;; Model interface program |
| 3 |
;;; 1988.8.13 by M.Inaba |
| 4 |
;;; 1988.10.29 using new viewport.l |
| 5 |
;;; (pickmenu) |
| 6 |
;;; |
| 7 |
;;; |
| 8 |
(defclass pickmenu |
| 9 |
:super sunview-frame |
| 10 |
:slots |
| 11 |
( |
| 12 |
picked-object |
| 13 |
pick-command |
| 14 |
pickpanel pickcanvas |
| 15 |
; apickport |
| 16 |
drag-start-pos |
| 17 |
left-right-angle up-down-angle |
| 18 |
pick-mark |
| 19 |
) |
| 20 |
) |
| 21 |
|
| 22 |
(defmethod pickmenu |
| 23 |
(:objects (&optional (v objects)) |
| 24 |
(send apickport :objects v)) |
| 25 |
(:make-cube (&rest args) |
| 26 |
(push (apply #'make-cube args) objects)) |
| 27 |
(:make-cylinder (&rest args) |
| 28 |
(push (apply #'make-cylinder args) objects)) |
| 29 |
(:pickport (&rest msg) |
| 30 |
(if msg |
| 31 |
(apply #'send (cons apickport msg)) |
| 32 |
apickport)) |
| 33 |
(:draw-picked-object-axis |
| 34 |
(&optional (size 10)) |
| 35 |
(send apickport :draw-mark picked-object size) |
| 36 |
) |
| 37 |
(:pick-object |
| 38 |
(window click button pos time) |
| 39 |
(case |
| 40 |
button |
| 41 |
(left |
| 42 |
(send apickport :viewsurface :set-erase-mode) |
| 43 |
(send self :draw-picked-object-axis) |
| 44 |
(setq picked-object |
| 45 |
(case |
| 46 |
pick-command |
| 47 |
(object (send apickport :pick-object pos)) |
| 48 |
(face (send apickport :pick-face pos)) |
| 49 |
(edge (send apickport :pick-edge pos)) |
| 50 |
(2dlnseg (send apickport :pick-2dlnseg pos)) |
| 51 |
(vertex (send apickport :pick-vertex pos)) |
| 52 |
(junction (send apickport :pick-junction pos)) |
| 53 |
(edge-image (send apickport :pick-edge-image pos))) |
| 54 |
) |
| 55 |
(send apickport :viewsurface :set-show-mode) |
| 56 |
(send self :draw-picked-object-axis) |
| 57 |
) |
| 58 |
(middle |
| 59 |
(let ((o)) |
| 60 |
(case pick-command |
| 61 |
(2dlnseg (setq o (send apickport :pick-line pos))) |
| 62 |
) |
| 63 |
(send apickport :clear) |
| 64 |
(send (send apickport :viewsurface) :draw-one o))) |
| 65 |
(right (send apickport :clear) |
| 66 |
) |
| 67 |
) |
| 68 |
(send apickport :flush) |
| 69 |
) |
| 70 |
(:zooming |
| 71 |
(window click button pos time) |
| 72 |
(case button |
| 73 |
(left (send apickport :erase-hid-objects) |
| 74 |
(send apickport :viewing :zoom 0.8) |
| 75 |
(send apickport :hid-objects) |
| 76 |
) |
| 77 |
(right (send apickport :erase-hid-objects) |
| 78 |
(send apickport :viewing :zoom 1.2) |
| 79 |
(send apickport :hid-objects) |
| 80 |
) |
| 81 |
(middle (send apickport :hid-objects) |
| 82 |
) |
| 83 |
) |
| 84 |
(send apickport :flush) |
| 85 |
) |
| 86 |
(:drag-object |
| 87 |
(window click button pos time) |
| 88 |
(let* |
| 89 |
((obj (send apickport :pick-coordinates pos))) |
| 90 |
(when |
| 91 |
obj |
| 92 |
(send apickport :draw obj) |
| 93 |
(send apickport :draw-box-cursor (send obj :worldpos)) |
| 94 |
(send obj :locate |
| 95 |
(send apickport :pick-vector pos |
| 96 |
(case |
| 97 |
button |
| 98 |
(left (float-vector 1 0 0)) |
| 99 |
(middle (float-vector 0 1 0)) |
| 100 |
(right (float-vector 0 0 1))) |
| 101 |
(send obj :worldpos)) |
| 102 |
'world) ;;;;;<< tra 'world 'world ;;;mer |
| 103 |
(send apickport :draw obj) |
| 104 |
;;; (send apickport :draw-box-cursor (send obj :worldpos)) |
| 105 |
(send apickport :flush) |
| 106 |
)) |
| 107 |
) |
| 108 |
(:select-drag-object |
| 109 |
(window click button pos time) |
| 110 |
(send apickport :viewsurface :rasterop (logxor pix_src pix_dst)) |
| 111 |
(send apickport :draw-box-cursor |
| 112 |
(send (send apickport :pick-coordinates pos) :worldpos)) |
| 113 |
) |
| 114 |
(:release-drag-object |
| 115 |
(window click button pos time) |
| 116 |
(send apickport :draw-box-cursor |
| 117 |
(send (send apickport :pick-coordinates pos) :worldpos)) |
| 118 |
(send apickport :viewsurface :rasterop pix_src)) |
| 119 |
(:drag-viewport |
| 120 |
(window click button pos time) |
| 121 |
(let |
| 122 |
((p (v- pos drag-start-pos))) |
| 123 |
(send apickport :erase-hid-objects) |
| 124 |
(send apickport :viewport :translate (2dvector-to-3dvector p) 'world) |
| 125 |
(setq drag-start-pos pos) |
| 126 |
(send apickport :draw (model-pickport-edge-images apickport)) |
| 127 |
(send apickport :flush) |
| 128 |
)) |
| 129 |
(:drag-start |
| 130 |
(window click button pos time) |
| 131 |
(send apickport :erase-hid-objects) |
| 132 |
(setq drag-start-pos pos) |
| 133 |
(send apickport :draw (model-pickport-edge-images apickport)) |
| 134 |
(send apickport :flush) |
| 135 |
) |
| 136 |
(:file-name (value i e) (print value)) |
| 137 |
(:init |
| 138 |
(&optional parent |
| 139 |
&key |
| 140 |
objects |
| 141 |
(width 400) |
| 142 |
(height 400) |
| 143 |
&allow-other-keys) |
| 144 |
(send-super :init parent |
| 145 |
:title "Pick View by M.Inaba of UTOKYO 1988" |
| 146 |
:x 400 :y 0) |
| 147 |
(setq pickpanel (send self :create-subwindow sunview-panel :vertical t |
| 148 |
:col-num 1 :item-size 20)) |
| 149 |
(send self :create-choice :change-event-proc |
| 150 |
:title "Event proc:" |
| 151 |
:display-level 'current |
| 152 |
:choices '(Default zooming drag-object)) |
| 153 |
(send self :create-item panel-button-item |
| 154 |
:nproc :superimpose :title "Superimpose") |
| 155 |
(send self :create-button :hid-objects :title "hid-objects") |
| 156 |
(send self :create-item panel-button-item |
| 157 |
:nproc :draw-objects :title "draw-objects") |
| 158 |
(send self :create-item panel-button-item |
| 159 |
:nproc :clear-port :title "clear-port") |
| 160 |
(send self :create-item panel-text-item |
| 161 |
:nproc :file-name :title "Text item" |
| 162 |
:value "text" :length 20) |
| 163 |
(send self :create-item panel-slider-item |
| 164 |
:nproc :left-right :title "lookaround-left-right:" |
| 165 |
:min -180 :max 180 :value 0 |
| 166 |
:notify-level 'all |
| 167 |
:item-col 0) |
| 168 |
(send self :create-item panel-slider-item |
| 169 |
:nproc :up-down :title "lookaround-up-down:" |
| 170 |
:min -180 :max 180 :value 0 |
| 171 |
:notify-level 'all |
| 172 |
:item-col 0) |
| 173 |
(send self :create-item panel-choice-item |
| 174 |
:nproc :buffer-mode :title "buffer mode:" :value nil |
| 175 |
:choices (vector t nil) :display-level 'current |
| 176 |
:item-col 0) |
| 177 |
(send self :create-item panel-choice-item |
| 178 |
:nproc :pick-object-type :title "Pick model:" :value 'object |
| 179 |
:choices |
| 180 |
(vector 'object 'face 'edge '2dlnseg 'vertex 'junction 'edge-image) |
| 181 |
:display-level 'all :item-col 0) |
| 182 |
(setq left-right-angle 0) |
| 183 |
(setq up-down-angle 0) |
| 184 |
(setq pick-command 'pick-object) |
| 185 |
;;; |
| 186 |
(setq pickcanvas (send self :create-subwindow sunview-canvas |
| 187 |
:right-of pickpanel |
| 188 |
:height height :width width |
| 189 |
:clicked-proc :pick-object |
| 190 |
:dragging-proc :drag-viewport |
| 191 |
:drag-started-proc :drag-start)) |
| 192 |
;;; |
| 193 |
(setq apickport |
| 194 |
(instance |
| 195 |
model-pickport |
| 196 |
:init |
| 197 |
:viewsurface |
| 198 |
(instance canvas-viewsurface :init |
| 199 |
:canvas pickcanvas :buffer-mode nil :cmap-type :mono) |
| 200 |
:viewing |
| 201 |
(instance perspective-viewing :init |
| 202 |
:screen-x 10 :screen-y 10 :viewdistance 40 |
| 203 |
:pos #f(500 300 150) :target #f(0 0 0)) |
| 204 |
:viewport |
| 205 |
(instance viewport |
| 206 |
:init :width 200 :height -200 |
| 207 |
:xcenter 200 :ycenter 200) |
| 208 |
)) |
| 209 |
(setq pick-mark (float-vector 0 0 0)) |
| 210 |
(send self :pickport :objects objects) |
| 211 |
(send self :hid-objects) |
| 212 |
(send self :show t) |
| 213 |
self) |
| 214 |
(:change-event-proc |
| 215 |
(value &optional item event) |
| 216 |
(case value |
| 217 |
(default (send pickcanvas :clicked-proc :pick-object)) |
| 218 |
(zooming (send pickcanvas :clicked-proc :zooming)) |
| 219 |
(drag-object |
| 220 |
(send pickcanvas :drag-started-proc :select-drag-object) |
| 221 |
(send pickcanvas :dragging-proc :drag-object) |
| 222 |
(send pickcanvas :drag-finished-proc :release-drag-object) |
| 223 |
) |
| 224 |
)) |
| 225 |
(:superimpose |
| 226 |
(&optional item event) |
| 227 |
(send apickport :hid-objects) |
| 228 |
(send apickport :flush) |
| 229 |
) |
| 230 |
(:hid-objects (&optional item event) (send apickport :hid-objects) |
| 231 |
(send apickport :flush)) |
| 232 |
(:draw-objects (&optional item event) (send apickport :draw-objects) |
| 233 |
(send apickport :flush)) |
| 234 |
(:clear-port (&optional item event) (send apickport :clear) |
| 235 |
(send apickport :flush)) |
| 236 |
(:left-right |
| 237 |
(value &optional item event) |
| 238 |
(send apickport :erase-hid-objects) |
| 239 |
(send apickport :viewing |
| 240 |
:lookaround (deg2rad (- left-right-angle value)) 0) |
| 241 |
(send apickport :hid-objects) |
| 242 |
(setq left-right-angle value) |
| 243 |
(send apickport :flush) |
| 244 |
) |
| 245 |
(:up-down |
| 246 |
(value &optional item event) |
| 247 |
(send apickport :erase-hid-objects) |
| 248 |
(send apickport :viewing |
| 249 |
:lookaround 0 (deg2rad (- up-down-angle value))) |
| 250 |
(send apickport :hid-objects) |
| 251 |
(setq up-down-angle value) |
| 252 |
(send apickport :flush) |
| 253 |
) |
| 254 |
(:pick-object-type |
| 255 |
(value &optional item event) |
| 256 |
(setq pick-command value) |
| 257 |
(send apickport :clear) |
| 258 |
(send apickport :hid-objects) |
| 259 |
(send apickport :flush) |
| 260 |
) |
| 261 |
(:buffer-mode |
| 262 |
(value &optional item event) |
| 263 |
(send apickport :viewsurface :buffer-mode value) |
| 264 |
(send apickport :viewsurface :clear)) |
| 265 |
) |
| 266 |
(defun pickmenu nil |
| 267 |
(setq cube |
| 268 |
(make-prism |
| 269 |
(list |
| 270 |
(float-vector 0 0 0) |
| 271 |
(float-vector 0 51 0) |
| 272 |
(float-vector 51 51 0) |
| 273 |
(float-vector 51 0 0)) |
| 274 |
51)) |
| 275 |
(setq wedge |
| 276 |
(make-prism |
| 277 |
(list |
| 278 |
(float-vector 0 0 0) |
| 279 |
(float-vector 0 37 0) |
| 280 |
(float-vector 37 0 0)) |
| 281 |
37)) |
| 282 |
(send wedge :locate #f(0 96 0) 'world) |
| 283 |
(send wedge :worldcoords) |
| 284 |
(setq *pickmenu* (instance pickmenu :init |
| 285 |
nil |
| 286 |
:objects (list cube wedge) |
| 287 |
)) |
| 288 |
) |
| 289 |
(format t "(pickmenu) ;; main of pickview.l~%") |