ofxOui - UI Components for OpenFrameworks

ofxOuiWaveform.hpp
Go to the documentation of this file.
1 /*
2  * ofxOuiWaveform.hpp
3  *
4  * Breakpoint function component
5  *
6  * This code has been authored by Jules Francoise <jfrancoi@sfu.ca>
7  * during his postdoc contract at Simon Fraser University (MovingStories
8  * project).
9  * See:
10  * http://julesfrancoise.com/
11  * http://movingstories.ca/
12  *
13  * Copyright (C) 2016 Jules Francoise.
14  *
15  * This Source Code Form is subject to the terms of the Mozilla Public
16  * License, v. 2.0. If a copy of the MPL was not distributed with this
17  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
18  */
19 
20 #ifndef ofxOuiWaveform_hpp
21 #define ofxOuiWaveform_hpp
22 
23 #include "ofxOuiComponent.hpp"
24 #include "ofxOuiGraph.hpp"
25 
26 namespace ofxOui {
27 
35 class Waveform : public Component {
36  public:
40  enum class Layout {
44  Superposed,
45 
50  };
51 
55  enum class Appearance {
59  Lines,
60 
64  FillBottom,
65 
69  FillTop,
70 
74  FillZero
75  };
76 
80  class EditEvent : public ofEventArgs {
81  public:
87  EditEvent(int frame_index_, vector<float> const &values_);
88 
93 
97  vector<float> values;
98  };
99 
107  Waveform(int x_ = 0, int y_ = 0, int width_ = 0, int height_ = 0);
108 
112  virtual ~Waveform();
113 
122  template <typename T, typename args, class ListenerClass>
123  void onEditPoint(T *owner, void (ListenerClass::*listenerMethod)(args)) {
124  using namespace std::placeholders;
125  if (owner)
126  callback_ = std::bind(listenerMethod, owner, _1);
127  else
128  callback_ = nullptr;
129  }
130 
134  virtual void update();
135 
139  void clipBounds();
140 
144  float *values;
145 
149  int size;
150 
155 
159  map<int, ofColor> channels_colors;
160 
164  shared_ptr<Graph> graph;
165 
170 
171  protected:
172  virtual void drawLabel();
173  std::function<void(Waveform::EditEvent &)> callback_;
174 };
175 }
176 
177 #endif
float * values
Vector of x/y values of the Waveform.
Definition: ofxOuiWaveform.hpp:144
shared_ptr< Graph > graph
2D Graph area
Definition: ofxOuiWaveform.hpp:164
virtual ~Waveform()
Destructor.
Definition: ofxOuiWaveform.cpp:30
Appearance
Appearance of the Waveform display.
Definition: ofxOuiWaveform.hpp:55
Appearance of the Waveform display.
Waveform(int x_=0, int y_=0, int width_=0, int height_=0)
Constructor.
Definition: ofxOuiWaveform.cpp:22
virtual void drawLabel()
Definition: ofxOuiWaveform.cpp:45
Base UI Component (equivalent to a label)
Definition: ofxOuiComponent.hpp:33
map< int, ofColor > channels_colors
Data channels to display and Associated colors.
Definition: ofxOuiWaveform.hpp:159
virtual void update()
OF-like update function.
Definition: ofxOuiWaveform.cpp:32
void onEditPoint(T *owner, void(ListenerClass::*listenerMethod)(args))
Set callback function for editing events.
Definition: ofxOuiWaveform.hpp:123
Breakpoint function component.
Definition: ofxOuiWaveform.hpp:35
int frame_index
Index of the edited frame.
Definition: ofxOuiWaveform.hpp:92
Layout
Layout of the different channels.
Definition: ofxOuiWaveform.hpp:40
void clipBounds()
Set the bounds to the min/max of the values.
Definition: ofxOuiWaveform.cpp:40
Definition: ofxOuiColormap.hpp:25
Event arguments when a frame is edited.
Definition: ofxOuiWaveform.hpp:80
int dimension
Dimension of the data (number of channels)
Definition: ofxOuiWaveform.hpp:154
Appearance appearance
Appearance of the Waveform display.
Definition: ofxOuiWaveform.hpp:169
vector< float > values
Edited values.
Definition: ofxOuiWaveform.hpp:97
std::function< void(Waveform::EditEvent &)> callback_
Definition: ofxOuiWaveform.hpp:173
Appearance of the Waveform display.
int size
Size of the data (number of frames)
Definition: ofxOuiWaveform.hpp:149