A fuzzy logic C++ library
Classes | Typedefs | Enumerations | Functions
slifis_plot Namespace Reference

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

Classes

struct  FCOLOR
 private 'float' color-type ([0.0-1.0]), needed for Cairo drawing functions More...
struct  GAPI_COLOR
 Abstract color type, common for all graphicals back-ends. More...
struct  GAPI_POINT
 Abstract integer 2D-point type (for pixels), common for all graphicals back-ends. More...
struct  GAPI_gtk_window
 A wrapper over a GTK window. More...
struct  CAIRO_GLOBALS
 Private class for static-related stuff of gapi, cairo version. More...
class  GRID
 Used only a a helper class for PLOT_RB_TEXT, holds pixel mouse position information AND destination image and font. More...
class  GRID_CELL
 A table cell, identified by origin point and size. See GRID. More...
struct  PLOT_MARGINS
 Margins of a plot, expressed in pixels. More...
class  PLOT_COLLECTION
 Maintains a set of all created plots. Private class, only instanciated as static member in class PLOT. More...
struct  PLOT_DATA
 private class, holds all static data needed for plotting More...
class  PLOT
 Pure virtual class, root for all kinds of plots. More...
class  PLOT_FS
 Plot of a set of membership functions. More...
struct  PLOT_HSCALE
 Struct used for transmitting horizontal scale of a plot, see PLOT_FUZZY::SetScale() and PLOT_FUZZY::GetScale() More...
class  PLOT_FUZZY
 Root pure virtual class for PLOT_FS and PLOT_MF. Is NOT designed to be used by library end users,. More...
class  PLOT_MF
 Plot of a membership function (see slifis::MEMBFUNC) More...
class  PLOT_RB
 this is a pure virtual root class for the 2 type of plots for a rule base : PLOT_RB_2D and PLOT_RB_TEXT It holds common attributes (GRID) More...
class  PLOT_RB_2D
 A plot of a 2-dimensional rule base, relevant ONLY for a FIS with 2 inputs. More...
struct  POSITION_INFO
 Holds information about what is at given position (row, col) of the plot. Also used for selection. More...
class  PLOT_RB_TEXT
 A plot of a rule base shown as a table: each rule is shown as a line of text, (table-view) More...

Typedefs

typedef cairo_surface_t GAPI_IMAGE
typedef void GAPI_FONT
typedef void(* MouseCallback )(int event, int x, int y, int flags, void *param)

Enumerations

enum  EN_LINE_TYPE { en_aa_off, en_aa_on }
 Line type, to enable or not anti-aliasing in function GAPI_DrawLine() More...
enum  EN_TEXT_ORIENTATION { EN_TXT_HORIZ, EN_TXT_VERT }
 Orientation of text for text functions (ignored in OpenCv build) More...
enum  EN_TEXT_POS_H { TEXT_POS_HL, TEXT_POS_HC, TEXT_POS_HR }
 Horizontal position of text in a cell. See GRID_CELL::DrawText() More...
enum  EN_TEXT_POS_V { TEXT_POS_VT, TEXT_POS_VC, TEXT_POS_VB }
 Vertical position of text in a cell. See GRID_CELL::DrawText() More...
enum  EN_POS_TYPE {
  RBT_POS_INVALID = 0, RBT_POS_ROW, RBT_POS_NEW_ROW, RBT_POS_OUTPUT_VALUE,
  RBT_POS_INPUT_NAME, RBT_POS_INPUT_VALUE, RBT_POS_RULE_OP
}
 Used for defining what type of position is the current (mouse) position on the plot. Related to class POSITION_INFO, inside PLOT_RB_TEXT. More...
enum  EN_SELECTION_TYPE {
  NO_SELECTION = 0, SELECT_ROW, SELECT_NEW_ROW, SELECT_TERM_INPUT,
  SELECT_TERM_VALUE, SELECT_RULE_OP, SELECT_OUTPUT
}
 Type of selection currently active in a plot of type PLOT_RB_TEXT. More...

Functions

CAIRO_GLOBALScairo_globals ()
 Static allocation of cairo-related static stuff, using idiom "Construct On First Use".
static GAPI_gtk_windowFindWindowByName (const std::string &name)
 Auxiliary private function.
static void RemoveWindowByName (const std::string &name)
 Auxiliary private function.
static gboolean cb_OnKeyPress (GtkWidget *, GdkEventKey *event, gpointer)
 Callback fo GTK window.
static gboolean 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 Paint (GtkWidget *widget, GAPI_IMAGE *im)
 Paints the image in the gtk+ window.
static gboolean cb_expose_event (GtkWidget *widget, GdkEventExpose *, gpointer image)
 callback for GTK+ backend, actually draws the image in the GTK+ window
static FCOLOR 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.
PLOT_DATAplot_data ()
 Static allocation of static stuff for plots, using idiom "Construct On First Use".
void GetFiringStrengthVector (const FUZZY_IN &fin, std::vector< size_t > &temp_i, std::vector< double > &temp_fs)
 Helper function for computing fire strength lines on plot.
Data-types handling
GAPI_POINT GAPI_BuildPoint (int x0, int y0)
 C-style constructor for point.
GAPI_COLOR GAPI_BuildColor (char r, char g, char b)
 C-style constructor for color.
GAPI_IMAGEGAPI_CreateImage (int w, int h)
void GAPI_ReleaseImage (GAPI_IMAGE **p_im)
Windowing and user-interface related functions
void GAPI_CreateWindow (std::string name, int x0, int y0)
 Open a window.
void GAPI_DestroyWindow (std::string wnd_name)
 Destroy the window wnd_name.
void GAPI_MoveWindow (std::string wnd_name, int x, int y)
 Moves the window wnd_name.
bool GAPI_WindowIsOpen (std::string name)
 Returns true if window is open (GTK2 version)
void 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 GAPI_WaitKey ()
 Blocking function, until a key is pressed.
void GAPI_ShowImage (std::string wnd_name, GAPI_IMAGE *im)
 Draw image on GTK window.
Misc.
void GAPI_Init (int argc, char **argv)
 Initialize the gtk windowing engine. Called each time a window is created.
int GAPI_GetImageW (GAPI_IMAGE *p_im)
int GAPI_GetImageH (GAPI_IMAGE *p_im)
void 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_FONTGAPI_InitFont ()
 Initializes font for drawing text (Cairo version, does nothing)
bool GAPI_SaveImage (std::string filename, GAPI_IMAGE *im)
 Saves image to file, returns false on failure.
Drawing-related functions
void GAPI_DrawRectangle (GAPI_IMAGE *p_im, GAPI_POINT p1, GAPI_POINT p2, GAPI_COLOR col, bool is_filled)
 Draw rectangle (Cairo version)
void 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 GAPI_DrawCircle (GAPI_IMAGE *p_im, GAPI_POINT p, double rad, GAPI_COLOR col, int line_width)
 Draw circle (Cairo version)
void GAPI_FillImage (GAPI_IMAGE *im, GAPI_COLOR col)
 Fill image im with color col (Cairo version)
void 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

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


Typedef Documentation

typedef cairo_surface_t slifis_plot::GAPI_IMAGE
typedef void slifis_plot::GAPI_FONT
typedef void(* slifis_plot::MouseCallback)(int event, int x, int y, int flags, void *param)

Enumeration Type Documentation

Line type, to enable or not anti-aliasing in function GAPI_DrawLine()

Enumerator:
en_aa_off 

AA off (default)

en_aa_on 

AA on.

Orientation of text for text functions (ignored in OpenCv build)

Enumerator:
EN_TXT_HORIZ 
EN_TXT_VERT 

Horizontal position of text in a cell. See GRID_CELL::DrawText()

Enumerator:
TEXT_POS_HL 

Left.

TEXT_POS_HC 

Center.

TEXT_POS_HR 

Right.

Vertical position of text in a cell. See GRID_CELL::DrawText()

Enumerator:
TEXT_POS_VT 

Top.

TEXT_POS_VC 

Center.

TEXT_POS_VB 

Bottom.

Used for defining what type of position is the current (mouse) position on the plot. Related to class POSITION_INFO, inside PLOT_RB_TEXT.

Enumerator:
RBT_POS_INVALID 

Invalid position (default value)

RBT_POS_ROW 

Row header.

RBT_POS_NEW_ROW 

last (empty) row

RBT_POS_OUTPUT_VALUE 

Output value.

RBT_POS_INPUT_NAME 
RBT_POS_INPUT_VALUE 
RBT_POS_RULE_OP 

position is on rule operator (AND/OR)

Type of selection currently active in a plot of type PLOT_RB_TEXT.

Enumerator:
NO_SELECTION 
SELECT_ROW 

Selection of whole row.

SELECT_NEW_ROW 

Selection of the last row, used for adding a new rule to rule base.

SELECT_TERM_INPUT 
SELECT_TERM_VALUE 
SELECT_RULE_OP 
SELECT_OUTPUT 

Function Documentation

GAPI_POINT slifis_plot::GAPI_BuildPoint ( int  x0,
int  y0 
)
GAPI_COLOR slifis_plot::GAPI_BuildColor ( char  r,
char  g,
char  b 
)

Static allocation of cairo-related static stuff, using idiom "Construct On First Use".

See http://www.parashift.com/c++-faq/static-init-order-on-first-use.html

Referenced by cb_OnKeyPress(), FindWindowByName(), GAPI_CreateWindow(), GAPI_DrawText(), GAPI_GetTextSize(), GAPI_WaitKey(), and RemoveWindowByName().

static GAPI_gtk_window* slifis_plot::FindWindowByName ( const std::string &  name) [static]

Auxiliary private function.

Searches the global std::list _l_gtk_window and returns a pointer on window with name name, or 0 if not found

References slifis_plot::CAIRO_GLOBALS::_l_gtk_window, and cairo_globals().

Referenced by GAPI_AssignCallback(), GAPI_CreateWindow(), GAPI_DestroyWindow(), GAPI_MoveWindow(), GAPI_ShowImage(), GAPI_WindowIsOpen(), and generic_mouse_callback().

static void slifis_plot::RemoveWindowByName ( const std::string &  name) [static]

Auxiliary private function.

References slifis_plot::CAIRO_GLOBALS::_l_gtk_window, and cairo_globals().

Referenced by GAPI_DestroyWindow().

static gboolean slifis_plot::cb_OnKeyPress ( GtkWidget *  ,
GdkEventKey *  event,
gpointer   
) [static]

Callback fo GTK window.

  • taken from opencv 2.1, file window_gtk.cpp, function cvWaitKey(), line 1327 (simplified)
  • modifies global last_key

References slifis_plot::CAIRO_GLOBALS::_last_key, cairo_globals(), and GAPI_TRACE.

Referenced by GAPI_CreateWindow().

void slifis_plot::GAPI_CreateWindow ( std::string  name,
int  x0,
int  y0 
)
void slifis_plot::GAPI_DestroyWindow ( std::string  wnd_name)
void slifis_plot::GAPI_MoveWindow ( std::string  wnd_name,
int  x,
int  y 
)

Moves the window wnd_name.

References slifis_plot::GAPI_gtk_window::_gtk_window, FindWindowByName(), and SLIFIS_WARNING_1.

Referenced by main().

bool slifis_plot::GAPI_WindowIsOpen ( std::string  name)

Returns true if window is open (GTK2 version)

References FindWindowByName().

Referenced by Process().

static gboolean slifis_plot::generic_mouse_callback ( GtkWidget *  ,
GdkEvent *  event,
gpointer  user_data 
) [static]

A generic mouse callback (GTK+ flavor) whose job is to call the user callback.

This is the callback function associated to the Gtk+2 window

see GAPI_AssignCallback()

This function basically identifies which window called this callback, then converts the GTK2 events into corresponding GAPI events, and eventually calls the user callback.

References slifis_plot::GAPI_gtk_window::_gtk_window, slifis_plot::GAPI_gtk_window::_on_mouse, slifis_plot::GAPI_gtk_window::_param, FindWindowByName(), GAPI_EVENT_LBUTTONDOWN, GAPI_EVENT_LBUTTONUP, GAPI_EVENT_MOUSEMOVE, GAPI_EVENT_RBUTTONDOWN, GAPI_EVENT_RBUTTONUP, GAPI_LOG, GAPI_TRACE, and SLIFIS_WARNING_1.

Referenced by GAPI_AssignCallback().

void slifis_plot::GAPI_AssignCallback ( std::string  wnd_name,
void(*)(int event, int x, int y, int flags, void *param)  userMouseCB,
void *  param 
)

Assigns the user mouse callback userMouseCB to window wnd_name.

Actually, at runtime, goes through generic_mouse_callback() before calling the user callback

References FindWindowByName(), GAPI_LOG, GAPI_TRACE, generic_mouse_callback(), and SLIFIS_WARNING_1.

Referenced by main().

Blocking function, until a key is pressed.

This function keeps on running once the gtk event-loop, while checking if the keyboard callback has not returned a new hit in g_last_key

References slifis_plot::CAIRO_GLOBALS::_last_key, and cairo_globals().

Referenced by main().

static void slifis_plot::Paint ( GtkWidget *  widget,
GAPI_IMAGE *  im 
) [static]

Paints the image in the gtk+ window.

References __IN__, __OUT__, slifis::ERR_GAPI, GAPI_TRACE, and SLIFIS_ERROR_2.

Referenced by cb_expose_event(), and GAPI_ShowImage().

static gboolean slifis_plot::cb_expose_event ( GtkWidget *  widget,
GdkEventExpose *  ,
gpointer  image 
) [static]

callback for GTK+ backend, actually draws the image in the GTK+ window

References GAPI_TRACE, and Paint().

void slifis_plot::GAPI_ShowImage ( std::string  wnd_name,
GAPI_IMAGE *  im 
)

Draw image on GTK window.

See:

Bug:
Problem here (gapi/cairo-gtk only): if we DO connect the signal, then when trying to show in the same window another image and the previous one is dead, the gtk callback is STILL alive and uses the dead image as argument (and crashes, of course). So we need to find a way to "disconnect" the signal from previous image, and that means keeping track of images in some way. At present, images only show after first mouse callback is called.

References slifis_plot::GAPI_gtk_window::_gtk_window, slifis_plot::GAPI_gtk_window::_HasBeenConnectedToSignal, FindWindowByName(), GAPI_GetImageH(), GAPI_GetImageW(), GAPI_TRACE, Paint(), SLIFIS_WARNING, and SLIFIS_WARNING_1.

Referenced by DrawDefuzz(), Process(), Show(), and slifis_plot::PLOT::Show().

void slifis_plot::GAPI_Init ( int  argc,
char **  argv 
)

Initialize the gtk windowing engine. Called each time a window is created.

Referenced by GAPI_CreateWindow().

GAPI_IMAGE * slifis_plot::GAPI_CreateImage ( int  w,
int  h 
)
void slifis_plot::GAPI_ReleaseImage ( GAPI_IMAGE **  p_im)
int slifis_plot::GAPI_GetImageW ( GAPI_IMAGE *  p_im)
int slifis_plot::GAPI_GetImageH ( GAPI_IMAGE *  p_im)
static FCOLOR slifis_plot::ConvertColor ( GAPI_COLOR &  col) [static]

Static utility for converting 'byte' color-type ([0-255]) to 'float' color-type ([0.0-1.0]), needed for Cairo API.

References slifis_plot::GAPI_COLOR::B, slifis_plot::FCOLOR::B, slifis_plot::GAPI_COLOR::G, slifis_plot::FCOLOR::G, slifis_plot::GAPI_COLOR::R, and slifis_plot::FCOLOR::R.

Referenced by GAPI_DrawCircle(), GAPI_DrawLine(), GAPI_DrawRectangle(), GAPI_DrawText(), and GAPI_FillImage().

void slifis_plot::GAPI_DrawRectangle ( GAPI_IMAGE *  p_im,
GAPI_POINT  p1,
GAPI_POINT  p2,
GAPI_COLOR  col,
bool  is_filled 
)
void slifis_plot::GAPI_DrawLine ( GAPI_IMAGE *  p_im,
GAPI_POINT  p1,
GAPI_POINT  p2,
GAPI_COLOR  col,
int  line_width,
EN_LINE_TYPE   
)
void slifis_plot::GAPI_DrawCircle ( GAPI_IMAGE *  p_im,
GAPI_POINT  p,
double  rad,
GAPI_COLOR  col,
int  line_width 
)
void slifis_plot::GAPI_FillImage ( GAPI_IMAGE *  im,
GAPI_COLOR  col 
)
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 
)
void slifis_plot::GAPI_GetTextSize ( GAPI_IMAGE *  im,
const std::string &  txt,
GAPI_FONT *  ,
int &  t_w,
int &  t_h 
)

Initializes font for drawing text (Cairo version, does nothing)

Referenced by slifis_plot::PLOT::PLOT().

bool slifis_plot::GAPI_SaveImage ( std::string  filename,
GAPI_IMAGE *  im 
)

Saves image to file, returns false on failure.

References SLIFIS_WARNING.

Referenced by slifis_plot::PLOT::Save().

void slifis_plot::GetFiringStrengthVector ( const FUZZY_IN fin,
std::vector< size_t > &  temp_i,
std::vector< double > &  temp_fs 
)

Helper function for computing fire strength lines on plot.

See About the concept of "firing strength"

References __IN__, __OUT__, slifis::FUZZY_IN::GetInputFiringStrength(), and slifis::FUZZY_ROOT::GetNbMf().