3.16.13. Editable Graphics with comdraw/ivtools |
A very useful tool for scientists (an many other people) is the ability to produce editable graphics. Lush provides this feature through the "comdraw" graphic driver. The editability allows one to manually change colors, add text, change line styles, and do all kinds of other things to Lush graphics generated this way.
Opening a comdraw window is done simply with:
(comdraw-window 10 10 500 500 "My Comdraw Window")where the first four parameters are the desired positions and dimensions of the window. Any Lush graphic command executed while such a window is the current window will be drawn in this window and will be instantly editable. The graphics-batch construct has the effect of grouping the objects drawn within its scope.
3.16.13.0. Installing ivtools and comdraw |
3.16.13.1. (comdraw-window [[[x y] w h] name]) |
[DX] |
(setq window (comdraw-window))
3.16.13.2. Support for Graphics Commands |
comdraw Graphics are considerably slower than x11 graphics.
Functions clip and addclip are supported, but due to the lack of an internal clipping function in comdraw, only line clipping is performed in comdraw windows.
graphics-batch groups the object created by the evaluation of the graphics commands within its scope.
The graphics event functions hilite , get-click , get-vector , get-rect and the EventLock objects, read-event and check-event functions are not supported. The imaging functions hinton-map and get-image are not supported.
3.16.13.3. comdraw Specific Functions |
compview=rect(x0,y0,x1,y1) -- creates a rectangle compview=rectangle(x0,y0,x1,y1) -- creates a rectangle compview=line(x0,y0,x1,y1) -- creates a line compview=arrowline(x0,y0,x1,y1) -- creates an arrow line compview=ellipse(x0,y0,r1,r2) -- creates an ellipse compview=text(x0,y0 textstr) -- creates a text string on pixel coordinates x0, y0 compview=multiline(x0,y0[,x1,y1,...]) -- creates a multiline compview=arrowmultiline(x0,y0[,x1,y1,...]) -- creates an multiline with arrows compview=openspline(x0,y0[,x1,y1,...]) -- creates an open spline compview=arrowspline(x0,y0[,x1,y1,...]) -- creates an open spline with arrows compview=polygon(x0,y0[,x1,y1,...]) -- creates a polygon compview=closedspline(x0,y0[,x1,y1,...]) -- creates a closed spline compview=raster(x0,x1,y0,y1) -- creates an empty raster xylist=center(compview :xy :yx :x :y :scrn) -- returns the center of a compview (default is :xy) rectlist=mbr(compview :lbrt :lrbt :scrn) -- returns the minimum bounding rectangle of acompview (default is :lbrt) ptlist=points(compview :scrn) -- returns the point list from a compview graphic font(fontnum) -- sets the current font from the menu brush(brushnum) -- sets the current brush from menu pattern(patternnum) -- sets the current pattern from menu colors(fgcolornum bgcolornum) -- sets current fore ground and background colors from menu nfonts() -- returns the size of font menu nbrushes() -- returns the size of brush menu npatterns() -- returns the size of pattern menu ncolors() -- returns the size of color menus select([compview ...] :all :clear) -- makes the listed graphics the current selection delete(compview [compview ...]) -- deletes the graphic(s) move(dx dy) -- moves to the current selection scale(xflt yflt) -- scales the current selection rotate(degflt) -- rotates the current selection newgroup=growgroup(groupview compview) -- adds graphic to an existing group graphic newgroup=trimgroup(groupview compview) -- removes graphic from an existing group graphic compview=setattr(compview [:keyword value [:keyword value [...]]]) -- sets attributes of a graphic component attrlist(compview) -- returns attribute list of a component compview=frame([index]) -- returns composite component for a frame, defaults to current val=at(list|attrlist|compview n :set val) -- returns (or set) the nth item in a list. num=size(list|attrlist|compview) -- returns size of a list. update() -- updates the viewer error=save([pathstr]) -- saves the document (to the pathname) compview=import(pathstr :popen :next) -- imports graphic file from pathname or URL, or from a command if :popen (:next imports next in numeric series) export(compview[,compview[,...compview]] [path] :host host_str :port port_int :socket :string|:str :eps :idraw) -- exports a graphic file from pathname or URL, or from a command compview=paste(compview [xscale yscale xoff yoff | a00,a01,a10,a11,a20,a21]) -- pastes a graphic into the viewer val=pastemode([val] :get) -- toggles or set paste mode, default is 0, always pastes new graphics compview=addtool(pathname) -- adds button to toolbar based on zero-centered idraw drawing. ncols() -- onscreen horizontal extent in pixels nrows() -- onscreen vertical extent in pixels dx,dy=stod(sx,sy) -- converts from screen to drawing coordinates sx,sy=dtos(dx,dy) -- converts from drawing to screen coordinates dx,dy=gtod(compview gx,gy) -- converts from graphic to drawing coordinates gx,gy=dtog(compview dx,dy) -- converts from drawing to graphic coordinates handles(flag) -- enable/disable current selection tic marks and/or highlighting highlight(compview compviewgs) -- set the highlight graphic state for a graphic zoom(zoomflt) -- zoom by factor zoomin() -- zoom-in by 2 zoomout() -- zoom-out by 2 pan(px py) -- pan viewer smallpanup() -- small pan up smallpandown() -- small pan down smallpanleft() -- small pan left smallpanright() - small pan right largepanup() -- large pan up largepandown() -- large pan down largepanleft() -- large pan left largepanright() -- large pan right tilefile(inpath outpath [xsize] [ysiz]) -- tiles pgm or ppm image file poke(compview x y val) -- pokes pixel value into raster pcols(compview) -- returns number of columns in a raster pcols(compview) -- returns number of rows in a raster pflush(compview) -- flushes pixels poked into a raster pclip(compview x1,y1,x2,y2,x3,y3[,...,xn,yn]) -- clips raster with polygon alpha(compview [alphaval]) -- sets/gets alpha transparency -- requires plotmtv and pstoedit -- barplot([var_str value_float] [...] :title title_str :xtitle xtitle_str :ytitle ytitle_str :valtitle valtitle_str :newview) -- displays a barplot run(filename) -- runs commands from file quit() -- quits this interpreter exit() -- exits entire application pause([msgstr]) -- pauses script execution until C/R
3.16.13.4. Internals |
3.16.13.5. Differences in the Patched Version of comdraw |