Viewer

To get a drawing on a screen, four objects are needed: (1) objects to be drawn, (2) a viewing which defines the viewing coordinates and the projection, (3) a viewport for clipping in NDC and the transformation from NDC to physical screen coordinates, and (4) a viewsurface which performs drawing functions on a physical display device. A viewer object holds a viewing, a viewport and a viewsurface object, and controls successive coordinates transformation. Functions draw and hid described in section 17.5 use the instances of viewer.




viewer [class]


  :super   object 

:slots (eye :type viewint)
(port :type viewport)
(surface :type viewsurface)


defines the cascaded coordinates transformation from the viewing via the viewport to the viewsurface.


:viewing &rest msg [method]

If msg is given, msg is sent to the viewing (eye) object, Otherwise, the viewing (eye) object is returned.


:viewport &rest msg [method]
If msg is given, msg is sent to the viewport (port) object, Otherwise, the viewport (port) object is returned.


:viewsurface &rest msg [method]
If msg is given, msg is sent to the viewsurface (surface) object, Otherwise, the viewsurface (surface) object is returned.


:adjust-viewport [method]
When the size of viewsurface has been changed, :adjust-viewport changes viewport transformation sending a proper message to port.


:resize width height [method]
changes the size of viewsurface by sending :resize message to the viewsurface and :size message to viewport.


:draw-line-ndc p1 p2 &optional (do-clip t) [method]
draws a line whose two end points p1, p2 are defined in NDC.


:draw-polyline-ndc polylines [method]
draws polylines whose end points are defined in NDC.


:draw-star-ndc center &optional (size 0.01) [method]
draws a cross mark in NDC.


:draw-box-ndc low-left up-right [method]
draws a rectangle in NDC.


:draw-arc-ndc point width height angle1 angle2 [color] [method]
draws an arc in NDC. The viewsurface object bound in this viewer must accept :arc message.


:draw-fill-arc-ndc point width height angle1 angle2 [color] [method]
draws a filled-arc in NDC.


:draw-string-ndc position string [color] [method]
draws string at position defined in NDC.


:draw-image-string-ndc position string [color] [method]


:draw-rectangle-ndc position width height [color] [method]


:draw-fill-rectangle-ndc point width height [color] [method]


:draw-line p1 p2 &optional (do-clip t) [method]
draws a line whose two end points p1, p2 are defined in the world coordinates.


:draw-star position &optional (size 0.01) [method]
draws a cross at position located in the world.


:draw-box center &optional (size 0.01) [method]
draws a rectangular at centerin the world.


:draw-arrow p1 p2 [method]
draws an arrow from p1 to p2.


:draw-edge edge [method]


:draw-edge-image edge-image [method]


:draw-faces face-list &optional (normal-clip nil) [method]


:draw-body body &optional (normal-clip nil) [method]


:draw-axis coordinates &optional size [method]
draws coordinates axes whose length is size.


:draw &rest things [method]
draws 3D geometric objects. If the object is a 3D float-vector, a small cross is drawn at the position. If it is a list of 3D float-vectors, it is taken as a polyline. If thing accepts :draw message, the method is invoked with this viewer as its argument. If the object defines :drawners method, the :draw message is sent to the result of :drawners. Line, edge, polygon, face, and body objects are drawn by corresponding :draw-xxx methods defined in viewer.


:erase &rest things [method]
draws things with background color.


:init &key :viewing :viewport :viewsurface [method]
sets viewing, viewport and viewsurface to eye, port, and surface slots of this viewer.



\begin{emtabbing}
{\bf view}
\it\&key \= (size 500) (width size) (height size)
...
...en) (screen-y screen) \\
\> (xcenter 500) (ycenter 400) \\
\rm
\end{emtabbing}

creates a new viewer and pushes it in *viewers* list.


k-okada 2013-05-21