[go: up one dir, main page]

Menu

[0a098c]: / gui / ParamSlider.h  Maximize  Restore  History

Download this file

132 lines (111 with data), 3.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef __ParamSlider_h__
#define __ParamSlider_h__
#include <string>
#include <map>
#include <DAQ++/DAQid.h>
#include <gtk/gtk.h>
#include <gui/SpinSlider.h>
/**
* This class binds a Module parameter with a GtkAdjustment which can
* come from a GtkScale, a GtkSpinButton, etc. Changes in the adjustment
* will be sent to the Module parameter.
*
* The class mantains a static list of existing mappings.
*/
class ParamSlider
{
public:
/**
* This is a dictionary to associate parameters to
* GtkAdjustments
*/
typedef std::map<std::string, ParamSlider *> SliderList;
private:
GtkAdjustment *adj;
DAQpp::DAQid _id;
std::string par_name;
int cb_id;
void init();
/**
* This is the function in charge of forwarding the change in the
* GtkAdjustment value to the corresponding Parameter
*/
static void change_value(GtkAdjustment *w, ParamSlider *ptr);
/*
* This static dictionary that will keep the association between
* DAQ++ parameters and GtkAdjustments
*/
static SliderList vlist;
public:
/**
* \brief constructor
* @param id the DAQid of the module
* @param p the name of the module parameter
* @param w the GtkAdjustment
*/
ParamSlider(const DAQpp::DAQid &id, const std::string &p, GtkAdjustment *w) :
adj(w), _id(id), par_name(p), cb_id(-1)
{
init();
}
~ParamSlider()
{
}
// Returns the parameter id
const DAQpp::DAQid &get_id() const
{
return _id;
}
// Returns the parameter name
const std::string &get_par_name() const
{
return par_name;
}
/**
* Sets a new value.
* It will also emit the corresponding GLib signal
*/
void set_value(double x)
{
gtk_adjustment_set_value(adj, x);
}
/**
* Sets a new value. No GLib signal will be emitted
*/
void set_value_silent(double x)
{
g_signal_handler_block(adj, cb_id);
gtk_adjustment_set_value(adj, x);
g_signal_handler_unblock(adj, cb_id);
}
/**
* Returns the value of the GtkAdjustment
*/
double get_value() const
{
return gtk_adjustment_get_value(adj);
}
/**
* Deletes all the ParamSlider objects
*/
static void delete_all();
/**
* A ParamSlider Factory that creates the adequate link
* between the adjustment and the given adjustment
* @param id the DAQid of the module
* @param p the name of the module parameter
* @param o the GtkAdjustment
*/
static ParamSlider *new_slider(const DAQpp::DAQid &id,
const std::string &p,
GtkAdjustment *o);
/**
* Finds the corresponding ParamSlider associated with this name
*/
static ParamSlider *find(const std::string &);
/**
* Removes the ParamSlider associated with the given name
*/
static void remove(const std::string &);
};
#endif