{PLOTTER.INC--what it takes to set up a frame and plot data into it. Written for floating point data. Copyright 1984 by N.T.Carnevale. Permission granted for nonprofit use.} (*This file must be included after PCP, APLGR/G and APLGR/H. The following types (and corresponding variables) must be defined in the main file before PLOTTER is included: TYPE realdata=RECORD x,y:real; {x&y world coordinates, that is, "real data"} END; screendata=RECORD x,y:integer; {x&y display coordinates} END; realscalefactors=RECORD mx,my,bx,by:real; {used to map world into display} END; PLOTTER contains the following procedures: setframe--sets up the coefficients ("magnifications" and "shifts") that are used to transform or map "real data" to the display. Parameters are: lowerleft,upperright:realdata--the opposite corners of a rectangular area that contains the range of "real data" to be plotted ("corners of the real world"). frameloc:screendata--left upper corner of area on the screen where the data is to go (where to put the picture). framesize:screendata--dimensions of the area on the screen where the data is to go (how big to make the picture). VAR frame:realscalefactors--this record contains the coefficients (calculated by setframe) that will be used by other procedures to map "real data" to the display. plot--draws a point on the hires page using specified scale factors. Parameters are: point:realdata--x,y coordinates of the point in the "real world." frame:scalefactors--the coefficients used to map the point onto the display. plotline--starting from present cursor location, draws a line to the point on the screen that corresponds to a specified endpoint in the "real world," using specified scale factors. Parameters are: endpoint:realdata--x,y coordinates of the end of the line in the "real world." frame:scalefactors--the coefficients used to map the point onto the display. Procedures not in this file that would be nice to have: --"moveto" a specific location without drawing a point (unlike plot, which moves the cursor to a point and draws a point there) --"relative" cursor moves (plot and plotline put the cursor at a specific or "absolute" location on the display --true clipping, so that, if one or both endpoints of a line lies outside the defined frame, only the portion of it that is within the frame will be drawn --a circle drawing procedure *) {sets up the scale factors used by the plot routines} PROCEDURE setframe (lowerleft, upperright:realdata; {data limits} frameloc:screendata; {left upper corner of display area} framesize:screendata; {dimensions of display area} VAR frame:realscalefactors {calculated by setframe} ); BEGIN WITH frame DO BEGIN mx:=(framesize.x-1)/(upperright.x-lowerleft.x); bx:=frameloc.x-mx*lowerleft.x; my:=(framesize.y-1)/(lowerleft.y-upperright.y); {note: Apple's screen is "upside-down"} by:=frameloc.y-my*upperright.y; END; END; {put cursor and plot a point at a specified location} PROCEDURE plot(point:realdata; frame:realscalefactors); VAR h,v:integer; {actual display coords} BEGIN WITH frame DO BEGIN h:=round(mx*point.x+bx); v:=round(my*point.y+by); hplot(h,v); END; END; {draw a line from present cursor location to specified endpoint} PROCEDURE plotline(endpoint:realdata; frame:realscalefactors); VAR h,v:integer; {actual display coords} BEGIN WITH frame DO BEGIN h:=round(mx*endpoint.x+bx); v:=round(my*endpoint.y+by); hline(h,v); END; END; {end of PLOTTER.INC}