33 typedef std::function<void(RangeSelectedCallbackArgs)>
35 typedef std::function<void(ValueHighlightedCallbackArgs)>
39 void*
data =
nullptr) {
42 ofAddListener(ofEvents().mousePressed,
this,
44 ofAddListener(ofEvents().mouseDragged,
this,
46 ofAddListener(ofEvents().mouseReleased,
this,
50 template <
typename T1,
typename arg,
class T>
52 void*
data =
nullptr) {
53 using namespace std::placeholders;
58 void*
data =
nullptr) {
65 template <
typename T1,
typename arg,
class T>
67 void*
data =
nullptr) {
68 using namespace std::placeholders;
72 virtual MatrixDouble
getData(uint32_t x_start_idx, uint32_t x_end_idx) = 0;
73 virtual vector<double>
getData(uint32_t x_idx) = 0;
89 return (
x_ <= x && x <=
x_ +
w_ &&
y_ <= y && y <=
y_ +
h_) ?
true 186 bool setup(uint32_t num_dimensions,
string title,
string subtitle =
"");
187 bool setData(
const GRT::MatrixDouble&
data);
189 bool clearContentModifiedFlag();
191 bool push_back(
const vector<double>& data_point);
197 virtual MatrixDouble
getData(uint32_t x_start_idx, uint32_t x_end_idx) {
200 MatrixDouble selected_data;
201 for (uint32_t i = x_start_idx; i < x_end_idx && i < data_.getSize();
203 vector<double> v_double(data_.getRowVector(i).begin(),
204 data_.getRowVector(i).end());
205 selected_data.push_back(v_double);
207 return selected_data;
210 virtual vector<double>
getData(uint32_t x_idx) {
211 return vector<double>(data_.getRowVector(x_idx).begin(),
212 data_.getRowVector(x_idx).end());
215 bool setRanges(
float minY,
float maxY,
bool lockRanges =
false);
216 std::pair<float, float> getRanges();
218 bool setColorPalette(
const vector<ofColor>& colors);
220 bool setTitle(
const string& title);
221 void renameTitleStart();
222 void renameTitleDone();
224 const string& getTitle()
const;
226 bool draw(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
233 background_color_ = color;
246 float x_step =
w_ * 1.0 / data_.getNumRows();
247 return std::min(std::max((uint32_t) 0, (uint32_t)(x / x_step)),
248 data_.getNumRows() - 1);
253 bool is_content_modified_;
254 bool is_in_renaming_;
255 uint32_t num_dimensions_;
256 vector<ofColor> colors_;
260 float minY_, default_minY_;
261 float maxY_, default_maxY_;
262 GRT::MatrixDouble data_;
264 ofColor background_color_ = ofColor(0, 0, 0);
265 ofColor text_color_ = ofColor(0xFF, 0xFF, 0xFF);
266 ofColor grid_color_ = ofColor(0xFF, 0xFF, 0xFF);
272 bool draw(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
277 ofxGrtTimeseriesPlot::draw(x, y, w, h);
281 ofEnableAlphaBlending();
283 ofSetColor(0xFF, 0xFF, 0xFF, 0x7F);
288 ofSetColor(0xFF, 0xFF, 0xFF, 0x2F);
294 virtual MatrixDouble
getData(uint32_t x_start_idx, uint32_t x_end_idx) {
297 MatrixDouble selected_data;
298 for (uint32_t i = x_start_idx;
299 i < x_end_idx && i < dataBuffer.getSize(); i++) {
300 vector<double> v_double(dataBuffer[i].begin(), dataBuffer[i].
end());
301 selected_data.push_back(v_double);
303 return selected_data;
306 virtual vector<double>
getData(uint32_t x_idx) {
307 return vector<double>(dataBuffer[x_idx].begin(),
308 dataBuffer[x_idx].end());
313 float x_step =
w_ * 1.0 / timeseriesLength;
314 return std::min(std::max((uint32_t) 0, (uint32_t)(x / x_step)),
315 timeseriesLength - 1);
virtual uint32_t mouseCoordinateToIndex(uint32_t x)
Definition: plotter.h:312
onValueHighlightedCallback value_highlighted_callback_
Definition: plotter.h:176
void title(const std::string &titlestr)
Definition: matplotlibcpp.h:292
void duringSelection(ofMouseEventArgs &arg)
Definition: plotter.h:115
void * data
Definition: plotter.h:14
void startSelection(ofMouseEventArgs &arg)
Definition: plotter.h:107
Definition: plotter.h:182
uint32_t x_start_
Definition: plotter.h:167
InteractivePlot * source
Definition: plotter.h:24
uint32_t x_end_
Definition: plotter.h:168
uint32_t y_
Definition: plotter.h:153
void onRangeSelected(T1 *owner, void(T::*listenerMethod)(arg), void *data=nullptr)
Definition: plotter.h:51
virtual uint32_t mouseCoordinateToIndex(uint32_t x)
Definition: plotter.h:245
uint32_t w_
Definition: plotter.h:154
bool is_tracking_mouse_
Definition: plotter.h:171
void * value_highlighted_callback_data_
Definition: plotter.h:177
uint32_t start
Definition: plotter.h:12
void clearSelection()
Definition: plotter.h:80
void onValueHighlighted(T1 *owner, void(T::*listenerMethod)(arg), void *data=nullptr)
Definition: plotter.h:66
uint32_t h_
Definition: plotter.h:155
void * data
Definition: plotter.h:20
virtual uint32_t mouseCoordinateToIndex(uint32_t x)=0
virtual MatrixDouble getData(uint32_t x_start_idx, uint32_t x_end_idx)
Definition: plotter.h:294
void * data
Definition: plotter.h:25
void mouseMoved(ofMouseEventArgs &arg)
Definition: plotter.h:93
std::pair< uint32_t, uint32_t > getSelection()
Definition: plotter.h:75
void setTextColor(ofColor color)
Definition: plotter.h:236
uint32_t x_click_
Definition: plotter.h:161
Definition: plotter.h:269
std::function< void(RangeSelectedCallbackArgs)> onRangeSelectedCallback
Definition: plotter.h:34
InteractivePlot * source
Definition: plotter.h:18
bool contains(uint32_t x, uint32_t y)
Definition: plotter.h:88
void onValueHighlighted(const onValueHighlightedCallback &cb, void *data=nullptr)
Definition: plotter.h:57
void endSelection(ofMouseEventArgs &arg)
Definition: plotter.h:130
std::function< void(ValueHighlightedCallbackArgs)> onValueHighlightedCallback
Definition: plotter.h:36
void setGridColor(ofColor color)
Definition: plotter.h:240
bool draw(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
Definition: plotter.h:272
void onRangeSelected(const onRangeSelectedCallback &cb, void *data=nullptr)
Definition: plotter.h:38
virtual vector< double > getData(uint32_t x_idx)
Definition: plotter.h:306
void * range_selected_callback_data_
Definition: plotter.h:174
uint32_t end
Definition: plotter.h:13
virtual MatrixDouble getData(uint32_t x_start_idx, uint32_t x_end_idx)=0
void setBackgroundColor(ofColor color)
Definition: plotter.h:232
virtual MatrixDouble getData(uint32_t x_start_idx, uint32_t x_end_idx)
Definition: plotter.h:197
uint32_t x_
Definition: plotter.h:152
uint32_t x_move_
Definition: plotter.h:157
void normalize()
Definition: plotter.h:124
virtual GRT::MatrixDouble & getData()
Definition: plotter.h:193
InteractivePlot * source
Definition: plotter.h:11
InteractivePlot()
Definition: plotter.h:28
uint32_t index
Definition: plotter.h:19
onRangeSelectedCallback range_selected_callback_
Definition: plotter.h:173
uint32_t x_release_
Definition: plotter.h:162
void setup()
Definition: user_accelerometer_gestures.cpp:111
virtual vector< double > getData(uint32_t x_idx)
Definition: plotter.h:210