A fuzzy logic C++ library
|
A plot of a 2-dimensional rule base, relevant ONLY for a FIS with 2 inputs. More...
#include <plot_rb_2d.hpp>
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_TABLE * | p_rbt |
Pointer initialised by constructor. | |
const slifis::FUZZY_IN * | fin_row |
Pointer on input set associated to rows, see Draw() | |
const slifis::FUZZY_IN * | fin_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. |
A plot of a 2-dimensional rule base, relevant ONLY for a FIS with 2 inputs.
slifis_plot::PLOT_RB_2D::PLOT_RB_2D | ( | const slifis::RULE_BASE & | rule_base, |
int | w = 400 , |
||
int | h = 300 |
||
) |
Constructor.
References __IN__, __OUT__, _head_height, _head_width, slifis_plot::PLOT::_margins, slifis::RULE_BASE::GetRbtable(), slifis_plot::PLOT_MARGINS::m_vt, p_rbt, slifis_plot::PLOT_RB::rb, and Unselect().
slifis_plot::PLOT_RB_2D::PLOT_RB_2D | ( | const PLOT_RB_2D & | ) | [private] |
bool slifis_plot::PLOT_RB_2D::Draw | ( | ) | [virtual] |
Implementation of virtual method of PLOT.
Implements slifis_plot::PLOT_RB.
References __IN__, __OUT__, slifis_plot::PLOT_RB::_grid, _head_height, _head_width, slifis_plot::PLOT::_margins, _NbFunc_col, _NbFunc_row, _Sel_col, _Sel_row, col_selected_box, col_selected_txt, slifis::RB_TABLE::Compute(), slifis_plot::GRID::DrawGrid(), slifis_plot::GRID_CELL::Fill(), fin_col, fin_row, slifis_plot::GRID_CELL::GC_DrawText(), slifis_plot::GRID::GetCell(), slifis::RB_TABLE::GetFuzzySet_col(), slifis::RB_TABLE::GetFuzzySet_row(), slifis_plot::PLOT::GetH(), slifis::FUZZY_ROOT::GetMf(), slifis::MEMBFUNC::GetName(), slifis::RULE_BASE::GetNbInputs(), slifis::FUZZY_ROOT::GetNbMf(), slifis_plot::PLOT::GetW(), slifis::RB_TABLE::IsComputed(), slifis_plot::PLOT_MARGINS::m_hl, slifis_plot::PLOT_MARGINS::m_hr, slifis_plot::PLOT_MARGINS::m_vb, slifis_plot::PLOT_MARGINS::m_vt, MIN_CELL_SIZE, P_DrawFiringStrength(), P_DrawIndexes(), slifis_plot::PLOT::P_InitDraw(), p_rbt, slifis_plot::PLOT_RB::rb, slifis_plot::PLOT_RB::Resize(), slifis_plot::GRID::SetColumnWidth(), slifis_plot::GRID::SetRowHeight(), slifis_plot::GRID::SetSize(), SLIFIS_DEBUG_LOG, SLIFIS_WARNING, SLIFIS_WARNING_1, slifis_plot::TEXT_POS_HC, slifis_plot::TEXT_POS_HR, slifis_plot::TEXT_POS_VB, and slifis_plot::TEXT_POS_VC.
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] |
Implements slifis_plot::PLOT_RB.
References slifis_plot::PLOT::_HasWndName, and slifis_plot::PLOT::_wndname.
bool slifis_plot::PLOT_RB_2D::BoxIsSelected | ( | ) | const [inline] |
void slifis_plot::PLOT_RB_2D::Unselect | ( | ) | [inline] |
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().
void slifis_plot::PLOT_RB_2D::P_DrawFiringStrength | ( | ) | [private] |
Colors background of a line/column in the rule table showing how the input values "fires" a rule.
References __IN__, __OUT__, slifis_plot::PLOT_DATA::_col_backgnd, slifis_plot::PLOT_RB::_grid, _NbFunc_col, _NbFunc_row, slifis_plot::PLOT::_txtbuf, col_txt_fs, slifis_plot::GRID_CELL::Fill(), fin_col, fin_row, slifis_plot::GAPI_BuildColor(), slifis_plot::GRID_CELL::GC_DrawText(), slifis_plot::GRID::GetCell(), GetFiringStrengthVector, slifis::RULE_BASE::GetNbInputs(), slifis_plot::plot_data(), slifis_plot::PLOT_RB::rb, slifis_plot::TEXT_POS_HL, slifis_plot::TEXT_POS_HR, slifis_plot::TEXT_POS_VC, and slifis_plot::TEXT_POS_VT.
Referenced by Draw().
void slifis_plot::PLOT_RB_2D::P_DrawIndexes | ( | ) | [private] |
Print indexes of inputs in line/column headers, and outputs indexes in cells.
References __IN__, __OUT__, slifis_plot::PLOT_DATA::_font, slifis_plot::PLOT_RB::_grid, slifis_plot::PLOT::_margins, _NbFunc_col, _NbFunc_row, slifis_plot::PLOT::_p_img, slifis_plot::PLOT::_txtbuf, col_txt_header_col, col_txt_header_row, col_txt_idx_out, col_txt_idx_rule, slifis_plot::PLOT::DrawText(), slifis_plot::EN_TXT_HORIZ, slifis_plot::EN_TXT_VERT, fin_col, fin_row, slifis_plot::GAPI_GetTextSize(), slifis_plot::GRID_CELL::GC_DrawText(), slifis_plot::GRID::GetCell(), slifis_plot::PLOT::GetH(), slifis::FUZZY_ROOT::GetMf(), slifis::FUZZY_ROOT::GetName(), slifis::MEMBFUNC::GetName(), slifis::RULE_BASE::GetNbInputs(), slifis::RULE_BASE::GetNbRules(), slifis::RB_TABLE::GetOutputIndexString(), slifis::RB_TABLE::GetRuleIndexString(), slifis_plot::PLOT::GetW(), slifis::RB_TABLE::HasSomethingHere(), slifis_plot::PLOT_MARGINS::m_vt, p_rbt, slifis_plot::plot_data(), slifis_plot::PLOT_RB::rb, slifis_plot::TEXT_POS_HC, slifis_plot::TEXT_POS_HL, slifis_plot::TEXT_POS_HR, slifis_plot::TEXT_POS_VB, slifis_plot::TEXT_POS_VC, and slifis_plot::TEXT_POS_VT.
Referenced by Draw().
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().
slifis::RB_TABLE* slifis_plot::PLOT_RB_2D::p_rbt [private] |
Pointer initialised by constructor.
Referenced by Draw(), P_DrawIndexes(), and PLOT_RB_2D().
const slifis::FUZZY_IN* slifis_plot::PLOT_RB_2D::fin_row [private] |
Pointer on input set associated to rows, see Draw()
Referenced by Draw(), P_DrawFiringStrength(), and P_DrawIndexes().
const slifis::FUZZY_IN* slifis_plot::PLOT_RB_2D::fin_col [private] |
Pointer on input set associated to columns, see Draw()
Referenced by Draw(), P_DrawFiringStrength(), and P_DrawIndexes().
size_t slifis_plot::PLOT_RB_2D::_NbFunc_row [private] |
Referenced by Draw(), P_DrawFiringStrength(), P_DrawIndexes(), and SelectBox().
size_t slifis_plot::PLOT_RB_2D::_NbFunc_col [private] |
Referenced by Draw(), P_DrawFiringStrength(), P_DrawIndexes(), and SelectBox().
int slifis_plot::PLOT_RB_2D::_head_width [private] |
Referenced by Draw(), and PLOT_RB_2D().
int slifis_plot::PLOT_RB_2D::_head_height [private] |
Referenced by Draw(), and PLOT_RB_2D().
int slifis_plot::PLOT_RB_2D::cell_w [private] |
width of a column (including line between cells)
int slifis_plot::PLOT_RB_2D::cell_h [private] |
height of a row (including line between cells)
int slifis_plot::PLOT_RB_2D::_Sel_col [private] |
column index of selected box, -1 if none
Referenced by BoxIsSelected(), Draw(), GetSelected(), SelectBox(), and Unselect().
int slifis_plot::PLOT_RB_2D::_Sel_row [private] |
column row of selected box, -1 if none
Referenced by Draw(), GetSelected(), SelectBox(), and Unselect().
GAPI_COLOR slifis_plot::PLOT_RB_2D::col_selected_box = GAPI_BuildColor( 200, 250, 250 ) [static, private] |
color of selected box
Referenced by Draw().
GAPI_COLOR slifis_plot::PLOT_RB_2D::col_selected_txt = GAPI_BuildColor( 0, 50, 50 ) [static, private] |
color of text in selected column/line header
Referenced by Draw().
GAPI_COLOR slifis_plot::PLOT_RB_2D::col_txt_header_row = GAPI_BuildColor( 50, 50, 200 ) [static, private] |
color of text in header (rows)
Referenced by P_DrawIndexes().
GAPI_COLOR slifis_plot::PLOT_RB_2D::col_txt_header_col = GAPI_BuildColor( 50, 200, 50 ) [static, private] |
color of text in header (cols)
Referenced by P_DrawIndexes().
GAPI_COLOR slifis_plot::PLOT_RB_2D::col_txt_idx_out = GAPI_BuildColor( 50, 50, 100 ) [static, private] |
color of index of the output mf, in cell
Referenced by P_DrawIndexes().
GAPI_COLOR slifis_plot::PLOT_RB_2D::col_txt_idx_rule = GAPI_BuildColor( 150, 50, 50 ) [static, private] |
color of rule index, in cell
Referenced by P_DrawIndexes().
GAPI_COLOR slifis_plot::PLOT_RB_2D::col_txt_fs = GAPI_BuildColor( 250, 10, 20 ) [static, private] |
color of firing strength text }
Referenced by P_DrawFiringStrength().