A fuzzy logic C++ library
Classes | Namespaces | Defines | Functions
gapi_glue.cpp File Reference

glue code between slifis gapi interface (header file gapi_glue.hpp), which defines some datatypes, and the back-end graphical and windowing library. More...

#include <cassert>
#include <cmath>
#include "gapi_glue.hpp"
#include "error_handler.hpp"
#include "debug.h"
#include <cstring>
+ Include dependency graph for gapi_glue.cpp:

Classes

struct  slifis_plot::FCOLOR
 private 'float' color-type ([0.0-1.0]), needed for Cairo drawing functions More...

Namespaces

namespace  slifis_plot
 

This namespace includes both the set of interface functions to the backend graphical library and the plot classes, see Slifis Graphical API for plotting.


Defines

#define SLIFIS_FONTSIZE   0.4
 Font size scale (used only in Opencv backend)
#define GAPI_TRACE   if(0) std::cerr
 Private macro for logging.
#define GAPI_LOG   if(0) std::cerr
#define GAPI_ERROR   std::cerr <<

Functions

CAIRO_GLOBALS & slifis_plot::cairo_globals ()
 Static allocation of cairo-related static stuff, using idiom "Construct On First Use".
static GAPI_gtk_window * slifis_plot::FindWindowByName (const std::string &name)
 Auxiliary private function.
static void slifis_plot::RemoveWindowByName (const std::string &name)
 Auxiliary private function.
static gboolean slifis_plot::cb_OnKeyPress (GtkWidget *, GdkEventKey *event, gpointer)
 Callback fo GTK window.
static gboolean slifis_plot::generic_mouse_callback (GtkWidget *, GdkEvent *event, gpointer user_data)
 A generic mouse callback (GTK+ flavor) whose job is to call the user callback.
static void slifis_plot::Paint (GtkWidget *widget, GAPI_IMAGE *im)
 Paints the image in the gtk+ window.
static gboolean slifis_plot::cb_expose_event (GtkWidget *widget, GdkEventExpose *, gpointer image)
 callback for GTK+ backend, actually draws the image in the GTK+ window
static FCOLOR slifis_plot::ConvertColor (GAPI_COLOR &col)
 Static utility for converting 'byte' color-type ([0-255]) to 'float' color-type ([0.0-1.0]), needed for Cairo API.
Data-types handling
GAPI_POINT slifis_plot::GAPI_BuildPoint (int x0, int y0)
 C-style constructor for point.
GAPI_COLOR slifis_plot::GAPI_BuildColor (char r, char g, char b)
 C-style constructor for color.
GAPI_IMAGE * slifis_plot::GAPI_CreateImage (int w, int h)
void slifis_plot::GAPI_ReleaseImage (GAPI_IMAGE **p_im)
Windowing and user-interface related functions
void slifis_plot::GAPI_CreateWindow (std::string name, int x0, int y0)
 Open a window.
void slifis_plot::GAPI_DestroyWindow (std::string wnd_name)
 Destroy the window wnd_name.
void slifis_plot::GAPI_MoveWindow (std::string wnd_name, int x, int y)
 Moves the window wnd_name.
bool slifis_plot::GAPI_WindowIsOpen (std::string name)
 Returns true if window is open (GTK2 version)
void slifis_plot::GAPI_AssignCallback (std::string wnd_name, void(*userMouseCB)(int event, int x, int y, int flags, void *param), void *param)
 Assigns the user mouse callback userMouseCB to window wnd_name.
char slifis_plot::GAPI_WaitKey ()
 Blocking function, until a key is pressed.
void slifis_plot::GAPI_ShowImage (std::string wnd_name, GAPI_IMAGE *im)
 Draw image on GTK window.
Misc.
void slifis_plot::GAPI_Init (int argc, char **argv)
 Initialize the gtk windowing engine. Called each time a window is created.
int slifis_plot::GAPI_GetImageW (GAPI_IMAGE *p_im)
int slifis_plot::GAPI_GetImageH (GAPI_IMAGE *p_im)
void slifis_plot::GAPI_GetTextSize (GAPI_IMAGE *im, const std::string &txt, GAPI_FONT *, int &t_w, int &t_h)
 Returns size of text txt (Cairo version)
GAPI_FONT * slifis_plot::GAPI_InitFont ()
 Initializes font for drawing text (Cairo version, does nothing)
bool slifis_plot::GAPI_SaveImage (std::string filename, GAPI_IMAGE *im)
 Saves image to file, returns false on failure.
Drawing-related functions
void slifis_plot::GAPI_DrawRectangle (GAPI_IMAGE *p_im, GAPI_POINT p1, GAPI_POINT p2, GAPI_COLOR col, bool is_filled)
 Draw rectangle (Cairo version)
void slifis_plot::GAPI_DrawLine (GAPI_IMAGE *p_im, GAPI_POINT p1, GAPI_POINT p2, GAPI_COLOR col, int line_width, EN_LINE_TYPE)
 Draw line (Cairo version)
void slifis_plot::GAPI_DrawCircle (GAPI_IMAGE *p_im, GAPI_POINT p, double rad, GAPI_COLOR col, int line_width)
 Draw circle (Cairo version)
void slifis_plot::GAPI_FillImage (GAPI_IMAGE *im, GAPI_COLOR col)
 Fill image im with color col (Cairo version)
void slifis_plot::GAPI_DrawText (GAPI_IMAGE *p_im, std::string txt, GAPI_POINT p, GAPI_FONT *, GAPI_COLOR col, EN_TEXT_ORIENTATION txt_or)
 Draws text on image (cairo version)

Detailed Description

glue code between slifis gapi interface (header file gapi_glue.hpp), which defines some datatypes, and the back-end graphical and windowing library.

The choice of library is done through preprocessor symbols, defined in makefile. At present, the available choices are:


Define Documentation

#define SLIFIS_FONTSIZE   0.4

Font size scale (used only in Opencv backend)

#define GAPI_TRACE   if(0) std::cerr
#define GAPI_LOG   if(0) std::cerr
#define GAPI_ERROR   std::cerr <<