<!--these sections will sit under sect1 - Implementation Issues-->

<sect2><title>User Interface</title>

<sect3><title>Introduction</title>
<para>
The <command>GDMS</command> user interface is the most prominent part of the application. It is the main way in which the user 
experiences the application. <command>GDMS</command> currently supports two user interface variants:
</para>

<itemizedlist>
<listitem><para>The X windows user interface (the program called <command>GDMS</command>)</para></listitem>
<listitem><para>The batch user interface (the program called <command>gdms-batch</command>)</para></listitem>
</itemizedlist>

<para>
This section will deal primarily with the research undertaken for implementing the X windows user interface. 
This is not only due to the fact that the scale of implementation required was much greater for this variant, and because 
there were many more alternatives available.
</para>
</sect3> <!--Introduction-->

<sect3><title>Graphical user interface</title>
<para>
There are a plethora graphical user interface toolkits available today. As each has it's advantages, a small survey of the 
options considered, and then a discussion of why <emphasis>wxWindows</emphasis> was selected is appropriate.
</para>

<sect4><title>CDE</title>
<para>
The Common Desktop Environment (CDE) was jointly developed by Hewlett-Packard, IBM, Novell and Sun Microsystems. 
These companies have subsequently adopted CDE as the standard window manager as shipped on a variety of their various 
operating systems (Chapman 2002). CDE uses the Motif windowing toolkit.
</para>

<figure><title>Sun Microsystem's default CDE configuration (Chapman 2002)</title>
<execute><cmd>img</cmd><args>sun-cde.gif</args></execute>
</figure>

</sect4>

<sect4><title>CDE</title>
<para>
KDE development started in October 1996 (KDE 2002), as a replacement for Sun's CDE. KDE is based on Trolltech's qt widget set 
(Trolltech 2002). KDE is available as an installation option on the majority of the Linux distributions available.
</para>

<figure><title>The default KDE theme, Konquerer (KDE 2002)</title>
<execute><cmd>img</cmd><args>kde300-snapshot2-320x240.jpg</args></execute>
</figure>
</sect4>

<sect4><title>Gnome</title>
<para>
Gnome is the default window manager and windowing toolkit set for many Linux distributions, including Red Hat Linux, 
which the Survey Lab at the University of Canberra makes extensive use of. Gnome is implemented using the GTK windowing 
toolkit (GTK 2002).
</para>

<para>
Sun Microsystems have recently announced that from Solaris 8, Gnome will be available as a window manager. 
They have also announce that CDE will be replaced with Gnome in future releases (Sun Microsystems 2002).
</para>

<figure><title>The Solaris version of the GNOME desktop (Gnome 2002)</title>
<execute><cmd>img</cmd><args>gnome.png</args></execute>
</figure>
</sect4>

<sect4><title>Microsoft Windows</title>
<para>
Whilst not a X windows toolkit, Window's MFC toolkit was considered as a development alternative for <command>GDMS</command>. 
However, the survey lab does not currently contain any Microsoft Windows machines, so this option was not pursued any further.
</para>

<figure><title>The Windows XP desktop (Microsoft 2002)</title>
<execute><cmd>img</cmd><args>mfc-xp.jpg</args></execute>
</figure>
</sect4>

<sect4><title>wxWindows</title>
<para>
Whilst wxWindows is not a window manager in the same sense as the others discussed in this section, 
it has a variety of advantages relevant to <command>GDMS</command>. These include:
</para>

<itemizedlist>
<listitem><para><emphasis>The ability to use a variety of windowing toolkits</emphasis>. wxWindows supports GTK and Motif for Unix 
and Unix-like operating systems. Windows is also supported.</para></listitem>
<listitem><para><emphasis>Cross platform functionality</emphasis>. This allows <command>GDMS</command> to run on a variety of 
Unix and Unix-like operating systems.</para></listitem>
</itemizedlist>
</sect4>

</sect3>

<sect3><title>Windowing toolkit selection</title>
<para>
Based on the factors outlined above, the group selected wxWindows for the user interface implementation of <command>GDMS</command>.
As previously mentioned, all of these toolkits require developers to write in C++, which was one of the determining factors in the 
language choice for the development of the application.
</para>
</sect3>

<sect3><title>Batch user interface</title>
<para>
There are two common implementation methodologies for scripting languages. Both of these were considered for the 
<command>GDMS</command> implementation. The most common manner for implementing the parser and grammar for a scripting language 
is by using the compiler construction tools <command>yacc</command>, and <command>lex</command> (or their free versions, 
<command>bison</command> and <command>flex</command>). 
</para>

<sect4><title>Compiler construction tools</title>
<para>
<command>Lex</command> and <command>flex</command> are parser generation tools. They take a lexical specification file, 
and generate a LALR finite state machine for matching input strings (Aho, Sethi &amp; Ullman 1986). A sample of a lexical 
specification is shown below (in this case for the PDF file format):
</para>

<programlisting>
&lt;INITIAL&gt;\%PDF-[0-9]+\.[0-9]+    {
  debuglex(yytext, -1, "version");
  yylval.sval.data = (char *) returnStr(yytext, -1);
  yylval.sval.len = yyleng;
  return VERSION;
  }

&lt;INITIAL&gt;[+-]?[0-9]+\.[0-9]+     {
  debuglex(yytext, -1, "floating point");
  yylval.sval.data = (char *) returnStr(yytext, yyleng);
  yylval.sval.len = yyleng;
  return FP;
  }

&lt;INITIAL&gt;[+-]?[0-9]+\.[0-9]+\&gt;\&gt; {
  debuglex(yytext, -1, "floating point");
  yyless(yyleng - 2);
  yylval.sval.data = (char *) returnStr(yytext, yyleng);
  yylval.sval.len = yyleng;
  return FP;
  }
</programlisting>

<para>
In this example, two tokens are defined, VERSION, and FP. The syntax for these specifications is relatively simple. The first 
field, which is wrapped in angled brackets, is the name of the state that the specification should be used in. All of the examples 
shown here are for the default state, known as INITIAL (Levin, Mason &amp; Brown 1990). What follows this is a posix compliant 
regular expression to be matched. Finally, within the braces lies C code to execute when a match occurs.
In each of these examples, the C code writes a log entry for the match, sets up the data structure symbolising the match, and then 
returns the name of the lexical token which was matched.
</para>

<para>
<command>Yacc</command> and <command>bison</command> define the grammar which uses the tokens defined by <command>lex</command> 
or <command>flex</command>. In effect, this defines valid orders for the tokens to appear in, and what operations should be 
performed when a set of tokens is matched. Error handling for undefined token combinations is also supplied by the grammar. 
This is done through the use of hooks for reporting to the user in a manner which is appropriate to that particular application.
</para>

<para>
A sample grammar specification, in this case for SQL (Connolly &amp; Begg 1998) is as follows:
</para>

<programlisting>
SQL      : create SQL | insert SQL | select SQL
         |
         ;

create   : CREATE TABLE STRING '(' colvalspec ')' ';' {}
         ;

insert   : INSERT INTO STRING '(' colvalspec ')' VALUES 
           '(' colvalspec ')' ';' {}
         ;

select   : SELECT cvsaster FROM STRING {} wsel ';' {}
</programlisting>

<para>
A grammar consists of three building blocks. Each of the tokens which can be returned by the lexer is termed a 
<emphasis>terminal</emphasis>. Examples from above include <emphasis>CREATE</emphasis>, <emphasis>TABLE</emphasis>, 
<emphasis>STRING</emphasis>, <emphasis>INSERT</emphasis>, <emphasis>INTO</emphasis>, <emphasis>VALUES</emphasis>, 
and <emphasis>SELECT</emphasis>. These terminals are used by <emphasis>non-terminals</emphasis>, such as <emphasis>SQL</emphasis>, 
<emphasis>create</emphasis>, <emphasis>insert</emphasis>, and <emphasis>select</emphasis> from the example above. The rule which 
groups a non-terminal with a series of other non-terminals, and terminals, is called a <emphasis>production</emphasis> 
(Aho, Sethi &amp; Ullman 1986).
</para>

<para>
This grammar defines a language in which a SQL statement can consist of either a <emphasis>create</emphasis>, an 
<emphasis>insert</emphasis>, or a <emphasis>select</emphasis> statement, as shown by the SQL production. The empty non-terminal 
on the SQL production ensures that an end of file or empty line is also matched.
It should also be noted that the SQL production is recursive, except for this case which matches the empty line or end of file.

</para>
</sect4>

<sect4><title>Hand coded parsers</title>
<para>
The alternative to using the compiler construction tools is to develop a language parser by hand. Depending on the complexity of 
the grammar to be implemented, this can be quite a realistic alternative. On the other hand, if the grammar is complex, then it 
can rapidly escalate into task of much larger scale, comparable to that of the rest of the application.
This option was found to be the most suitable for the <command>GDMS</command>. The grammar for the scripting language implemented 
by the batch version of <command>GDMS</command> is relatively simple,
in that all commands are parsed based on only one line, and no recursion within productions is required.
</para>
</sect4>
</sect3>

  <sect3><title>Implementation</title>
  <para>
As mentioned earlier in this section, the graphical user interface to <command>GDMS</command> was 
implemented using the wxWindows windowing toolkit. 
The batch user interface was developed using a hand coded parser written in c++.
This has maximised the amount of design flexibility enjoyed by the development team, 
whilst minimising the amount of unnecessary code development.
  </para>      
  </sect3> <!--Implementation-->
  
<sect3><title>Integration</title>
<para>
A significant portion of the <command>GDMS</command> user interface development was integrating the various classes and features 
with the graphical user interface.
This integration has been facilitated by a standard process for integrating mathematical functionality. The process is as 
follows:
</para>

<itemizedlist>
  <listitem>
    <para><emphasis>All functionality is either accessed from the mouse, or a menu</emphasis>.
       This leads to a consistent user interface, and minimises user confusion.
  </para></listitem>
  <listitem>
    <para>
      <emphasis>The output of all mathematical operations is a new dataset</emphasis>,
      and hence a new tab in the main application window. This has several advantages, including:-
        <itemizedlist>
          <listitem><para>Facilitating the implementation of the batch interface to the application.</para></listitem>
          <listitem><para>Allowing ease of comparison of the dataset before and after the application of the mathematical 
          operation</para></listitem>
        </itemizedlist>
    </para>
  </listitem>
</itemizedlist>

<para>
Further documentation of the actual functionality available in the <command>GDMS</command> application is available in the user 
manual.
</para>
</sect3> <!--Integration-->


<sect3><title>Future Enhancements</title>
<para>
Whilst the user interface for <command>GDMS</command> is fully functional,
there are a variety of improvements which could be made in the future. These include:
</para>

<itemizedlist>
<listitem>
  <para><emphasis>Online help</emphasis>: the application does not currently provide any help in
  the user interface. wxWindows supports the display of HTML files within windows, which would an
  efficient and standard method for the implementation of online help within the application.</para></listitem>
<listitem>
  <para><emphasis>Greater resilience to errors</emphasis>: if an error is discovered, the application
  currently abandons all further processing on that dataset. This should be improved in the future, so
  that a failure will not stop all calculations.</para></listitem>
<listitem>
  <para><emphasis>Greater flexibility in the batch user interface</emphasis>: Further research into what other
  commands should be implemented needs to be undertaken.</para></listitem>
<listitem>
  <para><emphasis>The ability to determine the value of the nearest data point by hovering over
  it</emphasis>: Currently the application checks the location of the mouse and looks up the relevant graph values.
  This is misleading as the display resolution means that is almost impossible to determine with any accuracy,
  the value of the data point at which you are pointing.</para></listitem>
<listitem>
  <para><emphasis>The ability to edit out points from the dataset</emphasis>: once accurate mouse pointing is
  integrated this will be trivial.</para></listitem>
<listitem>
  <para><emphasis>Meaningful graticules</emphasis>: currently the graphs are displayed with a fixed number
  of graticules, and the scale is modified accordingly. This can be deceptive and must be revisited in a
  future release. Revision of this code was attempted late in the process, but due to time constraints and an
  uncooperative plotting library this was abandoned.</para></listitem>
<listitem>
  <para><emphasis>Analysis of plotting precision</emphasis>: currently the precision of the graphs is such that
  using high sampling frequencies and cause them to lose precision. Analysis of the plotting functions
  needs to be considered to minimise this.</para></listitem>
</itemizedlist>
</sect3> <!--Future Enahncements-->


</sect2> <!--UI-->

