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

Plot of a membership function (see slifis::MEMBFUNC) More...

#include <plot_mf.hpp>

+ Inheritance diagram for slifis_plot::PLOT_MF:
+ Collaboration diagram for slifis_plot::PLOT_MF:

List of all members.

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::MEMBFUNCp_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.

Detailed Description

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.


Constructor & Destructor Documentation

No args constructor, builds a plot with default size.

References __IN__, __OUT__, and P_Init().

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]

Member Function Documentation

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.

Referenced by Process(), and Show().

References _MfColor.

Marks the point of index i as selected.

  • if i is negative, unselect any previously selected point
  • if i higher or equal than number of points, does nothing

References _idx_selected, slifis::MEMBFUNC::GetNbPoints(), and p_mf.

References _idx_selected.

std::string slifis_plot::PLOT_MF::GetPlotName ( ) const [virtual]

Returns a string, that can be:

  1. the associated window name, if any, or
  2. the caption of the plot, if any, or
  3. the name of the function.

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]
void slifis_plot::PLOT_MF::P_DrawPlot ( ) [private, virtual]

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().


Member Data Documentation

pointer on corresponding membership function

Referenced by AssignMf(), DrawValue(), GetPlotName(), P_CheckSelection(), P_ComputeScale(), P_DrawPlot(), P_Init(), and SelectPoint().

Color of the function, default is DEF_COLOR_MF.

Referenced by P_DrawPlot(), P_Init(), and SetColor().

Index of selected point, -1 if none.

Referenced by AssignMf(), GetSelectedPoint(), P_CheckSelection(), P_DrawPlot(), P_Init(), and SelectPoint().