A fuzzy logic C++ library
|
Plot of a membership function (see slifis::MEMBFUNC) More...
#include <plot_mf.hpp>
Public Member Functions | |
PLOT_MF () | |
No args constructor, builds a plot with default size. | |
PLOT_MF (const slifis::MEMBFUNC &_mf, int w=400, int h=300) | |
~PLOT_MF () | |
void | AssignMf (const slifis::MEMBFUNC &mf) |
Assigns Membership Function _mf to plot, and deselects any previously selected point. | |
void | DrawValue (slifis::REALVAL x, GAPI_COLOR col=GAPI_BuildColor(0, 255, 0)) |
Draws the value of x and its fuzzified value on membership function. | |
void | SetColor (GAPI_COLOR col) |
void | SelectPoint (int i) |
Marks the point of index i as selected. | |
int | GetSelectedPoint () const |
std::string | GetPlotName () const |
Returns a string, that can be: | |
Private Member Functions | |
PLOT_MF (const PLOT_MF &) | |
bool | P_ComputeScale () |
Computing best horizontal scale. | |
void | P_DrawPlot () |
Draw plot of function on image. | |
void | P_CheckSelection () |
Checks that selection is still valid, if not unselect. | |
void | P_Init () |
Private Attributes | |
const slifis::MEMBFUNC * | p_mf |
pointer on corresponding membership function | |
GAPI_COLOR | _MfColor |
Color of the function, default is DEF_COLOR_MF. | |
int | _idx_selected |
Index of selected point, -1 if none. |
Plot of a membership function (see slifis::MEMBFUNC)
Please note that this class only holds a pointer on the membership function, so any changes to this function will be reported in the plot, assuming you call the DrawPlot() funtion at the right time.
It also holds an index on the currently selected point in the function.
All functions here except AssignMf() will call before doing anything the P_CheckSelection() function, that will ensure that the corresponding MF still "has" the selected point. If a discrepancy is detected, then deselecting is done.
For example, if a point is selected (say, idx_selected
= 1) and the function has not points anymore, then this function will revert idx_selected
to -1.
slifis_plot::PLOT_MF::PLOT_MF | ( | const slifis::MEMBFUNC & | _mf, |
int | w = 400 , |
||
int | h = 300 |
||
) |
References __IN__, __OUT__, AssignMf(), and P_Init().
slifis_plot::PLOT_MF::PLOT_MF | ( | const PLOT_MF & | ) | [private] |
void slifis_plot::PLOT_MF::AssignMf | ( | const slifis::MEMBFUNC & | mf | ) | [inline] |
Assigns Membership Function _mf
to plot, and deselects any previously selected point.
References _idx_selected, and p_mf.
Referenced by PLOT_MF().
void slifis_plot::PLOT_MF::DrawValue | ( | slifis::REALVAL | x, |
GAPI_COLOR | col = GAPI_BuildColor( 0,255,0) |
||
) | [virtual] |
Draws the value of x and its fuzzified value on membership function.
Implements slifis_plot::PLOT_FUZZY.
References __IN__, __OUT__, slifis_plot::PLOT_FUZZY::DrawPoint(), slifis::MEMBFUNC::Fuzzify(), and p_mf.
void slifis_plot::PLOT_MF::SetColor | ( | GAPI_COLOR | col | ) | [inline] |
References _MfColor.
void slifis_plot::PLOT_MF::SelectPoint | ( | int | i | ) |
Marks the point of index i
as selected.
References _idx_selected, slifis::MEMBFUNC::GetNbPoints(), and p_mf.
int slifis_plot::PLOT_MF::GetSelectedPoint | ( | ) | const [inline] |
References _idx_selected.
std::string slifis_plot::PLOT_MF::GetPlotName | ( | ) | const [virtual] |
Returns a string, that can be:
Reimplementation of PLOT::GetPlotName()
Implements slifis_plot::PLOT_FUZZY.
References slifis_plot::PLOT_FUZZY::_caption, slifis_plot::PLOT_FUZZY::_HasCaption, slifis_plot::PLOT::_HasWndName, slifis_plot::PLOT::_wndname, slifis::MEMBFUNC::GetName(), and p_mf.
bool slifis_plot::PLOT_MF::P_ComputeScale | ( | ) | [private, virtual] |
Computing best horizontal scale.
Returns false if unable (i.e. function is empty)
Implements slifis_plot::PLOT_FUZZY.
References __IN__, __OUT__, slifis_plot::PLOT_FUZZY::_hscale, slifis_plot::PLOT_FUZZY::_PreviousScaleAvailable, slifis_plot::PLOT_FUZZY::_x_range, slifis::MEMBFUNC::GetFirstPoint(), slifis::MEMBFUNC::GetLastPoint(), slifis::MEMBFUNC::GetName(), slifis::MEMBFUNC::GetNbPoints(), slifis::FPOINT::GetX(), slifis::MEMBFUNC::IsValid(), P_CheckSelection(), p_mf, slifis_plot::PLOT_HSCALE::scale, SLIFIS_WARNING, SLIFIS_WARNING_1, and slifis_plot::PLOT_HSCALE::x0.
void slifis_plot::PLOT_MF::P_DrawPlot | ( | ) | [private, virtual] |
Draw plot of function on image.
This means (in that order):
Implements slifis_plot::PLOT_FUZZY.
References __IN__, __OUT__, slifis_plot::PLOT_DATA::_font, slifis_plot::PLOT_FUZZY::_hscale, _idx_selected, _MfColor, slifis_plot::PLOT::_p_img, slifis_plot::PLOT::_txtbuf, slifis_plot::PLOT_FUZZY::_x_first, slifis_plot::PLOT_FUZZY::_x_last, slifis_plot::PLOT_FUZZY::col_txt, slifis_plot::PLOT_FUZZY::col_xlabel, slifis_plot::PLOT_FUZZY::col_xtic, DEF_COLOR_MF_SEL_PT, slifis_plot::GAPI_BuildPoint(), slifis_plot::GAPI_DrawCircle(), slifis_plot::GAPI_DrawLine(), slifis_plot::GAPI_DrawText(), slifis::MEMBFUNC::GetName(), slifis::MEMBFUNC::GetNbPoints(), slifis::MEMBFUNC::GetPoint(), slifis::FPOINT::GetX(), slifis::FPOINT::GetY(), slifis::MEMBFUNC::IsEmpty(), slifis::MEMBFUNC::IsValid(), P_CheckSelection(), slifis_plot::PLOT_FUZZY::P_DrawMembFunc(), slifis_plot::PLOT_FUZZY::P_GetRealValue(), slifis_plot::PLOT_FUZZY::P_GetXLabel(), p_mf, slifis_plot::plot_data(), slifis_plot::PLOT_FUZZY::TransformCoordR2S(), slifis_plot::PLOT_HSCALE::x0, slifis_plot::PLOT_FUZZY::y_0, and slifis_plot::PLOT_FUZZY::y_1.
void slifis_plot::PLOT_MF::P_CheckSelection | ( | ) | [private] |
Checks that selection is still valid, if not unselect.
References _idx_selected, slifis::MEMBFUNC::GetNbPoints(), and p_mf.
Referenced by P_ComputeScale(), and P_DrawPlot().
void slifis_plot::PLOT_MF::P_Init | ( | ) | [private] |
References _idx_selected, _MfColor, DEF_COLOR_MF, and p_mf.
Referenced by PLOT_MF().
const slifis::MEMBFUNC* slifis_plot::PLOT_MF::p_mf [private] |
pointer on corresponding membership function
Referenced by AssignMf(), DrawValue(), GetPlotName(), P_CheckSelection(), P_ComputeScale(), P_DrawPlot(), P_Init(), and SelectPoint().
GAPI_COLOR slifis_plot::PLOT_MF::_MfColor [private] |
Color of the function, default is DEF_COLOR_MF.
Referenced by P_DrawPlot(), P_Init(), and SetColor().
int slifis_plot::PLOT_MF::_idx_selected [private] |
Index of selected point, -1 if none.
Referenced by AssignMf(), GetSelectedPoint(), P_CheckSelection(), P_DrawPlot(), P_Init(), and SelectPoint().