GPC-Qt 0.0

Hugo Vanwoerkom

May 30, 2007

Sourceforge Users: This is work in progress (TM)

  1. This is a Linux port of GraphiC 7.0 for windows. It is a system for a display of linear x-y plots, linear contour plots, 3-D contours, polar plots, pie charts, error function plots, wedge plots, log-log plots, 3-D surfaces, 3-D bars, bar charts, Smith charts, polar contour plots and triangle contour plots. Also a plot of the daemon db of the CPU temperature. This one was done on Qt-embedded and the horizontal red line is when the system was down because I replaced a bad power-supply. It has its own font design system.
  2. History: in 1990 I wanted a system to draw astrological charts. I needed something that would draw astrological symbols and draw them in circular fashion. Version 5.0 of this system did that and gave you the source of everything. It ran on DOS. Version 7.0 ran on windows but only gave binaries of the windows specific code. GPC-Qt is a Qt port of the latter, with rewrite of the display code.
  3. Included are 2 applications and the 31 example programs of the package. The applications are an astrological program to draw   natal charts and transit charts based only on time of birth and geographical position of birth. The latter 2 must be provided by the user. The other application is a set of graphs of stock market funds. It reads the data from a DBIII+ database as provided by FlagShip.
  4. Implemented differently. GraphiC 7.0 has a view (or "play") facility of its .tkf file. Currently the .tkf file is still generated but in addition a .svgz file can be viewed (and optionally enlarged) with Batik, the Apache svg viewer. Also 'play' is implemented by Qt. A graph can be saved as a picture, and be played back anytime.
  5.   Prerequisites:
    1. Any Qt version. It has been tested on:
      • Linux Debian (Woody g++ 2.95) Qt-X11-1.45
      • Linux Debian (Woody g++ 2.95) Qt-X11-2.3.1
      • Linux Debian (Woody g++ 2.95) Qt-X11-3.1.1
      • Linux Debian (Woody g++ 2.95) Qt-Embedded-3.1.1
      • Linux RH8.0 (g++ 3.2) Qt-X11-3.0.5
      • Windows-XP (Visual Studio 6) Qt-Non-Commercial-2.3.0
      Sources for earlier distributions are:
      http://ftp.unicamp.br/pub/systems/Linux/libs/qt/
      http://linux.sarang.net/ftp/mirror/development/widget/qt/source/
      http://www.netsw.org/x11/libs/qt/

      Flags for the different Versions of Qt
       Qt Ver ../include/comp.h .. /include/user.h
      1 #define MSQ 0 #define _VER_ 1
      . #define TCQ 1 .
      2(x11) #define MSQ 0 #define _VER_ 2
      . #define TCQ 1 .
      2(win) #define MSQ 1 #define _VER_ 2
      . #define TCQ 0 Comment out #define TESTMEM
      . . #define Q_TNC
      3(x11) #define MSQ 0 #define _VER_ 3
      . #define TCQ 1 .
      3(embedded) #define MSQ 0 #define _VER_ 3
      . #define TCQ 1 .


      Favorite: 3.1.1-Embedded.  
    2. FlagShip if you want to use the DBIII+ interfaces. You can get that here:
      http://www.fship.com/
       
    3. Batik, if you want to display the .svgz files with (possible) enlarging. You can get that here:
      http://xml.apache.org/batik/dist/batik-1.5beta4b.zip
      You MUST install the java SDK for this to work. You can get that here:
      http://java.sun.com/j2se/1.4/download.html
  6. Installation.

    1. Install Qt first, or have it already installed.
    2. Setup the $QTDIR global variable to point to where it is installed.
    3. Copy the library onto the library path, so make can find it.
    4. Untar GPC-Qt.
    5. Version 1 or 2 on Linux:  
      • Set /etc/tmake/tmake.conf TMAKE_QTDIR to what QTDIR points to.
      • run: tmake <name>.pro -o Makefile
      • change the INCPATH in the Makefile:
        INCPATH	=	-I/home/hugo/GPC-Qt/include -I$(QTDIR)/include -I$(QTDIR)/include/qt
        
        from 'home/hugo' to where you put GPC-Qt.
      • run: make
      • run the application in a terminal window on X.
    6. Version 3-x11 on Linux:  
      • Set /etc/tmake/tmake.conf TMAKE_QTDIR to what QTDIR points to.
      • run: tmake <name>.pro -o Makefile
      • Copy the whole ####### Compiler, tools and options section to the Makefile
      • change the INCPATH in the Makefile:
        INCPATH	=	-I/home/hugo/GPC-Qt/include -I$(QTDIR)/include -I$(QTDIR)/include/qt
        
        from 'home/hugo' to where you put GPC-Qt.
      • run: make
      • run the application in a terminal window on X.
    7. Version 3-Embedded on Linux:  
      • Set /etc/tmake/tmake.conf TMAKE_QTDIR to what QTDIR points to.
      • run: tmake <name>.pro -o Makefile
      • Copy the whole ####### Compiler, tools and options section to the Makefile
      • change the INCPATH in the Makefile:
        INCPATH	=	-I/home/hugo/GPC-Qt/include -I$(QTDIR)/include -I$(QTDIR)/include/qt
        
        from 'home/hugo' to where you put GPC-Qt.
      • run: make
      • turn off gpm (the vc mouse)
      • turn off anything that writes to the vc
      • Make sure the keyboard and the mouse device are read/writeable by users (see the installation section of the doc) or get into root (bad idea!). The keyboard is /dev/tty and the mouse device you can find in /var/log/XFree86.x.log
      • run: 11run ./<name> (See below on segfaults in Qt-Embedded).
    8. M$ Windows:  
      • Install QT as directed.
      • If you are using the Non-Commercial Version have Visual Studio 6.
      • If you bought a version you can use any compiler. (THIS HAS NOT BEEN TESTED!)
      • Unzip the GPC-Qt zip file in a GPC-Qt dir of the QT examples dir.
      • In the Dos box cd to:
        C:\qt\examples\GPC-Qt
        
      • run tmake -t vcapp <name>.win.pro -o <name>.dsp
      • Open workspace on Visual Studio
      • Select the .dsp you just created
      • Be sure project->settings->C/C++->options has /ZI and /GZ off and /GX on and set for "maximum speed".
      • Build->Rebuild all. Only a few C4273 and C4700 warnings show up.
      • Ctrl-F5 executes the application.
      The above obviously calls for a ./configure. I have not yet gotten around to that.
      Also note that a segfault in Qt-Embedded might have strange consequences. The following remark from the Qt-team is appropriate:  

      This is an unavoidable consequence of Qt/Embedded using raw keyboard
      mode on the terminal. If this happens, it is necessary to run
      kbd_mode -a on the system. This is easy to do if the machine is networked, of
      course, but there are ways to trigger this on a standalone machine as
      well. (The simplest is to run your program from a script.)
      If you run your program with -nokeyboard, it will not mess up the
      keyboard (Answer from qt-bugs@trolltech.com: Issue N 14657, 1/20/03).

      In order to facilitate the script portion of this answer, there is a script on the distribution tarball called '11run' which contains the following:
      #!/bin/bash
      set -x
      if ! [ -z $1 ] ; then
         RUN=$1  
      else
            echo "This runs a qws application "
            echo "Enter the application as parameter  "
      fi      
      $RUN -qws &>anything
      kbd_mode -a
      exit 
      

      If you run this, instead of running your application directly from the commandline, you will always fall into 'kbd_mode -a' which restores the keyboard to ascii and enables you to continue normal operations.
     
  7. Adjustments of the frame and client area for different versions + windowmanagers.
    Note: this only has been tried on Windows-XP, Fvwm and KDE. It seems that only Windows gets it right the first time. Parameters refer to entries in application.ini. Can be changed with an editor or with the Adj button.

    Adjustments of the frame and client area
    Affecting Variable 3.1.1-Emb. 3.1.1-x11 3.0.5-x11 2.3.0-NC 2.3.1-x11 1.45-x11
    Window Mgr . . Fvwm KDE2 KDE3 Win Fvwm KDE2 Fvwm KDE2
    Frame desktop_x_off 0 7 0 0 7 7 0 7 0
    . desktop_y_off 0 31 0 0 31 31 0 31 0
    . width_diff 8 12 8 40 12 12 8 12 8
    . client_height_diff 28 35 29 30 35 35 29 35 28
    client-area fs_view_height_diff 80 96 96 108 112 96 96 96 96
    . nl_view_height_diff 53 52 52 72 80 52 52 52 67
    Font main_window_font h* h* h* h* h* h* h* h* h*
    . font_point_size 12 12 12 12 112 12 12 12 12
    . font_weight 55 55 55 60 112 55 55 55 55


    h* = helvetica
    KDE2 = KDE2.2
    KDE3 = KDE3.1
    Why? This is mainly to suit F11-Fullscreen. What I wanted was a fullscreen that remembered when it was not fullscreen. That is what F11 does across executions.

     
  8. How it works.
    Each application has a main, which sets up 2 parameter arrays. A global and a local one. These are large files called application.ini and <application>.ini A large amount of the parameters are needed. Many are historical. Then it sets up the application window object. This sets up an application window and paints the "user-code" inside of it. All user code is a function called gpc_main. It contains any number of GPC calls in a specific order. GraphiC was not designed with OOP and is in principle not reusable code. Qt on the other hand assumes that all usercode IS reusable (or repaintable). So occasionally there are problems. The worst of these are sudden segfaults if you put something in the wrong place or not do something necessary. GraphiC allows display of multiple plots (e.g funds.c) In windows one would be displayed and the GraphiC code would "hang" on an interrupt. That you cannot do with Qt. So a parm value "next" is used. First plot is painted when "next" is 0, and so on. Each sample has an "About" with it that summarizes what this thing does.
     
  9. Description of the parameter record:
    • name - the name of the parameter
    • type - whether the parameter is int, float, double or long.
    • setvalue - what the value is of the parameter
    • limit - what the parameter should be not exceed. Used in stepping "next".
    • increase value - by what amount the parameter should be increased
    • use - set to 1 when parameter is used.
    • description - a description of the parameter
     
  10. Each application has its own paramers. (E.g aa = aa.ini)
    In there you can select tracing parameters:
    Debug now selects with "trace_<0-x>" in local vars.

    • If trace_0 exists he will look for a trace_<0..> that is set and trace its description when it matches GivenName.
    • If none are set or if it does not exists he will trace all (e.g funds)
    • If trace_x exists he will trace nothing.
      If you define gpcmain_<next> as a float he will collect elapsed time for each plot and use it on subsequent runs to paint the progressbar.
     
  11. Style of the Main Window.
    The description of variable 'app_style' can be set to CDE, Motif, MotifPlus, SGI or Windows.
     
  12. Description of the Main Window.
    The user sees a Main Window. The size depends on what "maxw" and "maxh" are set at in application.ini. The viewport depends on what "vox" "voy" "viw" and "vih" are set at. All of these can be changed with the Adjustment menu.
    • On the menu bar are the following:  
      • File - the File selection button. Submenu:  
        • Print. Pops up a popup to have the screen printed  
        • Open. Pops up a openfile dialog that is application dependent. Currently it displays .fnt files if the application is not ./aa (the astrology application). It displays .gpc-data files if it is. Actually it depends upon the application (in gpc_main) to read this from the parameter file. If the app is "aa" it puts the selected entry in "aa_auto", if "fonttabl" in "font_name". But the extensions to look for are still hardcoded (CHANGE ME).  
        • Save. Pops up a menu of the various save formats available and upon selection saves the screen shown in a particular format.  
        • Picture. Alows the saving of the graph as a picture.  
        • Play. Opens a dialog from which previously saved pictures can be selected. If an image is played, zoom is disabled.  
        • Quit.
         
      • Adjustment. Is a toggle. Opens up a listbox with all parameters in it. When you DOUBLECLICK on this with the mouse and with NUMLOCK ON, the RIGHT ARROW will INCREASE the value and the LEFT ARROW will DECREASE it. Closes the listbox window.  
      • Redraw. Redraws the screen by re-executing the user code in gpc_main!  
      • Debug. Is a toggle.
        The user application sets:
        	QString _t_ = "xxxxxx.xxx";
        	set_desc(_t_,get_var_x("app_debug"));
        	i.e. the description part of the app_debug parm. Then Debug
                opens up a window that displays the contents of xxxxxx.xxx. You write to this
        	with:
        	TDebug    		samp;
        	...
                char name[32]="gpc_main";
        	...
        	samp.Debug(name,">>**Started... %s","\n");
        
        You can write anything to this file, but the display is read-only.
        Hitting Debug again turns the window off.
         
      • Sequence. Submenu:
           
        • Next. Bumps the "next" parameter.
        • Prev. Decrements it. It depends on the user code to do something with this.
        • First. Sets it to 0. The value of the "next" parameter is displayed in the statusbar. The "next" value will not exceed the "limit" of "next" so you application must set this if "next" is used. If "next" is used in AA it will flip between natal and transit charts. All of this for historical reasons: GCP would "hang" in between plots. In Qt you don't.
         
      • About. Display the "About" text from the user's code.
      • Format. Sets "aa_format" to either 1 or 2 showing different format natal charts.
      • Rotate. Sets "aa_rotate" to either 0 or 1, showing the natal chart rotated or not.  
      • Svgz. If set it sets "gen_svgz" which then causes generation of the svgz data file called:
              <tkf file name from bgnplot call>X<next value>.svgz
        
        IMPORTANT: Graphic has very fancy contour filling code which is used to fill font characters if the font is filled. (E.g. "news.fnt", "swiss.fnt") But all this does is create little lines, which "confuses" svgz enabled systems like Batik. So for best svgz viewing fonts should be UNFILLED. For best X viewing they should be FILLED. All examples employ a test for this variable before the call to fillfont. (E.g. bar.c) There is only one example that generates a svgz file that is too large. So it has "gen_svgz" turned off, this is fermi.c.
        IN ORDER TO GENERATE A 'good' SVG File:
        • Use Adjust(or an editor) to set use_smooth_scale to '0'.
        • Use button SVGZ to draw the graph.
        • Select the generated file (see above) with Batik.
        The Qt drawn graph won't look good because it is not smoothscaled and drawn too thin. See the remarks on smoothscale in the list of included examples/applications.
         
      • Zoom. Rubberband something with the LeftButton. Then right click. Unzoom by right clicking again.
       
    • Accelerator keys:
      Ctrl+q = quit
      Ctrl+s = save
      Ctrl+p = print
      Ctrl+o = open
      Ctrl+n = next
      Ctrl+f = first
      Ctrl+r = previous
      Ctrl+a = adjust
      Ctrl+d = debug
      Ctrl+z = zoom

    • On the message bar (on the bottom of the screen) are the following:
      If the application is "aa":
      • Type = Natal/Transit - changeable with the "Type" menu button.
      • Format = 1/2 - changeable with the "Format" menu button.
      • Rotate = 0/1 - changeable with the "Rotate" menu button.
      • Svgz = on/off - whether an svgz file was generated or not.
      • Next = x - what this value in the parms is set at
      • Limit = x - what the limit of the "next" parameter is set at.
  13. F11 is a "fullscreen" key. You hit it and the mainwindow fills your screen. Hitting it again returns the display to the size it was at before F11 was hit. This is remembered across sessions, so you can remain in F11 mode on repeated invocations.
  14. Writing your own code. Take an example that is closest to what you want to do and fiddle with it.
  15. Documentation of GraphiC functions is at:
    http://www.sciend.com/manual/Library.html
  16. Caveats:
    • GPC is a superb contour filler. It fills (optionally) anything, even its fonts. It generates contour plots, etc. But it does this by drawing lines within a polygon, and... that takes time. Tztest takes 11 minutes to generate on a 850MHz 256MB box with a RivaTNT2 card. Warnings are given when appropriate. To alleviate this somewhat a progress bar is shown.
    • On Linux it is dependent on the session/window manager that is used. I have only tried this on the best window manager in the world: fvwm. This is of no importance if you only pop up graphs, but it is if you start using the Adjustment facility, which superimposes a list-box on the plot.
  17. Bugs:
    See the Problems file.
    This is a mix of code going back to DOS over 10 or more years. That code was non OOP. Specifically when switching between root/non-root the code will segfault when trying to write to the .tkf and .OFF files. Delete those first!
  18. List of applications in the package:
    Time to run is on a 850MHz box with Riva TNT2 M64 card, 826MB Ram.

    List of applications
    Name Function Linux Smoothing
    - - Exec(secs) -
    aa Astrological program. Draws natal + transit charts. 8.0 3*
    . 41.1 .
    astrosyms Draws explanation of astrological symbols in Spanish 12.1 3
    bar Draws bar chart with legend. Shows duration warning message. 314.0 3*
    bar3d Draws 3d bars. 3.7 3*
    bess 2-D projection within a grid. 5.2 3*
    clrtest Semi-log plots. 3 plots. 1.2 3*
    . 1.9 .
    . 1.6 .
    cnttest Contour plot. 2.1 3*
    d2test Draws 4 plots on one page. 29.8 .
    d3test Plots 3-D surfaces. 2 plots. 2.1 3*
    . 3.8 .
    delays Plots a non-linear polar grid plot from a datafile. 18.7 2*
    erftest Plots a single curve on an error function grid. 1.3 3*
    exh Plots the E by H vectors on the Z axis. 7.12 3*
    fermi Example of simultaneous plots. Duration warning message. 239.5 3*c
    filltest Example of using surmat() to draw 3-D surfaces. 7.1 .
    . Duration warning message. 2 plots. 26.3 3*
    fonttabl Plots a font with all ascii characters. Select from File-Open. 5.4 3*
    fnttest1 Plots a sample of many fonts. 8.5 3*
    funds Database extraction. Mutual fund plots. 5 plots. Last one contour 4.5 3*
    . 3.6 .
    . 13.4 .
    . 14.6 .
    . 119.8 .
    jcont Proton tokamak orbit plot. 7.9 3*
    logtest Semi-log and log-log plot. 2 plots. 1.9 3*
    . 2.5 .
    machii Contour plot from random data. Duration warning. 96.0 3*
    orbits Plots Tokamak Banana Orbits. 4.0 3*
    pat256 Plots patterns 1-16 and GPC colors 200-447 25.9 3*
    pattern Plots patterns 1-16, IBM colors 0>-15, GPC colors 50-174 10.1 3*
    pie Plots a pie chart. Duration warning. 228.0 3*
    poltest Plots 2 polar plots. 1.0 3*
    . 1.2 .
    r3test Plots 3-D surface and contour map of random points. 2 plots. 10.1 3*
    . 2.6 .
    rates Plots airport arrivals. 3 plots. Boxplot + 2 contours. Warning. 2.9 2*g
    . 119.5 .
    . 87.1 .
    sample Simple sample x-y plot. 2.2 3*
    smtest The famous Smith Chart. 3.0 3*
    tritest Triangle plot. 3.2 3*
    tztest 3 contour plots of airtraffic over the us. Longest running. 79.0 3*
    . 670.0 .
    . 126.9 .
    vfield Plot of the vector() function - a magnetic field. 2.2 3*


    In the above table "Smoothing" refers to smoothing ("antialiasing") results:

    • 0 = the results are unacceptable: some parts of the graph don't show up.
    • 1 = the results are mediocre. Everything shows up, but some things poorly.
    • 2 = OK. The results are alright but not spectacular.
    • 3 = The results are spectacular in their difference with non-smoothing.
    • * = the application has to be modified for smoothing to function well.
    If the smoothing results are not 3, the qualifier refers to:
    • c = symbol #16( a point) does not show up well smoothed, use #12.
    • g = boxplots are not well done because of the deemphasized central bar.
  19. Smoothing. If you set the "use_smooth_scale" variable the application graph will be smoothed. Note:
    • The application has to be changed to draw fatter lines. Cf. sample.c and aa.cpp
    • Smoothing has drawbacks sometimes. Most application do terrific, others not.
    • What does NOT do well:
      Emphatically thick lines show less.
      This applies to boxplots: rates:plot #1
     
  20. XComments, questions:
    gpc_qt@yahoo.com

Hugo M. Van Woerkom, May 30, 2007 (HyperLatex - 2.6.21-1-k7 on (Sda1))