\documentstyle[12pt, psfig, epsfig,fullpage]{article}
%\renewcommand{\baselinestretch}{2.0}


\input epsf
\input psfig.tex
\title{}
\author{}
\thispagestyle{empty}
\begin{document}
\pagestyle{empty}
\thispagestyle{empty}
\addcontentsline{toc}{subsection}{\bf Abstract}
\tableofcontents
\newpage
\listoffigures
\newpage
\listoftables
\newpage
\maketitle
\newpage
\pagestyle{plain}
\pagenumbering{arabic}
\begin{center}
\subsection*{\bf \large   Abstract}
\end{center}

\begin{titlepage}

\begin{center}
{\Large  WD-pic, A WYSIWYG, Direct-Manipulation pic \\}
\vspace{1.5in}
Project Thesis\\
\vspace{1.5in}
Submitted in partial fulfillment of the requirements\\
for the degree of Master of Science\\
in Computer Science\\
\vspace{1.5in}
{\large Shpilberg Faina\\}
\vspace{1in}
Submitted to the Senate of the Technion - Israel Institute of Technology\\
Av 5757 \hspace{1.5in} Haifa \hspace{1.5in}August 1997
\end{center}

\newpage



 The {\bf Pic} language is a TROFF preprocessor for drawing line drawing in UNIX environments.
In this work, a classification of the elements of the {\bf Pic} language is introduced, and a convenient graphical interface, corresponding to this classification,  WD-pic, for {\bf Pic} users is developed in the X Windows environment, using Motif.  WD-pic combines graphics and text building and editing of pictures,
and it produces pictures on a screen and a corresponding internal representation, which is fully compatible with
the {\bf Pic} language. The displayed pictures in  WD-pic are realized partly  with the help of the existing {\bf Pic} compiler and partly with  new code. The original {\bf Pic} compiler's source code was modified and incorporated as a separate process in  WD-pic. Creating pictures in WD-pic was tested and  compared with writing description of the same pictures in the {\bf Pic} language  and creating the same pictures with the help of {\it xfig}.


\newpage


\section{General Description}

\subsection{Batch vs. WYSIWYG Drawing Programs}

Picture drawing software comes in two different varieties [16, 17]:

\begin{itemize}
	\item	batch, such as {\bf Pic} [1,2,3,4], and

	\item	WYSIWYG (What You See Is What You Get) direct manipulation,
		such as {\it xfig} [14], {\it idraw} [13], {\it Adobe Illustrator}[15], etc.

\end{itemize}

\noindent The advantages of batch drawing software are:  
\begin{itemize}
   \item  The user can insert or delete an element or change its size or location without destroying the entire picture.
   \item It is easier to manipulate large groups of elements treated as a unit.
\end{itemize}

\noindent The disadvantages of batch drawing software are:
\begin{itemize}
   \item The user cannot see the picture as it is being composed, and because of it he/she could have problems with proportions, sizes, text string lengths, etc.
   \item It is easier to make an error.
\end{itemize}

\noindent The advantages of WYSIWYG, direct-manipulation drawing software are:
\begin{itemize}
  \item  The user can see  the whole  picture. 
  \item It is easier to make decisions about such matters as exact types of elements, for example {\bf box} or {\bf circle}, element sizes, positions of text string, etc., and to avoid  obvious errors.
\end{itemize}

\noindent The disadvantages of WYSIWYG, direct-manipulation drawing software are:
\begin{itemize}
  \item A change of one element can destroy an entire picture.
  \item It is not comfortable to manipulate  large groups of elements, for example changing the default size for all {\bf boxes} or changing the direction of elements in the picture. 
\end{itemize}
   
\subsection{Goal and Requirements for WD-pic}

We want to get the best of both worlds in the form of a combination batch,
WYSIWYG, direct-manipulation drawing program, called  WD-pic ({\bf W}YSIWYG, {\bf D}irect-manipulation {\bf Pic} drawing program), an
enhancement of the well-known batch {\bf Pic} program that works with the
same {\bf Pic} language[1,2,4]. The {\bf Pic} language is ideally suited for the kinds of diagrams occuring in Computer Science  documents. That is it should be possible to get a box drawn by either clicking box button or by typing ``box''. However, even in direct manipulation, the batch defaults should hold. The internal representation of any picture is an
editable {\bf Pic} language description of the picture in the style that a human would enter.  In this work we tried to make an internal representation of a picture close to what a human would write as possible. For example, if the user wants to draw a line, connecting a specific corners of two boxes, he/she  would write something like ``line from first box.ne to second box.sw'', which is more understandable then ``line from 1.00245 to 3.52671''. In order to follow this goal, we sometimes need to constrain the WD-pic interface.

WD-pic is a UNIX system line drawing program. It is intended chiefly for
technical document illustration, such as flow charts, state diagrams and so on.
Pictures, interactively created by WD-pic can be saved as batch {\bf Pic} programs,
and batch {\bf Pic} programs can be displayed and edited interactively with the help of
WD-pic.

 In  Fig.1, we see the connection between WD-pic, {\bf Pic}, and TROFF[18,19].
\begin{figure}
%\epsfbox{PicPicture/Pic-Troff.ps}
\epsffile[0 0 500 130]{PicPicture/Pic-Troff.ps}
\caption{Connection between WD-pic, {\bf Pic} and TROFF.}
\label{Fig. 1}
\end{figure}
 
\subsection{Prototyping Method}


This thesis is intended to report on an example of prototyping to determine
actual requirements starting from a vague idea of the general requirements.

The mission was to decide the requirements and design of an interchangeable
batch-WYSIWYG drawing system based on the picture desciption language
for the batch program {\bf Pic}. This is a case in which the requirements and
design affect each other in that what is not implementable is not
requirable (and of course, vice versa). The hard part of this mission is
to simultaneously determine a reasonable way to structure the software
that would meet the requirements and to determine the best user interface
that makes the switching between
batch and WYSIWYG input as seamless as possible.

The method used to refine the requirements and to get a first
implementation of WD-pic is the traditional requirements exploration
prototyping method. A prototype is rapidly programmed to a first version of
the requirements. Users get to play with the prototype to discover
inappropriate requirements. The requirements are adjusted and a new round
begins. The process continues until satisfactory requirements and an
implementing prototype are obtained or until it is determined that the
path of decisions taken cannot yield satisfactory requirements without
throwing out most of the work done so far.

In the case of word-processing software such as WD-pic, the prototypes can
be exercised to produce the figures that will be used in the documentation
of the software. Indeed, all of the figures in this thesis were produced by
the author using WD-pic. Having a set of real-life examples, as opposed to
toy, concocted examples, assures a good exercising of the problem domain
that is to be covered by the software. Furthermore, these same examples
give a way to evaluate the software against real-life uses.

Requirements exploration prototyping requires being able to rapidly put
together a new version of the program with maximum reuse of what has been
done before and is not discarded. Consequently, some time was spent to
identify a syntax directed structure for the basic interpreter. In
addition, to make it easy to change the content of the user interface
decisions, i.e., what is printed in a prompt to the user and what is
expected from the user as a response and as confirmation, it was decided to
use a prepackaged library of user-interface widgets. While this choice did
make it relatively easy to change the program as requirements were changed,
it did end up standing in the way of meeting one of the goals, namely that
of interchangeability of batch-style, textual and direct manipulation inputs.



\section {Existing Systems}


The existing drawing systems come in two different flavors, batch and
WYSIWYG. A number of each of these are described in this chapter. It will
be seen that none of them meet the requirements set out for WD-pic.
First it is clear that any program which is either batch or WYSIWYG cannot
meet the requirements of being interchangeably batch and WYSIWYG. Therefore
the criticisms are focused on such issues as whether batch-like defaults
are available in a WYSIWYG system, whether its internal representation is
accessible, understandable, and editable by the user, and how close the
internal representation of a picture is to what a human would write to get
the same figure in the same language.

\subsection{Batch}


Two of the main batch drawing programs are {\bf Pic} and {\it ideal}[27], both AT\&T products.
Both are troff preprocessors. pic is an imperative system in which one
gives explicit commands for a sequence of figure items to be drawn, one
after the other. ideal is a declarative system in which one describes what
is in the picture and give equations whose solutions provide values for the
constants needed to place and size figure items. Both output troff commands
which explicitly draw the figure in terms of points, lines, ellipses, and
splines, which are the basic troff drawing commands. A third program is {\it MetaPost}[22], a
METAFONT[20, 21] to PostScript[23] translator. METAFONT is a combination imperative,
declarative system normally used to specify glyphs for a font. Since a
glyph is just a drawing, clearly one can use METAFONT to specify arbitrary
drawings. The output of {\it MetaPost} is a sequence of PostScript commands that
draw the specified figure.

Of the three, for the kinds of figures that are
normally drawn in computer science technical literature, {\bf Pic} has the
simplest interface, because it has exactly the right set of primitives and
defaults that a flow diagram the sequence of processes P1, P2, and P3
can be specified by the {\bf Pic} commands

``box ``P1''; arrow; box ``P2''; arrow; box ``P3'' ''.
\newline
No other batch drawing program has such a simple specification of the flow
diagram.

Of course, all of these have all the drawbacks of batch programs
and none of the advantages of the WYSIWYG, direct manipulation programs.

\subsection{WYSIWYG}

There are a large variety of WYSIWYG, direct manipulation drawing programs.
It seems that every operating system builder has one and there are still
others supplied by third parties. This section reviews a representative
collection in a more tabular fashion. They are
\begin{enumerate}
\item {\it Adobe Illustrator (AI)}
\item {\it idraw}
\item {\it MacDraw} [26]
\item {\it Paint}[25]
\item {\it PowerPoint}[24]
\item {\it xfig}
\end{enumerate}


{\it AI} is produced by Adobe and it runs on all three major
platforms, PCs with Windows, Macintoshes with MacOS, and Suns with UNIX.
{\it idraw} is a public domain program distributed in source form and can be run
on any platform with a C compiler. {\it MacDraw} is produced by Apple and runs on Macintoshes with MacOS. {\it PageDraw} is another public domain program that runs on PCs with Windows. {\it Paint} is produced by Microsoft and runs on PCs with Windows. {\it PowerPoint} is produced by Microsoft and runs on PCs with Windows. Actually {\it PowerPoint} is a general formatting system for making slide shows and has a picture drawing palette to enable drawing pictures for these slides. {\it xfig} is a public domain program distributed in source form and can be run
on any platform with a C compiler and X windows, as it assumes the X
protocol for accessing the graphic screen on which to draw the pictures.

All of them have a very similar user interface with a palette of drawing
figures, it seems, always on the left side of the screen and an associated
drawing canvas. The palettes all provide basically the same primitive
drawing items, including boxes, lines, circles, ellipses, etc. The more
advanced of these, such as {\it AI} and {\it xfig}, provide an additional
collection of buttons that provide a very complete set of locally and
globally applicable manipulation commands such as scaling, rotating,
translating, etc.

In all of them, after clicking a primitive item, e.g., box, it is necessary
to explicitly place and size the item with the mouse on the drawing
canvas. None provide default positioning and sizing such as provided by
{\bf Pic}.

The saved files for {\it AI}, {\it idraw}, {\it PageDraw}, and {\it xfig} are in plain ASCII format,
with that of the first three being PostScript and that of the fourth being
a representation found in no other program. All of these formats are
editable by the user, although in the opinion of the author's advisor,
only that of {\it xfig} is really intuitive to the user with commands one-for-one
with visible objects on the canvas. While all are editable, the user faces
a danger that after editing, it will not be in a form interpretable by the
program, i.e., the resulting specification is not well formed. The user
should always save a back-up copy to allow restoring to an interpretable
specification should the editing hopelessly mess up the specification.
Note also that none of these programs were designed on the assumption that
the user would be manually editing the saved file; hence they take no pains
to insure clarity of the representation. {\it MacDraw}, {\it Paint}, and {\it PowerPoint} all produce binary saved files to protect
the manuafacturers' trade secrets. For the systems whose saved representation is not PostScript and is
therefore not directly printable, there is a way to generate a PostScript
description of the saved figure. 
In all the programs, in the printable PostScript representation, either the
saved file itself or one obtained by translation from it, the constant
numbers defining positions and sizes are multi-digit numbers with long
fractional parts, e.g., 2.079573454, decidedly not what a human being
would choose to write, e.g. 2 or even 1.25. Moreover, in the case of {\it Paint},
the PostScript is that of a bitmap rather than a sequence of commands to
draw the figure.

\subsection{Conclusions}

All of the reviewed programs are really only either batch or WYSIWYG. None are
both.

The closest that comes to being both is {\it Picasso}, which is intended to
be a WYSIWYG version of {\bf Pic}. However, it does not allow editing of the
internal pic from within {\it Picasso}. If one edits it externally, there is the
problem of assuring that the result is syntactically and semantically
correct. {\it Picasso} simply breaks when it attempts to set itself up on an
internal representation that is not syntactically or semantically correct.

The same problem holds for {\it xfig} and {\it AI}, whose internal
representations are fairly obscure, but ASCII files.

The internal
representation of {\it xfig} has for each object a line consisting of a list of
numbers, the first being the object type, and the rest being its
parameters, the last of which are the defining ordered x,y pairs. It is
hard to edit this internal representation to yield another meaningful, {\it xfig}
interpretable internal representation and a good picture. Note that the
author's advisor does this editing all the time to effect changes that are
a pain to do with the standard interface, e.g., change all occurence of a
particular word to another or to change all rectangles into circles, but he
constantly backs up internal representation files in case he makes errors
that are too messy to undo.

The internal representation of {\it AI} is a rather obscure PostScript
that interprets to a picture only in the presence of a prolog defining the
abbreviated instructions that are used in the internal representation.
Thus, it is hard for the user to read, understand, and modify the internal
representation in a manner that yields syntactically and semantically
correct PostScript and a good picture.
The same holds for {\it idraw}'s internal representation. It is claimed by the
authors of both {\it AI} and {\it idraw}, that any PostScript program
can be converted into a form readable by the program to allow imported
PostScript programs to be manipulated in a WYSIWYG fashion.

Every single one of the WYSIWYG programs known to this author requires
placement of objects in the canvas. That is when the box is requested by
clicking on the box button, the mouse must be used to position the box in
the canvas. The user must click the mouse on two points or click on one
corner and drag to the opposite corner. None put the box in a default
position or as the next item in the current path, as is the default with
both the {\bf Pic} internal representation of {\it Picasso} and in the PostScript
internal representation of of the canvas drawing. Moreover, when one looks
at the {\bf Pic} or PostScript generated for these internal representions or the
{\bf Pic} or PostScript obtained by fig2dev from an {\it xfig} internal representation,
one sees lots and lots of multi-digit real numbers as x and y values, even
if all items in fact are of default size and placement. Moreover, the {\bf Pic}
code generated for a box is four lines connecting the corners expressed as a pair of multi-digit real number.

Therefore, it is fair to say that no existing system meets the stated
initial and key requirements for WD-pic.





\section{High Level Design}
\subsection{Basic Design Idea}


In WYSIWYG drawing software, which is used in Graphical User Interface (GUI)
environments, it is possible to make all screen drawing with the help of the mouse
and to use keyboard input to insert text. Each action with the mouse or keyboard is
called an event.
 The principal execution steps in WD-pic in going from a GUI event to the picture on the screen are shown in Fig.2. 
 \begin{enumerate}
   \item  WD-pic gives to each kind of event, invoked by the user interface, a unique number,  called a token.
   \item The {\bf Pic} interpreter belonging to  WD-pic transforms  the unique number
 into drawing data structures and simultaneously into an internal representation in the the {\bf Pic}
 language. When the {\bf Pic} compiler translates {\bf Pic} text
into TROFF format, it creates data structures,
for producing  text in TROFF format.  When we run the {\bf Pic}
compiler on  {\bf Pic} text, created by  WD-pic, we get drawing data structures. These data structures are equivalent to the drawing data 
structures created by  WD-pic itself.

\begin{figure}
%\epsfbox{PicPicture/Design.ps}
\epsffile[0 0 500 400]{PicPicture/Design.ps}
\caption{Principal execution steps in WD-pic from GUI event to the picture}
\label{Fig. 2}
\end{figure}

   \item  The drawing data structures are used for  drawing  the picture on the screen. 
  Of course, this picture is the same as the picture created by {\bf Pic}, TROFF, etc. given as input the {\bf Pic} text produced by  WD-pic. 
\end{enumerate}




\subsection{Two ways of creating picture and its internal representation in the WD-pic}
  
     There are two ways to create a picture and its representation
in  WD-pic:
\begin{itemize}
 \item using the WYSIWYG graphic interface to draw the picture,
 \item writing a textual description of the picture in the {\bf Pic} language.
\end{itemize}
  From the user's point of view, these two ways are equivalent in the final effect. 
\begin{enumerate}
  \item When the user draws a picture on a screen using the graphic interface, he/she simultaneously creates the picture's internal representation in the
{\bf Pic} language. This internal representation not only saves the  geometric and drawing characteristics of a picture's elements, such as coordinates of center, sizes, line style, etc., but also the relationship between elements. 
The graphic interface
allows  placing one element relative to another, specifying the size of one element relative to that of another, etc.  

  \item When the user changes the {\bf Pic} file corresponding to a picture  with the help
of a text editor, he/she immediately sees a changed picture
on the screen. After that the user can continue to work with the picture
using the graphic interface. Note that, the WD-pic interface allows  passing freely from WYSIWYG picture drawing to editing of the internal representation and vice versa.
\end{enumerate}

 At any given  time,
the picture on the screen is the same as the picture created via {\bf Pic}, TROFF, etc. with the accumulated internal representation as input. For each picture
element, all its parameters, for example size, line style, etc., can be
defined explicitly with the help of the WD-pic interface. If a parameter
is not defined, then it is assigned the corresponding {\bf Pic} default value.
Each new element is placed always at the current insertion point, which
is by default, the end point of the last element. WD-pic allows  placing the element in any place in a picture, using explicit instruction, that redefine the current insertion point while describing a new element. Simultaneously, the description of
this element in  {\bf Pic} format is added to the current insertion point in the internal representation.  The current insertion point has a visual manifestation as well as being the place in the internal representation after which the new tokens go. At any time, this accumulated internal representation (AIR) can be converted into a {\bf Pic} file by adding  special symbols to the beginning and to the end. After the insertion of a new element, 
the picture displayed on the screen is the same as that generated on paper by 
submitting the AIR to {\bf Pic} piped to TROFF, with the geographic center of the two pictures being the same. 
   

\subsection{Conditional classification of  {\bf Pic} language elements}

 It is convenient for our purposes to divide the main elements of the {\bf Pic} 
language into  five groups:
\begin{itemize}
 \item {\bf Pic} tokens: {\bf box, circle, ellipse, line, spline,
arrow, move, text, arc}, and the special symbol  ``{\bf ;}''.
 \item Drawing directions: parameters, that influence the rest of the picture. There are four such parameters, {\bf up, down, left,} and {\bf right}.
 \item  Element parameters: some of them can be united into groups. \newline
 \[\begin{array}{ll}
     \mbox{{\large \bf Group}}  &\mbox{\large \bf Pic elements}\\
     \mbox{Sizes}  &\mbox{\bf width, height}\\
                  &\mbox{\bf radius, diameter} \\ 
     \mbox{Directions}  &\mbox{\bf up, down, right, left} \\
     \mbox{Line style}   &\mbox{\bf solid, dotted, dashed, invisible}\\
     \mbox{Sources and destinations} &\mbox{\bf from, to}\\
     \mbox{Places}    &\mbox{\bf at, with ... at}\\
     \mbox{Arrow heads} &\mbox{ $->$, $<-$, $<->$}\\
     \mbox{Adjustments}   &\mbox{\bf above, below, right, left} \\
     \mbox{Arc directions}  &\mbox{\bf clockwise} 
     
\end{array}
 \]
   Other element parameters are {\bf fill} and {\bf same}
   
 \item Default values: 
{\bf scale, boxwid, boxht, linewid, lineht, circlerad, arcrad, ellipsewid,
ellipseht, movewid} and {\bf moveht}

 \item Operators: {\bf if ... then ... else ...} and \newline  {\bf for ... to ... by ... do ...}
 
\end{itemize}
\subsection{Conclusions}

All of the issues described above affect the user interface, which is the
subject of the next chapter, and ultimately the requirements of the program
under consideration.




\end{itemize}
\begin{figure}
\epsfig{file=PSpicture/MainW.ps,width=6in,angle=90}
\caption{MainWindow of WD-pic.}
\label{Fig. 3}
\end{figure}
 \newpage  
      
\section{User Interface}

\subsection{Main Window}

 WD-pic starts up with the main window shown in Fig.3.
\newline
   There are three parts in the main window:
   \begin{itemize}
     \item the button panel in the left part of  the main window.
     \item the menu bar
     \item the drawing area with vertical and horizontal scrollbars, used to reveal 
additional parts of the drawing area
   \end{itemize}
   The button panel is divided into three parts in accordance with the {\bf Pic} language classification that was given earlier:
    \begin{itemize}
     \item {\bf Pic} tokens
     \item drawing directions
     \item element parameters
    \end {itemize}
 Each of these parts contains buttons, in principle, for each of the elements of these
classifications described above. However, due to space limitations, at any time, only these elements that are legal to choose at this time are displayed. This,
of course, helps the user to avoid what would be a syntax error in the {\bf Pic} language.
  \subsection{ {\bf Pic} tokens}
  The {\bf Pic} tokens part of the button panel contains ten push buttons;
     one push button for each {\bf Pic} basic element; {\bf box, line, arrow,
   circle, ellipse, arc, spline, move, text}, and  {\bf ``;''}.
  The last is used to mark the end of the current element description. \newline
    \newline 

  \subsection{ Drawing directions}
      
    In {\bf Pic}, there are four drawing directions, {\bf up, down, left, right}, 
 which control
 the direction of drawing from the point in which they are pushed.
  The buttons for  directions contain arrows 
indicating the direction. Accordingly, these buttons are called arrow buttons. \newline
  
  \subsection{ Drawing element parameters}

  Element parameters allow the user to change the size of an element, its placement,
or its line style, to fill a {\bf box}, {\bf circle} or {\bf ellipse}, to change an {\bf arc}'s direction, to put an arrowhead on a {\bf line, spline, arrow,} or {\bf arc}, 
or to specify the adjustment of {\bf text}. There are default values for
all these parameters in the {\bf Pic} language. For example, the default line style
for all elements is solid, the only placement is at the current insertion point, the default fill value for {\bf box, circle}, or {\bf ellipse} is 0.3, and the default {\bf arc} direction is counterclockwise.  If any parameter is not given for any element, the default applies.
 In the table below, the size names and their default values  are presented.
\addcontentsline{lot}{table}{Table of size names and their default values.}
 \newline \newline \newline
\begin{tabular}{|l||l||r|} \hline
\emph{description} & \emph{parameter} & \emph{value(inches)} \\ \hline
width of a {\bf box}   & {\bf boxwid}   & 0.75 \\
height of a {\bf box}   & {\bf boxht}     &0.5 \\  
width of an {\bf ellipse}   & {\bf ellipsewid}   & 0.75 \\
height of an {\bf ellipse}   & {\bf ellipseht}     & 0.5 \\ 
radius of a {\bf circle}    & {\bf circlerad}     & 0.25 \\
radius of an {\bf arc}    & {\bf arc}     & 0.25 \\
horizontal {\bf line} length   & {\bf linewid} & 0.5 \\
vertical {\bf line} length   & {\bf lineht} & 0.5 \\
horizontal {\bf move} length   & {\bf movewid} & 0.5 \\
vertical {\bf move} length   & {\bf moveht} & 0.5 \\  \hline
\end{tabular}
\newline \newline \newline
 All defaults are chosen so that many typical  diagrams that computer scientists make in technical papers can be produced 
entirely with elements without any parameters. This means that in WD-pic, 
these diagrams can be constructed almost entirely by clicking element buttons one
after the other, using the keyboard only for {\bf text}.

 
  In the beginning,  the drawing element parameters part of the button panel is empty.  After the user selects an
 element from the {\bf Pic} token part, then a set of 
 push buttons  appears, each of which allows the user to define a different drawing parameter of the  
current  element. 
 \newline
      The parameters for {\bf box, circle,} and {\bf ellipse} are:

\begin{enumerate}

 \item {\bf sizes} - to change the element's size.
 \item {\bf lines} - to change the element's line style.
 \item {\bf place} - to change the element's place.
 \item {\bf fill}  - to fill the element.
 \item {\bf same}  - the element has the same size as the previous element of this kind.
\end{enumerate}

    The parameters  for {\bf line, arrow,} and {\bf spline} are:

\begin{enumerate}

 \item {\bf direction} - to change the element's direction.
 \item {\bf line}   - to change the element's line style.
 \item {\bf from - to} - to change the beginning and the end of the element.
 \item $-> $   - to put an arrowhead on the element .
 \item {\bf same} -  the element has the same size as the previous element of this kind. 
\end{enumerate}

   The parameters for {\bf arc} are: 
\begin{enumerate}

  \item {\bf radius} - to change the element's radius.
  \item {\bf invisible} - to make the element invisible.
  \item {\bf from - to}- to change the beginning and the end of the element.
  \item {\bf direction} - to choose the direction of the element, which may be either counterclockwise or clockwise.
  \item $->$ to put an arrowhead on the element.
\end{enumerate}

    The parameters for {\bf move} are:

\begin{enumerate}
  \item {\bf direction} - to change the direction of the element.
  \item {\bf to} - to choose the end point of the element, which may be relative to another element of the picture.
  \item {\bf same} - the element has the same size as the previous element of this kind.
\end{enumerate}

    The parameters  for {\bf text}  associated with an element are:
\begin{enumerate}
  \item {\bf adjust} - to specify the adjustment of the {\it text} relative to its position.
  \item {\bf to element} - to return to the push button set, corresponding to
the element, containing this {\it text}.
\end{enumerate}
   {\bf Text} associated with an element is the only kind of {\bf Pic} element that can be
embedded  in another one. In order to allow the user to continue to
work with the enclosing {\bf Pic} element, the parameter {\bf to element}
was introduced.
   

     The parameters for self-standing {\bf text} are:

\begin{enumerate}

  \item {\bf place} - to choose the {\it text's} position.
  \item {\bf adjust} - to specify the adjustment of the {\it text} relative to its position.

\end{enumerate}

  In  Fig. 4, a structure showing which parameters appear for each
{\bf Pic} token is presented. 


\begin{figure}
\epsffile[0 0 500 380]{PicPicture/Button.ps}
\caption{{\bf Pic} tokens and their parameters.}
\label{Fig. 2.2}
\end{figure}


   \subsubsection{Size control}

   For each kind of {\bf Pic} basic element, except {\bf text}, of course there is a push button in the corresponding push button set, that allows  controlling
the element's size.

   For a {\bf box, circle,} or {\bf ellipse} this is the {\bf size} push button.    The size of a{\bf line, arrow,} or {\bf spline} can be changed with the help of the {\bf direction}  push button. 
   For an {\bf arc}, the {\bf radius} push  allows to change a size of element.  For a {\bf move}, this is the {\bf place} push button.

    \subsubsection{ Place control}

  As for  size control,  for  place control there is also a push button  that allows  controlling the element's placement.

  For a {\bf box, circle,} and {\bf ellipse}, it is the {\bf place} push button. 
    For an {\bf arrow, line, spline,} or {\bf arc}, there is a {\bf from-to} push button, which 
allows  placing  the beginning of the {\bf arrow, line, spline} or {\bf arc}, and its end.
 
  
     \subsubsection{ Line style}
\newline

 The {\bf lines} push button  serves for selecting a line's style. There are four possible line styles: {\bf solid}, {\bf dotted}, {\bf dashed} and
{\bf invisible}. 
   
 

      \subsubsection{ Fill style}
\newline

 In {\bf Pic}, the attribute {\bf fill} applies only to {\bf box}, {\bf circle} and {\bf ellipse}. 

     \subsubsection{ Attribute {\bf same}}

  The push button set for each element except {\bf text} and {\bf arc} contains the push button {\bf same}.
This push button serves for changing the size of the current element according  to the
size of last element of the same kind. 

  \subsection{ Menu bar}
\newline

   The menu bar contains five popup menus: 
\begin{itemize}
  \item {\it File}
 \item {\it Edit}
 \item {\it View}
 \item {\it Structures}
 \item {\it Defaults}
\end{itemize}
  The menu bar can be conditionally divided into two parts. The first part, containing
the  {\it File, Edit,} and {\it View} popup menus, corresponds to the interaction of the graphic
interface with the file and the displayed picture.  The second part, containing the {\it Structures} and {\it Defaults} popup menus, corresponds to the operator group and default 
group of {\bf Pic} language elements.     

      \subsubsection{{\it File} popup menu}
\newline
 

   The {\it File} popup menu   has the following
items:  {\it New, Save Current File, Store as New File, Read File,} and {\it Quit.} These options allows the user to start a new picture, to save a picture, to save a picture with a new name, to read a picture, and to finish work with WD-pic.  \newline


     \subsubsection{{\it Edit} popup menu}
\newline

 The {\it Edit} popup menu   has the following
items: {\it Select element, Insert, Add, End Insert/Add, Modify attribute,
 Delete}, and {\it Text edit.} These options allows the user to select any
element of a picture, to add a new group of elements before or after the
selected element, to finish new element addition, to modify an attributes of the selected element, to delete the selected element, and to change a picture
useing text editor.


   \subsubsection {{\it View} popup menu}

 
 The  popup menu  {\it View} contains only one 
item: {\it File View.}, which allows the user to view  any existing {\bf Pic} file and also the  {\bf Pic}
text corresponding to the current picture.




   \subsubsection{{\it Structures} popup menu}

 WD-pic provides the  possibility of  using {\bf Pic} {\bf if} statements and {\bf for} loops. These items were regarded as not really appropriate or feasible for direct manipulation as they represent repeatedly
conditionally performed requirements of button clicks. Therefore it was decided to use a menu interface for them. The {\it Structures} popup menu   contains two options, {\it Loop} and 
{\it if ... then ... else.} for {\bf if} statements and {\bf for} loops accordingly.



          \subsubsection{{\it Defaults} popup menu}

   WD-pic provides  scale and default sizes control. For this purpose, the  
popup menu  {\it Defaults} contains three items, {\it Scale, New defaults,} and {\it Reset}.


\subsection{Conclusions}

The elements of the user interface follow the structure of the language
elements described earlier in Section 3. This assists in the prototyping
effort in that whenever there is a change to the structure of the language
or to the way dealing with an element of the language, the place in the
interpreter affected by the change is clear.


\newpage

\section{ Implementation}

   \subsection{ Data structures}
  \subsubsection{Pic compiler execution and its data structures}
\newline

      In order to understand the behavior of WD-pic, we need to analyze the execution of the
 {\bf Pic} compiler  and  the data structures created by {\bf Pic}
 compiler.

   In  Fig. 5, the connection between and the data flow between {\bf Pic} and TROFF is presented.


 Schematically,  we can represent a run of the {\bf Pic} compiler as the following sequence
of steps:
  \begin{itemize}
     \item The {\bf Pic} compiler gets a {\bf Pic} file, i.e. program, written in 
the {\bf Pic} language, describing a picture, as  input.
     \item Using lexical and syntax analysis, the {\bf Pic} compiler translates
the input into special data structures, containing all the necessary geometric and drawing
information. 
    \item Using these data structures, the {\bf Pic} compiler produces a description of the same picture in the
TROFF language. 
  \end{itemize} 

\begin{figure}
%\psfig{figure = PicPicture/PicExecution.ps}
%\epsffile[50 500 300 620]{PicPicture/PicExecution.ps}
\epsffile[0 0 500 110]{PicPicture/PicExecution.ps}
\caption{Connection  and data flow between {\bf Pic} and TROFF}
\label{Fig. 7}
\end{figure}



   It seems natural to use the data structures, created by {\bf Pic},   with some  changes, in  WD-pic. It gives the possibility to simplify the interface of WD-pic with the {\bf Pic} compiler
and allows, in some cases, to use the {\bf Pic} compiler directly for
creating drawing data structures, as will be described later.\newline
\begin{figure}
\epsfbox[0 0 500 320]{PicPicture/ObjStr.ps}
\caption{Connection between object array and string array}
\label{Fig. 8}
\end{figure}

  Fig. 6 presents two data structures of the {\bf Pic} compiler, the object array and
the string array.

 \begin{itemize}
   \item Object array - an array of picture elements. Each  element in 
the object array contains a pointer to an object structure. Each object structure contains an element type (box, circle, etc.), an element
geometry,  a line style, a fill mode, etc.  Also an object structure
contains two indexes of  elements in the string array.  The first, 
{\it o\_nt1}, is the index of the element, containing a first text string, that belongs to
the {\bf Pic} element corresponding to the object structure.  The second, 
{\it o\_nt2}, is the index of the element containing the first text string which does not belong
to the {\bf Pic} element corresponding to the object structure.
   \item String array. Each element of the string array corresponds to a 
{\bf text}, which may be associated with a picture element or may be self standing, 
and also contains the {\bf text}'s adjustment (left, right, up, down) type.
 \end{itemize}   

  

 \subsubsection{Methods of picture representation in  WD-pic}

       A picture is represented in  WD-pic in two different ways:
 \begin{itemize}
   \item  with the help of drawing data structures, structures containing all necessary geometric and
drawing information for each element of the picture.
   \item with the help of a data structure containing a representation of the {\bf Pic} text, ``{\bf Pic} data structure'' for brevity.
 \end{itemize}
    
  Of course,  a connection exists between the drawing data structures and the {\bf Pic}
data structure. 

  

  
\begin{figure}
\epsfbox[0 0 400 230]{PicPicture/DS.ps}
%\begin{picture}(300,120)
%\end{picture}
\caption{WD-pic execution}
\label{Fig. 7}
\end{figure}

\subsubsection{WD-pic execution scheme and its data structures}

     In Fig. 7, we can see the scheme of a WD-pic execution.
   WD-pic has two kinds of  input data:
\begin{itemize}
  \item data structures, created by the {\bf Pic} compiler.

    We have  this  data when the user wants to read a text file in the {\bf Pic} language. Then this file  is passed to the {\bf Pic} compiler as input. In  turn, the {\bf Pic} compiler  creates all necessary data structures and passes them to the WD-pic for it to draw the picture. This passing is indicated by the arrow
marked ``2'' in Fig. 7.


  \item user data, created with the help of the graphic interface. 
    In this case, there are two types of  input data treatment:
\begin{enumerate}
\item For the first type,  WD-pic  either creates new data structure elements or adds new information to existing ones. This data flow is indicated by the arrow marked ``1'' in Fig. 7.
\item For the second type, created by the interface, a picture representation in the {\bf Pic} language is used. WD-pic changes only
this representation and uses it to create a file according to the {\bf Pic} standard. This file is passed to the {\bf Pic} compiler as input data. 
The {\bf Pic} compiler creates all necessary data structures and passes them to the WD-pic for it to draw the picture. This passing is indicated by the arrow marked ``2'' in Fig. 7. This method is used, when complex
calculations are needed, for example, to change {\bf box, circle,} or {\bf ellipse} sizes,
to place an element, etc. 
\end{enumerate}
\end{itemize}

 
     \subsubsection{Pic data structures}
\newline

     An internal picture representation in the {\bf Pic} language is stored in the memory as a linked list,
called the Pic text list. This data structure allows   carrying out such operations,
as an insertion of a new element into the list and  a deletion of an element from the list.
Appendix B contains a detailed description of Pic text list
 
  Each element of the {\bf Pic} text list corresponds either to a {\bf Pic} element, to a {\bf Pic} operator, or to a {\bf Pic} default size change.    

     

\end{enumerate}

\subsubsection{Drawing data structures}

   As was mentioned earlier, the drawing data structures were borrowed with some additions from the
{\bf Pic} compiler.
    In the {\bf Pic} compiler, all information necessary for drawing  is contained
in the elements of the object array. We use this object array in  WD-pic. However, in order to keep a connection between 
an element's drawing information and its description in the {\bf Pic} language,  a new data field was added to
the structure of the object array element. This data field allows accessing to 
the corresponding element of the {\bf Pic} text list. The detailed description 
of object array is shown in Appendix B.

   In Fig. 8, we can see connections between the {\bf Pic} text list, the object array, and the string array.


\begin{figure}
\epsfbox[0 20 320 400]{PicPicture/PicObjStr.ps}
\caption{Connections between the {\bf Pic} text list, the object array and the string array}
\label{fig 8}
\end{figure}


 WD-pic  also uses the string array. Each element of the string array contains
the drawing information for its {\bf text}

 
   


   \subsubsection {Changes to the Pic compiler's code}
  Because we want  the {\bf Pic} compiler to create the data structures that can be easily
transformed to WD-pic data structures, 
some changes were made to the original {\bf Pic} compiler. In this subsection we
are using italic font for code, which was added to the {\bf Pic} compiler, and
normal font for its original code.

A new array  was added, the {\bf Pic} text array. Its
elements have the same structure as an element of the {\bf Pic} text list of WD-pic, and
contain the same information.
The code below contains a description of the  {\bf Pic} text array element structure: \newline\newline
{\em typedef struct Def\{ \newline
  \hspace*{1.0in}                  char *curString; \newline                  
  \hspace*{1in}                  int   curStringLength;\newline
                  \} PicTextDef;\newline}

\newline \newline

The following variables were added to the {\bf Pic} compiler's code: \newline \newline
\hspace*{0.5in}/* a pointer to the beginning of the {\bf Pic} text array */ \newline
{\em PicTextDef  *picText;}\newline \newline
\hspace*{0.5in}/* the index of the current element of Pic text array */\newline 
{\em int curNumPicText;}     \newline \newline
\hspace*{0.5in} /* the maximum number of elements in the Pic text array */\newline
{\em int maxNumPicText;}   
\newline \newline
Here  is the initialization of the Pic text array: \newline
{\em picText = (PicTextDef *) grow((char *)picText, "PicTextDef", \newline
\hspace*{1in} maxNumPicText += 1000, sizeof(PicTextDef));}
\newline \newline
For compatibility with WD-pic, the  new field, {\it PicTextUnion}, was added to the
object array. This field contains an index of the corresponding element of
Pic text array.

  Besides the changes in the data structures, some additions were made to the {\bf Pic}
compiler's code.  The main additions were  in the lexical analysis part.
For each {\bf Pic} word,  function {\em CreatePicElementText} was added. This
function builds the {\bf Pic} text array. 
For example, for  the word {\em ellipse} we have now   the LEX code: \newline

 $<$A$>$ellipse \hspace{0.4in}{\it	\{  if (MarkStruct $!=$ String\_pic)\{  \newline                                                             
      \hspace*{1.5in}            CreatePicElementText(!ElemRef,"ellipse",ELLIPSE);\newline
       \hspace*{1.5in}                  ElemRef $=$ 1; \newline
        \hspace*{1.5in}           \} } \newline
        \hspace*{1.5in}           return(yylval.i $=$ ELLIPSE);\newline
         \hspace*{1.5in}       \}
\newline \newline

  The function {\it CreatePicElementText} adds  a new  element to the {\bf Pic} text array. This element  contains  a pointer to the string {\em ellipse}.  This function makes all necessary changes to the {\bf Pic} text array.  In  WD-pic, the analogous function
makes all necessary changes to the {\bf Pic} text list. Because these functions are very
important, we  give here the code of one of them, which is
used in {\bf Pic} compiler.
\newline

This function gets as  input: \newline 
\hspace{0.4in} {\it textElement},  a {\bf Pic} word, \newline
\hspace{0.4in}{\it Element},  its code,\newline
\hspace{0.4in  } {\it NewElem},  a parameter that marks a {\bf Pic} 
element that is not inside a {\bf Pic} operator, a {\bf box, arrow, circle, ellipse, spline, move,}  self-standing {\bf text}, or the first word of a {\bf Pic} operator ({\bf for} or {\bf if}). \newline

For a {\bf Pic} word that is marked by {\it NewElem}, we begin a new 
element in the {\bf Pic} text array. For all other {\bf Pic} words, we just add a new
word to the string of the current {\bf Pic} text array element.\newline\newline
\footnotesize
{\em void CreatePicElementText(NewElem, textElem,Element) \newline
int NewElem;  \newline
char* textElem; \newline
int Element;   \newline
\{ \newline
 int length;  \newline
 char *ptr;   \newline
 char *text;  \newline
 int i;       \newline

/* If textElem contains a full {\bf Pic} word we  add a blank to the end of
   the word                                                                 */

  
 if (Element $!=$ 999) \newline
      \{ \newline

       length = strlen(textElem) + 1;

       text = malloc(length * sizeof(char));

       strncpy(text,textElem,length -1);

       text[length-1] = ' ';

      \}

 else \newline

/* If textElem contains only one symbol, figure  or letter, which \newline
is part of  number or  label, we don't add a blank */ 



     \{

       length = 1;

       text = malloc(sizeof(char));

       text[0] = textElem[0];

     \}



 /***********************************************************************

    There are two possible cases :
\begin{enumerate}

             \item a new element in the picture or the header of a structure i.e., an if

         or a loop, that requires a new element addition to the {\bf Pic} text array

             \item An existing element parameter or the body of a structure that 

         must be added  to the string of {\bf Pic} text array element. This string
         
         already contains a {\bf Pic} element description or a {\bf Pic} structure

         header.
\end{enumerate}

  ***********************************************************************/




 /***********************************************************************/
    
     {\em picText}  is a pointer to the beginning of {\bf Pic} text array.


     {\em curNumPicText}  is the index of the current {\bf Pic} Text Array  element.


*************************************************************************/


 
 if (NewElem) 
    \{

        /**********   New   element  or structure header  ***********/

         curNumPicText++;

         if (curNumPicText $>=$ maxNumPicText)
            \{

         	picText $=$ (PicTextDef *) grow((char *)picText, 

                              "PicTextDef", maxNumPicText += 1000, 

                                               sizeof(PicTextDef));


           \}

                     
         picText[curNumPicText].curString $=$ 

                           (char*)malloc(length * sizeof(char));

         strncpy(picText[curNumPicText].curString, text, length);

         picText[curNumPicText].curStringLength = length;

   \}

 else \{



    /**********   Element parameter or body of a structure    ************/        

         picText[curNumPicText].curString = 

           (char*)realloc(picText[curNumPicText].curString,

             (picText[curNumPicText].curStringLength += length) * sizeof(char));

         ptr = picText[curNumPicText].curString +

              (picText[curNumPicText].curStringLength - length) * sizeof(char);

         strncpy(ptr, text, length);

 \}

 free(text); 

\} 
}
\normalsize

\newline
\newline
\vspace*{0.4in}


   In the YACC code of the {\bf Pic} compiler  for ELLIPSE  is the definition

\vspace*{0.4in}
\newline
\newline
prim: \hspace{0.4in}  ELLIPSE attrlist \hspace{0.4in}\{ \$\$ = circgen(\$1); \}

\newline
\newline \vspace*{0.4in}

    In the function circgen(), new elements are added to the object array
and the string array. In order to establish connection between the object array and
the Pic text array, the new string was added to the function:
\newline
\newline

        {\em p-$>$PicTextUnion.Num $=$ curNumPicText;}
\newline
\newline

Here, {\em p}  is a pointer to the object array element corresponding to the ellipse.

\subsubsection{Summary}
  \newline
     Using {\bf Pic} compiler data structures, we created  the WD-pic data
structures, allowing  us to store all necessary information  for
working with a picture via both graphical interface and a text editor interface. After that,
we modified the {\bf Pic} compiler data structures in order that they conform  to the 
WD-pic data structures. Also we changed  the {\bf Pic} compiler code
so that it supports the modified data structures. 


       \subsection{Internal program organization}

\subsubsection{Callback function as a connection between the graphic interface and data structures}

   In previous sections, we described  the interface of  WD-pic and the picture
representations in WD-pic. The user can change the picture with the help of elements of the interface via data structures.  Also, using elements of the interface, he/she
can deal with the file, containing the {\bf Pic} text corresponding to the picture. In Motif, each element of
interface has a set of events, each of which can be treated by a callback function.
   We can consider callback functions, corresponding to each element of the
WD-pic interface as a connection between the graphic interface and  either the  data
structures or the {\bf Pic} file (Fig. 9).

\begin{figure}
\epsfbox[0 20 500 200]{PicPicture/Callback.ps}
\caption{Connection between the interface and either data structures or {\bf Pic} text}
\label{Fig. 11}
\end{figure}

   In the table below, the  callback functions for all elements of the interface are listed:
\addcontentsline{lot}{table}{Table of callback functions for all elements of interface.}
   \[\begin{array}{ll}
     \mbox{{\large \bf Elements of the interface}}  &\mbox{\large \bf Callback functions}\\
     \mbox{Push buttons}  &\mbox{{\bf ButtonFunction}}\\
     \mbox{{\it File} popup menu}       &\mbox{{\bf FileCb}} \\
     \mbox{{\it Edit} popup menu}       &\mbox{{\bf EditCb}}\\
     \mbox{{\it View} popup menu}       &\mbox{{\bf ViewCb}}\\
     \mbox{{\it Defaults} popup menu}   &\mbox{{\bf DefaultCb}}\\
     \mbox{{\it Struct} popup menu}     &\mbox{{\bf StructCb}} \\
    \end{array}
 \]

  {\bf Button Function, StructCb} and {\bf DefaultCb} correspond to 
{\bf Pic} language elements. {\bf FileCb, EditCb} and {\bf ViewCb} correspond
to interactions of the graphic interface with the file and the current
picture.

      \subsubsection{Push buttons Callback function - ButtonFunction}

    All push buttons, described in the interface part, share one and the same callback function, called {\bf ButtonFunction}. Each push button has a unique number.  After the user has pushed chosen push button, {\bf Button Function} starts its execution  with the push button's unique number as a parameter. \newline

   {\bf ButtonFunction} executes in two steps:
\begin{enumerate}
  \item  It returns the background and the foreground of the previously selected push button, 
(if present) to the original and reverses the background and the foreground of the
currently selected push button.
  \item It calls function {\bf Interpreter} with the push button's unique number as a
parameter.
\end{enumerate}

      The function {\bf Interpreter}, according to its parameter, chooses the proper treatment function for the selected push button. 
  
    \subsubsection{General description of push buttons treatment functions.}
 All treatment functions
translate events, invoked by the user interface, into a
string or substring of {\bf Pic} lexical tokens, which must be added to the {\bf Pic} picture representation.
   Some of these functions do not need additional information, for example
treatment functions corresponding to {\bf box, move,} or {\bf  circle} push buttons.
Some of them do need  additional information, for example, the treatment
function corresponding to the {\bf text} push button. Such functions create a new
elements of interface in order to get this information.
   Each treatment function executes in two modes:
\begin{itemize}
   \item {\it Append} mode, corresponding to an  addition of a new string or substring
to the end of the {\bf Pic} picture representation.
   \item {\it Insert} mode, corresponding to an insertion of a new string or substring
 in the {\bf Pic} picture representation.
 \end{itemize} 

   In Subsection 5.1, we described two methods of treatment of input data, invoked with the help of graphic interface. All treatment functions can be
divided into two groups:
  \begin{itemize}
    \item Callback functions, which implement in {\it append} mode the first method.
    \item Callback functions, which implement in {\it append} mode the second method.
  \end{itemize}
  In {\it insert} mode all treatment functions implement the second method.
   Realization of the first method doesn't introduce any problems, but realization
of the second method is more complex and needs  detailed explanation:

  \begin{enumerate}
      \item WD-pic,  creates  a empty character array in memory . All strings from Pic text list are copied into this array. Also  special {\bf Pic} symbols are added to the beginning and end of the array. At the end, this array contains the {\bf Pic}
text corresponding to the picture on the screen.
       
      \item  WD-pic, using {\em fork} and {\em exec} UNIX system calls, creates a child
process, which executes the {\bf Pic} compiler. 
      \item With the help of a {\em pipe},  WD-pic establishes a connection with its child process.
      \item The standard input of {\bf Pic} compiler is redirected to the {\em pipe}.
      \item Using the {\em pipe}, WD-pic delivers the string to the {\bf Pic}
compiler as an input and waits for data structures produced by {\bf Pic}.
     \item The {\bf Pic} compiler starts execution.
     \item  When the {\bf Pic} compiler finishes its execution it sends the new data structures
to  WD-pic using the {\em pipe}
  \end{enumerate} 
     
 
   
     \subsubsection{Pic token treatment}

  Here is a part of function {\bf Interpreter} code. \newline \newline 
\footnotesize
 case (\_BOX)    :  \newline
/* Call of treatment function for {\bf box} */ \newline
\hspace*{1in}BoxFunction(); \newline
/* If  push button parameter set for box exists then break */\newline
\hspace*{1in} if (currentPanelNumber == 0) break; \newline
/* If exists push button parameter set for any {\bf Pic} \newline  token except box then destroy it */ \newline  
\hspace*{1in} if (currentPanelNumber != -1)  \newline
\hspace*{1.8in} XtDestroyWidget(buttonFrameParam); \newline
/* Create push button set for {\bf box} */ \newline                
\hspace*{1in}BoxParameters(); \newline
\hspace*{1in}currentPanelNumber = prevPanelNumber = 0; \newline
\hspace*{1in} break; 
\normalsize
\newline
\newline
  This code  calls  the  treatment function for the {\bf Pic} token {\bf box}
and creates the push button parameter set for {\bf box}.  For other {\bf Pic} tokens,
the same operations are executed.

  The treatment functions for a {\bf box, line, arrow, ellipse, circle, arc,} and  {\bf spline}
  first of all check the current mode, {\it append} or {\it insert}, and then execute the following steps:
  \begin{itemize}
     \item  For {\it append} mode, they update the data structures 
 using first method of graphic input treatment. This method for {\bf Pic} tokens  is explained in detail below.
   \begin{enumerate}
     \item  If there is a free place in the object array, it is used as a pointer to
the structure, corresponding to the new object. If the object array is full,  
its length is increased by a constant number, and the first free place is used as a pointer to this structure.
    \item  The structure corresponding to the new object is filled according
to {\bf Pic} defaults and the current state of the picture.
    \item  A new element, containing a string in {\bf Pic} format that corresponds to the {\bf Pic} token is
added to the {\bf Pic} text list and the pointer to the new element of the {\bf Pic} text list
is inserted into the object structure.
   
\end{enumerate}


Here is some code from the treatment function for {\bf box}. This part corresponds to the {\it append}
mode execution. This code creates and fills the object structure,
that was described in the previous section. \newline


\footnotesize

 obj* ptr; \newline
 ElemReference = 0; \newline
 /* In function Create Obj free place searching  in object array and object
 structure creation are executed */ \newline
 ptr = CreateObj(2); \newline
 /* CurrentX and CurrentY are coordinates of the current insertion point */

 ptr$->$o\_x = CurrentX;

 ptr$->$o\_y = CurrentY;

 /* Calculations of coordinates of the {\bf box} center and coordinates of
  the new current insertion point. These calculation depend on the current
picture direction */ 
 
 if (CurDirection == R\_DIR)
 \{ 

             ptr$->$o\_x += 0.5 * MyDefaultTable[0].pixel;

             CurrentX += MyDefaultTable[0].pixel;

 \}

 if (CurDirection == L\_DIR)
 \{

       ptr$->$o\_x -= 0.5 * MyDefaultTable[0].pixel;

       CurrentX -= MyDefaultTable[0].pixel;

  \}

 if (CurDirection == U\_DIR)
 \{

          ptr$->$o\_y -= 0.5 * MyDefaultTable[1].pixel;

          CurrentY -= MyDefaultTable[1].pixel;

  \}

 if (CurDirection == D\_DIR)
 \{

          ptr$->$o\_y += 0.5 * MyDefaultTable[1].pixel;

          CurrentY += MyDefaultTable[1].pixel;

  \} 

 /* Structure filling */

 ptr$->$o\_type = BOX;

 ptr$->$o\_nt1 = ptr$->$o\_nt2 = NumText;

 ptr$->$o\_mode = CurDirection;

 ptr$->$o\_count = 2;

 ptr$->$o\_val[0] = MyDefaultTable[0].pixel;

 ptr$->$o\_val[1] = MyDefaultTable[1].pixel;

 ptr$->$o\_attr = 0;

 ptr$->$o\_ddval = MyDefaultTable[14].pixel;

 ptr$->$o\_fillval = MyDefaultTable[18].pixel;

/* Addition of the new element, containing pointer to the string ``box'' to
the Pic text list */

 CreatePicElementText(!ElemReference,"box",BOX);

/* Establishing pointer to the corresponding Pic text list element */ \newline

 ptr$->$PicTextUnion.Ptr = curPicText;  \newline \newline

\normalsize



   \item For {\it insert} mode, we use the second method of graphic input treatment: 
  \begin{enumerate}
     \item The new element is inserted into the {\bf Pic} text list. This element contains a pointer to the string in the {\bf Pic} language corresponding to the {\bf Pic} token.
     \item  The second method of data treatment, described above, is executed.
   
\end{enumerate}
  \end{itemize}

 After either updating the old data structures or   getting new data structures, the 
treatment function
\begin{itemize}

\item executes all necessary geometric calculations, using the object array.
\item draws  the resulting picture.
\end{itemize}

      The treatment function for {\bf move} executes all those steps, except last two
 in the normal mode (geometric calculation and drawing).

   The treatment function for {\bf text},  different from other {\bf Pic} token
treatment functions, needs additional information. In order to get this
 information, it creates a standard prompt dialog in which user is asked to insert a string.\newline

    There are two kinds of {\bf text} in the {\bf Pic} language:
     \begin{enumerate}
        \item {\bf text}, associated with a {\bf Pic} element.
        \item self-standing {\bf text}.
     \end{enumerate}
 For each kind of a {\bf text}, there is a different treatment in the {\it append} mode.  
    \begin{itemize}
        \item For {\bf text} associated with a {\bf Pic} element:   
            \begin{enumerate}
                      \item Add this {\bf text} to the string of the {\bf Pic} text list element corresponding to the {\bf Pic} element containing this {\bf text}.
               \item If there is a free place in  the string array, insert into it the new element. If string array is full 
its length is increased by a constant number and the first free place is used for the new element.

               \item Change  field, {\it o\_nt2}, in the object structure 
corresponding to the {\bf Pic} element with which the string is associated.
          \end{enumerate}
        \item  For self-standing {\bf text}.
             \begin{enumerate} 
                 \item Add a new element to the {\bf Pic} text list.
                
                 \item Insert a new element into  the string array, as was described earlier.
                \item Create a new object structure in the object array the same way as
was done for the other {\bf Pic} tokens.
             \end{enumerate}
     \end{itemize}

  For {\it insert} mode, the treatment function just changes the {\bf Pic} text list as was described before and uses the {\bf Pic} compiler to get new data structures. After updating or receiving new data structures from the {\bf Pic} compiler, the treatment function for  {\bf text} executes following steps:
\begin{enumerate}
 \item geometric calculation based on the object array
\item  drawing
\end{enumerate}


    \subsubsection{Element parameter treatment}

  Earlier, we defined two methods of treatment of input data, invoked with the help 
of the graphic interface. In the classification of the {\bf Pic} language (Chapter 3),   almost all
element parameters were divided into groups. Now, parameters from  these groups and parameters, which are not 
united into groups can be divided according to their treatment method in the {\it append} mode.
    Below is the list of parameter groups and parameters that are
treated by the first method in the {\it append} mode:
   \begin{enumerate}
      \item Line Styles group
      \item Directions group
      \item Arrow Heads group
      \item Adjustment group
      \item {\bf fill} parameter
      \item {\bf at} parameter from the Places group, when the user wants to place 
an element by the coordinates of its center
   \end{enumerate}


  Below is the list of parameter groups and parameters, which are
treated by the second method in the {\it append} mode:
    
  
  \begin{enumerate}
    \item Sizes group
    \item Sources and destinations group
    \item Places group, except the {\bf at} parameter for placing element by its
center
    \item Arc directions group.
    \item {\bf same} parameter
  \end{enumerate}


\subsubsection{Drawing directions treatment}

   The treatment function for drawing directions executes the following steps:
\begin{enumerate}
  \item Define a current mode ({\it append} or {\it insert}).
  \item Add to the {\bf Pic} text list a new element containing a pointer to
the string with the chosen direction name.
  \item In {\it append} mode, give to the global variable Direction a
new value.
  \item In {\it insert} mode, execute the second method of the graphic input treatment.
\end{itemize}

  


\subsubsection{{\it File} popup menu callback function}
  \newline



    This callback function  chooses a treatment
function for the selected menu item.  
   \begin{itemize}
       \item The treatment function for the menu item {\it New} is:
           \begin{enumerate}
                \item Destroy the {\bf Pic} text list, object array, and string array.
                \item Clear the drawing area.
                \item Create the empty object array and
                     the empty string array.
                \item  Assign the default values.
            \end{enumerate}
        \item The treatment function for the menu item {\it Save Current File} is: \newline

         If the {\bf Pic} file, corresponding to the picture has no name yet, i.e., the picture was not read from the file and was not saved before, then
         the treatment function for the {\it Store as new File} item is called.\newline 
 Otherwise, starting from the beginning of the {\bf Pic} text list,
         strings
         in {\bf Pic} format from each element of the list are written to the file. Of course, to the
        beginning and to the end of the file, the special {\bf Pic} symbols, .PS and .PE, are added.
              
        \item The treatment function for the menu item {\it Store as New File} is:
            \begin{enumerate}
                  \item A file selection dialog is created in order to give
           the user the possibility to choose a file name.
                  \item The {\bf Pic} text is recorded into the file the same way
                as for the {\it Save Current File} item.
            \end{enumerate}
         
         \item The treatment function for the menu item {\it Read File} is
    \begin{enumerate} 
        \item Destroy the {\bf Pic} text list, object array, and string array.
        \item Clear the   drawing area.
       
        \item   A file selection dialog is created in order to give
           the user the possibility to choose a file.
          
     \item Using the {\em fork} and {\em exec} UNIX system calls, create a child
process to execute the {\bf Pic} compiler. 
      \item With the help of a {\em pipe}, establish a connection between
WD-pic and the child process.
      \item  The standard input of the {\bf Pic} compiler is redirected from the chosen file.
      
     \item {\bf Pic} compiler begins its execution.
     \item  When the {\bf Pic} compiler finishes its execution, it sends new data structures
to WD-pic using the {\em pipe}.
   \end{enumerate}

  We can see that this method  looks like the second method of graphic input
treatment, except that {\bf Pic} compiler's input is redirected from the file and not from the {\em pipe}.

       \item The treatment function for the menu item {\it Quit}  quits the WD-pic execution with the help of the UNIX system call
  {\em exit}
  \end{itemize}

 


        

\subsubsection{{\it Edit} popup menu callback function}
      
    {\it Edit} popup menu callback function chooses a treatment
function according to the selected menu item.

     \begin{itemize}
      \item {\it Select element}: The treatment function for this item establishes the handler function for a mouse press event in the drawing area. In order to select a picture element the user must press the left mouse button at  some point of the drawing area belonging to the element. Pressing the mouse button invokes the handler function, which executes the following steps:

     \begin{enumerate}
        \item  Search for the element in the object array whose screen coverage includes the coordinates of the point.
        \item The selected object array element is a pointer to the structure that 
 contains  the field with the address of the corresponding 
{\bf Pic} text list element. The special pointer to the current element of the {\bf Pic} text list, {\it curPicText}, is established pointing to
this {\bf Pic} text list element. The special pointer to the previous element of
{\bf Pic} text list is established pointing to the previous element of the current {\bf Pic} text list
element. 

       \item  The selected element is redrawn with a double line by the function {\it DrawSelectElement}.
    \end{enumerate}

Here is code for element selection: \newline \footnotesize

/* (x, y) are coordinates of the point, selected with the help of mouse */ \newline
   x = event$->$x;

   y = event$->$y;

/* Searching an element containing the point (x,y) */ \newline
   sel\_obj = FindObj(x,y);


   if (sel\_obj!= NULL)


 \{

/* {\it curPicText} is a pointer to the Pic text list element, corresponding to the chosen object */

\hspace*{1in}   curPicText = sel\_obj$->$PicTextUnion.Ptr; \newline
/* {\it prevPicText} is a pointer to the Pic text list element, previous to the element, pointed by {\it curPicText} */

\hspace*{1in} prevPicText = DefinePrev(curPicText);

\hspace*{1in} IsSelect = 1;

/* redrawing of the selected element by double line */

\hspace*{1in} DrawSelectElement(sel\_obj); \newline
\hspace*{1in}        CurElemNum = DefineElemNum(sel\_obj);
   \} 
\newline
\normalsize

    \item {\it Insert}:  The treatment function for this item  establishes {\it insert} mode.
   \item {\it Add}:  The treatment function for this item: 
 \begin{enumerate}
\item  establishes {\it insert} mode, and
\item  reestablishes the previous pointer to the current pointer, and the current pointer to the next element of the current {\bf Pic} text list element.
\end{enumerate}
   \item {\it End Insert|Add}: The treatment function for this item  cancels
{\it insert} mode.
   \item {\it Modify attribute}: The treatment function for this item creates a dialog,
containing a text window with a {\bf Pic}  string describing the selected object. The pointer
to this string is contained in the current {\bf Pic} text list element. After the user has
finished changing  the string, the pointer to the new string replaces the pointer
to the old one in the current {\bf Pic} text list element.
 
   \item {\it Delete attribute}: The treatment function for this item deletes element of the
{\bf Pic} text list corresponding to the current drawing object. After that it
gets a new data structures from the {\bf Pic} compiler, as was described for the second method of graphical input treatment. Finally, it redraws the picture.
   \item {\it Text edit}: The treatment function for this item:
\begin{enumerate}
 
  \item creates a temporary file named tempXX.pic, where XX is the current process number. Using  the {\bf Pic} text list, it
writes into this file the text in {\bf Pic} format corresponding to the current picture, and after that closes this file. 
   \item creates a child process with the help of the {\it fork} system 
call,  and waits for its completion. 
   \item the child process in  turn invokes the text editor named by the environment variable EDITOR 
with the help of the {\it exec} system call. 
   \item after the user has finished changing  
tempXX.pic and has closed the editor, the parent process continues its execution and
invokes the {\bf Pic} compiler as described earlier, 
with  standard input redirected  from the temporary file.
   
   \item after getting new data structures, the picture is redrawn, and the temporary file is deleted.
  \end{enumerate}
\end{itemize}

\subsubsection{{\it View} popup menu callback function}
    The {\it View} popup menu contains only one item,{\it View}.  The callback for this item
  \begin{enumerate} 
     \item creates a prompt dialog, in order to get a file name.
     \item if the user didn't insert file name, all strings from {\bf Pic} text list elements are copied into a one character array in the memory with addition of special symbols to the beginning and to the end.
If the user inserted a file name into the prompt dialog, the file is read into a character array. 
     \item creates a scrolled text, containing a {\bf Pic} file. 
     \item destroys the temporary file, if one was created.
   \end{enumerate}

\subsubsection{{\it Structures} popup menu callback function}
   The callback for the {\it Structure} popup menu chooses functions for treatment of {\it loop} and  
{\it if... then...else} items.
   \begin{itemize} 
      \item 
         The treatment function for {\it loop}
       \begin{enumerate}
           \item creates a dialog, which allows the user to insert the loop's
      index, the high and low boundaries and the step.
           \item creates a temporary file and writes the {\bf Pic} text corresponding to the current picture into the file and adds the string
``from  {\it index-name} = {\it low-boundary} to {\it high boundary} by {\it step -name} do {...}'' to the current insertion point of the file.
           \item executes the same steps as for the {\it Text edit} item of the {\it Edit} menu.
        \end{enumerate}

 \item .
      The treatment function for {\it if ... then ... else}
 \begin{enumerate}
 \item creates a temporary file and writes the {\bf Pic} text corresponding to the current picture into the file and adds the string
``if ... then ... else to the current insertion point of the file.
  \item executes the same steps as for the {\it Text edit} item of the {\it Edit} menu.

   \end{enumerate}
\end{itemize}

   \subsubsection{{\it Defaults} popup menu callback function}
  The {\it Defaults} popup menu callback function chooses a treatment
function according to the selected menu item. All information related to the {\bf Pic} default sizes is contained in the special
 default table, containing all {\bf Pic} default values. Each table element has
the following structure: \newline
   {\it 
 \hspace*{0.5in} char  name[11]; \newline
 \hspace*{0.5in} int pixel; \newline
  \hspace*{0.5in} double inch; \newline
  \hspace*{0.5in} double def\_inch } \newline \newline

  Here
 \begin{itemize}
   \item {\it name} - is the name of the default parameter.
   \item {\it pixel} - is the current  parameter value in pixels.
   \item {\it inch} - is the current parameter value in inches.
   \item {\it def\_inch} - is the {\bf Pic} default value for the  parameter in inches.
 \end{itemize}
  The items of the {\it Default} popup menu allow the user to change the value of any parameter. 

  \begin{itemize}
    \item {\it New scale}. \newline
       The treatment function for this menu item executes following steps:
       \begin{enumerate}
         \item Create a prompt dialog, allowing the user to insert new value of  scale.
         \item Read the new scale value and  changes the {\it pixel} and the {\it inch} fields for all element of the default table.
        \item Replace the old scale value by the new one.
        \item Add a new element, containing a pointer to the 
string ``scale = {\it new\_scale\_value}'', to the {\bf Pic} text list.
        \item If the current mode is {\it insert}, then
the second method of graphic  input treatment is executed.
  \end{enumerate}
   \item {\it New Default}. \newline
      The treatment function for this  item executes following steps:
     \begin{enumerate}
        \item Create a dialog, containing a list of all default parameters
and their current values. The user can change these current values.
        \item For each default parameters, check if it was changed. If a  parameter
was changed, make all necessary changes in its default table element, corresponding to
the new value.
        \item For each changed default parameter, add to the {\bf Pic} text list a new element, containing a pointer to the string ``{\it default value name} = {\it new\_default\_value}".
      \item If the current mode is {\it insert}, then
the second method of graphic  input treatment is executed.
  \end{enumerate}
\item {\it Reset}. \newline
     The treatment function for this menu item executes following steps:
  \begin{enumerate}
        \item Find all default table elements for which the current default value
is not equal to the {\bf Pic} default value.
        \item Create a dialog, containing  the names of all such elements. This dialog
allows resetting either  some of their values or  all of them.
        \item For each reset parameter, replace its {\it inch} value by
its  {\it def\_inch} value and recalculate its {\it pixel} value, using screen metrics.
       \item If any of parameters were reset, for all such parameters,
 add to the  {\bf Pic} text list a new element containing a pointer to the
 string ``reset {\it default value name}".
        If all  parameters were reset add to the {\bf Pic} text list a new element containing a pointer to the string ``reset all".
     \item If the current mode is {\it insert}, then
the second method of graphic  input treatment is executed.
\end{enumerate}
 
\end{itemize}

\newpage
\section {Evaluation of usability of WD-pic}
\subsection{Method}

As stated in the introduction, it is desired that the evaluation be as
realistic as possible, consisting in using WD-pic to build diagrams that
are like those in real-life as much as possible. Accordingly, it was
decided to use WD-pic to prepare all the figures in this report. The
rationale is that the pictures in this report are typical of those needed
in computer science documents, precisely the domain of pic.

The author used WD-pic to draw all of these figures and others that were
not used. The author had become an expert in WD-pic by virtue of having
written it; she knew exactly what is allowed and what is not and exactly
what would do the job and what would not. Thus, she represents the expert
user. As mentioned, she used what she
learned from doing these drawings to discover problems with the
requirements of WD-pic and to suggest alternative behaviors.

The author's advisor used WD-pic to draw a few pictures for papers he was
writing. Although he is an expert in {\bf Pic} and can generate {\bf Pic} code for a
picture on the fly, he was a total novice in the use of WD-pic and actually
encountered quite a few difficulties, some of which led to changes in the
software's requirements.

Both compared their efforts to make drawings with WD-pic to their efforts
to make the same drawings with {\it xfig}, which they were both expert at.

This chapter first shows an example of making the same drawing in {\it xfig} and
WD-pic in order to give the reader a flavor of the way these comparisons
went. A number of pros and cons of WD-pic are apparent from this example.
Next, the WD-pic generated {\bf Pic} code for many of the figures shown in this
book is shown. These show that the main goal of human-like {\bf Pic} as the
internal representation has been achieved. The author's advisor agrees that
he would make {\bf Pic} very much like these if he were specifying them in normal
batch {\bf Pic}.
\newline
Finally comes a list of the drawbacks of WD-pic. These all amount to
problems with the current requirements for WD-pic, requirements that will
have to change if WD-pic is ever to be a successful software system. It
will be seen that many of these come from constraints that were observed to
meet the main goals and many of these come from the original choice of
using a set of widgets to build the user interface. 

\subsection{Figures in Thesis}

 Here are texts of {\bf Pic} files that correspond to  pictures presented
in this work. Please note how close these are to what a skilled human user of {\bf Pic} would write. \newline \newline

\begin{center}
{\bf Fig.1} \newline 
\end{center}
\footnotesize

.PS

right

A0 :box "WD-pic" 

arrow 

A1 :ellipse width 0.9 height 0.6 "Pic file" 

arrow 

box "Pic" 

arrow 

box "TROFF" 

arrow 

circle radius 0.4 "Picture" 

arrow from A0 .s down lineht *1 

circle same "Picture" 

arrow from A1 .s 

circle same "Disc" 

.PE
\normalsize
\newline \newline

\begin{center}
{\bf Fig.2} \newline
\end{center}
\footnotesize

.PS

down  

ellipse width 1.2 height 0.8 "Event" "generated by GUI" 

arrow 

box "WD-pic" 

arrow 

A0 :ellipse width 0.9 height 0.7 "Unique" "number" 

right 

arrow right linewid from A0 .e 

A0 :box width 0.8 height 1 "Pic" "interpreter" 

arrow 

circle radius 0.6 "drawing" "data structures" 

arrow 

box width 1 "picture" 

arrow from A0 .s down linewid *1 

circle same "Pic internal" "representation" 

.PE

\normalsize
\newline \newline
\newpage

\begin{center}
{\bf Fig.4} \newline 
\end{center}

\footnotesize

.PS

scale =1.1 

movewid =0.27 

A2 :box width 1 height 0.7 "Pic tokens" 

A3 :ellipse at A2 -(2 ,1.9 )same width 0.8 height 0.7 "box" "circle" "ellipse" 

move 

A4 :ellipse same "line" "spline" "arrow" 

move 


A5 :ellipse same "move" 

move 

A6 :ellipse same "arc" 

move 

A7 :ellipse same "text" 

arrow from A2 .sw to A3 .n 

arrow from A2 .sw to A4 .n 

arrow from A2 .s to A5 .n 

arrow from A2 .se to A6 .n 

arrow from A2 .se to A7 .n 

arrow from A3 .s down 0.30 

box width 0.8 height 0.5 "Parameters" 

arrow down 0.30 

box height 0.3 "sizes" 

box same "lines" 

box "place" same 

box same "fill" 

box same "same" 

arrow from A4 .s down 0.30 

box width 0.8 height 0.5 "Parameters" 

arrow down 0.30 

box height 0.3 "direction" 

box same "line" 

box same "from-to" 

box same "$->$" 

box same "same" 

arrow from A5 .s down 0.30 

box width 0.8 height 0.5 "Parameters" 

arrow same 

box height 0.3 "direction"
 
box same "to" 

box same "same" 

arrow from A6 .s same 

box width 0.8 height 0.5 "Parameters" 

arrow same 

box height 0.3 "radius" 

box same "invisible" 

box same "from-to" 

box same "direction" 

box same "$->$" 

A8 :ellipse at A7 +(-0.10 ,-1 )width 1 height 0.6 dashed "text " "associated 
with" "element" 

arrow same 

box width 0.8 height 0.5 "Parameters" 

arrow same 

box height 0.3 "adjust" 

box same "to element" 

A9 :ellipse at A7 +(1.2 ,-1 )same dashed "self-standing" "text" 

arrow same 

box width 0.8 height 0.5 "Parameters" 

arrow same 

A0 :box height 0.3 "place" 

arrow from A7 .s to A8 .n 

arrow from A7 .s to A9 .n 

box same with .nw at A0 .sw "adjust" 

.PE

\normalsize
\newline \newline
\begin{center}
{\bf Fig.7} \newline
\end{center}

\footnotesize

.PS

move down 1 right 1.5

box width 1.2 height 0.8 "PIC" "compiler" 

arrow 

ellipse width 1.2 height 0.8 "PIC" "Data Structures" 

arrow 

circle radius 0.5 "Interface" "to" "TROFF" 

.PE

\normalsize
\newline \newline
\begin{center}
{\center \bf Fig.8} \newline
\end{center}

\footnotesize

.PS

down 

"Object array" 

move down 0.49 

A9 :box width 0.6 height 0.3 

A11 :box same 

A13 :box same 

move right 1.50 up moveht *6 

down 

A10 :box " ..." 

A0 :box height 0.2 "o\_nt1" 

A2 :box same "o\_nt2" 

box "..." 

move 

A12 :box "..." 

A4 :box height 0.2 "o\_nt1" 

A5 :box same "o\_nt2" 

box "..." 

move 

A14 :box "..." 

A7 :box height 0.2 "o\_nt1" 

A8 :box same "o\_nt2" 

box "..." 

move right 2.00 up moveht *9 

down 

"String array" 

move down 0.30 

A1 :box 

box 

A3 :box 

box 

box 

box 

A6 :box 

arrow from A0 .e to A1 

arrow from A2 .e to A3 

arrow from A4 .e to A3 

arrow from A5 .e to A6 

arrow from A7 .e to A6 

arrow from A8 .e to A6 

arrow from A9 to A10 .nw 

arrow from A11 to A12 .nw 

arrow from A13 to A14 .nw 

.PE

\normalsize

\newline \newline

\begin{center}
{\bf Fig.9}\newline
\end{center}

\footnotesize

.PS

linewid =0.4 

arrow "File" above 

move left linewid *1 down lineht *1 

arrow right linewid *1 "GUI" above 

move up 0.24 

right 

A1 :box width 0.8 height 0.8 "WD-pic" 

arrow 

B0 :box same "PIC" "compiler" 

arrow 

A0 :ellipse width 1.2 height 0.8 "PIC" "Data Structures" 

arrow 

circle "Interface" "to" "TROFF" radius 0.5 

arrow 

A3 :arrow from A0 .s down lineht *2  \backslash

 then left linewid *4  \backslash

 to A1 .s 

A2 :arrow from A1 .s down lineht *2 

ellipse same "WD-pic" "Data Structures" 

"1" at A2 +(-0.09 ,-0.53 )

"2" at A3 +(-1.13 ,-0.94 )

box with .nw at B0 +(-0.7 ,0.8 )width 4.3 height 1.5 dotted 

.PE

\normalsize

\newline \newpage
\begin{center}
{\bf Fig.10} \newline
\end{center}

\footnotesize

.PS

down 

"Object array" 

move down 0.5 

A9 :box width 0.6 height 0.3 

A11 :box same 

A13 :box same 

move right 1.50 up moveht *6 

down 

A10 :box height 0.2 "Pic ptr" 

box " ..." 

A0 :box height 0.2 "o\_nt1" 

A2 :box same "o\_nt2" 

box "..." 

move 

A12 :box height 0.2 "Pic ptr" 

box "..." 

A4 :box height 0.2 "o\_nt1" 

A5 :box same "o\_nt2" 

box "..." 

move 

A14 :box height 0.2 "Pic ptr" 

box "..." 

A7 :box height 0.2 "o\_nt1" 

A8 :box same "o\_nt2" 

box "..." 

move right 2.00 up moveht *9 

down 

"String array" 

move down 0.30 

A1 :box 

box 

A3 :box 

box 

box 

box 

A6 :box 

arrow from A0 .e to A1
 
arrow from A2 .e to A3 

arrow from A4 .e to A3 

arrow from A5 .e to A6 

arrow from A7 .e to A6 

arrow from A8 .e to A6 

arrow from A9 to A10 .nw 

arrow from A11 to A12 .nw 

arrow from A13 to A14 .nw 

move left 3.00 up moveht *6 

down 

"Pic Text List" 

move down 0.30 

A15 :box 

arrow 

A16 :box 

arrow 

A17 :box 

spline from A10 .w left linewid *3 down lineht *1  \backslash

 then left linewid *1 down lineht *1 to A15 $->$ 

spline from A12 .w left linewid *1 up lineht *1  \backslash

 then left linewid *2 up lineht *1  \backslash

 then left linewid *1 down lineht *1  \backslash

 then left linewid *1 down lineht *1 to A16 $->$
 
spline from A14 .w left linewid *3 to A17 $->$ 

.PE

\normalsize
\newline \newline

\begin{center}
{\center \bf Fig.11} \newline 
\end{center}

\footnotesize

.PS

ellipse width 1 height 0.6 "WD-pic" "interface" 

arrow 

A1 :circle radius 0.6 dashed "Set of" "callback" "functions" 

arrow 

box width 0.8 height 0.6 "Data" "structures" 

arrow 

A0 :box width 0.8 height 0.6 

box at A0 "picture" 

arrow from A1 .s down lineht *1 

A2 :line left 0.50 down 0.30  \backslash

 then right 0.50 down 0.30  \backslash

 then right 0.50 up 0.30  \backslash

 then left 0.50 up 0.30 

"Pic text" at A2 +(0 ,-0.3 )

.PE

\normalsize

\subsection{Author's Assessment}

  WD-pic was utilized to produce a large number of pictures. Some of them are
provided throughout this text.

 First of all, it must be mentioned that it is simpler and faster to draw pictures with the help of the WD-pic than to create and correct {\bf Pic} files directly, using standard UNIX text editor such as vi, because we provide all the possibilities for forming {\bf Pic} file but add additional 
options for direct graphical online editing. 

 A popular tool for producing line drawing, which is supplied in the  X Windows environment is {\em xfig} drawing editor. From the comparative study of WD-pic and {\em xfig} following conclusions can be derived.
\begin{itemize}
\item For simple linear diagrams such as chains of element ({\bf boxes, circles,} or {\bf ellipse}), possibly containing {\bf text}, and connected by {\bf lines, arrows } or {\bf spline}, for example Fig. 1, Fig. 2, Fig. 5, WD-pic is more comfortable to use than {\em xfig}. This occurs because by default {\bf Pic} produces chains of drawing elements with default sizes and placement. Such kind of pictures can be produced simply by clicking push buttons
with subsequent adjustment of sizes and insertion {\bf text} without adjustment or
placement of elements. \newline

\begin{figure}
\epsffile[0 0 500 100]{PicPicture/Simple.ps}
\caption{Simple example}
\label{Fig.12}
\end{figure}
   For example the Fig. 10 was produced with the help of WD-pic and {\em xfig}. In WD-pic the following sequence of actions was executed.
 \begin{enumerate}
   \item Click the push button {\it circle}.
   \item Click the push button {\it line}.
   \item Click the push button {\it circle}.
   \item Click the push button {\it same}.
 \end{enumerate}
  In {\it xfig} the following sequence of actions was executed.
 \begin{enumerate}
   \item Click the push button for {\bf circle}.
   \item Adjust the circle size.
   \item Click the push button for {\bf line}.
   \item Adjust the line length and direction.
   \item Click the push button  copy.
   \item To copy the first {\bf circle} and adjust it position.
 \end{enumerate}
   In WD-pic for the all elements, we use the default sizes and don't need
to adjust sizes or positions of elements . \newline
 \item  Here is the {\bf Pic} text generated by WD-pic for this picture: \newline \newline
 {\em circle  \newline
      line  \newline
      circle same}  \newline \newline
   Here is the {\bf Pic} text generated by {\it fig2dev} from the picture, created in  {\it xfig}: \newline  \newline 
{\em circle at 1.000,9.025 rad 0.255 \newline
circle at 2.012,9.012 rad 0.255 \newline
line from 1.256,9.012 to 1.756,9.012} \newline 

  From this example, we can see that the {\bf Pic} text generated by WD-pic is more user-friendly. Also the {\bf Pic}
text generated by WD-pic can be easily reused in other picture, reusing
the text created by {\it fig2dev} is more difficult, because the coordinates of the circles
and of the line's end points are defined explicitly.
 \item Changing position or size of one element in {\em xfig} can destroy entire picture. In WD-pic, this destruction can be avoided because connections between elements are  realized in the picture's internal representation. \newline

  For example if we want to change the {\bf circles} sizes in the Fig 10 using {\em xfig}
we need to change size of first circle, readjust line,  destroy the second {\bf circle},  copy the first {\bf circle}, and readjust the new second {\bf circle}. On the other hand, in WD-pic, we need only to change the size of the first {\bf circle}.
  \item In WD-pic we can easily insert  new elements in the middle of an
element chains and easily delete elements from the chain without any changes in the following part. In {\em xfig} we need to divide the figure into the parts on opposite sides of the insertion point and move at least one of them to make room for the inserted element.
  \end{itemize}
    On the other hand, WD-pic, in its present realization, is more limited then {\em xfig} in drawing complex non-regular pictures. However, once the picture is drawn in WD-pic, it is easier to correct such pictures because of features described above. WD-pic's set of primitive elements is poorer. It also doesn't have the full set of element manipulations that {\em xfig} has. \newline 

 We can say that WD-pic has the following shortcoming, independently of {\bf Pic} limitations

\begin{enumerate}
\item It is impossible to change sizes of a {\bf box, circle} or {\bf ellipse} by direct mouse manipulation.
\item It is impossible to change position of a {\bf box, circle} or {\bf ellipse}
by direct mouse manipulation.
\item It is impossible to insert an entire file into the {\bf Pic} specification  by direct mouse manipulation.
\item  Editing functions such as  Copy and Paste, working with clipboard, and Undo are not available.
\item It is impossible to choose a font for a {\bf text} string.
\item It is impossible to delete simultaneously a number of independent elements from the picture by
direct mouse manipulation.
\item It is impossible to print the displayed picture, directly from WD-pic.
\end{enumerate}



\newline
   It follows from the author's experience  using WD-pic 
\begin{enumerate}
   \item that it is preferable to construct a picture sequentially, according
to the order of element in the picture,
   \item that it is desirable to understand clearly connections between elements before
starting to draw the picture and to use the possibilities of WD-pic, such as  placing one element relative to another.
   \item that the  user must work in the insertion mode with care, especially if he  needs
to change directions in the process of insertion, because the initial part of a picture influences the rest and it could lead to many difficulties for
complex insertion. Sometimes it is better to make an insertion using the {\it Text
edit} option of the {\it Edit} menu.
 \end{enumerate}

\subsection{Advisor Assessment}

Besides the author, the advisor of the author exercised the prototype,
although not as extensively as the author. Recall that the advisor was also
the customer for the program and was responsible for supplying the
requirements for WD-pic. He exercised the prototype for two main purposes:
\begin{enumerate}
\item to determine if the prototype captured his intentions.

\item to use it to make some figures that he needed for papers he was writing.
\end{enumerate}
He knew the batch program {\bf Pic} very well, often able to write {\bf Pic}
descriptions of figures strictly from imagining the figure.
He did not know WD-pic well and, initially had to ask the author how to do
certain things.

He reports tremendous satisfaction when using WD-pic to prepare diagrams
for which he could either think the description in real time or for which
he prepared a hand-written draft of the specification ahead of time. In
these cases, things went super fast as he was able to click buttons for the
commands in rapid sequence much much faster than typing out the commands
with the help of an editor, that is it was much much faster to click the
box button, then the arrow button, and then the box button, click, click,
click, that it was to type out ``box; arrow; box''. When a button click had
to be accompanied by text entry, such as for the textual contents of a box,
the WD-pic was not quite as satisfying, because the entry of text required
a dialog window to pop up, the text to be entered, and then that entry to
be confirmed by clicking ``Yes''; this is considerably slower than just
typing the text enclosed by standard double quote marks. Still even less
satisfying and in many cases, a down right nuisance were the heavily
parameterized commands and changing already entered commands. These
involved many many pop-up windows each of which demanded confirmation that
it had understood what had just been entered. Moreover, selecting the
drawing object to which or after which to apply parameters required pulling
down and clicking a menu item rather than simply pointing at the object
with the mouse. Thus, to him, WD-pic leaves much to be desired in direct
manipulation. He found it much less painful to just edit the internal {\bf Pic}
representation to add the paramters or new objects anywhere, and got into
the habit of using WD-pic to rapidly produce a first version and then to
use his favorite text editor for all subsequent changes.

\section{Conclusions and Future Work}

WD-pic has met some of its goals but not all of them. It certainly is
interchangeably batch and WYSIWYG. It certainly produces human-like {\bf Pic}
code as its internal representation. The user can certainly produce
diagrams that are simple to express in {\bf Pic} much much faster with WD-pic
than with other systems, as these require simply a series of button
pushes and typing of simple text in text windows and no movement of the
mouse to the drawing canvas.

The program that was produced has the right design except for the
lexical portion and the use of standard widgets, and the user interface
is clumsy in the less used parts of the language.

The problems in the user interface are not fixable given the decision
to use standard widgets. These widgets require bringing up an
interaction window when it is desired to input tokens from the key
board and these windows require confirmation of the input.  The
profusion of pop-up windows that present themselves when one begins to
have parameters and deviate from the defaults is inundating. Each one
takes time to fill and demands confirmation.  It would be much much
nicer to be able to simply type what needs to be typed directly to a
window that comes up under where the cursor is pointing without having
to wait for it to come to the screen and for the mouse to point to it
and without having to confirm what has been typed.  This would also
make it easy to use the mouse in place of textual description of
places.  Of course doing so means using an entirely different set of
user-interface widgets, ones that seem to differ from the standard that
seems to have established itself among most applications running on X,
Windows, and MacOS. It may even be necessary to program it from
scratch.

The decision to use standard widgets, wrong in retrospect, was taken to
make it easy to prototype, i.e., to rapidly explore different options
and be able to throw out what has been done already without feeling
that a lot of work has been wasted. This is the first time, in the
author's advisor's experience, that the requirements of the prototyping
process prevented adopting good requirements for the software.

The other main deficiency is in direct manipulation. It would be nice
to be able to place a box where the cursor points rather than at the
default position or a position specified by explicitly writing
positioning parameters either via pop up window or via the editor in
the internal representation. The problem with these direct
manipulations is that they get in the way of adhering to the goal of
keeping the internal representation similar to what a human would
write. If one can place a box anywhere on the canvas, one will find {\bf Pic}
code like

box at 1.234297, 5.8593683\newline
in the internal representation.

The idea of laying out grids that have spacing equal to the value of
pic variables was good, but is a pain to set up with the pop up window
interface. It would be nice if the variables could be selected by mouse
when they are simple, and have to be typed only when they involve
expressions.  Even better would be for the grid to have a default
spacing of moveht vertically and movewid horizontally. Moreover, it
would be nice if the origin of the grid could be a point selected by
direct manipulation, with gravity pulling to predefined and
non-numerically specified points such as the eight corners of a box,
.n, .e, .s, .w, .ne, .se, .sw, and .nw.

To add more direct manipulation will require more creativity to come up
with interfaces that constrain it in a natural and unobtusive way to
that which corresponds to what humans want. That is the challenge for
the designer of the next version.



 
\newpage
\addcontentsline{toc}{subsection}{\bf Appendix A}

\appendix
\subsection*{\Large Appendix A}
\begin{center}
{\bf \Large User Manual}
\end{center}
\addcontentsline{toc}{subsubsection}{A.1 A new element addition}
\newline
{\bf  \large A.1  A new element addition} \newline \newline
  In order to add a new element to the picture  user need to click on the
corresponding push button from the {\bf Pic} tokens part of the button panel.
The new element is placed in the drawing area 
 with default drawing and geometric parameters. This element is placed at
the current insertion point. 
At any time, the accumulated drawing is centered in the drawing area. 
Simultaneously, a corresponding string is added to the {\bf Pic} internal representation.
   If immediately after choosing some element, such as {\bf box, circle} etc., the {\bf text} push button is chosen, then {\bf text}
is inserted into the element. In order to create self-standing {\bf text}
user must press the ``{\bf ;}'' push button  before pressing {\bf text} push button  in order that the current {\bf text} not be considered as part of the previous element. For example, 
 when the user clicks on the {\bf box} push button,  the string {\it box} is added to the current insertion point in the {\bf Pic} file,  the
following picture is added to the current insertion point on the drawing area, and the whole accumulated picture is centered again.
\newline
\begin{picture}(500, 40)(30, 0)
  \put(80, 0){\framebox(50,30)}
\end{picture}
%\begin{figure}
%\special{psfile = PicPicture/Box.ps}
%\epsffile[0 0 500 20]{PicPicture/Box.ps}
%\end{figure}
\addcontentsline{toc}{subsubsection}{A.2 Changing a direction of a picture}
\newline
\newline
{\bf \large A.2 Changing the direction of a picture} \newline\newline
 In order to change a direction of a picture the user must click on a arrow button whose arrow points to the desired direction. For example,  when the user clicks on a arrow button whose arrow points to the right, the  string {\em right} is added  to the current place in the {\bf Pic} file. 
 The effect of this is to cause the picture to grow to the right from the current insertion point on the screen. If the current insertion point is not
the end, then this may cause portion of the picture to change their orientation
entirely when the picture is redrawn.
\newline \newline
\addcontentsline{toc}{subsubsection}{A.3 Changing the size of an element}
 {\bf \large A.3 Changing the size of an element} \newline  \newline
  In order to change a size of a {\bf box, circle,} or {\bf ellipse} the user  need to click on  the {\bf size} push button. When this push button  is pressed,  a dialog  appears in the lower left corner of the main window. 

   This dialog has  two labeled text windows: for {\bf box} and {\bf ellipse}, they are {\bf width} and {\bf height}, for {\bf circle}, they are {\bf radius} and {\bf diameter}. The dialog also has two push buttons ``OK'' and
``Cancel''.  In  Fig. 11, we see sizes dialog for a {\bf box} or an {\bf ellipse}. The user must insert the  required parameters into the text windows. For
a {\bf circle}, he/she needs to insert only one of them. If the user defines the  parameters and then presses the push button ``OK'' then the element in the
drawing area immediately changes its size according to the  inserted values. Simultaneously, the corresponding substring  is added to the current place in the {\bf Pic} internal representation. For example, result of  changing a {\bf box}'s size is the addition of the substring {\it width x height y} to the string in the {\bf Pic} text that describes the {\bf box}.
\begin{center}
\begin{figure}
\epsfbox{PSpicture/Size.ps}
\caption{ Sizes dialog for {\bf box} or {\bf ellipse}}
\label{Fig. 5}
\end{figure}
\end{center}
   The size of a{\bf line, arrow,} or {\bf spline} can be changed with the help of the {\bf direction}  push button. Selection of this push button calls a dialog, which is shown in Fig. 12.
\newline
  The user can insert data directly into the text windows, labeled by ``dX'' and ``dY''. Alternatively, the user can select an arrow button, corresponding to the
current text window and choose one of the standard {\bf Pic} sizes from a menu
that pops up after the button is pressed.
 After pressing the ``OK'' push button, a grid is imposed on the picture with
its cell sizes dX, dY, assuming valid dX and dY.  The user can choose 
end points for all segments of a {\bf line} or an {\bf arrow} or  end points for a  {\bf spline}'s guiding lines on this grid by the left mouse button. He/she can finish the task by pressing the middle mouse button  or by choosing  a new element from {\bf Pic} tokens. After each
chosen point, the {\bf line, arrow}, or {\bf spline} immediately changes its view. Simultaneously, the string like {\it left linewid * x up lineht * y} is added to the current place in the {\bf Pic} internal representation.
\newline
  For an {\bf arc}, the {\bf radius} push button invokes the same dialog as the {\bf size} push button  for a {\bf circle}  with the same action.
\begin{center}
\begin{figure}
\epsfbox{PSpicture/LineDirection.ps}
\caption{ Direction dialog for {\bf line, arrow} or {\bf spline}}
\label{Fig. 6}
\end{figure}
\end{center}
 For a {\bf move}, the {\bf place} push button  calls the same dialog as the {\bf direction} push
button  for {\bf line, arrow,} and {\bf spline} with the same action, except that the user can
choose only one point on the grid.
\newline
\newline
\addcontentsline{toc}{subsubsection}{A.4 Changing a place of an element}
{\bf \large A.4 Changing the place of an element} \newline  \newline
 In order to change a placement of  a {\bf box, circle,} and {\bf ellipse}, the user need to click on the {\bf place} push button. Selection of this push  
button invokes a dialog that offers two kinds of  element placement.
  \begin {enumerate}
   \item Place the element by its center, using the {\bf at} option.
   \item Place the element by one of its corners, using the {\bf with} option.
\end {enumerate}
 
  There is a toggle button for each option. If the chosen option is to place the element by its corner, a new dialog is invoked, and it asks the user to point to the suitable corner with the left mouse button.
  If the chosen option is to place element by its center or if the user has chosen a
suitable corner of the element, a new dialog  appears. This dialog offers
three ways to place the element,
  \begin {enumerate}
    \item by the coordinates of its center or corners.
    \item relative to  another, labeled element. If this element has no label
  yet, then label will be added automatically.
    \item relative to a numbered object of chosen kind, for example relative to 
 the  first box.
\end {enumerate}
 After selection of the suitable  option, the user must
\begin{itemize}
  \item for the first option, choose one point in the
drawing area
 \item for the second and the third options, choose an element and after that click on  the 
required point. If this point is a corner of the object then in the {\bf Pic} text,
it will be entered as the element's corner.
  \end{itemize}
   Here are examples of {\bf Pic} texts, generated by each  option for circle placement.
 \begin{itemize}
  \item first option: ``circle rad z {\it at x, y}''.
  \item second option: \newline
   \hspace*{1in} `` {\it A1}: box \newline
   \hspace*{1.2in}        ... \newline
   \hspace*{1.2in}   circle rad z {\it at A1 + (x, y)}''

 \item third option: \newline
   \hspace*{1in} `` box \newline
   \hspace*{1.2in}        ... \newline
   \hspace*{1.2in}   circle rad z {\it at first box + (x, y)}''
\end{itemize}
\newline

    For an {\bf arrow, line, spline,} or {\bf arc}, there is a {\bf from-to} push button, which 
allows  placing  the beginning of the {\bf arrow, line, spline} or {\bf arc}, and its end.
Selection of the push button invokes a dialog, that offers two instances of the element placement in order to
  \begin {enumerate}
   \item place the beginning of the object with the {\bf from} option, and
   \item place the end of the object with the {\bf to} option.
\end {enumerate}
   \newline

   After that, the same dialog as for a {\bf box, circle,} and {\bf ellipse} offers  the user
 three ways to place beginning or end of the element, and the user must execute the
 same actions as in the previous case. \newline
  Here are a few examples of the {\bf Pic} text generated for placement of the beginning and the end of a line:
 \begin{itemize}
  \item  first option: ``line {\it from (x,y)} up x1 left y1 {\it to (z,w)} ''.
  \item  second option:\newline
   \hspace*{1in} `` {\it A1}: box \newline
   \hspace*{1.2in}     ... \newline
   \hspace*{1.2in}  {\it A2}: circle \newline
   \hspace*{1.2in}        ... \newline
   \hspace*{1.2in}   line {\it from A1.n} up x left y then down 2 {\it to B1}''

 \item third option: \newline
   \hspace*{1in} `` box \newline
    \hspace*{1.2in}  circle\newline
   \hspace*{1.2in}        ... \newline
   \hspace*{1.2in}   line {\it from first box to second circle.w}''
\end{itemize}
\newline
\newline
\addcontentsline{toc}{subsubsection}{A.5 Line style changing}
{\bf  \large A.5 Changing Line Style }
\newline  \newline
 In oreder to change a line style of an element the user must click on the {\bf lines} push button. The corresponding
dialog offers four possible line styles: {\bf solid}, {\bf dotted}, {\bf dashed} and
{\bf invisible}. For each option  there is a toggle button. If no line style is selected, then the default {\bf solid} is used. \newline
 For example, when the {\bf dotted} line style is selected the substring {\it dotted} is added to the current place of the {\bf Pic}  internal  representation.
\newline
\newline
\addcontentsline{toc}{subsubsection}{A.6 Fill style changing}
\newline
\newline
{\bf \large A.6 Changing Fill Style}
\newline
\newline
When the user click on the {\bf fill} push button the corresponding dialog is appeared
The dialog contains a slider, with the help of which the user can set a gray scale value.
    An example of the corresponding {\bf Pic} internal  representation is the string ``box  {\it fill 0.5}''\newline
\newline
\addcontentsline{toc}{subsubsection}{A.7 Changing an element size  according  to the
size of last element of the same kind}
{\bf \large A.7 Changing an element's size  according  to the
size of last element of the same kind} \newline
\newline
When the user want to change the size of the current element according to 
the size of last element of the same size he/she need to click on the push button {\bf same}. \newline
An example of the resulting {\bf Pic} internal representation  is: \newline
    \hspace*{1in} `` box  wid x \newline
    \hspace*{1.2in}  box  {\it same}'' \newline
\newline
\addcontentsline{toc}{subsubsection}{A.8 {\it File} popup menu}}
\newline
{\bf \large A.8 {\it File} popup menu}\newline  \newline
 The {\it File} popup menu   has the following
items:  {\it New, Save Current File, Store as New File, Read File,} and {\it Quit.}
  \begin{enumerate}
    \item {\it New:}   Start a new picture.
    \item {\it Save Current File:} If the current picture has a name i.e., it was saved before or it was loaded by {\it Read File}, then the {\bf Pic} internal representation 
is saved with the same name, otherwise the user is asked for a new
name and the {\bf Pic} internal representation of the picture  is saved in the  file with the new name.
   \item {\it Store as New File:} The user is asked for a name, and the internal representation of the current picture is
saved in a file with this name.
    \item {\it Read File:} The user is asked for a name of a file. If a file with this name exists and the file doesn't contain any syntax error, it is loaded as a {\bf Pic} file, and then  the represented picture is displayed in the drawing area. Otherwise, if the {\bf Pic} file contains errors, then a new window,
named ``Errors and warning messages"  displaying the error messages is opened.
    \item {\it Quit:} Exit  WD-pic.
  \end{enumerate}
\newline
\newline
\newline
\addcontentsline{toc}{subsubsection}{A.9 {\it Edit} popup menu}
{\bf \large A.9 {\it Edit} popup menu}
\newline \newline

 The {\it Edit} popup menu   has the following
items: {\it Select element, Insert, Add, End Insert/Add, Modify attribute,
 Delete}, and {\it Text edit.}

\begin{enumerate}
 \item {\it Select element:}  After choosing  this option, the user can select any element on the drawing area. The selected element will be drawn by double line.
After {\it Select element},  any of the 
{\it Insert, Add, Modify attribute,} and {\it Delete} options can be chosen.
 \item {\it Insert:} If the user has selected this option then each new element will be added before the selected element, until the {\it End Insert/Add} option  is selected.
\item {\it Add:} If the user has selected this option, then each new element will be added
after selected element, until the {\it End Insert/Add} option is selected.
\item {\it End Insert/Add:} The user selects this option to finish an addition or insertion of new elements into the
picture.
\item {\it Modify attribute:} If the user has selected this option, a new dialog appears
in the center of the main window. It contains text window with the {\bf Pic} string
corresponding to the selected element. In the button panel, in the element
parameters section appears a push button set corresponding to the selected element. The user
can change element attributes directly in the text window or with the help of the
element parameters push buttons. If he/she prefers the push buttons,  all changes
immediately appear in the text window and, of course, in the drawing area.
 \item {\it Delete element:} Delete the selected element.
 \item {\it Text edit:} WD-pic allows two ways to edit a picture, by graphic editing and text editing. The previous six options are for graphic editing. This {\it Text edit} option allows editing the  text of the {\bf Pic} internal
representation.
 If environment variable EDITOR is defined in the containing UNIX system, for
example EDITOR = vi, then after  selection of this option,  the editor named by EDITOR is opened on the current intermediate representation.
The user can change the {\bf Pic} text as he/she wants. After user
exits from EDITOR, the resulting  changed picture immediately appears on the drawing area, if of course, the changed {\bf Pic} text is  a correct {\bf Pic} program. Otherwise, if the changed {\bf Pic} text contains errors, then a new window,
named ``Errors and warning messages" is opened. Also, a dialog is opened
that informs the user that a new file ERROR.pic was created and this file contains
the changed {\bf Pic} text. The original internal representation is lost.

\end{enumerate}
\newline
\newline
\addcontentsline{toc}{subsubsection}{A.10 {\it View} popup menu}
{\bf \large A.10 {\it View} popup menu} \newline  \newline
   The  popup menu  {\it View} contains  one
item: {\it File View.}
\begin{enumerate}
 \item {\it File View:} After user has selected this option, a standard prompt dialog 
immediately appears in the center of the main window. This dialog asks the user for
the name of a file. The user must insert a file name and press the ``OK'' push button.
If the push button was pressed without having given a file name, then the user is presumed to  want
to see the {\bf Pic} text corresponding to the current picture. The user can see
desired text in  a newly created window ``View''. This new window contains a ``OK'' push button. After this button is pressed, the window is destroyed. 
\end{enumerate} 
\newline
\newline
\addcontentsline{toc}{subsubsection}{A.11 {\it Structures} popup menu}
{\bf \large A.11 {\it Structures} popup menu}  \newline

 The {\it Structures} popup menu   contains two options, {\it Loop} and
{\it if ... then ... else.}
  \begin{enumerate} 
   \item {\it Loop}: If this option is selected, then a dialog pops up on the screen in the center of main window. This dialog allows  inserting the loop index, 
the high and low boundaries, and the step. After that, the user can press 
the ``OK''  push button  and the preferred text editor is opened the same way as in the {\it Text edit} item of the {\it Edit} menu. But this time, the {\bf Pic} text contains a  string
``for ... = ... to ... by ...'' according to the user's choice. The user fills in  the missing body of the loop. After the user 
exits the text editor,  the changed picture immediately appears in the drawing area.

  \item {\it If ... then ... else}: After  selecting  this option, 
the preferred text editor is opened immediately. The {\bf Pic} text will contain a  string ``if ... then ... else". The user fills in the missing expression and
commands.
After the user exits the text editor,  the changed picture immediately appears on the drawing area.
 \end{enumerate}
\newline
\addcontentsline{toc}{subsubsection}{A.12 {\it Defaults} popup menu}
{\bf \large A12 {\it Defaults} popup menu}  \newline 

    The  
popup menu  {\it Defaults} contains three items, {\it Scale, New defaults,} and {\it Reset}.
\begin{enumerate}
   \item {\it Scale} allows the user to change the picture's scale. When the user selects this item a new dialog pops up on the screen in the center of the main window.  The user can insert a new
scale value.
   \item {\it New defaults} allows the user to change size defaults. When the user selects this item, a dialog pops up on the screen. The dialog contains a table of
all current size defaults. The user can change any of these.
  \item {\it Reset} allows the user to reset all defaults to their beginning values. When the user selects this option, a dialog
pops up on the screen. The dialog contains a table of all default sizes that were changed. There is a toggle button near each size. Pressing a particular
toggle button  means  to reset the corresponding size to its old default. This dialog
also contains the toggle button RESET ALL. By pushing this toggle button, the user resets all  default sizes to their beginning values. This affects only the part of the picture described by the text after the current insertion point. All changes take
effect on the picture displayed right after editing this dialog.  
\end{enumerate}
\newpage

\newpage
\addcontentsline{toc}{subsection}{\bf Appendix B}

\appendix
\subsection*{Appendix B}

\addcontentsline{toc}{subsubsection}{B.1 {\bf Pic} text list }

{\bf \large B.1 Pic text list}
\newline  \newline
 Each element of the {\bf Pic} text list contains the following fields:
\newline
   {\it  \  \newline
 \hspace*{1in} char *curString;  \newline                
 \hspace*{1in} int   curStringLength; \newline
} 
\newline
where, 
\begin{enumerate}
     \item {\it curString} is a pointer to the string written in the {\bf Pic} language.\newline
    \item {\it curStringLength} is the number of characters in this string.

\end{enumerate}
 Here are examples of strings:
\begin{itemize} 
  \item  corresponding to a {\bf Pic} element: \newline

    ``{\em A1: box dotted width 1}''  \newline

   or ``{\em circle rad 1 ``CIRCLE''  }''

          \item corresponding to a {\bf Pic} operator: \newline

  ``{\em  for $i = 1$ to 10 by 2 do \{ \newline
      circle radius $0.5 * i$ \newline
      \}}''
       \item  corresponding to a {\bf Pic} default size change:\newline

``{\em boxwid = 1.5}'' \newline
or ``{\em reset boxwid}'' \newline

 \end{itemize}
        

\end{enumerate}
\newline
\newline
\addcontentsline{toc}{subsubsection}{B.2 Object array}
\newline
{\bf \large B.2 Object array} \newline 

 We can see below a full description of the object array element structure with the changes,
necessary for using it in the WD-pic: \newline      
   {\it 
  \hspace*{1in}  union \{ \newline
  \hspace*{1.2in}             PicTextDef     *Ptr; \newline
  \hspace*{1.2in}            int             Num; \newline
  \hspace*{1in}       \}PicTextUnion;\newline
  \hspace*{1in}  	int	o\_type;\newline
  \hspace*{1in}  	int	o\_count;\newline
  \hspace*{1in}  	int	o\_nobj;	\newline
  \hspace*{1in}  	int	o\_mode; \newline
  \hspace*{1in}  	float	o\_x;  \newline
  \hspace*{1in}  	float	o\_y; \newline
  \hspace*{1in}  	int	o\_nt1; \newline
  \hspace*{1in}  	int	o\_nt2; \newline
  \hspace*{1in}  	int	o\_attr; \newline
  \hspace*{1in}  	int	o\_size;	\newline
  \hspace*{1in}  	int	o\_nhead;\newline
  \hspace*{1in}  	void   *o\_symtab;\newline
  \hspace*{1in}  	float	o\_ddval;	\newline
  \hspace*{1in}  	float	o\_fillval;\newline
  \hspace*{1in}  	ofloat	o\_val[1];\newline
	}			
  Here: 
\begin{enumerate}
   \item  {\it PicTextUnion} is a pointer, which 
contains either  the address of the element of the {\bf Pic} text list in WD-pic itself or  the index of an element in the {\bf Pic} text array  in the {\bf Pic} compiler.
  \item {\it o\_type} is an object type. It may be BOX, LINE,  ARROW,
CIRCLE, ELLIPSE, LINE, SPLINE, MOVE, or TEXT.
  \item {\it o\_count} is the number of elements in the array {\it  o\_val}, which is described below. 
  \item {\it o\_nobj} is  the index of the element in the object array.
 \item {\it o\_mode} is the direction for drawing the element. It may be R\_DIR,
for the right direction, L\_DIR, for the left direction, UP\_DIR, for the up direction,
and DOWN\_DIR, for the down direction.
 \item {\it o\_x, o\_y} are the coordinates for positioning the element;  for a {\bf box, circle,} or {\bf ellipse} they are the coordinates of
the geometric center, for a {\bf array, line, spline, arc,} or {\bf move},  they are the coordinates of the beginning, for a {\bf text} they are coordinates of the left or right
boundary or the center, depending on the {\bf text}'s adjustment type. 
\item {\it o\_nt1} is the index of the string array element that contains  the first text string that belongs
to the object.
\item {\it o\_nt2} is the index of the string array element that contains the first text string that does  not  belong
to the object. If no  text string belongs to the object, then {\it o\_nt1}
and {\it o\_nt2} have the same number.
\item {\it o\_attr} contains the following information :
   \begin{enumerate}
       \item the kind of arrowhead for a {\bf line, spline, arrow,} or {\bf arc}.
       \item the line style.
       \item the fill mode for a {\bf box, circle,} or {\bf ellipse}.
       \item the {\bf arc} direction.
   \end{enumerate}

\item {\it o\_size, o\_nhead, o\_symtab,} and {\it o\_ddval}  are not
used by the WD-pic, but are needed  for compatibility with the {\bf Pic}
compiler.
\item {\it o\_fillval} is a fill value.
\item {\it o\_val[]} is an  array whose length is usually  more than 1,  and it
contains  additional information, depending on the element type:
  \begin{enumerate}
     \item for a {\bf box},  the width and height.
     \item for a {\bf circle} or {\bf ellipse}, the two radii, which are equal for a {\bf circle}.

     \item for a {\bf line, spline,} or {\bf arrow,} the number of parts, the relative coordinates of the end points, the absolute coordinates of the last point, and the width and the height of the arrowhead, if any.
     \item for an {\bf arc}, the  coordinates of the end points, and the width and the height
of arrowhead, if any, and the radius.
     \item for a {\bf text} the width and height.
  \end{enumerate}

\end{enumerate}
\newline
\newline
\addcontentsline{toc}{subsubsection}{B.3 {\bf Pic} String array }
\newline
{\bf  \large B.3 String array} \newline
\newline
Each element of the string array contains following fields:
 \newline
\hspace*{1in}{\it int     t\_type;} \newline
\hspace*{1in}{\it char   t\_op;}	\newline
\hspace*{1in}{\it char   t\_size;}\newline	
\hspace*{1in}{\it char  *t\_val;}\newline

  here,
\begin{enumerate}
   \item {\it t\_type} is the string's adjustment, which may be LDJUST, RDJUST,
ABOVE, BELOW, or CENTER.
  \item {\it t\_op} and {\it t\_size}  are not used, but are needed 
for compatibility with the {\bf Pic} compiler.
  \item {\it t\_val} is  a pointer to the string.
\end{enumerate}

\newpage
   
\addcontentsline{toc}{subsection}{\bf Bibliography  }

\begin{thebibliography}{99}
   \bibitem {} Brian W. Kernighan.  PIC - A language for 
       Typesetting Graphics.  Software - Practice
       and Experience, vol. 12, pp. 1-21 (1982) \newline

   \bibitem {} Narain Gehani. Document Formatting and 
       Typesetting on the UNIX System. Second edition. 
       Silicon Press, 1987.\newline

   \bibitem {} Kenneth H. Rosen, Richard R. Rosinski, 
       and James M. Farber. UNIX SYSTEM V Release 4.
       An introduction for new and experienced users.
       Osborne Mc Graw-Hill 1990. \newline

   \bibitem {} David Barron and Nike Rees. Text Processing and Typesetting
       with UNIX. Addison-Wesley 1987 \newline
   
   \bibitem {} UNIX Programmer's Manual. Vol 1-2,
       Holt, Reinhart, and Winston, 1983 \newline

   \bibitem {} Brian W. Kernighan and Rob Pike. The UNIX Programming
       Environment. Prentice Hall, 1984 \newline

   \bibitem {} Marc J. Rochkind. Advanced UNIX Programming.
       Prentice Hall, Inc, 1985 \newline

   \bibitem {} Adrian Nye. Xlib Programming Manual. 
       O'Reilly \& Associates, Inc, 1990 \newline

   \bibitem {} Xlib Reference Manual.  O'Reilly \& Associates,  1991 \newline

   \bibitem {} Adrian Nye and Tim O'Reilly. XToolkit Intrinsics, Programming
        Manual, OSF/Motif Edition. O'Reilly \& Associates,  1990 \newline
 
   \bibitem {} XToolkit Intrinsics, Reference
        Manual.  O'Reilly \& Associates,  1990 \newline

   \bibitem {} Dan Heller. Motif Programming Manual for OSF/Motif Version 1.1.
        O'Reilly \& Associates, 1991 \newline

   \bibitem {} InterViews Reference Manual idraw, 1989 \newline
   \bibitem {} User commands xfig, fig2dev \newline
   \bibitem {} Adobe Illustrator. Tutorial. Adobe System Incorporated, 1992 \newline
   \bibitem {} B. Shneiderman. Designing the User Interface: Strategies for Effective Human-Computer Interaction. Addison-Wesley. Reading, MA, 1984  \newline
   \bibitem {}  A. Dix, J. Finlay, G. Abowd, R. Beale. Human-Computer Interaction. Prentice Hall New York, 1993 \newline

  \bibitem {} NROFF/TROFF User's Manual. J.F. Ossana. Technical Report Bell Laboratories. Murray Hill, NJ, October 11, 1976  \newline

\bibitem {} B.W. Kernighan.  A Typesetter-independent TROFF. Computing Science Technical Report No. 97 Bell Laboratories. Murray Hill, NJ, March, 1982 \newline

\bibitem {} D.E. Knuth. The \fLG METAFONT \fP book. Addison-Wesley Reading, MA,
1986 \newline

\bibitem {} J.D. Hobby. A \fLG METAFONT\fP -like System with PostScript Output
 TUGboat. 1989 \newline


\bibitem {}J.D. Hobby. A User's Manaual for MetaPost. Technical Report  AT\&T Bell Laboratories. Murray Hill, NJ, 199?  \newline

 
\bibitem {}  PostScript Red Book.  POSTCRIPT Language Reference Manual, Second Edition. Adobe Systems Incorporated, Addison-Wesley. Reading, MA, 1992  \newline

\bibitem {} Microsoft Inc. PowerPoint. Microsoft Inc. Redmond, WA, 1997 \neline
 
\bibitem {} Microsoft Inc. Paint. Microsoft Inc. Redmond, WA, 1995 \newline
 
\bibitem{} Apple Computers Inc. MacDraw. Apple Computers Inc. Cupertino, CA, 19??
\bibitem {} Ideal manual.


 \newline

 
\end{thebibliography} 

   \end{document}

  
  

       





