mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
draw pucks (signal positions) on vbap panner
git-svn-id: svn://localhost/ardour2/branches/3.0@8890 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
0d61f205ab
commit
96cc6c3410
7 changed files with 40 additions and 27 deletions
|
|
@ -24,10 +24,11 @@
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <gtkmm/menu.h>
|
#include <gtkmm/menu.h>
|
||||||
|
|
||||||
|
#include "gtkmm2ext/gtk_ui.h"
|
||||||
|
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
#include "pbd/cartesian.h"
|
#include "pbd/cartesian.h"
|
||||||
#include "ardour/panner.h"
|
#include "ardour/panner.h"
|
||||||
#include <gtkmm2ext/gtk_ui.h>
|
|
||||||
|
|
||||||
#include "panner2d.h"
|
#include "panner2d.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
@ -94,10 +95,6 @@ Panner2d::reset (uint32_t n_inputs)
|
||||||
pucks.resize (n_inputs);
|
pucks.resize (n_inputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Targets::iterator x = pucks.begin(); x != pucks.end(); ++x) {
|
|
||||||
(*x)->visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (n_inputs) {
|
switch (n_inputs) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
@ -120,12 +117,9 @@ Panner2d::reset (uint32_t n_inputs)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PANNER_HACKS
|
for (uint32_t i = 0; i < n_inputs; ++i) {
|
||||||
for (uint32_t i = existing_pucks; i < n_inputs; ++i) {
|
pucks[i]->position = panner->signal_position (i);
|
||||||
pucks[i]->position = panner->streampanner (i).get_position ();
|
}
|
||||||
pucks[i]->visible = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* add all outputs */
|
/* add all outputs */
|
||||||
|
|
||||||
|
|
@ -165,11 +159,16 @@ Panner2d::on_size_allocate (Gtk::Allocation& alloc)
|
||||||
width = alloc.get_width();
|
width = alloc.get_width();
|
||||||
height = alloc.get_height();
|
height = alloc.get_height();
|
||||||
|
|
||||||
|
/* our idea of our width/height must be "square
|
||||||
|
*/
|
||||||
|
|
||||||
if (height > 100) {
|
if (height > 100) {
|
||||||
width -= 20;
|
width -= 20;
|
||||||
height -= 20;
|
height -= 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dimen = min (width, height);
|
||||||
|
|
||||||
DrawingArea::on_size_allocate (alloc);
|
DrawingArea::on_size_allocate (alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,8 +243,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
|
||||||
which = 0;
|
which = 0;
|
||||||
pwhich = 0;
|
pwhich = 0;
|
||||||
|
|
||||||
cerr << "@ " << x << ", " << y << endl;
|
|
||||||
|
|
||||||
for (Targets::const_iterator i = pucks.begin(); i != pucks.end(); ++i, ++pwhich) {
|
for (Targets::const_iterator i = pucks.begin(); i != pucks.end(); ++i, ++pwhich) {
|
||||||
candidate = *i;
|
candidate = *i;
|
||||||
|
|
||||||
|
|
@ -257,8 +254,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
|
||||||
distance = sqrt ((c.x - x) * (c.x - x) +
|
distance = sqrt ((c.x - x) * (c.x - x) +
|
||||||
(c.y - y) * (c.y - y));
|
(c.y - y) * (c.y - y));
|
||||||
|
|
||||||
cerr << "\tConsider candiate " << candidate->text << " @ " << c.x << ", " << c.y << ", " << c.z << " distance = " << distance << endl;
|
|
||||||
|
|
||||||
if (distance < best_distance) {
|
if (distance < best_distance) {
|
||||||
closest = candidate;
|
closest = candidate;
|
||||||
best_distance = distance;
|
best_distance = distance;
|
||||||
|
|
@ -271,8 +266,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << "the winner is " << closest->text << endl;
|
|
||||||
|
|
||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,7 +323,7 @@ Panner2d::on_expose_event (GdkEventExpose *event)
|
||||||
|
|
||||||
/* the circle on which signals live */
|
/* the circle on which signals live */
|
||||||
|
|
||||||
cairo_arc (cr, width/2, height/2, height/2, 0, 2.0 * M_PI);
|
cairo_arc (cr, width/2, height/2, dimen/2, 0, 2.0 * M_PI);
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
|
|
||||||
if (!panner->bypassed()) {
|
if (!panner->bypassed()) {
|
||||||
|
|
@ -357,7 +350,7 @@ Panner2d::on_expose_event (GdkEventExpose *event)
|
||||||
|
|
||||||
puck->position.cartesian (c);
|
puck->position.cartesian (c);
|
||||||
cart_to_gtk (c);
|
cart_to_gtk (c);
|
||||||
|
|
||||||
x = (gint) floor (c.x);
|
x = (gint) floor (c.x);
|
||||||
y = (gint) floor (c.y);
|
y = (gint) floor (c.y);
|
||||||
|
|
||||||
|
|
@ -561,9 +554,12 @@ Panner2d::cart_to_gtk (CartesianVector& c) const
|
||||||
so max values along each axis are 0,width and
|
so max values along each axis are 0,width and
|
||||||
0,height
|
0,height
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const uint32_t hoffset = (width - dimen)/2;
|
||||||
|
const uint32_t voffset = (height - dimen)/2;
|
||||||
|
|
||||||
c.x = (width / 2) * (c.x + 1);
|
c.x = hoffset + ((dimen / 2) * (c.x + 1));
|
||||||
c.y = (height / 2) * (1 - c.y);
|
c.y = voffset + ((dimen / 2) * (1 - c.y));
|
||||||
|
|
||||||
/* XXX z-axis not handled - 2D for now */
|
/* XXX z-axis not handled - 2D for now */
|
||||||
}
|
}
|
||||||
|
|
@ -571,8 +567,8 @@ Panner2d::cart_to_gtk (CartesianVector& c) const
|
||||||
void
|
void
|
||||||
Panner2d::gtk_to_cart (CartesianVector& c) const
|
Panner2d::gtk_to_cart (CartesianVector& c) const
|
||||||
{
|
{
|
||||||
c.x = (c.x / (width / 2.0)) - 1.0;
|
c.x = ((c.x / (dimen / 2.0)) - 1.0);
|
||||||
c.y = -((c.y / (height / 2.0)) - 1.0);
|
c.y = -((c.y / (dimen / 2.0)) - 1.0);
|
||||||
|
|
||||||
/* XXX z-axis not handled - 2D for now */
|
/* XXX z-axis not handled - 2D for now */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ class Panner2d : public Gtk::DrawingArea
|
||||||
bool allow_target;
|
bool allow_target;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
int dimen;
|
||||||
|
|
||||||
bool bypassflag;
|
bool bypassflag;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,10 @@ class Panner : public PBD::Stateful, public PBD::ScopedConnectionList
|
||||||
virtual double width () const { return 0.0; }
|
virtual double width () const { return 0.0; }
|
||||||
virtual double elevation () const { return 0.0; }
|
virtual double elevation () const { return 0.0; }
|
||||||
|
|
||||||
virtual void reset() {}
|
virtual PBD::AngularVector signal_position (uint32_t) const { return PBD::AngularVector(); }
|
||||||
|
|
||||||
|
virtual void reset() {}
|
||||||
|
|
||||||
virtual bool bypassed() const { return _bypassed; }
|
virtual bool bypassed() const { return _bypassed; }
|
||||||
virtual void set_bypassed (bool yn);
|
virtual void set_bypassed (bool yn);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,3 +331,13 @@ VBAPanner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
|
||||||
return _pannable->value_as_string (ac);
|
return _pannable->value_as_string (ac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AngularVector
|
||||||
|
VBAPanner::signal_position (uint32_t n) const
|
||||||
|
{
|
||||||
|
if (n < _signals.size()) {
|
||||||
|
return _signals[n]->direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AngularVector();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ public:
|
||||||
XMLNode& get_state ();
|
XMLNode& get_state ();
|
||||||
int set_state (const XMLNode&, int version);
|
int set_state (const XMLNode&, int version);
|
||||||
|
|
||||||
|
PBD::AngularVector signal_position (uint32_t n) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Signal {
|
struct Signal {
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ using namespace std;
|
||||||
|
|
||||||
VBAPSpeakers::VBAPSpeakers (boost::shared_ptr<Speakers> s)
|
VBAPSpeakers::VBAPSpeakers (boost::shared_ptr<Speakers> s)
|
||||||
: _dimension (2)
|
: _dimension (2)
|
||||||
, _speakers (s->speakers())
|
, parent (s)
|
||||||
{
|
{
|
||||||
// s.Changed.connect_same_thread (speaker_connection, boost::bind (&VBAPSpeakers::update, this));
|
parent->Changed.connect_same_thread (speaker_connection, boost::bind (&VBAPSpeakers::update, this));
|
||||||
update ();
|
update ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +59,9 @@ void
|
||||||
VBAPSpeakers::update ()
|
VBAPSpeakers::update ()
|
||||||
{
|
{
|
||||||
int dim = 2;
|
int dim = 2;
|
||||||
|
|
||||||
|
_speakers = parent->speakers();
|
||||||
|
|
||||||
for (vector<Speaker>::const_iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
|
for (vector<Speaker>::const_iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
|
||||||
if ((*i).angles().ele != 0.0) {
|
if ((*i).angles().ele != 0.0) {
|
||||||
cerr << "\n\n\nSPEAKER " << (*i).id << " has ele = " << (*i).angles().ele << "\n\n\n\n";
|
cerr << "\n\n\nSPEAKER " << (*i).id << " has ele = " << (*i).angles().ele << "\n\n\n\n";
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ public:
|
||||||
private:
|
private:
|
||||||
static const double MIN_VOL_P_SIDE_LGTH = 0.01;
|
static const double MIN_VOL_P_SIDE_LGTH = 0.01;
|
||||||
int _dimension;
|
int _dimension;
|
||||||
|
boost::shared_ptr<Speakers> parent;
|
||||||
std::vector<Speaker> _speakers;
|
std::vector<Speaker> _speakers;
|
||||||
PBD::ScopedConnection speaker_connection;
|
PBD::ScopedConnection speaker_connection;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue