ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

AuxLibExtra Quick Reference
AuxLibE_Logo
CAModBase   CAMonit   CellAutoOut   DMDebugHelp   DMHeapWatch   DMQuickDraw   Make   MatAri   MatEditor   MatInterpol   MatReshape   MatSclOps   MatVecOps   MatWOut  
                      RAMSES Extra Auxiliary Library Modules

   Copyright (c) 1986-2006 by Olivier Roth, Andreas Fischlin, Thomas Nemecek,
   Klara Vancso, Juerg Thoeny and ETH Zurich.

   mailto://RAMSES@env.ethz.ch                      http://www.sysecol.ethz.ch/

   (*************************************************************************)
   (*#####   S Y S T E M   E C O L O G Y   E X T R A   M O D U L E S   #####*)
   (*************************************************************************)

   The following modules are maintained by the Systems Ecology Group of the
   Institute of Integrative Biology, ETH Zurich, Switzerland.
   All rights reserved.

   The authors reserve the right to make changes, additions, and improvements
   to the software or documentation at any time without notice to any person or
   organization; no guarantee is made that further versions of either will be
   compatible with any  other version.

   The authors hereby disclaim any and all guarantees and warranties on the
   software or its documentation, both expressed or implied.  No liability
   of any form shall be assumed by the authors.  Any user of this sofware uses
   it at his or her own risk and no fitness for any purpose whatsoever nor
   waranty of merchantability are claimed or implied.


(*============================     CAModBase     ==============================*)

  CONST maxLen=8000;

  TYPE CAMod;
    CAArC   = POINTER TO RowC;
    CAArD   = POINTER TO RowD;
    ColCPtr = POINTER TO ColC;
    ColDPtr = POINTER TO ColD;

    RowC= ARRAY[1.. maxLen] OF ColCPtr;
    RowD= ARRAY[1.. maxLen] OF ColDPtr;
    ColC= ARRAY[1.. maxLen] OF REAL;
    ColD= ARRAY[1.. maxLen] OF INTEGER;

    UpdateMode=( withNewState, withStateChange, noUpdate );
    StateType= ( continuous, discrete );

    CellProc      = PROCEDURE( CAMod, INTEGER, INTEGER );
    ConditionProc = PROCEDURE( CAMod, INTEGER, INTEGER ): BOOLEAN;
    MappingProc   = PROCEDURE( CAMod, REAL ): INTEGER;
    RemoveProc    = PROCEDURE( CAMod ); CAModProc= PROCEDURE( CAMod );

  VAR nonexistentCAMod: CAMod; (* read only *)

  (* CA management *)
  PROCEDURE DeclCAMod( VAR caMod: CAMod; stateType: StateType;
                           x, y, minState, maxState: INTEGER;    mode: UpdateMode );
  PROCEDURE GetStatePtrsC( caMod: CAMod; VAR stateC, updStateC: CAArC );
  PROCEDURE GetStatePtrsD( caMod: CAMod; VAR stateD, updStateD: CAArD );
  PROCEDURE GetCASpecs(    caMod: CAMod; VAR stateType: StateType;
                       VAR x, y, minState, maxState: INTEGER; VAR mode: UpdateMode );
  PROCEDURE RemoveCAMod( VAR caMod: CAMod );
  PROCEDURE AddRemoveProc( caMod: CAMod; rp: RemoveProc );
  PROCEDURE DeleteRemoveProc( caMod: CAMod; rp: RemoveProc );
  PROCEDURE CAExists( caMod: CAMod ): BOOLEAN;

  (* Cell state *)
  PROCEDURE SetCellC( caMod: CAMod; x, y: INTEGER; state: REAL );
  PROCEDURE GetCellC( caMod: CAMod; x, y: INTEGER; VAR state: REAL );
  PROCEDURE CellC( caMod: CAMod; x, y: INTEGER ): REAL; (* for easy access *)
  PROCEDURE SetUpdCellC( caMod: CAMod; x, y: CARDINAL; updateSt: REAL );
  PROCEDURE GetUpdCellC( caMod: CAMod; x, y: CARDINAL; VAR updateSt: REAL );
  PROCEDURE SetCellD( caMod: CAMod; x, y: INTEGER; state: INTEGER );
  PROCEDURE GetCellD( caMod: CAMod; x, y: INTEGER; VAR state: INTEGER );
  PROCEDURE CellD( caMod: CAMod; x, y: INTEGER ): INTEGER; (* for easy access *)
  PROCEDURE SetUpdCellD( caMod: CAMod; x, y: CARDINAL; updateSt: INTEGER );
  PROCEDURE GetUpdCellD( caMod: CAMod; x, y: CARDINAL; VAR updateSt: INTEGER );

  (* CA state *)
  PROCEDURE InitCAState( caMod: CAMod; VAR f: TextFile ); (* not yet implemented *)
  PROCEDURE FillCAModC( caMod: CAMod; val: REAL );
  PROCEDURE FillCAModD( caMod: CAMod; val: INTEGER );
  PROCEDURE UpdateCAState( caMod: CAMod );
  PROCEDURE ResetCAUpdateState( caMod: CAMod );

  (* statistics *)
  PROCEDURE CAFrequencies( caMod: CAMod; VAR nInState: ARRAY OF LONGINT;
                           VAR propInState: ARRAY OF REAL; useStatsCond: BOOLEAN );
  PROCEDURE CAMean( caMod: CAMod; VAR mean: REAL; useStatsCond: BOOLEAN );
  PROCEDURE SetStatsCond( caMod: CAMod; scp: ConditionProc );
  PROCEDURE GetStatsCond( caMod: CAMod; VAR scp: ConditionProc );
  PROCEDURE SetMappingProc( caMod: CAMod; mp: MappingProc );
  PROCEDURE GetMappingProc( caMod: CAMod; VAR mp: MappingProc );

  (* auxiliary *)
  PROCEDURE SetIndexCheckMode( doCheck: BOOLEAN );
  PROCEDURE GetIndexCheckMode( VAR doCheck: BOOLEAN );
  PROCEDURE DoForAllCells( caMod: CAMod; p: CellProc; useStatsCond: BOOLEAN );
  PROCEDURE DoForAllCAMods( cp: CAModProc );

(*=============================     CAMonit     ===============================*)

  TYPE Str255= ARRAY[0..255] OF CHAR; Str63= ARRAY[0..63] OF CHAR;

  (* Management of CA monitoring *)
  PROCEDURE DeclCAMonit( caMod: CAMod; title, subTitle: Str255 );
  PROCEDURE GetCAMonit( caMod: CAMod; VAR title, subTitle: Str255 );
  PROCEDURE RemoveCAMonit( caMod: CAMod );
  PROCEDURE CAMonitDeclared( caMod: CAMod ): BOOLEAN;

  (* Management of CA display *)
  PROCEDURE InitCADisplay( caMod: CAMod; w: Window; caArea, legendArea: RectArea; withLines: BOOLEAN );
  PROCEDURE TermCADisplay( caMod: CAMod );
  PROCEDURE SetCALegendDescrs( caMod: CAMod; legendDescrs: ARRAY OF Str63 );
  PROCEDURE GetCALegendDescrs( caMod: CAMod; VAR legendDescrs: ARRAY OF Str63 );
  PROCEDURE SetDisplayAttr( caMod: CAMod;     colors: ARRAY OF Color;
                                patterns: ARRAY OF Pattern;     symbols: ARRAY OF CHAR );
  PROCEDURE GetDisplayAttr( caMod: CAMod; VAR colors: ARRAY OF Color;
                            VAR patterns: ARRAY OF Pattern; VAR symbols: ARRAY OF CHAR );
  PROCEDURE DisplayCA( caMod: CAMod; time: REAL );
  PROCEDURE DisplayCell( caMod: CAMod; x, y: INTEGER; time: REAL );
  PROCEDURE DisplayLegend( caMod: CAMod );	PROCEDURE SetTimeDisplay( dispT: BOOLEAN );
  PROCEDURE GetTimeDisplay( VAR dispT: BOOLEAN ); (* default is TRUE *)

  (* File output *)
  PROCEDURE DumpCA( caMod: CAMod; VAR f: TextFile; time: REAL; writeLegend, useStatsCond: BOOLEAN );

(*============================   CellAutoOut   ================================*)

  TYPE CellAutoID; Symbol = CHAR; UnderlayMode = (underlayWhite, dontUnderlay );
  CellProcess = PROCEDURE (INTEGER, INTEGER );

  VAR notExistingCA: CellAutoID;

  PROCEDURE DeclCellOutput( VAR caID: CellAutoID; VAR outWindow: Window; plotFrame: RectArea;
                                numbX, numbY: INTEGER; withGridLines: BOOLEAN );
  PROCEDURE RemoveCellOutput( VAR caID: CellAutoID );
  PROCEDURE RemoveAllCellOutputs;
  PROCEDURE CellOutputExists( caID: CellAutoID ): BOOLEAN;
  PROCEDURE SelectCellOutput( caID: CellAutoID );
  PROCEDURE GetCurCellOutput( VAR caID: CellAutoID );
  PROCEDURE ClearCell( x,y: INTEGER );
  PROCEDURE FillCell( x,y: INTEGER; pattern: Pattern; col: Color );
  PROCEDURE DrawInCell( x, y: INTEGER; sym: Symbol; underlay: UnderlayMode );
  PROCEDURE DoForAllCells( doCellProc: CellProcess );
  PROCEDURE CalcCellArea( x,y: INTEGER ): RectArea;
  PROCEDURE CalcCellMiddle( x, y: INTEGER; VAR xCoord,yCoord: INTEGER );
  PROCEDURE GetPlotFrame( caID: CellAutoID ): RectArea;

(*===========================     DMDebugHelp     =============================*)

  PROCEDURE CopyString( from: ARRAY OF CHAR; i1: INTEGER; VAR to: ARRAY OF CHAR; VAR i2: INTEGER );
  PROCEDURE IntToString( x: LONGINT; VAR str: ARRAY OF CHAR; n: CARDINAL );

  PROCEDURE Write( ch: CHAR );
  PROCEDURE WriteString( s: ARRAY OF CHAR );
  PROCEDURE WriteLn;
  PROCEDURE WriteInt( x: LONGINT; n: CARDINAL );
  PROCEDURE WriteDataStructure( VAR x: ARRAY OF SYSTEM. BYTE; b: BOOLEAN; li: LONGINT; msg: ARRAY OF CHAR );

  PROCEDURE MessageWindow( x, y, w, h: INTEGER; p: PROC );

  PROCEDURE StartReportOnFile( fileName, msg: ARRAY OF CHAR );
  PROCEDURE CloseReportFile( msg: ARRAY OF CHAR ); (* stop writing to file *)

  PROCEDURE GetModuleIdent( moduleID: INTEGER; VAR modId: ARRAY OF CHAR );

  VAR lastModuleID: ARRAY [0..31] OF CHAR;
  PROCEDURE Message( s1, s2: ARRAY OF CHAR );

(*===========================     DMHeapWatch     =============================*)

  CONST maxBlocks = 15;
  TYPE
    AllocInfo = PROCEDURE( ADDRESS, ADDRESS, LONGINT, INTEGER ); (* pBefore, pAfter,  size, level *)
    DeallocInfo = PROCEDURE( ADDRESS, ADDRESS, INTEGER ); (* pBefore, pAfter,  level *)

  VAR
    ptrCount, handleCount, windowCount, TECount, controlCount, menuCount, dialogCount: INTEGER;
    blockSizes: ARRAY [0..maxBlocks] OF LONGINT;
    debugProc: PROCEDURE( ARRAY OF CHAR, INTEGER, LONGINT ); (* callee, level, size *)
    showLevels: PROCEDURE( ARRAY OF CHAR, INTEGER, LONGINT ); (* callee, level, size *)
    allocInfoProc: AllocInfo;
    deallocInfoProc: DeallocInfo;
    clearBlockAtAlloc: BOOLEAN;

(*===========================     DMQuickDraw     =============================*)

  CONST  (* the 16 transfer modes *)
    srcCopy = 0; srcOr = 1; srcXor = 2; srcBic = 3; notSrcCopy = 4; notSrcOr = 5;
    notSrcXor = 6; notSrcBic = 7; patCopy = 8; patOr = 9; patXor = 10;
    patBic = 11; notPatCopy = 12; notPatOr = 13; notPatXor = 14; notPatBic = 15;

  CONST (* QuickDraw color separation constants *)
    normalBit = 0; inverseBit = 1; redBit = 4; greenBit = 3; blueBit = 2; cyanBit = 8;
    magentaBit = 7; yellowBit = 6; blackBit = 5;
    blackColor = 33D; whiteColor = 30D; redColor = 205D; greenColor = 341D;
    blueColor = 409D; cyanColor = 273D; magentaColor = 137D; yellowColor = 69D;
    picLParen = 0; picRParen = 1;

  TYPE
    QDByte      = SignedByte;
    QDPtr       = Ptr; (* blind pointer *)
    QDHandle    = Handle; (* blind handle *)
    Pattern     = ARRAY [0..7] OF BYTE; Bits16   = ARRAY [0..15] OF INTEGER;
    VHSelect    = ( v, h );
    VHSelectR   = [v..h];
    GrafVerb    = ( frame, paint, erase, invert, fill );
    StyleItem   = ( bold, italic, underline, outline, shadow, condense, extend );
    Style       = SET OF StyleItem;
    FontInfo    = RECORD
                    ascent: INTEGER; descent: INTEGER; widMax: INTEGER; leading: INTEGER;
                  END;
    Point       = RECORD
                    CASE: INTEGER OF
                     0: v: INTEGER; h: INTEGER;
                    |1: vh: ARRAY VHSelectR OF INTEGER;
                    END;
                  END;
    Rect        = RECORD
                    CASE :INTEGER OF
                      0: top: INTEGER; left: INTEGER; bottom: INTEGER; right: INTEGER;
                    | 1: topLeft: Point; botRight: Point;
                    END;
                  END;
     BitMap     = RECORD baseAddr: Ptr; rowBytes: INTEGER; bounds: Rect; END;
     Cursor     = RECORD data: Bits16; mask: Bits16; hotSpot: Point; END;
     PenState   = RECORD pnLoc: Point; pnSize: Point; pnMode: INTEGER; pnPat: Pattern; END;
     PolyHandle = POINTER TO PolyPtr;
     PolyPtr    = POINTER TO Polygon;
     Polygon    = RECORD polySize: INTEGER; polyBBox: Rect; polyPoints: ARRAY[0..0] OF Point; END;
     RgnHandle  = POINTER TO RgnPtr;
     RgnPtr     = POINTER TO Region;
     Region     =  RECORD rgnSize: INTEGER; rgnBBox: Rect; END;
     PicHandle  = POINTER TO PicPtr;
     PicPtr     = POINTER TO Picture;
     Picture    =  RECORD picSize: INTEGER; picFrame: Rect; END;
     QDProcsPtr = POINTER TO QDProcs;
     QDProcs    = RECORD
                   textProc: Ptr; lineProc: Ptr; rectProc: Ptr; rRectProc: Ptr; ovalProc: Ptr;
                   arcProc: Ptr; polyProc: Ptr; rgnProc: Ptr; bitsProc: Ptr; commentProc: Ptr;
                   txMeasProc: Ptr; getPicProc: Ptr; putPicProc: Ptr;
                 END;
     GrafPtr   = POINTER TO GrafPort;
     GrafPort  = RECORD
                   device: INTEGER; portBits: BitMap; portRect: Rect; visRgn: RgnHandle; clipRgn: RgnHandle;
                   bkPat: Pattern; fillPat: Pattern; pnLoc: Point; pnSize: Point; pnMode: INTEGER;
                   pnPat: Pattern; pnVis: INTEGER; txFont: INTEGER; txFace: Style; txMode: INTEGER;
                   txSize: INTEGER; spExtra: LONGINT; fgColor: LONGINT; bkColor: LONGINT; colrBit: INTEGER;
                   patStretch: INTEGER; picSave: Handle; rgnSave: Handle; polySave: Handle;
                   grafProcs: QDProcsPtr;
                END;
     FMOutPtr = POINTER TO FMOutRec;
     FMOutRec = RECORD
                  errNum: INTEGER; fontHandle: QDHandle; bold: Byte; italic: Byte; ulOffset: Byte;
                  ulShadow: Byte; ulThick: Byte; shadow: Byte; extra: SignedByte; ascent: Byte; descent: Byte;
                  widMax: Byte; leading: SignedByte; unused: Byte; numer: Point; denom: Point;
                END;

  VAR (* Private QuickDraw variables *)
    fontData: FMOutRec; fontPtr: FMOutPtr; fontAdj: LONGINT; patAlign: Point; polyMax: INTEGER;
    thePoly: PolyHandle; playIndex: INTEGER; playPic: PicHandle; rgnMax: INTEGER; rgnIndex: INTEGER;
    rgnBuf: QDHandle; wideData: Region; wideMaster: RgnPtr; wideOpen: RgnHandle;
    (* Public QuickDraw variables *)
     randSeed: LONGINT; screenBits: BitMap; arrow: Cursor; dkGray: Pattern; ltGray: Pattern;
     gray: Pattern; black: Pattern; white: Pattern; thePort: GrafPtr;

  TYPE
    QDGlobals = RECORD
                  randSeed: LONGINT; screenBits: BitMap; arrow: Cursor; dkGray: Pattern;
                  ltGray: Pattern; gray: Pattern; black: Pattern; white: Pattern; thePort: GrafPtr;
               END;
     QDGlobalsPtr = POINTER TO QDGlobals;

  VAR QDGPtr: QDGlobalsPtr;

  (* String conversion routines *)
  PROCEDURE ArrToStr( VAR modula2Str, macPascalStr: ARRAY OF CHAR );
  PROCEDURE StrToArr( VAR macPascalStr, modula2Str: ARRAY OF CHAR );

  (* GrafPort Routines *)
  PROCEDURE InitGraf( globalPtr: Ptr ); CODE0 A86EH;
  PROCEDURE OpenPort( port: GrafPtr ); CODE0 A86FH;
  PROCEDURE InitPort( port: GrafPtr ); CODE0 A86DH;
  PROCEDURE ClosePort( port: GrafPtr ); CODE0 A87DH;
  PROCEDURE SetPort( port: GrafPtr ); CODE0 A873H;
  PROCEDURE GetPort( VAR port: GrafPtr ); CODE0 A874H;
  PROCEDURE GrafDevice( device: INTEGER ); CODE0 A872H;
  PROCEDURE SetPortBits( VAR bm: BitMap ); CODE0 A875H;
  PROCEDURE PortSize( width, height: INTEGER ); CODE0 A876H;
  PROCEDURE MovePortTo( leftGlobal, topGlobal: INTEGER ); CODE0 A877H;
  PROCEDURE SetOrigin( h, v: INTEGER ); CODE0 A878H;
  PROCEDURE SetClip( rgn: RgnHandle ); CODE0 A879H;
  PROCEDURE GetClip( rgn: RgnHandle ); CODE0 A87AH;
  PROCEDURE ClipRect( VAR r: Rect ); CODE0 A87BH;
  PROCEDURE BackPat( VAR pat: Pattern ); CODE0 A87CH;

  (* Cursor Routines *)
  PROCEDURE InitCursor; CODE0 A850H;
  PROCEDURE SetCursor( VAR crsr: Cursor ); CODE0 A851H;
  PROCEDURE HideCursor; CODE0 A852H;
  PROCEDURE ShowCursor; CODE0 A853H;
  PROCEDURE ObscureCursor; CODE0 A856H;

  (* Line Routines *)
  PROCEDURE HidePen; CODE0 A896H;
  PROCEDURE ShowPen; CODE0 A897H;
  PROCEDURE GetPen( VAR pt: Point ); CODE0 A89AH;
  PROCEDURE GetPenState( VAR pnState: PenState ); CODE0 A898H;
  PROCEDURE SetPenState( VAR pnState: PenState ); CODE0 A899H;
  PROCEDURE PenSize( width, height: INTEGER ); CODE0 A89BH;
  PROCEDURE PenMode( mode: INTEGER ); CODE0 A89CH;
  PROCEDURE PenPat( VAR pat: Pattern ); CODE0 A89DH;
  PROCEDURE PenNormal; CODE0 A89EH;
  PROCEDURE MoveTo( h, v: INTEGER ); CODE0 A893H;
  PROCEDURE Move( dh, dv: INTEGER ); CODE0 A894H;
  PROCEDURE LineTo( h, v: INTEGER ); CODE0 A891H;
  PROCEDURE Line( dh, dv: INTEGER ); CODE0 A892H;

  (* Text Routines *)
  PROCEDURE TextFont( font: INTEGER ); CODE0 A887H;
  PROCEDURE TextFace( face: Style ); CODE0 A888H;
  PROCEDURE TextMode( mode: INTEGER ); CODE0 A889H;
  PROCEDURE TextSize( size: INTEGER ); CODE0 A88AH;
  PROCEDURE SpaceExtra( extra: Fixed ); CODE0 A88EH;
  PROCEDURE ToolboxDrawChar( ordCh: INTEGER ); CODE0 A883H;
  PROCEDURE ToolboxDrawString( VAR theString: Str255 ); CODE0 A884H;
  PROCEDURE DrawText( textBuf: Ptr; firstByte, byteCount: INTEGER ); CODE0 A885H;
  PROCEDURE ToolboxCharWidth( ordCh: INTEGER ): INTEGER; CODE0 A88DH;
  PROCEDURE ToolboxStringWidth( VAR theString: Str255 ): INTEGER; CODE0 A88CH;
  PROCEDURE TextWidth( textBuf: Ptr; firstByte, byteCount: INTEGER ): INTEGER; CODE0 A886H;
  PROCEDURE GetFontInfo( VAR info: FontInfo ); CODE0 A88BH;

  (* Point Calculations *)
  PROCEDURE AddPt( src: Point; VAR dst: Point ); CODE0 A87EH;
  PROCEDURE SubPt( src: Point; VAR dst: Point ); CODE0 A87FH;
  PROCEDURE SetPt( VAR pt: Point; h, v: INTEGER ); CODE0 A880H;
  PROCEDURE EqualPt( pt1, pt2: Point ): BOOLEAN; CODE0 A881H;
  PROCEDURE ScalePt( VAR pt: Point; VAR fromRect, toRect: Rect ); CODE0 A8F8H;
  PROCEDURE MapPt( VAR pt: Point; VAR fromRect, toRect: Rect ); CODE0 A8F9H;
  PROCEDURE LocalToGlobal( VAR pt: Point ); CODE0 A870H;
  PROCEDURE GlobalToLocal( VAR pt: Point ); CODE0 A871H;

  (* Rectangle Calculations *)
  PROCEDURE SetRect( VAR r: Rect; left, top, right, bottom: INTEGER ); CODE0 A8A7H;
  PROCEDURE EqualRect( VAR rect1, rect2: Rect ): BOOLEAN; CODE0 A8A6H;
  PROCEDURE EmptyRect( VAR r: Rect ): BOOLEAN; CODE0 A8AEH;
  PROCEDURE OffsetRect( VAR r: Rect; dh, dv: INTEGER ); CODE0 A8A8H;
  PROCEDURE MapRect( VAR r: Rect; VAR fromRect, toRect: Rect ); CODE0 A8FAH;
  PROCEDURE InsetRect( VAR r: Rect; dh, dv: INTEGER ); CODE0 A8A9H;
  PROCEDURE SectRect( VAR src1, src2: Rect; VAR dstRect: Rect ): BOOLEAN; CODE0 A8AAH;
  PROCEDURE UnionRect( VAR src1, src2: Rect; VAR dstRect: Rect ); CODE0 A8ABH;
  PROCEDURE PtInRect( pt: Point; VAR r: Rect ): BOOLEAN; CODE0 A8ADH;
  PROCEDURE Pt2Rect( pt1, pt2: Point; VAR dstRect: Rect ); CODE0 A8ACH;
  PROCEDURE FrameRect( VAR r: Rect ); CODE0 A8A1H;
  PROCEDURE PaintRect( VAR r: Rect ); CODE0 A8A2H;
  PROCEDURE EraseRect( VAR r: Rect ); CODE0 A8A3H;
  PROCEDURE InvertRect( VAR r: Rect ); CODE0 A8A4H;
  PROCEDURE FillRect( VAR r: Rect; VAR pat: Pattern ); CODE0 A8A5H;

  (* RoundRect Routines *)
  PROCEDURE FrameRoundRect( VAR r: Rect; ovWd, ovHt: INTEGER ); CODE0 A8B0H;
  PROCEDURE PaintRoundRect( VAR r: Rect; ovWd, ovHt: INTEGER ); CODE0 A8B1H;
  PROCEDURE EraseRoundRect( VAR r: Rect; ovWd, ovHt: INTEGER ); CODE0 A8B2H;
  PROCEDURE InvertRoundRect( VAR r: Rect; ovWd, ovHt: INTEGER ); CODE0 A8B3H;
  PROCEDURE FillRoundRect( VAR r: Rect; ovWd, ovHt: INTEGER; VAR pat: Pattern ); CODE0 A8B4H;

  (* Oval Routines *)
  PROCEDURE FrameOval( VAR r: Rect ); CODE0 A8B7H;
  PROCEDURE PaintOval( VAR r: Rect ); CODE0 A8B8H;
  PROCEDURE EraseOval( VAR r: Rect ); CODE0 A8B9H;
  PROCEDURE InvertOval( VAR r: Rect ); CODE0 A8BAH;
  PROCEDURE FillOval( VAR r: Rect; VAR pat: Pattern ); CODE0 A8BBH;

  (* Arc Routines *)
  PROCEDURE FrameArc( VAR r: Rect; startAngle, arcAngle: INTEGER ); CODE0 A8BEH;
  PROCEDURE PaintArc( VAR r: Rect; startAngle, arcAngle: INTEGER ); CODE0 A8BFH;
  PROCEDURE EraseArc( VAR r: Rect; startAngle, arcAngle: INTEGER ); CODE0 A8C0H;
  PROCEDURE InvertArc( VAR r: Rect; startAngle, arcAngle: INTEGER ); CODE0 A8C1H;
  PROCEDURE FillArc( VAR r: Rect; startAngle, arcAngle: INTEGER; VAR pat: Pattern ); CODE0 A8C2H;
  PROCEDURE PtToAngle( VAR r: Rect; pt: Point; VAR angle: INTEGER ); CODE0 A8C3H;

  (* Polygon Routines *)
  PROCEDURE OpenPoly( ): PolyHandle; CODE0 A8CBH;
  PROCEDURE ClosePoly; CODE0 A8CCH;
  PROCEDURE KillPoly( poly: PolyHandle ); CODE0 A8CDH;
  PROCEDURE OffsetPoly( poly: PolyHandle; dh, dv: INTEGER ); CODE0 A8CEH;
  PROCEDURE MapPoly( poly: PolyHandle; VAR fromRect, toRect: Rect ); CODE0 A8FCH;
  PROCEDURE FramePoly( poly: PolyHandle ); CODE0 A8C6H;
  PROCEDURE PaintPoly( poly: PolyHandle ); CODE0 A8C7H;
  PROCEDURE ErasePoly( poly: PolyHandle ); CODE0 A8C8H;
  PROCEDURE InvertPoly( poly: PolyHandle ); CODE0 A8C9H;
  PROCEDURE FillPoly( poly: PolyHandle; VAR pat: Pattern ); CODE0 A8CAH;

  (* Region Calculations *)
  PROCEDURE NewRgn( ): RgnHandle; CODE0 A8D8H;
  PROCEDURE DisposeRgn( rgn: RgnHandle ); CODE0 A8D9H;
  PROCEDURE CopyRgn( srcRgn, dstRgn: RgnHandle ); CODE0 A8DCH;
  PROCEDURE SetEmptyRgn( rgn: RgnHandle ); CODE0 A8DDH;
  PROCEDURE SetRectRgn( rgn: RgnHandle; left, top, right, bottom: INTEGER ); CODE0 A8DEH;
  PROCEDURE RectRgn( rgn: RgnHandle; VAR r: Rect ); CODE0 A8DFH;
  PROCEDURE OpenRgn; CODE0 A8DAH;
  PROCEDURE CloseRgn( dstRgn: RgnHandle ); CODE0 A8DBH;
  PROCEDURE OffsetRgn( rgn: RgnHandle; dh, dv: INTEGER ); CODE0 A8E0H;
  PROCEDURE MapRgn( rgn: RgnHandle; VAR fromRect, toRect: Rect ); CODE0 A8FBH;
  PROCEDURE InsetRgn( rgn: RgnHandle; dh, dv: INTEGER ); CODE0 A8E1H;
  PROCEDURE SectRgn( srcRgnA, srcRgnB, dstRgn: RgnHandle ); CODE0 A8E4H;
  PROCEDURE UnionRgn( srcRgnA, srcRgnB, dstRgn: RgnHandle ); CODE0 A8E5H;
  PROCEDURE DiffRgn( srcRgnA, srcRgnB, dstRgn: RgnHandle ); CODE0 A8E6H;
  PROCEDURE XorRgn( srcRgnA, srcRgnB, dstRgn: RgnHandle ); CODE0 A8E7H;
  PROCEDURE EqualRgn( rgnA, rgnB: RgnHandle ): BOOLEAN; CODE0 A8E3H;
  PROCEDURE EmptyRgn( rgn: RgnHandle ): BOOLEAN; CODE0 A8E2H;
  PROCEDURE PtInRgn( pt: Point; rgn: RgnHandle ): BOOLEAN; CODE0 A8E8H;
  PROCEDURE RectInRgn( VAR r: Rect; rgn: RgnHandle ): BOOLEAN; CODE0 A8E9H;

  (* Graphical Operations on Regions *)
  PROCEDURE FrameRgn( rgn: RgnHandle ); CODE0 A8D2H;
  PROCEDURE PaintRgn( rgn: RgnHandle ); CODE0 A8D3H;
  PROCEDURE EraseRgn( rgn: RgnHandle ); CODE0 A8D4H;
  PROCEDURE InvertRgn( rgn: RgnHandle ); CODE0 A8D5H;
  PROCEDURE FillRgn( rgn: RgnHandle; VAR pat: Pattern ); CODE0 A8D6H;

 (* Graphical Operations on BitMaps *)
  PROCEDURE ScrollRect( VAR dstRect: Rect; dh, dv: INTEGER; updateRgn: RgnHandle ); CODE0 A8EFH;
  PROCEDURE CopyBits( VAR srcBits, dstBits: BitMap; VAR srcRect, dstRect: Rect;
                      mode: INTEGER; maskRgn: RgnHandle ); CODE0 A8ECH;

  (* Picture Routines *)
  PROCEDURE OpenPicture( VAR picFrame: Rect ): PicHandle; CODE0 A8F3H;
  PROCEDURE ClosePicture; CODE0 A8F4H;
  PROCEDURE DrawPicture( myPicture: PicHandle; VAR dstRect: Rect ); CODE0 A8F6H;
  PROCEDURE PicComment( kind, dataSize: INTEGER; dataHandle: Handle ); CODE0 A8F2H;
  PROCEDURE KillPicture( myPicture: PicHandle ); CODE0 A8F5H;

  (* The Bottleneck Interface: *)
  PROCEDURE SetStdProcs( VAR procs: QDProcs ); CODE0 A8EAH;
  PROCEDURE StdText( count: INTEGER; textAddr: Ptr; numer, denom: Point ); CODE0 A882H;
  PROCEDURE StdLine( newPt: Point ); CODE0 A890H;
  PROCEDURE StdRect( verb: GrafVerb; VAR r: Rect ); CODE0 A8A0H;
  PROCEDURE StdRRect( verb: GrafVerb; VAR r: Rect; ovWd, ovHt: INTEGER ); CODE0 A8AFH;
  PROCEDURE StdOval( verb: GrafVerb; VAR r: Rect ); CODE0 A8B6H;
  PROCEDURE StdArc( verb: GrafVerb; VAR r: Rect; startAngle, arcAngle: INTEGER ); CODE0 A8BDH;
  PROCEDURE StdPoly( verb: GrafVerb; poly: PolyHandle ); CODE0 A8C5H;
  PROCEDURE StdRgn( verb: GrafVerb; rgn: RgnHandle ); CODE0 A8D1H;
  PROCEDURE StdBits( VAR srcBits: BitMap; VAR srcRect, dstRect: Rect; mode: INTEGER; maskRgn: RgnHandle ); CODE0 A8EBH;
  PROCEDURE StdComment( kind, dataSize: INTEGER; dataHandle: Handle ); CODE0 A8F1H;
  PROCEDURE StdTxMeas( count: INTEGER; textAddr: Ptr; VAR numer, denom: Point; VAR info: FontInfo ): INTEGER; CODE0 A8EDH;
  PROCEDURE StdGetPic( dataPtr: Ptr; byteCount: INTEGER ); CODE0 A8EEH;
  PROCEDURE StdPutPic( dataPtr: Ptr; byteCount: INTEGER ); CODE0 A8F0H;

  (* Misc. Utility Routines *)
  PROCEDURE GetMouse( VAR pt: Point ); CODE0 A972H;
  PROCEDURE GetPixel( h, v: INTEGER ): BOOLEAN; CODE0 A865H;
  PROCEDURE Random( ): INTEGER; CODE0 A861H;
  PROCEDURE StuffHex( thingptr: Ptr; theString: ARRAY OF CHAR ); (* CODE 0A866H; *)
  PROCEDURE ForeColor( color: LONGINT ); CODE0 A862H;
  PROCEDURE BackColor( color: LONGINT ); CODE0 A863H;
  PROCEDURE ColorBit( whichBit: INTEGER ); CODE0 A864H;
  PROCEDURE UpdateQDGlobals;

(*===============================     Make     ================================*)

  PROCEDURE SetBatchMode( on: BOOLEAN );
  PROCEDURE IsInBatchMode(): BOOLEAN;

  PROCEDURE Ask( question: ARRAY OF CHAR; butTexts: ARRAY OF CHAR; butWidth: CARDINAL;
                 VAR answer: INTEGER );

  PROCEDURE GetVersion( prompt: ARRAY OF CHAR; VAR versStr: ARRAY OF CHAR );

  PROCEDURE SetTerminalProtocolFile( fn: ARRAY OF CHAR ): BOOLEAN;
  PROCEDURE SetReportProtocolFile( fn: ARRAY OF CHAR ): BOOLEAN;

  PROCEDURE Message( lnsbefore: INTEGER; s: ARRAY OF CHAR );
  PROCEDURE MessageLn( lnsbefore: INTEGER; s: ARRAY OF CHAR ); (* writes EOL at end *)

  PROCEDURE StripExtFrom( fn: ARRAY OF CHAR );

  PROCEDURE SetDefltCompiler( obsoleteCompName, newCompName: ARRAY OF CHAR );
  PROCEDURE CompCompiler( compName, fn, cmdfn: ARRAY OF CHAR ): BOOLEAN;
  PROCEDURE Compile( fn, cmdfn: ARRAY OF CHAR ): BOOLEAN;
  PROCEDURE Compile20( fn, cmdfn: ARRAY OF CHAR ): BOOLEAN;
  PROCEDURE CompileAndRename( fname, fnext, tail: ARRAY OF CHAR );
  PROCEDURE Compile20AndRename( fname, fnext, tail: ARRAY OF CHAR );
  PROCEDURE CompileLinkAndRename( fname, fnext, tail, lnkcmdfnTail: ARRAY OF CHAR );
  PROCEDURE CompAnyLinkAndRename( compiler, fname, fnext, tail, lnkcmdfnTail: ARRAY OF CHAR );
  PROCEDURE MakeDefault( fn, tail: ARRAY OF CHAR );
  PROCEDURE MakeComp20Default( fn, tail: ARRAY OF CHAR );
  PROCEDURE MakeVariantsFlex( modName, v1, v2, compiler1, compiler2, opt1, opt2: ARRAY OF CHAR;
                              prelink: BOOLEAN );
  PROCEDURE ForceRename( oldname, newname: ARRAY OF CHAR );
  PROCEDURE RenameAndAddResource( oldname, newname: ARRAY OF CHAR );
  PROCEDURE CompileAndStripExt( alreadyCompiled: BOOLEAN; modIdent: ARRAY OF CHAR );
  PROCEDURE MakeLinkOptString( optChars, creator: ARRAY OF CHAR; VAR options: ARRAY OF CHAR );
  PROCEDURE LaunchLink( masterfn, cmdfn, newfn, options: ARRAY OF CHAR );
  PROCEDURE Prelink( alreadyCompiled: BOOLEAN; moduleIdent: ARRAY OF CHAR );
  PROCEDURE CompilePCVariant( mn: ARRAY OF CHAR; pcSBMs: BOOLEAN );
  PROCEDURE CompileAndLink( mn: ARRAY OF CHAR; pcSBMs: BOOLEAN );
  PROCEDURE GetFullName( fn: ARRAY OF CHAR; VAR fullName: ARRAY OF CHAR ): BOOLEAN;
  PROCEDURE GetFilePath( fn: ARRAY OF CHAR; VAR path: ARRAY OF CHAR ): BOOLEAN;

  PROCEDURE CopyFile( sourcePath, sourceFn, destPath, destFn: ARRAY OF CHAR; VAR done: BOOLEAN );
  PROCEDURE MoveFile( sourcePath, sourceFn, destPath: ARRAY OF CHAR; VAR ok: BOOLEAN );
  PROCEDURE ForceCopy( sourcePath, sourceFn, destPath, destFn: ARRAY OF CHAR; VAR ok: BOOLEAN );
  PROCEDURE ForceMove( sourcePath, sourceFn, destPath: ARRAY OF CHAR; VAR ok: BOOLEAN );
  PROCEDURE ForceDelete( pfn: ARRAY OF CHAR ); (* deletes if exists *)

  PROCEDURE UseCustomIcon( pfn: ARRAY OF CHAR );

  PROCEDURE CallSubMake( makename: ARRAY OF CHAR );

  PROCEDURE AnErrEncountered( msgbeg, ins1, msgmiddle, ins2, msgend: ARRAY OF CHAR );
  PROCEDURE AnyErrsEncountered(): BOOLEAN;

  PROCEDURE PlaySuccessMelody( final: BOOLEAN );

  PROCEDURE SetFileTypes( defltCreator, defltType,
                          compCreator, sbmType, obmType, rfmType: ARRAY OF CHAR );

(*==============================     MatAri     ===============================*)

  TYPE Operation=( add, sub, mul, div, inv, ln, exp, sqr, sqrt, power, trunc, round,
                    fract, min, max, sin, cos, tan, arcSin, arcCos, arcTan );

  PROCEDURE DoAriWithMatrix( a: Matrix; area: Selection; ops: Operation; x: REAL );
  PROCEDURE SeriesMat( a: Matrix; area: Selection; byRows: BOOLEAN; base, step: REAL );

(*============================     MatEditor     ==============================*)

  PROCEDURE OpenMatrixEditor;	PROCEDURE CloseMatrixEditor;
  PROCEDURE ShowMatrixInWindow( VAR a: Matrix; wF: WindowFrame );
  PROCEDURE HideMatrixInWindow( VAR a: Matrix );
  PROCEDURE AddMatrixToMatEdList( a: Matrix );
  PROCEDURE DelMatrixFromMatEdList( a: Matrix );
  PROCEDURE SetSelection( a: Matrix; sel: Selection );
  PROCEDURE GetSelection( a: Matrix; VAR sel: Selection );

(*===========================     MatInterpol     =============================*)

  PROCEDURE YI( m: Matrix; x: REAL ): REAL;
  PROCEDURE YIE( m: Matrix; x: REAL ): REAL; (* like YI, but does also extrapolate *)
  PROCEDURE ZI( m: Matrix; x, y: REAL ): REAL;
  PROCEDURE ZIE( m: Matrix; x, y: REAL ): REAL; (* like ZI, but does also extrapolate *)

(*============================     MatReshape     =============================*)

  PROCEDURE InsertMatrixRow( a: Matrix; nrRow: INTEGER );
  PROCEDURE InsertMatrixCol( a: Matrix; nrCol: INTEGER );
  PROCEDURE DeleteMatrixRow( a: Matrix; nrRow: INTEGER );
  PROCEDURE DeleteMatrixCol( a: Matrix; nrCol: INTEGER );

(*============================     MatSclOps     ==============================*)

  VAR matrixSclOpsOk: BOOLEAN; (* returns success of operation *)
  PROCEDURE AddVecToMatrixRow( v: Matrix; m: Matrix; irow: INTEGER );
  PROCEDURE AddVecToMatrixCol( v: Matrix; m: Matrix; icol: INTEGER );
  PROCEDURE ColSum( a: Matrix; VAR rowVec: Matrix );
  PROCEDURE RowSum( a: Matrix; VAR colVec: Matrix );
  PROCEDURE TotSum( a: Matrix ): REAL;
  PROCEDURE DiagVec( a: Matrix; VAR r: Matrix );
  PROCEDURE DiagSum( a: Matrix ): REAL;
  PROCEDURE DiagProd( a: Matrix ): REAL;
  PROCEDURE EqualMatrix( a, b: Matrix; maxErr: REAL ): BOOLEAN;
  PROCEDURE ScalarMul( a: Matrix; scal: REAL );
  PROCEDURE ScalarDiv( a: Matrix; scal: REAL );
  PROCEDURE ScalarVecProd( a, b: Matrix ): REAL;

(*============================     MatVecOps     ==============================*)

  VAR matrixVecOpsOk: BOOLEAN; (* returns success of operation *)
  PROCEDURE MatAdd( a, b: Matrix; c: Matrix ); (* c := a + b *)
  PROCEDURE MatSub( a, b: Matrix; c: Matrix ); (* c := a - b *)
  PROCEDURE MatMult( a, b: Matrix; c: Matrix ); (* c := a * b *)
  PROCEDURE MatInv( a: Matrix ); (* a := a^-1 *)
  PROCEDURE MatTranspose( a: Matrix ); (* a := a' *)

(*=============================     MatWOut     ===============================*)

  TYPE MatFormat= RECORD
                   realF: RealFormat;
                   len, dec: CARDINAL;
                   separator: ARRAY[0..63] OF CHAR;
                   crCol: INTEGER;
                   eOM: ARRAY[0..63] OF CHAR;
                  END;

  VAR standardO: MatFormat;

  PROCEDURE SetMatFormat( mf: MatFormat );
  PROCEDURE GetMatFormat( VAR mf: MatFormat );
  PROCEDURE WriteMatrix( m: Matrix );
  PROCEDURE WriteRow( m: Matrix; rowNr: INTEGER );
  PROCEDURE WriteCol( m: Matrix; colNr: INTEGER );
  PROCEDURE WriteEle( m: Matrix; row, col: INTEGER );


(*  ============================     E N D     ==============================  *)

     The auxiliary library modules may be freely copied but not for profit!

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]