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

Pure virtual class, root for all kinds of plots. More...

#include <plot.hpp>

+ Inheritance diagram for slifis_plot::PLOT:
+ Collaboration diagram for slifis_plot::PLOT:

List of all members.

Public Member Functions

virtual ~PLOT ()
 Destructor, deallocates the image.
GAPI_IMAGEGetPlotImage ()
 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

Detailed Description

Pure virtual class, root for all kinds of plots.


Constructor & Destructor Documentation

slifis_plot::PLOT::~PLOT ( ) [virtual]
slifis_plot::PLOT::PLOT ( int  w,
int  h 
) [protected]
slifis_plot::PLOT::PLOT ( const PLOT ) [protected]

Member Function Documentation

Returns the plot, and draws it if needed.

Warning:
This function will draw only if a scale is available (or can be computed). If unable for some reason, it will return 0.

References __IN__, __OUT__, _DrawOK, _p_img, and Draw().

Referenced by DrawDefuzz(), Process(), Show(), and Show().

bool slifis_plot::PLOT::Save ( const std::string &  filename)

Save the plot into a file filename, full path is build.

Low Priority Todo:
Find a way to call automatically the Draw() function if needed

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]
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 
)
void slifis_plot::PLOT::AssignWindow ( std::string  wndname)

References _HasWndName, and _wndname.

Referenced by main(), and Process().

virtual std::string slifis_plot::PLOT::GetPlotName ( ) const [pure virtual]
void slifis_plot::PLOT::SetAll_ShowPointValues ( bool  v) [static]

static function, calls Set_ShowPointValues() on all existing plots

Warning:
Plots created AFTER calling this functions will NOT be affected

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

Warning:
Plots created AFTER calling this functions will NOT be affected

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]
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]
void slifis_plot::PLOT::SetRootFolder ( std::string  p) [static]
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::P_InitDraw ( ) [protected]
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]

Member Data Documentation

char slifis_plot::PLOT::_txtbuf[64] [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().