KRESLITKO Online Documentation

 Do you remember these golden days of graphics programming in 1993?
We used the Borland graphics library or graph.tpu in Turbo Pascal,
and everything was very very simple.
But than Windows and X-Windows have come and the programming of graphics applications
has become boring, as you needed to do all this 
boring windowing stuff about events, mouse, repaint and so on.
Simply, you couldn't write sequential code as the days before.
Now, the paradise lost has its comeback: I wrote this simple application called 
KRESLITKO
which it is able to do every windowing and event handling stuff for you alone and you alone can focus on what you just want to do.

Ondra Hrstka <ondra@klobouk.fsv.cvut.cz>


What's new in latest release 0049:

1. It's possible to hide whole kreslitko
2. Vieport messages added
3. Function set_points works for rectangles too
4. Enable and disable buttons
5. Polygon item added
6. Standard Quit signal




Contents:

  • What Is KRESLITKO?
  • Features
  • Screenshots
  • Download
  • How to install KRESLITKO
  • How to use KRESLITKO in your application
  • Function Reference
  • NTE (Non-Trivial Example)
  • Trial application 'grafeek'
  • Class k3d
  • What was new in ...

  •  

     


    What is KRESLITKO?

    KRESLITKO is a simple library/application that makes you able to write sequential code even if you want to create graphics application under X-Windows.
    It contains of two parts: the shared library, that you can use in your application in the similar way as for example stdio.h; and the server, the stand-alone application, that takes messages (via Posix IPC system) from your application - generated by the library. Server itself draws everything on the screen and works-around all windows-like and event handling stuff.
    Thus, you can write for example this sequential code:
    #include <kreslitko.h>
    ...
    int  main ( void )
    {
        kreslitko K ;
        K.open_graphics( ... ) ;
        K.line( 0.1,0.1,0.9,0.9 ) ;
        K.line( 0.1,0.9,0.9,0.1 ) ;
        ...
    }
    and get this kind of image:

    You can now do anything you want with this window, for example resize it - and it will resize itself correctly.
    The whole code of this first example is included as 'example1.c'.

    Note: KRESLITKO has a face of a C++ class; I decided to do it this way, because it is the most easy and most 'pleasant' way if you want to have more than one opened window. You simply create two or more instances of class kreslitko.

    (Please, let me know if you started to use KRESLITKO for some purpose.)


    Features:

    KRESLITKO is able to:

    Screenshots:

    Here you can see the rich configuration of KRESLITKO: some lines of different colors in the viewport, the mouse 'cursor', one text entry widget and two buttons.
    More screenshots will come later, when me or other people will create some nice pictures with it. (Please, if you are using KRESLITKO and you have some nice example, send it to me and I will paste it to this document.)


     

    This is a simple usage of KRESLITKO: to draw a graph of some function. See example4.c for the source code how to create that picture.

    Trial application 'grafeek' that is included in KRESLITKO distribution. See some documentation.

    Using class (library) 'k3d' it is possible to generate 3d-pictures. See documentation of k3d.

    3d function graph generated also using class (library) 'k3d'.

    3d function graph of so called FSWE-Type 1 function (by Navarro) - also using 'k3d'.


    Download:

          tgz archive here
                version 0049 (June 18 2011)


    How to install KRESLITKO:

    If you want to install KRESLITKO on your computer, you need only Qt library of version 3.3.x. Version 3.4 and above is not supported, probably is going to be in one of following versions.
    Also, you need to have some compiler of C++ (GNU g++) and GNU make.

    Than, you can follow these steps:

    1. You have archive kreslitko-xxxx.tgz. Unpack it using 'tar xzvf kreslitko-xxxx.tgz' in some directory like /usr/local/src/kreslitko.

    2. Go to that directory.

    3. Run 'configure.sh'. The script will alert you for possible problems.

    4. Run 'make'.

    5. Run 'make install' to install the library, server binary, includes and icons. If you cannot do it as superuser (don't have root privilegies), go to step 7.

    6. Look into the 'examples' directory to see how an application using kreslitko may be written and compiled.

    7. The script 'configure.sh' can be started with an optional parameter '--prefix==/home/joe/opt' or something of that type. This will change the installation destination directory into the given path. Note that you would have to specify -I and -L options for later compilation of your kreslitko-using programs:

    -I/home/joe/opt/include
    -L/home/joe/opt/lib

    and possibly also add "/home/joe/opt/bin" into your PATH, so the kreslitko server can be launched, and "/home/joe/opt/lib" into your LD_LIBRARY_PATH, so the application itself can be launched.

    For UBUNTU users: It has been spotted than on some versions of UBUNTU (like 11.4) it was not possible to configure kreslitko because of the missing POSIX IPS library. If that happens, follow this instruction lines:

    1. Download  libc6_2.11.2-10_i386.deb from this page: http://packages.debian.org/squeeze/i386/libc6/download
    2. Open libc6_2.11.2-10_i386.deb for instance in mc. It will unpack it and show you the contents. Go to CONTENTS->lib.
    3. Copy file librt-2.11.2.so to your /lib directory.
    4. Create a link from /lib/librt-2.11.2.so to /usr/lib/librt.so

    Now your should be able to configure kreslitko. Maybe similar problem may occur on another distribution than UBUNTU, but the solution should be the same.


    How to use KRESLITKO in your application:

    First of all, you must include my header file:

        #include <kreslitko.h>

    Kreslitko in your application lives as a C++ class, you must declare it somewhere before you use it for the first time:

         kreslitko K ;

    Before drawing anything, you must open the graphic viewport - but if you want to create some buttons, text entries or status bar, you must do it now. So, for example:

        K.create_button( "Button1",1 ) ;
        K.create_button( "Button2",2 ) ;
        K.create_text_entry( 3,"What?" ) ;
        K.create_status_bar() ;

    This means that you will have button with label 'Button1' and this button will send signal '1' each time it is pressed (how to gain this signal I will discuss later) and also button with label 'Button2' that will return signal '2'. Then you create text entry with label 'What?' and its value you will be able to access using id number '3'. And status bar, finally - it can be only one and so it has not any id number.
    Well, if you want simply to draw, you dont't have to do such a thing and you can go straigh to next step - opening the graphic viewport.

        K.open_graphics( 0.0,0.0,1.0,1.0,300,300,0.1 ) ;

    This call open graphic viewport. It has virtual size and real size. Real size is 300x300 pixels and virtual size is (0.0-1.0)x(0.0-1.0). You will draw all items using the virtual coordinates and KRESLITKO itself will recompute them into real coordinates. Note: real size is initial size of window and it also works as minimum size of the viewport. Last parameter is optional and means an oversize of the window (0.1 means that real size will be from -0.1 to 1.1 in both dimensions).

    Now you can draw whatever you want. So, for example:

        K.line( 0.1,0.1,0.9,0.9 ) ;
        K.circle( 0.5,0.5,0.2 ) ;

    and so on. Please look beside to function reference for all drawing functions. Note: Start point of coordinate system (0.0,0.0) is in the left bottom like on the paper.
    Items you draw can have their id numbers. So you can for example call this:

        K.line( 0.1,0.9,0.9,0.1,301 ) ;

    It creates a line with id number 301. Using these id numbers you can later delete, hide or redraw these items (see function reference). More than one item may have the same id number - in that case you will be able to delete, hide or redraw all items with the same id by one function call. Drawing texts you can this way:

        K.text( 0.2,0.2,"Hello world!",0 ) ;

    It places text 'Hello world!' into virtual coordinates 0.2,0.2 and will use font number 0 - in KRESLITKO fonts have their own numbers and you assign fonts to these number using function assign_font (see function reference). Also texts can have theis id numbers - send it to function text as last (optional) parameter.
    Sometimes you draw many many items one time and you don't need to see them appearing on the viewport one after one. This case you can use cached drawing. Open a cache using:

        K.begin_serial() ;

    Than draw whatever you want and than close cache using:

        K.flush_serial() ;

    KRESLITKO is able to be mouse sensitive (but in this version it is only a cosmetic property). Toggle it on using:

        K.mouse_sensitive( 1 ) ;

    Function mouse_tracking toggles also writing virtual coordinates into top left angle of the viewport.
    All items are drawn with so called 'actual' color. This color can be changed with function set_color. Colors have their numbers and you can assign a color (specified by red, green and blue values) using function assign_rgb_color. Background color can be specified using set_background_color (and it takes red, green and blue values). You may have maximum of a 128 colors on a viewport one time. Note: background color is 0, so if you assign some values to color 0, it is the same as if you set background color. System uses color 1 for mouse cursor and so on.
    Picture drawn by your application can be saved as xpm (using save_as_xpm) or as png (using save_as_png) or exported (black-and-white version) to PostScript (using export_as_ps).

    Buttons can be used par example for controling run of your process. They return signals which are given in function create_button and you can scan if they have come using functions:

            int wait_for_signal ( int osignal ) ;
            int peek_for_signal ( int osignal ) ;
            int receive_signal ( int &osignal ) ;
            int wait_and_receive_signal ( int &osignal ) ;

    For detailed description see beside my NTE (Non-Trivial Example).

    If you need a scale (a ruler) you can draw it on the screen using functions x_scale and y_scale. See function reference. Note, that scale itself will be drawn using actual color (by set_color), but text using actual text color (by set_text_color).

    Compiling your application does not need any special switches. Linking requires '-lkreslitko -lrt'. Example 'example1.c' can be made by this:

        g++ -o example1 example1.c -lkreslitko -lrt


    Function Reference:

    Constructor, destructor:

        kreslitko::kreslitko ( void ) ;

                    constructor; it runs server and opens a message queue

        kreslitko::~kreslitko ( void ) ;

                    destructor; it stops server and deletes the message queue
     
     

    Creating buttons, text entries, status bar, service area:

        int kreslitko::create_button ( char *oname , int osignal ) ;

                    creates signal button with title 'oname' that will send signal 'osignal'

        int kreslitko::create_text_entry ( int oid , char *oname ) ;

                    creates text entry with label 'oname'; values from it can be obtained through id number 'oid'; 'oid' is also a signal that will be sent by KRESLITKO if return is pressed over this entry

        int kreslitko::create_status_bar ( void ) ;

                    creates status bar

        int kreslitko::create_service_area ( int viewport_resize_lock, int zoom_tools, int num_items, int cursor_position );

                    creates service area on the top of the kreslitko screen; the parameters (if set to 1) can switch on the following items inside the service area: the toggle to fix the size of the kreslitko viewport, zoom buttons to zoom inside the viewport, a box with actual number of items, a box with actual mouse cursor position - if the mouse sensitivity is enabled
     

    Opening graphic viewport, resizing, setting window caption:

        int kreslitko::open_graphics ( double ox1 , double oy1 , double ox2 , double oy2 , int owidth , int oheight , double ooversize=0.0 ) ;

                    opens graphics viewport vith virtual coordinates (ox1-ox2)x(oy1-oy2) and real coordinates (0-owidth)x(0-oheight); zero of coordinate system is in the left bottom; last parameter is optional and means an oversize of window (space around virtual viewport that is also displayed)

        int kreslitko::set_caption ( char *oname ) ;

                    sets caption of kreslitko's screen to 'oname'

        int kreslitko::resize_viewport ( int owidth , int oheight ) ;

                    resizes viewport size to (0-owidth)x(0-oheight)

        int kreslitko::visible_viewport ( double &ox1, double &oy1, double &ox2, double &oy2 );

                    concerns zooming; fills the actual viewport corners into supplied double variables

        int kreslitko::fix_viewport_size ( int ofix );

                    makes the viewport size fixed or scalable - i.e. disables/enables zooming

        int kreslitko::get_actual_viewport_size ( int &owidth, int &oheight );

                    fills actual size of the viewport into supplied variables

           int kreslitko::resize_area ( idouble ox1 , double oy1 , double ox2 , double oy2, double ooversize=0.0 );

                    resizes the virtual drawing area to given coordinates (ox1-ox2)x(oy1-oy2)

           int kreslitko::hide ( void );

                    hides the whole graphic window

           int kreslitko::show ( void );

                    shows the whole graphic window (usually after it has beed hiden by calling the funtion above)

    Drawing items:

        int kreslitko::pixel ( double ox1 , double oy1 , int oid=-1 ) ;

                    draws pixel into coordinates (ox1,oy1); if you send last parameter, pixel will have id number 'oid'

        int kreslitko::line ( double ox1 , double oy1 , double ox2 , double oy2 , int oid=-1 ) ;

                    draws line from point (ox1,oy1) to point (ox2,oy2) ; if you send last parameter, line will have id number 'oid'

        int kreslitko::circle ( double ox1 , double oy1 , double or , int oid=-1 ) ;

                    draws circle with center (ox1,oy1) and radius 'or' ; if you send last parameter, circle will have id number 'oid'

        int kreslitko::cross ( double ox1 , double oy1 , double ow , int oid=-1 ) ;

                    draws cross with center (ox1,oy1) and size 'ow' ; if you send last parameter, cross will have id number 'oid'

        int kreslitko::arc ( double ox1 , double oy1 , double or , double osa , double oea , int oid=-1 ) ;

                    draws arc with center (ox1,oy1), radius 'or', start angle 'osa' and end angle 'oea' (angles are in degrees); if you send last parameter, arc will have id number 'oid'

        int kreslitko::ellipse ( double ox1 , double oy1 , double or1 , double or2 , int oid=-1 ) ;

                    draws ellipse with center (ox1,oy1), radius 'or1' in x-direction and 'or2' in y-direction; if you send last parameter, arc will have id number 'oid'

        int kreslitko::rectangle ( double ox1 , double oy1 , double ow , double oh , int oid=-1 ) ;

                    draws rectangle with one corner in (ox1,oy1) with width ow and height oh; if you send last parameter, rectangle will have id number 'oid'

        int kreslitko::arrow ( double ox1 , double oy1 , double oangle , double olen , int oid=-1 ) ;

                    draws arrow from coordinates (ox1,oy1) points into direction given by 'oangle' and length 'olen' ; if you send last parameter, pixel will have id number 'oid

        int kreslitko::polygon ( double *ox , double *oy , int on , int oid=-1 ) ;

                    draws a polygon that has on nodes and their coordinates are stored in arrays ox and oy

     
     

    Drawing rastered items:


             Note:  all rastered objects have parameter odensity that can be of value from 0.0 to 1.0 and represents how density of the raster.

        int kreslitko::rastered_rectangle ( double ox1 , double oy1 , double ow , double oh , double odensity , int oid=-1 ) ;

            the same thing as kreslitko::rectangle, but rastered

        int kreslitko::rastered_circle ( double ox1 , double oy1 , double or , double odensity , int oid=-1 ) ;

            the same thing as kreslitko::circle, but rastered

        int kreslitko::rastered_ellipse ( double ox1 , double oy1 , double or1 , double or2 , double odensity , int oid=-1 ) ;

            the same thing as kreslitko::ellipse, but rastered

        int kreslitko::rastered_chord ( double ox1 , double oy1 , double or , double osa , double oea , double odensity , int oid=-1 ) ;

            draws a chord; parameters are the same as for the kreslitko::are

        int kreslitko::rastered_pie ( double ox1 , double oy1 , double or , double osa , double oea , double odensity , int oid=-1 ) ;

            draws a pie; parameters are the same as for the kreslitko::pie

        int kreslitko::rastered_polygon ( double *ox , double *oy , int on , double odensity , int oid=-1 ) ;

            draws rastered polygon that has on nodes and their coordinates are stored in arrays ox and oy
     

    Drawing text items:

        int kreslitko::text ( double ox , double oy , char *otext , int ofont , int oid=-1 ) ;

                    draws text 'otext' with left bottom (ox,oy) using font number 'ofont' ; if you send last parameter, pixel will have id number 'oid'

        int kreslitko::set_fp_format ( char *oformat ) ;

                    sets format of floating point numbers - the same manner as using for example printf (so use something like "%10.10E " as 'oformat' )

              int kreslitko::set_sc_factor ( double ofact ) ;

                    sets scale factor for x_scale and y_scale; the meaning is - for instance - scale in range from -1000.0 to 1000.0, with scale factor 0.001 will be marked as from -1.0 to 1.0

        int viewport_message (char *omsg, int oline, int ofont=0, int oposition=KRESLITKO_VpMsgCentered, int oid=-1);
                    prints a message with text omsg into the viewport on line oline (from the top) using given font ofont, and it is able to position it either to left (use KRESLITKO_VpMsgLeft) either right (use KRESLITKO_VpMsgRight) either centered (use KRESLITKO_VpMSGCentered)

     

    Drawing marks:

        int kreslitko::mark_absolute ( double ox , double oy , int otype , int osize , int oid=-1 ) ;

                    draws mark of type otype at a position on (ox,oy) with size osize given in pixels; marks types are given in the picture bellow (and see example11.c)

        int kreslitko::mark_percentual ( double ox , double oy , int otype , int osize , int oid=-1 ) ;

                    draws mark of type otype at a position on (ox,oy) with size osize given in percents of a window size; marks types are given in the picture bellow (and see example11.c)
     

    Deleting, hiding, moving and redrawing items:

        int kreslitko::redraw ( void ) ;

                    redraws all items

        int kreslitko::redraw_items ( int oid ) ;

                    redraws only items that have id number 'oid'

        int kreslitko::redraw_area ( double ox1 , double oy1 , double ox2 , double oy2 ) ;

                    redraws area defined by rectangle given by coordinates ('ox1','oy1') and ('ox2','oy2')

        int kreslitko::delete_item ( int oid ) ;

                    deletes one (first found) item with id number 'oid'

        int kreslitko::delete_items ( int oid ) ;

                    deletes all items that have id number 'oid'

        int kreslitko::hide_item ( int oid ) ;

                    hides one (first found) item with id number 'oid'; hidden items are not displayed until redraw with the same id number is called

        int kreslitko::hide_items ( int oid ) ;

                    hides items that have id number 'oid'; hidden items are not displayed until redraw with the same id number is called

        int kreslitko::move_item ( int oid , double odx, double ody ) ;

                    moves one (first found) item with id number 'oid' by a vector ( odx, ody )

        int kreslitko::move_items ( int oid , double odx, double ody ) ;

                    moves items with id number 'oid' by a vector ( odx, ody )

        int kreslitko::move_item_to ( int oid , double odx, double ody ) ;

                    moves one (first found) item with id number 'oid' to coordinates ( odx, ody )

        int kreslitko::move_items ( int oid , double odx, double ody ) ;

                    moves items with id number 'oid' to coordinates ( odx, ody )

        int kreslitko::set_points ( int oid , double ox1, double oy1, double ox2, double oy2 ) ;

                    works on line items; sets the start and end point coordinates of the item with id number 'oid' to  ( ox1, oy1 ) and ( ox2, oy2 ) respectivelly


    Managing fonts:

        int kreslitko::assign_font ( int ofont , int osize , char *otype , int obold ) ;

                    font number 'ofont' will be assigned with font of type 'otype' (use "Times","Courier","Palatino" etc.), size 'osize' - in points and if 'obold' is non-zero, font will be bold

        int kreslitko::set_resizable_fonts ( int onabled );

                    enables/disables resizing of fonts with resizing the viewport and zooming

    Cached drawing:

        int kreslitko::begin_serial ( void ) ;

                    starts cached drawing; from the calling of this function everything will be drawn into cache and not to viewport

        int kreslitko::flush_serial ( void ) ;

                    flushes cache into viewport (the same can be performed by resizing, moving or hiding and unhiding window all by calling redraw)
     

    Being mouse sensitive:

        int kreslitko::mouse_sensitive ( int oenabled ) ;

                    toggles kreslitko to being mouse sensitive (it will take mouse cursor and draw coordinate cross over all viewport); if 'onenabled' is non-zero, mouse sensitivity will be enabled

        int kreslitko::mouse_tracking ( int oenabled ) ;

                    toggles on of off writing mouse coordinates into top left of viewport
     

    Setting colors, pen and item height:

        int kreslitko::set_background_color ( int ored , int ogreen , int oblue ) ;

                    sets background color to values given by (ored,ogreen,oblue)

        int kreslitko::assign_rgb_color ( int ocolor , int ored , int ogreen , int oblue ) ;

                    assigns color given (ored,ogreen,oblue) to color number 'ocolor'

        int kreslitko::set_color ( int ocolor ) ;

                    sets actual color to color number 'ocolor' which has previously assigned RGB values by assign_rgb_color; this color affects only non-text items

        int kreslitko::set_text_color ( int ocolor ) ;

                    sets actual text color to color number 'ocolor' which has previously assigned RGB values by assign_rgb_color; this color affects only text items

        int kreslitko::set_pen_width ( int owidth ) ;

                    sets actual pen_width ( in pixels )

          int kreslitko::set_pen_type ( int otype ) ;

                    sets actual pen type; possible values are: KRESLITKO_PenSolid, KRESLITKO_PenDashed, KRESLITKO_PenDotted, KRESLITKO_PenDashDot, KRESLITKO_PenDashDotDot

              int kreslitko::set_height ( int oheight ) ;

                    sets actual item width - will be used for all items from now on; the height is usable for instance for solving visibility - items with bigger height are more visible

     

    Saving and exporting picture:

        int kreslitko::save_as_png ( char *ofname ) ;

                    saves drawn picture in resolution given by real size of viewport in format PNG into file 'ofname'; must have library libpng installed

        int kreslitko::save_as_xpm ( char *ofname ) ;

                    saves drawn picture in resolution given by real size of viewport in format XPM into file 'ofname'; must have library libXpm installed

        int kreslitko::save_as_jpg ( char *ofname ) ;

                    saves drawn picture in resolution given by real size of viewport in format JPG into file 'ofname'; must have libraries libjpeg and libgd-1.8.3 or newer installed

        int kreslitko::export_as_ps ( char *ofname , double oxcm , double oycm , int oorient=1 ) ;

                    exports draws picture as PostScript into file 'ofname'; picture will have size (oxcm,oycm) and orientation given by 'oorient' (1 is portrait, 0 is landscape)
     

    Signals, values from text entries, printing to status bar, flags:

       int kreslitko::wait_for_signal ( int osignal ) ;

                    waits until some button sends signal given by 'osignal'; other signals are ignored

        int kreslitko::peek_for_signal ( int osignal ) ;

                    looks if some button have already send signal given by 'osignal'; other signals are ignored

        int kreslitko::receive_signal ( int &osignal ) ;

                    looks if any button have sent a signal and if finds any, stores it into 'osignal'

        int kreslitko::wait_and_receive_signal ( int &osignal ) ;

                    waits until any button sends any signal and then stores it into 'osignal'

        KRESLITKO_StdQuitSignal

                    signal which is returned by kreslitko in case a close button (in the window decoration) is clicked

        int kreslitko::text_entry_set_value ( int oid , int ovalue ) ;

                    sets value of text entry with id number 'oid' to integer value 'ovalue'

        int kreslitko::text_entry_set_value ( int oid , double ovalue ) ;

                    sets value of text entry with id number 'oid' to double value 'ovalue'

        int kreslitko::text_entry_set_value ( int oid , char *ovalue ) ;

                    sets value of text entry with id number 'oid' to string value 'ovalue'

        int kreslitko::text_entry_get_value ( int oid , int &ovalue ) ;

                    grabs value from text entry with id number 'oid' to 'ovalue' as integer

        int kreslitko::text_entry_get_value ( int oid , double &ovalue ) ;

                    grabs value from text entry with id number 'oid' to 'ovalue' as double

        int kreslitko::text_entry_get_value ( int oid , char *ovalue ) ;

                    grabs value from text entry with id number 'oid' to 'ovalue' as string

        int kreslitko::print_to_status_bar ( char *otext ) ;

                    prints a sentence in 'otext' into status bar 

              int kreslitko::prepare_flags ( int on ) ;

                    prepares on binary flags

              int kreslitko::set_flag ( int oid ) ;

                    sets flag with id = oid

              int kreslitko::unset_flag ( int oid ) ;

                    unsets flag with id = oid

              int kreslitko::get_flag ( int oid, int &oflag ) ;

                    fills the value of flag with od = oid into oflag

              int kreslitko::disable_button ( int osignal ) ;

                    finds the button associated with given signal osignal and disables it (so the click has no effect)

              int kreslitko::enable_button ( int osignal ) ;

                    finds the button associated with given signal osignal and enables it (so the click has effect)

     

    How many items:

        int kreslitko::number_of_items ( int &onumber ) ;

                    grabs number of items drawn to kreslitko and stores it into 'onumber'; it includes also hidden items

        int kreslitko::display_number_of_items ( int oenable ) ;

                    toggles if number of items will or will not be displayed into top right of viewport
     

    Drawing scales(rules):

        int kreslitko::x_scale ( double oy , double ox1 , double ox2 , int ofont , int odiv , int oid=-1 ) ;

                    draws horizontal scale in height 'oy' from x-coordinate 'ox1' to x-coordinate 'ox2' with division 'odiv'; text will be drawn using font 'ofont'

        int kreslitko::y_scale ( double ox , double oy1 , double oy2 , int ofont , int odiv , int oid=-1 ) ;

                    draws vertical scale in width 'ox' from y-coordinate 'oy1' to y-coordinate 'oy2' with division 'odiv'; tex will be drawn using font 'ofont'
     

    Displaying png and xpm images:

        int kreslitko::load_picture_as_png ( int oid , char *ofname ) ;

                    loads a picture in png format from file ofname and stores it under an id number oid; using this id number picture may be recalled for displaying

        int kreslitko::load_picture_as_xpm ( int oid , char *ofname ) ;

                    loads a picture in xpm format from file ofname and stores it under an id number oid; using this id number picture may be recalled for displaying

        int kreslitko::picture ( int opic_id , double ox , double oy , int oid=-1 ) ;

                    displays picture that has been loaded previously with id number opic_id at coordinates (ox,oy); last parameter oid has the same meaning as for all other items (lines,circles etc.)

        int kreslitko::scaled_picture ( int opic_id, double ox1, double oy1, double ox2, double oy2, int oid=-1 );

                    displays picture that has been loaded previously with id number opic_id into rectangle given by coordinates ( ox1,oy1 ) and ( ox2,oy2 ); this picture would be scaled on resize of the viewport or zoom

    Background pixmap

        int kreslitko::background_pixmap ( void );

                    prepares background pixmap bufer with the actual size of the viewport

        int kreslitko::set_background_pixel ( double ox, double oy, unsigned int ored, unsigned int ogreen, unsigned int oblue );   

                    sets one pixel of the background pixmap to color defined by ored, ogreen, oblue; note that to fill the whole pixmap, it is necessary to use this function as many times as is the number of pixels while the step should be a pixel size - see functions pixel_size_x and pixel_size_y

        int kreslitko::draw_background ( void );

                    flushed background with actually filled pixels; note that if the viewport size has changed (e.g. zoomed) since the creation of the pixmap using function background_pixmap, you might get result which you don;t expect

        int kreslitko::x_scale ( double oy , double ox1 , double ox2 , int ofont , int odiv , int oid=-1 ) ;

                    draws horizontal scale in height 'oy' from x-coordinate 'ox1' to x-coordinate 'ox2' with division 'odiv'; text will be drawn using font 'ofont'

    2-D Function mapping

        int kreslitko::bset_contour_parameter ( double ocnt=0.25 );                
               
                    sets the sensitivity of countour plotting; the higher is the parameter, the lower sensitivity of countour will be observed

        int kreslitko::map_function_greyscale ( double ofun( double, double ), double oz1, double oz2 );
               
                    plots a 2-D function in greyscale mode; ofun stands for the function itself, oz1and oz2 are limits of the function result

        int kreslitko::map_function_contour ( double ofun( double, double ), double ozero, double odist, int ocont=150, int obg=0 );
               
                    plots a 2-D function in contour mode; ofun stands for the function itself, ozero for the reference contour value, odist for contour distance; ocont is the grey value of contour lines, obg a color of the background

        int kreslitko::map_function_geographic ( double ofun( double, double ), double oz1, double oz2 );
               
                    plots a 2-D function in geographical mode (low values are blue, then green, then yellow, then brown); ofun stands for the function itself, oz1and oz2 are limits of the function result

        int kreslitko::map_function_geographic_contour ( double ofun( double, double ), double oz1, double oz2, double odist, int ocont=150 );
               
                    plots a 2-D function in geographical mode (low values are blue, then green, then yellow, then brown) with contours; ofun stands for the function itself, oz1and oz2 are limits of the function result; odist for contour distance; ocont is the grey value of contour lines



    NTE (Non-Trivial Example):

        I have created a simple application that reads commands such as 'line 0.1 0.1 0.9 0.9' from a file given on command line and executes them using kreslitko. Before two steps it waits until user pressed button 'Next'; if button 'End' is pressed, application ends.
        Look at this source file:
    #include <kreslitko.h>
    #include <stdio.h>
    #include <string.h>

    #define SignalNext 1
    #define SignalEnd 2

    int main ( int oargc , char *oargv[] )
    {
        // opening input file

        if ( oargc!=2 )
        {
            printf( "usage: example3 <filename>\n" ) ;
            exit( 0 ) ;
        }
        FILE *f ;
        f=fopen( oargv[1],"rt" ) ;
        if ( !f )
        {
            printf( "cannot open file %s\n",oargv[1] ) ;
            exit( 0 ) ;
        }

        // create kreslitko instance

        kreslitko K ;

        // create signal button that sends signal 'SignalNext'

        K.create_button( "Next",SignalNext ) ;

        // create signal button that sends signal 'SignalEnd'

        K.create_button( "End",SignalEnd ) ;

        // opening graphics viewport

        K.open_graphics( 0.0,0.0,1.0,1.0,300,300 ) ;

        int j ;

        // each line is in format:
        // some_command (like 'line' or 'circle') coordinates
        // first we will read command into string cmd, check what command it is and then read appropriate coordinates and draw appropriate item

        char cmd[32] ;
        double x1,x2,y1,y2,r ;

        while ( !feof( f ))
        {
            j=fscanf( f,"%s",&cmd ) ;
            if ( j!=-1 )
            {
                if ( !strcmp( cmd,"line" ))
                {
                    fscanf( f,"%lf",&x1 ) ;
               fscanf( f,"%lf",&y1 ) ;
               fscanf( f,"%lf",&x2 ) ;
               fscanf( f,"%lf",&y2 ) ;
                    K.line( x1,y1,x2,y2 ) ;
                }
                else
                    if ( !strcmp( cmd,"circle" ))
                    {
               fscanf( f,"%lf",&x1 ) ;
               fscanf( f,"%lf",&y1 ) ;
               fscanf( f,"%lf",&r ) ;
                        K.circle( x1,y1,r ) ;
                    }
                    else
                        if ( !strcmp( cmd,"cross" ))
                        {
               fscanf( f,"%lf",&x1 ) ;
               fscanf( f,"%lf",&y1 ) ;
               fscanf( f,"%lf",&r ) ;
                            K.cross( x1,y1,r ) ;
                        }
                        else
                            if ( !strcmp( cmd,"rectangle" ))
                            {
                                fscanf( f,"%lf",&x1 ) ;
                                fscanf( f,"%lf",&y1 ) ;
                                fscanf( f,"%lf",&x2 ) ;
                                fscanf( f,"%lf",&y2 ) ;
                                K.rectangle( x1,y1,x2,y2 ) ;
                            }
            }

            // here we are waiting for the user to press some button
            // the signal will be stored in variable 'j'

            K.wait_and_receive_signal( j ) ;

            // if received signal is 'SignalEnd' we won't continue

            if ( j==SignalEnd ) goto END ;

            // the only other signal can be 'SignalNext' so it is not necessary to check it
        }

    END:
        fclose( f ) ;

        // no closing function - we have a destructor

    }


    Trial application 'grafeek'

        Since version 0033 of KRESLITKO trial application 'grafeek' comes with it. It is a simple application that automatically draws some graphs from columns in a data file according to configuration file 'config'. It also generates PostScript picture and table in LaTEX format. More documentation will come later. Examples are included in grafeek subdirectory with the source code. See screenshot.


    What was new in...

     
    RELEASE DATE CHANGES
    kreslitko-0049.tgz June 18 2011 hide and show of the viewport - viewport message - set_points works now for rectangles -  enabling and disabling buttons - polygon - standard quit signal
    kreslitko-0048.tgz February 06 2010 bugs fixed - items moveable in absolute coordinates - line types - set_points for line items - multiple instances of kreslitko allowed - scale factor - flags - k3d integrated into the library - resizable area - item heights
    kreslitko-0047.tgz January 28 2010 2-D function mapping using greyscale, contours or geographical color mode
    kreslitko-0046.tgz January 20 2010 Qt 3 is used - Posix IPC is used instead of SystemV IPC, so no timing issues - number of shared memory segments is reduced to 1 (2 if background image is used) - QCanvas functionality is used to display viewport - QPrinter is used to export PS files, therefore PS quality is improved - resizable fonts - resizable pixmaps - moving items - hashing for quick searching of items by id - for move, delete, hide - pixmap buffer in the shared memory - the actual size of zoomed viewport can be obtained - service area to control the viewport from GUI - toggle button to fix the size of the content - zooming in the viewport - number of items in the service area - mouse position in the service area
    kreslitko-0042.tgz May 8 2001 item database is now dynamic (max 32 segments by 1024 items each)
    kreslitko-0041.tgz May 8 2001 internal class itemize was introduced
    kreslitko-0040.tgz May 7 2001 problems with IPC communication fixed
    kreslitko-0039.tgz April 7 2001 drawing marks with sizes given by pixels or be percents of the screen size
    kreslitko-0038.tgz April 6 2001 data transfer between the library and the server using System V IPC message queue replaced by a System V IPC shared memory segments
    kreslitko-0037.tgz January 15 2001 class (library) K3D that is able to display 3d data
    text entries also return signals same as buttons
    kreslitko-0036.tgz January 8 2001 ellipse and rastered ellipse
    kreslitko-0035.tgz December 4 2000 oversized viewport (parameter to open_graphics)
    xpm and png pictures can be displayed in the viewport
    kreslitko-0034.tgz December 1 2000 rastered objects
    kreslitko-0033.tgz November 17 2000 now is possible to adjust pen thickness (set_pen_width)
    displaying numbers can be adjusted using set_fp_format
    trial application grafeek added
    kreslitko-0029.tgz November 9 2000 libraries libpng, libXpm are now optional; 
    if libgd-1.8.3 or newer is installed, function save_as_jpeg is available
    kreslitko-0028.tgz November 8 2000 redraw_area
    kreslitko-0027.tgz October 23 2000 horizontal and vertical rulers
    kreslitko-0024.tgz October 12 2000 the first release