ofxOui - UI Components for OpenFrameworks

ofxOuiBpf.hpp
Go to the documentation of this file.
1 /*
2  * ofxOuiBpf.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 ofxOuiBpf_hpp
21 #define ofxOuiBpf_hpp
22 
23 #include "ofxOuiComponent.hpp"
24 #include "ofxOuiGraph.hpp"
25 
26 namespace ofxOui {
27 
35 class Bpf : public Component {
36  public:
40  enum class Appearance {
44  Lines,
45 
49  FillBottom,
50 
54  FillTop,
55 
59  FillZero
60  };
61 
65  class EditPointEvent : public ofEventArgs {
66  public:
72  EditPointEvent(float x_, float y_);
73 
77  float x;
78 
82  float y;
83  };
84 
92  Bpf(int x_ = 0, int y_ = 0, int width_ = 0, int height_ = 0);
93 
97  virtual ~Bpf();
98 
107  template <typename T, typename args, class ListenerClass>
108  void onEditPoint(T *owner, void (ListenerClass::*listenerMethod)(args)) {
109  using namespace std::placeholders;
110  if (owner)
111  callback_ = std::bind(listenerMethod, owner, _1);
112  else
113  callback_ = nullptr;
114  }
115 
119  virtual void update();
120 
124  void clipBounds();
125 
129  vector<ofVec2f> values;
130 
135 
140 
144  float point_radius = 8;
145 
146  protected:
147  virtual void drawLabel();
148  virtual void mousePressed(ofMouseEventArgs &e);
149  virtual void mouseDragged(ofMouseEventArgs &e);
150  virtual void mouseReleased(ofMouseEventArgs &e);
151 
154  std::function<void(Bpf::EditPointEvent &)> callback_;
155 };
156 }
157 
158 #endif
vector< ofVec2f > values
Vector of x/y values of the BPF.
Definition: ofxOuiBpf.hpp:129
Graph graph
2D Graph area
Definition: ofxOuiBpf.hpp:134
Appearance appearance
Appearance of the BPF display.
Definition: ofxOuiBpf.hpp:139
Bpf(int x_=0, int y_=0, int width_=0, int height_=0)
Constructor.
Definition: ofxOuiBpf.cpp:22
virtual void mouseDragged(ofMouseEventArgs &e)
Definition: ofxOuiBpf.cpp:151
Display as filled surface to the bottom of the display.
float point_radius
Radius of the node of the BPF.
Definition: ofxOuiBpf.hpp:144
Base UI Component (equivalent to a label)
Definition: ofxOuiComponent.hpp:33
virtual void mousePressed(ofMouseEventArgs &e)
Definition: ofxOuiBpf.cpp:107
virtual void update()
OF-like update function.
Definition: ofxOuiBpf.cpp:42
Appearance
Appearance of the BPF display.
Definition: ofxOuiBpf.hpp:40
Event arguments when a point is edited.
Definition: ofxOuiBpf.hpp:65
int point_selected_
Definition: ofxOuiBpf.hpp:152
void onEditPoint(T *owner, void(ListenerClass::*listenerMethod)(args))
Set callback function for editing events.
Definition: ofxOuiBpf.hpp:108
float time_mouse_pressed_
Definition: ofxOuiBpf.hpp:153
Display as filled surface to the top of the display.
Definition: ofxOuiColormap.hpp:25
void clipBounds()
Set the bounds to the min/max of the values.
Definition: ofxOuiBpf.cpp:50
float x
x value of the point edited
Definition: ofxOuiBpf.hpp:77
virtual void mouseReleased(ofMouseEventArgs &e)
Definition: ofxOuiBpf.cpp:168
Breakpoint function component.
Definition: ofxOuiBpf.hpp:35
Display as filled surface to zero.
virtual void drawLabel()
Definition: ofxOuiBpf.cpp:64
2D Graph Area (with virtual coordinate system)
Definition: ofxOuiGraph.hpp:32
std::function< void(Bpf::EditPointEvent &)> callback_
Definition: ofxOuiBpf.hpp:154
virtual ~Bpf()
Destructor.
Definition: ofxOuiBpf.cpp:33
float y
y value of the point edited
Definition: ofxOuiBpf.hpp:82