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

DEFINITION MODULE DMWPictIO;

  (*******************************************************************

    Module  DMWPictIO     ('Dialog Machine' DM_V3.0)

      Copyright (c) 1987-2006 by Olivier Roth, Andreas Fischlin and
      ETH Zurich.

    Purpose   Saves picture objects for a 'Dialog Machine'
              window in memory for later reference like
              redrawing, transfer to the clipboard or printing.

    Remarks   All DMWindIO output routines may be used to
              produce picture objects.

              A picture object belongs always to a particular
              'Dialog Machine' window and in a particular moment
              a window can own only a single picture.

              This module belongs to the 'Dialog Machine'.


    Programming

      o Design
        Olivier Roth              02/04/1987
        Andreas Fischlin          14/03/1989

      o Implementation
        Olivier Roth              02/04/1987
        Andreas Fischlin          14/03/1989


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  27/04/1993  AF

  *******************************************************************)


  FROM DMWindows IMPORT Window, RectArea;


  VAR
    PictIODone: BOOLEAN;
    (*
      Read only variable, which returns whether any of the
      following procedures has been successful.  E.g. if
      enough memory is available, etc.
    *)

  PROCEDURE StartPictureSave;
  (*
    Saves in memory all subsequent DM-Window output in a picture
    associated with the current Dialog Machine output window.
    NOTE: don't forget to terminate this saving with a call to
    StopPictureSave.
  *)

  PROCEDURE PausePictureSave;
  PROCEDURE ResumePictureSave;
  PROCEDURE StopPictureSave;
  (*
    Stops storing DM-Window output to the picture associated with
    the current Dialog Machine output window
  *)

  PROCEDURE DisplayPicture (ownerWindow: Window; destRect: RectArea);
  (*
    Displays the picture associated with the Dialog Machine window
    ownerWindow onto the current Dialog Machine output window in
    the destination rectangle destRect. If the width or height of
    the destRect is <0 then the picture will be displayed in its
    original size, if the lower left corner is =MIN(INTEGER) then
    the picture's original lower left corner will be respected,
    otherwise it will be resized to fit exactly into the given
    rectangle (exception: if all of destRect are =0 then the
    picture is fitted entirely into the destination window). The
    status of the picture in the owner window (pause/active and
    closed/open) is temporarily changed but restored after the
    display, whereas the destination picture status remains
    untouched. In case there is currently a text or picture object
    open (see also module DMWTextIO), note that the picture will be
    appended to the already existing picture but NOT to the
    eventually already existing text.  This mechanisms allows to
    copy a picture into a picture but not into a text object
    (different from DMWTextIO.DisplayText).

    Placing and sizing pictures with the dialog machine:

    If one wants to display an entire or a part of a picture at (destRect):
      a) its orig. origin, in its orig. size (ev. clipped)
      b) its orig. origin, in a     new size (fit into)
      c) a new origin    , in its orig. size (ev. clipped)
      d) a new origin    , in a     new size (fit into)
      e) fit into destination window {special case of d)}
    then one may use the following specifications for destRect instead of
    the actual values:
             x       y       w   h
     a)     MIN(INTEGER)    <0  <0
     b)     MIN(INTEGER)     w   h
     c)      x       y      <0  <0
     d)      x       y       w   h
     e)      …       …       0   0

    concerns:
    DMClipboard.GetPictureFromClipboard (simultaneousDisplay: BOOLEAN; destRect: RectArea);
    DMPTFiles.LoadPicture (VAR f: TextFile; simulDisplay: BOOLEAN; destRect: RectArea);
    DMWPictIO.DisplayPicture(ownerWindow: Window; destRect: RectArea);

    other related procedures:
    DMWPictIO.SetPictureArea(r: RectArea);
    DMWPictIO.GetPictureArea(VAR r: RectArea);
    DMWindows.GetWindowFrame(u: Window; VAR f: WindowFrame);
    DMWindIO.SetClipping(cr: RectArea);
    DMWindIO.GetClipping(VAR cr: RectArea);


    Logic of display and save mechanism of pictures with the dialog machine:
                            window has
                    open pict   closed/paused pict
    simulDisplay         d/s             d/ns
    not simulDisplay    nd/s            nd/ns
    (d = displayed, nd = not displayed, s = saved (appended), ns = not saved)

  *)


  PROCEDURE DiscardPicture;
  (*
    Discard the picture associated with the current output window
    completely, and make the allocated memory space available for
    other uses.  Note that once discarded, it is no longer possible
    to print the picture, write it to a file, or transfer it to the
    clipboard  (s.a. DMPrinting.PrintPicture, DMPTFiles.DumpPicture,
    and DMClipboard.PutPictureIntoClipboard).
  *)


  PROCEDURE SetPictureArea ( r: RectArea );
  PROCEDURE GetPictureArea ( VAR r: RectArea );
  (*
    Sets or gets the area to be used for subsequent picture saves.
    If this procedure is never called the default picture area used
    will be that of the window frame of the current output window
    when calling StartPictureSave. Typically this procedure is used
    to restrict the saving process to a portion of a picture.
  *)


  PROCEDURE SetHairLineWidth ( f: REAL );
  PROCEDURE GetHairLineWidth ( VAR f: REAL );
  (*
    The hair line width is the scaling factor by which all lines
    subsequently drawn via DMWindIO routines and collected via
    DMWPictIO.StartPictureSave will be printed on a PostScript
    printer.  E.g. a scaling factor f = 1 means, that lines drawn
    on the screen with a width of 1 pixel are printed on a laser
    printer with a width which corresponds to the proportion of the
    resolutions between the screen and the printer.  A Macintosh
    screen has a resolution of 72 x 72 pixels/inch, the Apple
    LaserWriter one of 300 x 300 dots/inch (ImageWriter 144 x 144
    pixels/inch).  Hence, the resolution on that laser printer is
    approximately 4 times as that of the screen. Hence with f = 1
    lines drawn on the screen with 1 pixel width are printed with a
    width of 4 dots. However, with e.g. a scaling factor f = 0.25,
    an actual, very fine hair line with a width of 1 dot will be
    printed where you see on the screen still a relatively "thick"
    line with a width of 1 pixel. Use this mechanisms to print
    lines thinner as what you could display on a screen, in order
    to produce prettier pictures. Note however that this mechanism
    affects all line drawing, in particular it would also allow to
    enlarge line widths.  Hence, be careful in its use.  Note also,
    that this mechanism won't work on an ImageWriter. The default
    scaling factor f is 0.5.
  *)

END DMWPictIO.

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