Graphic facilities

of the DIagram ANAlyser Diana
Last modified: Tuesday, 15 October 2002, 18:27
* Quick start.
* Detailed description.

Starting with the revision 2.17, Diana has several operators useful for creating the PostScript pictures of diagrams. Based on these operators, three PS drivers were elaborated on the TM language. In the revision 2.28 one new, fourth, PS driver has been developed.

The first driver can be used to print all of diagrams in the postscript file, arranging diagrams along several columns and rows on each page: screenshot

The second driver prints all diagrams into one postscript file, one diagram per page. The diagrams are printed together with the topology and momenta flow. Such a form is convinient not for printing, but for investigating the digram visually by means of some PostScript interpreter, e.g., by the GhostView: screenshot

The third driver can be used to create an encapsulated postscript file containing the current diagram: screenshot

The fourth driver can be used to create an encapsulated postscript file containing the current diagram with additional information about momenta flow: screenshot

Quick start

for those who use the styles "specmode.tml" or "folders.tml".

The styles "specmode.tml" and "folders.tml" contain all the necessary function calls. Thus the users of these styles only need to initialize the proper postscript driver in the environment \Begin(initialization) ... \End(initialization), or invoke the function \outEPS(...) or \outInfoEPS(...) to create an encapsulated PostScript file containing the current diagram.

Diana is able to produce the pictorial representation of diagrams only if the shapes of topologies are defined, i.e., if all coordinates for the topology are defined. The user can use the Diana topology editor to define the coordinates.

Optionally, the user may add to the model the description of a type of the drawing line, and description of a particle identifier to be printed. By default, the propagator will be drawn as a solid arrowed line of width 2, and the identifier coincides with the beginning of the propagator.

To print all diagrams in one file, arranging diagrams along several rows and columns on each page, the user has to initialize the PostScript driver by means of the function \initPostscript(. . . ) in the environment initialization. Example:

\Begin(program,routines.rtn)
\section(common,browser,regular)
\Begin(initialization)
  . . .
   \initPostscript(      pictures.ps,
                         A4,
                         Portrait,
                         20,
                         20,
                         40,
                         2,
                         10,
                         Helvetica,
                         15
   ) 
  . . .
\End(initialization)
  . . .
\End(program)
There is another form of graphical representation of diagram: all diagrams are printed into one postscript file, one diagram per page. The diagrams are printed together with the topology and momenta flow. Such a form is convinient not for printing, but for investigating the digram visually by means of some postscript interpreter, e.g., by the ghostview. To initialize this driver, the user has to define only the output file name by means of the function \initInfoPS(filename) in the environment initialization. Example:
\Begin(program,routines.rtn)
\section(common,browser,regular)
\Begin(initialization)
  . . .
  \initInfoPS(info.ps)
  . . .
\End(initialization)
  . . .
\End(program)
To print current diagram into the encapsulated postscript file, the user has to invoke the function \outEPS(filename,Height,font,fontsize) or, if the user wants to print momenta flow as well, \outInfoEPS(filename,Height,font,fontsize) in the environment
\Begin(output)...\End(output). 
Example:
. . .
\Begin(output,\askfilename())
   \outEPS( d\currentdiagramnumber().eps,100,Helvetica,15)
   \outInfoEPS( ie\currentdiagramnumber().eps,100,Helvetica,15)
   . . .
\End(output)
. . .
Some parameters of "info" eps pictures can be adjusted by the user.

Detailed description.

This section contains the description of
  1. There are several operators providing the graphic facilities.
    1. Operators:
            \getPSarclabel(l)
            \getPSvertexlabel(v)
            \getPSvertex(v)
      
      return X,Y coordinates of arcs, vertices or labels, if they are defined. If not, all these operators retur an empty string. Returned values are of the form x y so they can be used to load the PostScript parameters.
    2. Operators:
            \getPSarc(l)
            \getPSInfoArc(l)
      
      return the PostScript coordinates of the line number l in the form: ox oy r as ae l Here (ox,oy) -- the center coordinates, |r| -- radius, as,ae -- initial and target angles. If r<0.0, the angle is clockwise, if r>0.0, the angle is anti-clockwise. If r = 0.0, the line is stright, from (ox,oy) to (as,ae). l is the length of the arc.
      \getPSarc(l) assumes the line directions along directed propagators while \getPSInfoArc(l) assumes the line directions according the tolology possibly modified by operators \lsubstitution() or \vsubstitution().
    3. The operator \getXfromY(fontsize,height) returns the width of the diagram scaled to fit the EPS bounding box 0 0 width height.
    4. The operator \adjust(fontsize, x,y) outputs complete PS code to adjust the size of diagram so that it fits to 0 0 x y bounding box, together with up line of fontsize height.
      ATTENTION! The set of the PostScript operators generated by this operator leaves 2 parameters in the postscript stack which can be used for typing the text (x,y coordinates adjusted so that the text in font of fontsize height will be printed in proper place).
    5. The operator \parseParticleImage(particle,string) converts Diana-specific string into a set of Postscript routines.
    6. Operators \_PImage(l,id), \_PDocFonts(id), \_PDiaImages(formatstring), \_PAllImages(formatstring) are for internal use only! They are developed to speed up TM Postscript drivers from "specmode.tml".
    7. \initps(header,target) -- returns "" (empty srting) if ok, or none, if there are NO topologies with distributed coordinates. This operator reads information from the file header, filters out all comments and extra lines and appends the result to the file target. It reduces all separators to single spaces, so the result is the human unreadable text!
    8. \thiscoordinatesok() returns true or false depending on the completeness of all coordinates in the current topology.
    9. \coordinatesok() -- returns true, if at least one of topology has coordinates.
  2. The model is extended so there is possible to describe the type of the drawing line and the graphical representation of a symbol used to print the particle identifier in the propagator definition. Example:
    old version:
    [Wm,Wp ;W; VV(num,ind:1 ,ind:2 ,vec, 2)*i_ ;mmW]      
    
    Extension added in 2.17:
    [Wm,Wp ;W; VV(num,ind:1 ,ind:2 ,vec, 2)*i_ ;mmW;arrowWavy,4,2]
    
    Extension added in 2.28:
    [Wm,Wp ;W; VV(num,ind:1 ,ind:2 ,vec, 2)*i_ ;mmW;arrowWavy,4,2;W{y(5)-}]
    

    The first extension permits the user to desribe (optionally) how to draw this line. The syntax is:
    ;linetype,parameter,linewidth
    In the above example:

      linetype=arrowWavy
      parameter=4
      linewidth = 2
    

    The linetype is an abstract type of the line. It can be one of the following:

    The second model extension added in the revision 2.28 permits the user to desribe (optionally) how to print a particle identifier. To do that, the user must add, after a line type, the character ';' and a particle image.

    The particle image is the text with possible modifications, e.g.: W{y(10){f(Symbol)(8)a}} -> Example:

      [Wm,Wp ;W; VP(num,ind:2 ,ind:1 ,vec, 2)*i_ ;mmW] 
    
    - the line will be (default) - solid arrowed line, the particle image will be Wm.
      [Wm,Wp ;W; VP(num,ind:2 ,ind:1 ,vec, 2)*i_ ;mmW; arrowWavy,3,2;W{y(5){s(20)-}}] 
    
    - the line will be of a photon-like arrowed curve of a width 2 and amplitude 3, and the particle image will be

    All modifications are local agains block. Block is started by '{' followed one of a keyword with possible parameters in parenthesis:

    {x(#) ... } - paints the content shifted along x. After the block, the current point is set to (old x, new y);
    {y(#) ... } - paints the content shifted along y. After the block, the current point is set to (new x, old y);
    {xy(#)(#) ... } - paints the content with shift along both x and y. After the block, the current point is set to (old x, old y);
    {f(fontname)(#) ... } - sets font fontname scaled by # (in 1/10 fractions of the current font size);
    {s(#) ... } - scales current font by # (in 1/10 fractions of the current font size);
    {c(#)(#)(#) ... } - sets RGB color. Each parameters must be a positive decimal number in the region [0...1].

    All sizes are in 1/10 fractions of the base font size, i.e. "10" means the size of the current font, "20" is twice bigger, "5" is a half size.

    As a fontname, one can recommends to use only the standard 13 PostScript level 1 fonts:

    Courier, Courier-Oblique, Courier-Bold, Courier-BoldOblique, Helvetica, Helvetica-Oblique, Helvetica-Bold, Helvetica-BoldOblique, Times-Roman, Times-Italic, Times-Bold, Times-BoldItalic, Symbol:

    13 fonts

    The 35 standard fonts according to the PostScript level 2 are:

    Bookman-Demi, Bookman-DemiItalic, Bookman-Light, Bookman-LightItalic, Courier, Courier-Oblique, Courier-Bold, Courier-BoldOblique, AvantGarde-Book, AvantGarde-BookOblique, AvantGarde-Demi, AvantGarde-DemiOblique, Helvetica, Helvetica-Oblique, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Narrow, Helvetica-Narrow-Oblique, Helvetica-Narrow-Bold, Helvetica-Narrow-BoldOblique, Palatino-Roman, Palatino-Italic, Palatino-Bold, Palatino-BoldItalic, NewCenturySchlbk-Roman, NewCenturySchlbk-Italic, NewCenturySchlbk-Bold, NewCenturySchlbk-BoldItalic, Times-Roman, Times-Italic, Times-Bold, Times-BoldItalic, Symbol, ZapfChancery-MediumItalic, ZapfDingbats:

    13 fonts

    Example: the image graph was produced by the following description:

    {f(Symbol)(15)
       {c(0)(0)(1)
          W
       }
    }
    {c(1)(0.5)(0)
       {xy(1.2)(5)
          {s(27)
            +
          }
       }
       {y(5)
          {f(Courier)(30)
             o
          }
       }
    }
    
    Base font is "Helvetica", base fotn size is 18.

  3. New TM operators are used in the new revision of the TML resources. Most of new functions are added to the file "specmode.tml".
    1. To print all diagrams to the .ps file the user must:
      1. Initialize the PostScript driver by means of the function
               \initPostscript(  filename,
                                 papersize,
                                 orientation,
                                 xmargin,
                                 ymargin,
                                 xleftmargin,
                                 ncols,
                                 nrows,
                                 font,
                                 fontsize
               )
        
        This function creates the PS header, so it must be invoked only once.
        The parameters are:
        1. filename -- the output file name;
        2. papersize -- one of the possible paper size;
        3. orientation -- portrait or landscape
        4. xmargin -- both left and right margins
        5. ymargin -- both up and down margins
        6. xleftmargin -- additional left margin
        7. ncols -- number of columns per page
        8. nrows -- number of rows per page
        9. font -- the PostScript font name
        10. fontsize -- the PostScript font size
        Example:
                 \initPostscript(alldiargams.ps,
                                 A4,
                                 Portrait,
                                 20,
                                 20,
                                 40,
                                 2,
                                 10,
                                 Helvetica,
                                 15
                 )
        
      2. For each diagram, after the output expression is created, the user must invoke the function \outpostscript()
      3. After all diagrams are printed, the user must call the function \closePS()
    2. There is another form of graphical representation of diagram: all giagrams are printed into one postscript file, one diagram per page. The diagrams are printed together with the topology and momenta flows. Such a form is convinient not for printing, but for investigating the digram visually by means of some postscript interpreter, e.g., by the GhostView. To create such a picture, the user must:
      1. Initialize the PostScript driver by means of the function \initInfoPS(filename)
      2. For each diagram, after the output expression is created, the user must invoke the function \outInfoPS()
      3. After all diagrams are printed, the user must call the function \closePS()
      NOTE: the same function, \closePS(), is used to close .ps files opened by both initPostscript and initInfoPS. If the user opens both these files, he must call the function \closePS() only once to close both these files.

      The styles "specmode.tml" and "folders.tml" contain all the necessary functions calls. Thus users of these styles only need to initialize the proper postscript driver in the environment

      \Begin(initialization) ... \End(initialization)
    3. To print the the diagram into the Encapsulated Postscript file screenshot the user has to invoke the function \outEPS(filename,Height,font,fontsize) after the output expression is created. If fontsize == 0, then the particles labels will not be printed. The width of the diagram will be defined automatically. The diagram will be scaled to fit the EPS bounding box 0 0 Width Height No initialization, no \closePS()! Example see above.
    4. To print the the diagram into the Encapsulated Postscript file with additional information about momenta flows screenshot the user has to invoke the function \outInfoEPS(filename,Height,font,fontsize) after the output expression is created. If fontsize == 0, then the particles labels will not be printed. The width of the diagram will be defined automatically. The diagram will be scaled to fit the EPS bounding box 0 0 Width Height No initialization, no \closePS()!

      Some parameters may be adjusted by the user. There are two TM functions, \setIEPSshift() and \setIEPSpars(), which may be invoked in the "initialization" section to reset default parameters of this driver.

      \setIEPSshift(particle, shift) - sets a deviation of small arrow pointing a momentum flux, from the main propagator line: setIEPSshift
      May be set individually for each particle. If the first argument, particle, is empty, then the function sets the parameter shift for all propagators. Negative value is acceptable. Default is 10.

      The function \setIEPSpars(length, width,fsize,r,g,b) sets other parameters. The first argument, length, is the length of the arrow: IEPSlength Default is 20.
      The width of the arrow, width: IEPSwidth Default is 2.
      The third parameter, fsize, is the size of a font for momentua flows, in 1/10 fractions of the base font size, i.e. "10" means the size of the current font, "20" is twice bigger, "5" is a half size. Default is 7.
      fsize=7:IEPSfont7, and fsize=11:IEPSfont11.
      Last three parameters define the RGB color for momenta flows. Each of them must be between 0 and 1. Default is (1, 0.5, 0.3).

      The example was produced using the following propagators:

      [g,g;;VV(num,ind:1,ind:2,vec,3);0;spiral,5,2]
      [A,A;;VV(num,ind:1,ind:2,vec,0);0;wavy,3,3;{f(Symbol)(10)g}{xy(-5)(5)~}]
      [u,U;;FF(num,fnum,vec,0);mmU;arrowLine,0,2;e{y(4)-}]
      
      The corresponding TM code is:
      \Begin(initialization)
      \setIEPSshift(,10)
      \setIEPSshift(u,8)
      \setIEPSpars(20,2,7,1,0,0)
      \End(initialization)
      . . .
      \Begin(output,\askfilename())
         \outInfoEPS( ie\currentdiagramnumber().eps,100,Helvetica,15)
         . . .
      \End(output)
      
All of the above PS drivers use the same line type prescription. By default, all propagators are depicted by arrowed solid lines of width 2. There are two possibilities to change these default parameters.

The first one is to use the above mentioned model extension. Another one is using the the function

   \setpropagatorline(particle, linetype, parameter, linewidth)
Here parameters are the same as described for the model extension. The user can use this function to re-set line type come from the model. Here are several examples of the line types:
lines

By default, all of the above PS drivers use the same particle images. By default the particle will be printed as the beginning of a propagator. The user can set non-trivial image by means of the above described model extension, or using the function

   \setparticleimage(A,image)
Here image is the same as described particle image, e.g.:
   \setparticleimage(A,{f(Symbol)(10)g})
The user can use this function to re-set particle image come from the model.