A fuzzy logic C++ library
|
Pure virtual class, root for all kinds of plots. More...
#include <plot.hpp>
Public Member Functions | |
virtual | ~PLOT () |
Destructor, deallocates the image. | |
GAPI_IMAGE * | GetPlotImage () |
Returns the plot, and draws it if needed. | |
bool | Save (const std::string &filename) |
Save the plot into a file filename , full path is build. | |
size_t | GetW () const |
size_t | GetH () const |
void | DrawText (std::string txt, int x, int y, GAPI_COLOR, EN_TEXT_ORIENTATION=EN_TXT_HORIZ) |
Draws a text on the plot. | |
void | AssignWindow (std::string wndname) |
virtual std::string | GetPlotName () const =0 |
virtual void | Set_ShowPointValues (bool v) |
This function is empty and is there only to provide a default implementation of the virtual function, see re-implementations. | |
virtual void | Set_NbDec (int v) |
This function is empty and is there only to provide a default implementation of the virtual function, see re-implementations. | |
virtual void | Set_ThickLine (bool v) |
This function is empty and is there only to provide a default implementation of the virtual function, see re-implementations. | |
virtual bool | Draw ()=0 |
Returns a bool, because in some situations, we will not be able to draw the plot (returns false). | |
void | Show () |
Static Public Member Functions | |
static functions, related to the whole collection of plots | |
static void | SetAll_ShowPointValues (bool v) |
static function, calls Set_ShowPointValues() on all existing plots | |
static void | SetAll_NbDec (int v) |
static function, calls Set_NbDec() on all plots | |
static void | SetAll_ThickLine (bool v) |
static function, calls Set_ThickLine() on all plots | |
static size_t | GetNbPlots () |
static bool | SaveAll () |
Saves all plots in the set of plots, in the current folder. | |
static void | PrintPlots (FILE *f, const char *msg=0) |
Static function. | |
static void | SetRootFolder (std::string p) |
Protected Member Functions | |
PLOT (int w, int h) | |
Constructor with default values. | |
PLOT (const PLOT &) | |
void | P_InitDraw () |
Init of plot (draws background). Used by all types of plot. | |
int | P_GetTextWidth (const std::string &s) |
Helper function, returns width in pixel of a given text. | |
void | P_ChangeSize (int w, int h) |
Changes size of plot. | |
Protected Attributes | |
GAPI_IMAGE * | _p_img |
The image where the plot is drawn. | |
char | _txtbuf [64] |
Just a buffer used for string printing. | |
PLOT_MARGINS | _margins |
margins. These may not be the same in the inherited classes, although default values are provided | |
bool | _HasWndName |
std::string | _wndname |
Static Protected Attributes | |
static int | s_LineWidth = 1 |
default value for line width | |
Private Attributes | |
bool | _DrawOK |
Pure virtual class, root for all kinds of plots.
slifis_plot::PLOT::~PLOT | ( | ) | [virtual] |
Destructor, deallocates the image.
References __IN__, __OUT__, slifis_plot::PLOT_DATA::_collection, _p_img, slifis_plot::PLOT_COLLECTION::DeletePlot(), slifis_plot::GAPI_ReleaseImage(), and slifis_plot::plot_data().
slifis_plot::PLOT::PLOT | ( | int | w, |
int | h | ||
) | [protected] |
Constructor with default values.
Some day, maybe move the font init to GAPI_Init()...
References __IN__, __OUT__, slifis_plot::PLOT_DATA::_collection, _DrawOK, slifis_plot::PLOT_DATA::_font, _HasWndName, _p_img, slifis_plot::PLOT_COLLECTION::AddPlot(), slifis_plot::GAPI_CreateImage(), slifis_plot::GAPI_InitFont(), and slifis_plot::plot_data().
slifis_plot::PLOT::PLOT | ( | const PLOT & | ) | [protected] |
bool slifis_plot::PLOT::Save | ( | const std::string & | filename | ) |
Save the plot into a file filename
, full path is build.
References __IN__, __OUT__, _DrawOK, _p_img, slifis_plot::PLOT_DATA::_RootSaveFolder, slifis_plot::GAPI_SaveImage(), slifis_plot::plot_data(), SLIFIS_WARNING, and SLIFIS_WARNING_1.
Referenced by main(), and SavePlot().
size_t slifis_plot::PLOT::GetW | ( | ) | const [inline] |
References _p_img, and slifis_plot::GAPI_GetImageW().
Referenced by slifis_plot::PLOT_RB_2D::Draw(), slifis_plot::PLOT_FUZZY::Draw(), slifis_plot::PLOT_RB::GetIndexCoordinates(), slifis_plot::PLOT_FUZZY::P_ComputeMargins(), slifis_plot::PLOT_FUZZY::P_DrawAxis(), slifis_plot::PLOT_RB_2D::P_DrawIndexes(), and P_InitDraw().
size_t slifis_plot::PLOT::GetH | ( | ) | const [inline] |
void slifis_plot::PLOT::DrawText | ( | std::string | txt, |
int | x, | ||
int | y, | ||
GAPI_COLOR | col, | ||
EN_TEXT_ORIENTATION | txt_or = EN_TXT_HORIZ |
||
) |
Draws a text on the plot.
Fetches the font and calls GAPI_DrawText()
References _p_img, slifis_plot::GAPI_BuildPoint(), slifis_plot::GAPI_DrawText(), and slifis_plot::plot_data().
Referenced by slifis_plot::PLOT_RB_2D::P_DrawIndexes().
void slifis_plot::PLOT::AssignWindow | ( | std::string | wndname | ) |
References _HasWndName, and _wndname.
virtual std::string slifis_plot::PLOT::GetPlotName | ( | ) | const [pure virtual] |
Implemented in slifis_plot::PLOT_RB_TEXT, slifis_plot::PLOT_FUZZY, slifis_plot::PLOT_MF, slifis_plot::PLOT_RB_2D, slifis_plot::PLOT_FS, and slifis_plot::PLOT_RB.
Referenced by PrintPlots(), and Show().
void slifis_plot::PLOT::SetAll_ShowPointValues | ( | bool | v | ) | [static] |
static function, calls Set_ShowPointValues() on all existing plots
References slifis_plot::PLOT_DATA::_collection, slifis_plot::PLOT_COLLECTION::_vPlots, GetNbPlots(), and slifis_plot::plot_data().
void slifis_plot::PLOT::SetAll_NbDec | ( | int | v | ) | [static] |
static function, calls Set_NbDec() on all plots
References slifis_plot::PLOT_DATA::_collection, slifis_plot::PLOT_COLLECTION::_vPlots, GetNbPlots(), and slifis_plot::plot_data().
void slifis_plot::PLOT::SetAll_ThickLine | ( | bool | v | ) | [static] |
static function, calls Set_ThickLine() on all plots
Plots created after calling this functions will also be affected, unless a specific call of their Set_ThickLine() function is done.
References slifis_plot::PLOT_DATA::_collection, slifis_plot::PLOT_COLLECTION::_vPlots, GetNbPlots(), slifis_plot::plot_data(), and s_LineWidth.
size_t slifis_plot::PLOT::GetNbPlots | ( | ) | [static] |
References slifis_plot::PLOT_DATA::_collection, slifis_plot::PLOT_COLLECTION::GetNb(), and slifis_plot::plot_data().
Referenced by PrintPlots(), SaveAll(), SetAll_NbDec(), SetAll_ShowPointValues(), and SetAll_ThickLine().
bool slifis_plot::PLOT::SaveAll | ( | ) | [static] |
Saves all plots in the set of plots, in the current folder.
File name will be of the form:
saved_XXXX.png
with 'XXXX' either:
References slifis_plot::PLOT_DATA::_collection, slifis_plot::PLOT_COLLECTION::_vPlots, GetNbPlots(), and slifis_plot::plot_data().
void slifis_plot::PLOT::PrintPlots | ( | FILE * | f, |
const char * | msg = 0 |
||
) | [static] |
Static function.
References slifis_plot::PLOT_DATA::_collection, _p_img, slifis_plot::PLOT_COLLECTION::_vPlots, GetNbPlots(), GetPlotName(), and slifis_plot::plot_data().
void slifis_plot::PLOT::SetRootFolder | ( | std::string | p | ) | [static] |
References slifis_plot::PLOT_DATA::_RootSaveFolder, and slifis_plot::plot_data().
void slifis_plot::PLOT::Set_ShowPointValues | ( | bool | v | ) | [virtual] |
This function is empty and is there only to provide a default implementation of the virtual function, see re-implementations.
Reimplemented in slifis_plot::PLOT_FUZZY.
void slifis_plot::PLOT::Set_NbDec | ( | int | v | ) | [virtual] |
This function is empty and is there only to provide a default implementation of the virtual function, see re-implementations.
Reimplemented in slifis_plot::PLOT_FUZZY.
void slifis_plot::PLOT::Set_ThickLine | ( | bool | v | ) | [virtual] |
This function is empty and is there only to provide a default implementation of the virtual function, see re-implementations.
Reimplemented in slifis_plot::PLOT_FUZZY.
virtual bool slifis_plot::PLOT::Draw | ( | ) | [pure virtual] |
Returns a bool, because in some situations, we will not be able to draw the plot (returns false).
Implemented in slifis_plot::PLOT_RB_TEXT, slifis_plot::PLOT_FUZZY, slifis_plot::PLOT_RB_2D, and slifis_plot::PLOT_RB.
Referenced by GetPlotImage().
void slifis_plot::PLOT::Show | ( | ) |
References _HasWndName, _wndname, slifis_plot::GAPI_ShowImage(), GetPlotImage(), GetPlotName(), SLIFIS_ERROR_LOG, and SLIFIS_WARNING.
void slifis_plot::PLOT::P_InitDraw | ( | ) | [protected] |
Init of plot (draws background). Used by all types of plot.
References __IN__, __OUT__, _DrawOK, _p_img, slifis_plot::GAPI_DrawRectangle(), slifis_plot::GAPI_FillImage(), GetH(), GetW(), and slifis_plot::plot_data().
Referenced by slifis_plot::PLOT_RB_2D::Draw(), slifis_plot::PLOT_FUZZY::Draw(), and slifis_plot::PLOT_RB_TEXT::Draw().
int slifis_plot::PLOT::P_GetTextWidth | ( | const std::string & | s | ) | [protected] |
Helper function, returns width in pixel of a given text.
References _p_img, slifis_plot::GAPI_GetTextSize(), and slifis_plot::plot_data().
Referenced by slifis_plot::PLOT_RB_TEXT::p_ComputePlotSize(), and slifis_plot::PLOT_FS::P_DrawPlot().
void slifis_plot::PLOT::P_ChangeSize | ( | int | w, |
int | h | ||
) | [protected] |
Changes size of plot.
References __IN__, __OUT__, _DrawOK, _p_img, slifis_plot::GAPI_CreateImage(), slifis_plot::GAPI_FillImage(), slifis_plot::GAPI_ReleaseImage(), and slifis_plot::plot_data().
Referenced by slifis_plot::PLOT_RB::Resize(), and slifis_plot::PLOT_FUZZY::Resize().
GAPI_IMAGE* slifis_plot::PLOT::_p_img [protected] |
The image where the plot is drawn.
Referenced by slifis_plot::PLOT_FUZZY::Draw(), slifis_plot::PLOT_RB_TEXT::Draw(), slifis_plot::PLOT_FUZZY::DrawPoint(), DrawText(), GetH(), GetPlotImage(), GetW(), P_ChangeSize(), slifis_plot::PLOT_FUZZY::P_DrawAxis(), slifis_plot::PLOT_RB_2D::P_DrawIndexes(), slifis_plot::PLOT_FUZZY::P_DrawMembFunc(), slifis_plot::PLOT_FS::P_DrawPlot(), slifis_plot::PLOT_MF::P_DrawPlot(), slifis_plot::PLOT_FUZZY::P_DrawVLine2Point(), P_GetTextWidth(), P_InitDraw(), PLOT(), slifis_plot::PLOT_RB::PLOT_RB(), PrintPlots(), Save(), and ~PLOT().
char slifis_plot::PLOT::_txtbuf[64] [protected] |
Just a buffer used for string printing.
Referenced by slifis_plot::PLOT_RB_TEXT::Draw(), slifis_plot::PLOT_FUZZY::DrawPoint(), slifis_plot::PLOT_RB_2D::P_DrawFiringStrength(), slifis_plot::PLOT_RB_2D::P_DrawIndexes(), slifis_plot::PLOT_FUZZY::P_DrawMembFunc(), slifis_plot::PLOT_MF::P_DrawPlot(), and slifis_plot::PLOT_FUZZY::P_GetXLabel().
PLOT_MARGINS slifis_plot::PLOT::_margins [protected] |
margins. These may not be the same in the inherited classes, although default values are provided
Referenced by slifis_plot::PLOT_RB_2D::Draw(), slifis_plot::PLOT_FUZZY::DrawPoint(), slifis_plot::PLOT_RB::GetIndexCoordinates(), slifis_plot::PLOT_FUZZY::P_ComputeMargins(), slifis_plot::PLOT_RB_TEXT::p_ComputePlotSize(), slifis_plot::PLOT_FUZZY::P_DrawAxis(), slifis_plot::PLOT_RB_2D::P_DrawIndexes(), slifis_plot::PLOT_FUZZY::P_DrawMembFunc(), slifis_plot::PLOT_FS::P_DrawPlot(), slifis_plot::PLOT_FUZZY::PLOT_FUZZY(), slifis_plot::PLOT_RB::PLOT_RB(), and slifis_plot::PLOT_RB_2D::PLOT_RB_2D().
bool slifis_plot::PLOT::_HasWndName [protected] |
std::string slifis_plot::PLOT::_wndname [protected] |
int slifis_plot::PLOT::s_LineWidth = 1 [static, protected] |
default value for line width
Referenced by slifis_plot::PLOT_FUZZY::PLOT_FUZZY(), and SetAll_ThickLine().
bool slifis_plot::PLOT::_DrawOK [private] |
Referenced by GetPlotImage(), P_ChangeSize(), P_InitDraw(), PLOT(), and Save().