A fuzzy logic C++ library
|
A plot of a rule base shown as a table: each rule is shown as a line of text, (table-view) More...
#include <plot_rb_text.hpp>
Public Member Functions | |
PLOT_RB_TEXT (const slifis::RULE_BASE &rule_base) | |
Constructor (size of plot will be adjusted to necessary) | |
~PLOT_RB_TEXT () | |
bool | Draw () |
implementation of virtual method of PLOT | |
const POSITION_INFO & | GetPositionInfo (int x, int y) |
Returns information on the position in the plot, given a pixel position (x, y) in plot. | |
std::string | GetPlotName () const |
Select functions, take information from \c pos_info | |
void | SelectNewRule () |
Selection is a new rule. | |
void | SelectRule () |
Selects a whole row. | |
void | SelectOutput () |
Selects output corresponding to current row/rule (each row of the plot corresponds to a rule) | |
void | SelectInput () |
void | SelectRuleOp () |
void | SelectInputValue () |
EN_SELECTION_TYPE | GetSelectionType () const |
void | Unselect () |
Private Member Functions | |
PLOT_RB_TEXT (const PLOT_RB_TEXT &) | |
void | p_DrawSelection () |
Draws the current selection as background color on the plot. | |
void | P_PrintCell (size_t x_idx, size_t y_idx, std::string msg) const |
Prints txt inside cell (row,col) | |
void | p_ComputePlotSize () |
Computes all the grid attributes, and resizes plot according to these results. | |
Private Attributes | |
int | _line_h |
height of line | |
int | _selected_row |
int | _selected_col |
EN_SELECTION_TYPE | _sel_type |
POSITION_INFO | _pos_info |
holds information on current mouse position | |
Static Private Attributes | |
static GAPI_COLOR | s_ColSelectedRow = GAPI_BuildColor( 160,160, 50) |
A plot of a rule base shown as a table: each rule is shown as a line of text, (table-view)
Nb of columns = 1 (idx) + 1 ("if") + (nb of inputs*4) + 1 ("then") + 3 ("output is something") -1 = (nb of inputs*4) + 5
See Handling rules for an example.
Example for a 2 input FIS:
For example:
... 1 | if | temp | is | high | and | pressure | is | ok | then | output | is | bad 2 | if | temp | is | low | and | pressure | is | high | then | output | is | nice ...
slifis_plot::PLOT_RB_TEXT::PLOT_RB_TEXT | ( | const slifis::RULE_BASE & | rule_base | ) |
Constructor (size of plot will be adjusted to necessary)
References __IN__, __OUT__, _line_h, _sel_type, _selected_col, _selected_row, slifis_plot::NO_SELECTION, and p_ComputePlotSize().
slifis_plot::PLOT_RB_TEXT::PLOT_RB_TEXT | ( | const PLOT_RB_TEXT & | ) | [private] |
bool slifis_plot::PLOT_RB_TEXT::Draw | ( | ) | [virtual] |
implementation of virtual method of PLOT
Implements slifis_plot::PLOT_RB.
References __IN__, __OUT__, slifis_plot::PLOT_DATA::_font, slifis_plot::PLOT_RB::_grid, slifis_plot::PLOT::_p_img, _sel_type, slifis_plot::PLOT::_txtbuf, slifis_plot::GRID::DrawGrid(), slifis_plot::GAPI_BuildColor(), slifis_plot::GAPI_BuildPoint(), slifis_plot::GAPI_DrawText(), slifis::RULE_BASE::GetInputSet(), slifis::FUZZY_ROOT::GetMf(), slifis::FUZZY_ROOT::GetMfName(), slifis::FUZZY_ROOT::GetName(), slifis::MEMBFUNC::GetName(), slifis_plot::GRID::GetNbCols(), slifis::RULE_BASE::GetNbInputs(), slifis::RULE_BASE::GetNbRules(), slifis::RULE_IDX::GetNbTerms(), slifis::ROOT_RULE::GetOpType(), slifis::RULE_IDX::GetOutMfIndex(), slifis::RULE_BASE::GetOutputSet(), slifis::RULE_BASE::GetRule(), slifis::RULE_IDX::GetTerms(), slifis_plot::NO_SELECTION, slifis::OPR_AND, slifis::OPR_OR, p_ComputePlotSize(), p_DrawSelection(), slifis_plot::PLOT::P_InitDraw(), P_PrintCell(), slifis_plot::plot_data(), and slifis_plot::PLOT_RB::rb.
const POSITION_INFO & slifis_plot::PLOT_RB_TEXT::GetPositionInfo | ( | int | x, |
int | y | ||
) |
Returns information on the position in the plot, given a pixel position (x, y) in plot.
References slifis_plot::PLOT_RB::_grid, slifis_plot::POSITION_INFO::_idx_col, slifis_plot::POSITION_INFO::_idx_row, _pos_info, slifis_plot::POSITION_INFO::_pos_type, slifis_plot::POSITION_INFO::_rt_input_idx, slifis_plot::POSITION_INFO::_rt_input_value, slifis_plot::POSITION_INFO::Clear(), slifis_plot::PLOT_RB::GetIndexCoordinates(), slifis_plot::GRID::GetNbCols(), slifis::RULE_BASE::GetNbInputs(), slifis::RULE_BASE::GetNbRules(), slifis::RULE_BASE::GetRule(), slifis::RULE_IDX::GetTerms(), slifis_plot::PLOT_RB::rb, slifis_plot::RBT_POS_INPUT_NAME, slifis_plot::RBT_POS_INPUT_VALUE, slifis_plot::RBT_POS_NEW_ROW, slifis_plot::RBT_POS_OUTPUT_VALUE, slifis_plot::RBT_POS_ROW, slifis_plot::RBT_POS_RULE_OP, and slifis::RULE_IDX::UsesInput().
Referenced by Mouse_CB_rb_text().
std::string slifis_plot::PLOT_RB_TEXT::GetPlotName | ( | ) | const [virtual] |
Implements slifis_plot::PLOT_RB.
References slifis_plot::PLOT::_HasWndName, and slifis_plot::PLOT::_wndname.
Selection is a new rule.
References slifis_plot::POSITION_INFO::_idx_row, _pos_info, _sel_type, _selected_col, _selected_row, and slifis_plot::SELECT_NEW_ROW.
Referenced by Mouse_CB_rb_text().
Selects a whole row.
References slifis_plot::POSITION_INFO::_idx_row, _pos_info, _sel_type, _selected_col, _selected_row, and slifis_plot::SELECT_ROW.
Referenced by Mouse_CB_rb_text().
Selects output corresponding to current row/rule (each row of the plot corresponds to a rule)
References slifis_plot::POSITION_INFO::_idx_row, _pos_info, _sel_type, _selected_col, _selected_row, slifis::RULE_BASE::GetNbRules(), slifis_plot::PLOT_RB::rb, slifis_plot::SELECT_OUTPUT, and SLIFIS_WARNING_1.
Referenced by Mouse_CB_rb_text().
References slifis_plot::POSITION_INFO::_idx_col, slifis_plot::POSITION_INFO::_idx_row, _pos_info, _sel_type, _selected_col, _selected_row, and slifis_plot::SELECT_TERM_INPUT.
Referenced by Mouse_CB_rb_text().
References slifis_plot::POSITION_INFO::_idx_col, slifis_plot::POSITION_INFO::_idx_row, _pos_info, _sel_type, _selected_col, _selected_row, and slifis_plot::SELECT_RULE_OP.
Referenced by Mouse_CB_rb_text().
References slifis_plot::POSITION_INFO::_idx_col, slifis_plot::POSITION_INFO::_idx_row, _pos_info, _sel_type, _selected_col, _selected_row, and slifis_plot::SELECT_TERM_VALUE.
Referenced by Mouse_CB_rb_text().
EN_SELECTION_TYPE slifis_plot::PLOT_RB_TEXT::GetSelectionType | ( | ) | const [inline] |
References _sel_type.
Referenced by Mouse_CB_rb_text().
void slifis_plot::PLOT_RB_TEXT::Unselect | ( | ) | [inline] |
References _sel_type, and slifis_plot::NO_SELECTION.
Referenced by Mouse_CB_rb_2D(), and Mouse_CB_rb_text().
void slifis_plot::PLOT_RB_TEXT::p_DrawSelection | ( | ) | [private] |
Draws the current selection as background color on the plot.
References __IN__, __OUT__, slifis_plot::PLOT_RB::_grid, _sel_type, _selected_col, _selected_row, slifis_plot::GRID_CELL::Fill(), slifis_plot::GRID::GetCell(), slifis_plot::GRID::GetNbCols(), slifis_plot::GRID::GetRow(), s_ColSelectedRow, slifis_plot::SELECT_NEW_ROW, slifis_plot::SELECT_OUTPUT, slifis_plot::SELECT_ROW, slifis_plot::SELECT_RULE_OP, slifis_plot::SELECT_TERM_INPUT, and slifis_plot::SELECT_TERM_VALUE.
Referenced by Draw().
void slifis_plot::PLOT_RB_TEXT::P_PrintCell | ( | size_t | x_idx, |
size_t | y_idx, | ||
std::string | msg | ||
) | const [private] |
Prints txt
inside cell (row,col)
References __IN__, __OUT__, slifis_plot::PLOT_RB::_grid, DEF_COLOR_RBT_CELL_TXT, slifis_plot::GAPI_BuildPoint(), slifis_plot::GAPI_DrawText(), slifis_plot::GRID_CELL::GC_DrawText(), slifis_plot::GRID::GetCell(), slifis_plot::GAPI_POINT::x, and slifis_plot::GAPI_POINT::y.
Referenced by Draw().
void slifis_plot::PLOT_RB_TEXT::p_ComputePlotSize | ( | ) | [private] |
Computes all the grid attributes, and resizes plot according to these results.
Nb of columns = 1 (idx) + (nb of inputs*4) + 1 ("if") + 1 ("then") + 3 ("output is something") -1 = (nb of inputs*4) + 5
References __IN__, __OUT__, slifis_plot::PLOT_RB::_grid, _line_h, slifis_plot::PLOT::_margins, slifis_plot::GRID::GetH(), slifis::RULE_BASE::GetInputSet(), slifis::FUZZY_ROOT::GetMfName(), slifis::FUZZY_ROOT::GetName(), slifis_plot::GRID::GetNbCols(), slifis::RULE_BASE::GetNbInputs(), slifis::FUZZY_ROOT::GetNbMf(), slifis::RULE_BASE::GetNbRules(), slifis::RULE_BASE::GetOutputSet(), slifis_plot::GRID::GetW(), slifis_plot::PLOT_MARGINS::m_hl, slifis_plot::PLOT_MARGINS::m_hr, slifis_plot::PLOT_MARGINS::m_vb, slifis_plot::PLOT_MARGINS::m_vt, slifis_plot::PLOT::P_GetTextWidth(), slifis_plot::PLOT_RB::rb, slifis_plot::PLOT_RB::Resize(), slifis_plot::GRID::SetColumnWidth(), slifis_plot::GRID::SetRowHeight(), and slifis_plot::GRID::SetSize().
Referenced by Draw(), and PLOT_RB_TEXT().
int slifis_plot::PLOT_RB_TEXT::_line_h [private] |
height of line
Referenced by p_ComputePlotSize(), and PLOT_RB_TEXT().
int slifis_plot::PLOT_RB_TEXT::_selected_row [private] |
Referenced by p_DrawSelection(), PLOT_RB_TEXT(), SelectInput(), SelectInputValue(), SelectNewRule(), SelectOutput(), SelectRule(), and SelectRuleOp().
int slifis_plot::PLOT_RB_TEXT::_selected_col [private] |
Referenced by p_DrawSelection(), PLOT_RB_TEXT(), SelectInput(), SelectInputValue(), SelectNewRule(), SelectOutput(), SelectRule(), and SelectRuleOp().
Referenced by Draw(), GetSelectionType(), p_DrawSelection(), PLOT_RB_TEXT(), SelectInput(), SelectInputValue(), SelectNewRule(), SelectOutput(), SelectRule(), SelectRuleOp(), and Unselect().
holds information on current mouse position
Referenced by GetPositionInfo(), SelectInput(), SelectInputValue(), SelectNewRule(), SelectOutput(), SelectRule(), and SelectRuleOp().
GAPI_COLOR slifis_plot::PLOT_RB_TEXT::s_ColSelectedRow = GAPI_BuildColor( 160,160, 50) [static, private] |
Referenced by p_DrawSelection().