set_plot.c 1.45 KB
Newer Older
1
2
3
#ifndef HAVE_M_PI
#define HAVE_M_PI // avoid redefinition of M_PI when including SDL
#endif // !HAVE_M_PI
4
5
6
7
8

#include "set_plot.h"
#include "auto_plot.h"

static AutoPlot *auto_plot; // static AutoPlot structure with all the current user plots information
9
int flag_plot = 0; //!< 1 if init_set_plot was called, 0 otherwise
10

11
12
13
14
15
16
17
18
19
/*! \brief reset the flag_plot to 0. Useful when running
 *         several simulation in a row with different save2file
 *         settings.
 */
void reset_flag_plot()
{
    flag_plot = 0;
}

20

21
/*! \brief initialize the static auto_plot structure
22
 *
23
24
 * \param[in,out] screen_sdl SDL gestion main structure
 */
25
26

#ifdef SDL
27
28
29
30
31
32
33
34
void init_set_plot(Screen_sdl *screen_sdl)
{
    flag_plot = 1;

    auto_plot = init_auto_plot(screen_sdl->max_nb_curves);

    screen_sdl->auto_plot = auto_plot;
}
35
36
37
38
39
40
41
42
43
44
45
#else
void init_set_plot(Realtime_extern *realtime_ext, int max_nb_curves)
{
    flag_plot = 1;

    auto_plot = init_auto_plot(max_nb_curves);

    realtime_ext->auto_plot = auto_plot;

}
#endif
46
47
48
49
50
51
52
53

/*! \brief release memory of auto_plot
 */
void free_set_plot()
{
    if (flag_plot)
    {
        free_auto_plot(auto_plot);
54
    }
55
56
57
}

/*! \brief function called by the user to plot a curve
58
 *
59
60
61
 * \param[in] value current value of the curve
 * \param[in] label label of the curve
 */
Timothee Habra's avatar
Timothee Habra committed
62
void set_plot(double value, char* label)
63
64
65
66
67
68
{
    if (flag_plot)
    {
        update_auto_plot(auto_plot, value, label);
    }
}