A fuzzy logic C++ library
Public Member Functions | Private Member Functions | Private Attributes | Friends
slifis_plot::PLOT_RB_2D Class Reference

A plot of a 2-dimensional rule base, relevant ONLY for a FIS with 2 inputs. More...

#include <plot_rb_2d.hpp>

+ Inheritance diagram for slifis_plot::PLOT_RB_2D:
+ Collaboration diagram for slifis_plot::PLOT_RB_2D:

List of all members.

Public Member Functions

 PLOT_RB_2D (const slifis::RULE_BASE &rule_base, int w=400, int h=300)
 Constructor.
 ~PLOT_RB_2D ()
bool Draw ()
 Implementation of virtual method of PLOT.
void SelectBox (size_t idx_row, size_t idx_col)
 Defines cell as selected, so it will be drawn with a special color (used in mouse callback)
std::string GetPlotName () const
bool BoxIsSelected () const
 Returns true if a cell is selected.
void Unselect ()
 Unselect the selected cell (if any)
void GetSelected (int &idx_row, int &idx_col) const
 Returns row/col indexes of selected cell (-1 if none)

Private Member Functions

void P_DrawFiringStrength ()
 Colors background of a line/column in the rule table showing how the input values "fires" a rule.
void P_DrawIndexes ()
 Print indexes of inputs in line/column headers, and outputs indexes in cells.
 PLOT_RB_2D (const PLOT_RB_2D &)

Private Attributes

slifis::RB_TABLEp_rbt
 Pointer initialised by constructor.
const slifis::FUZZY_INfin_row
 Pointer on input set associated to rows, see Draw()
const slifis::FUZZY_INfin_col
 Pointer on input set associated to columns, see Draw()
size_t _NbFunc_row
size_t _NbFunc_col
int _head_width
int _head_height
int cell_w
 width of a column (including line between cells)
int cell_h
 height of a row (including line between cells)
int _Sel_col
 column index of selected box, -1 if none
int _Sel_row
 column row of selected box, -1 if none

Static Private Attributes

Colors used for drawing (all static)

{

static GAPI_COLOR col_selected_box = GAPI_BuildColor( 200, 250, 250 )
 color of selected box
static GAPI_COLOR col_selected_txt = GAPI_BuildColor( 0, 50, 50 )
 color of text in selected column/line header
static GAPI_COLOR col_txt_header_row = GAPI_BuildColor( 50, 50, 200 )
 color of text in header (rows)
static GAPI_COLOR col_txt_header_col = GAPI_BuildColor( 50, 200, 50 )
 color of text in header (cols)
static GAPI_COLOR col_txt_idx_out = GAPI_BuildColor( 50, 50, 100 )
 color of index of the output mf, in cell
static GAPI_COLOR col_txt_idx_rule = GAPI_BuildColor( 150, 50, 50 )
 color of rule index, in cell
static GAPI_COLOR col_txt_fs = GAPI_BuildColor( 250, 10, 20 )
 color of firing strength text }

Friends

void GetFiringStrengthVector (const slifis::FUZZY_IN &fin, std::vector< size_t > &temp_i, std::vector< double > &temp_fs)
 Helper function for computing fire strength lines on plot.

Detailed Description

A plot of a 2-dimensional rule base, relevant ONLY for a FIS with 2 inputs.


Constructor & Destructor Documentation

slifis_plot::PLOT_RB_2D::PLOT_RB_2D ( const slifis::RULE_BASE rule_base,
int  w = 400,
int  h = 300 
)

References __IN__, and __OUT__.


Member Function Documentation

bool slifis_plot::PLOT_RB_2D::Draw ( ) [virtual]
void slifis_plot::PLOT_RB_2D::SelectBox ( size_t  idx_row,
size_t  idx_col 
)

Defines cell as selected, so it will be drawn with a special color (used in mouse callback)

References _NbFunc_col, _NbFunc_row, _Sel_col, _Sel_row, SLIFIS_ERROR_LOG, and SLIFIS_WARNING.

Referenced by Mouse_CB_rb_2D().

std::string slifis_plot::PLOT_RB_2D::GetPlotName ( ) const [virtual]
bool slifis_plot::PLOT_RB_2D::BoxIsSelected ( ) const [inline]

Returns true if a cell is selected.

References _Sel_col.

Referenced by Mouse_CB_rb_2D().

Unselect the selected cell (if any)

References _Sel_col, and _Sel_row.

Referenced by Mouse_CB_rb_2D(), Mouse_CB_rb_text(), and PLOT_RB_2D().

void slifis_plot::PLOT_RB_2D::GetSelected ( int &  idx_row,
int &  idx_col 
) const [inline]

Returns row/col indexes of selected cell (-1 if none)

References _Sel_col, and _Sel_row.

Referenced by Mouse_CB_rb_2D().


Friends And Related Function Documentation

void GetFiringStrengthVector ( const slifis::FUZZY_IN fin,
std::vector< size_t > &  temp_i,
std::vector< double > &  temp_fs 
) [friend]

Helper function for computing fire strength lines on plot.

See About the concept of "firing strength"

Referenced by P_DrawFiringStrength().


Member Data Documentation

Pointer initialised by constructor.

Referenced by Draw(), P_DrawIndexes(), and PLOT_RB_2D().

Pointer on input set associated to rows, see Draw()

Referenced by Draw(), P_DrawFiringStrength(), and P_DrawIndexes().

Pointer on input set associated to columns, see Draw()

Referenced by Draw(), P_DrawFiringStrength(), and P_DrawIndexes().

Referenced by Draw(), and PLOT_RB_2D().

Referenced by Draw(), and PLOT_RB_2D().

width of a column (including line between cells)

height of a row (including line between cells)

column index of selected box, -1 if none

Referenced by BoxIsSelected(), Draw(), GetSelected(), SelectBox(), and Unselect().

column row of selected box, -1 if none

Referenced by Draw(), GetSelected(), SelectBox(), and Unselect().

color of selected box

Referenced by Draw().

color of text in selected column/line header

Referenced by Draw().

color of text in header (rows)

Referenced by P_DrawIndexes().

color of text in header (cols)

Referenced by P_DrawIndexes().

color of index of the output mf, in cell

Referenced by P_DrawIndexes().

color of rule index, in cell

Referenced by P_DrawIndexes().

color of firing strength text }

Referenced by P_DrawFiringStrength().