13
0

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:
Paul Davis 2011-02-17 18:54:13 +00:00
parent 0d61f205ab
commit 96cc6c3410
7 changed files with 40 additions and 27 deletions

View File

@ -24,10 +24,11 @@
#include <cairo.h>
#include <gtkmm/menu.h>
#include "gtkmm2ext/gtk_ui.h"
#include "pbd/error.h"
#include "pbd/cartesian.h"
#include "ardour/panner.h"
#include <gtkmm2ext/gtk_ui.h>
#include "panner2d.h"
#include "keyboard.h"
@ -94,10 +95,6 @@ Panner2d::reset (uint32_t n_inputs)
pucks.resize (n_inputs);
}
for (Targets::iterator x = pucks.begin(); x != pucks.end(); ++x) {
(*x)->visible = false;
}
switch (n_inputs) {
case 0:
break;
@ -120,12 +117,9 @@ Panner2d::reset (uint32_t n_inputs)
break;
}
#ifdef PANNER_HACKS
for (uint32_t i = existing_pucks; i < n_inputs; ++i) {
pucks[i]->position = panner->streampanner (i).get_position ();
pucks[i]->visible = true;
}
#endif
for (uint32_t i = 0; i < n_inputs; ++i) {
pucks[i]->position = panner->signal_position (i);
}
/* add all outputs */
@ -165,11 +159,16 @@ Panner2d::on_size_allocate (Gtk::Allocation& alloc)
width = alloc.get_width();
height = alloc.get_height();
/* our idea of our width/height must be "square
*/
if (height > 100) {
width -= 20;
height -= 20;
}
dimen = min (width, height);
DrawingArea::on_size_allocate (alloc);
}
@ -244,8 +243,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
which = 0;
pwhich = 0;
cerr << "@ " << x << ", " << y << endl;
for (Targets::const_iterator i = pucks.begin(); i != pucks.end(); ++i, ++pwhich) {
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) +
(c.y - y) * (c.y - y));
cerr << "\tConsider candiate " << candidate->text << " @ " << c.x << ", " << c.y << ", " << c.z << " distance = " << distance << endl;
if (distance < best_distance) {
closest = candidate;
best_distance = distance;
@ -271,8 +266,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
return 0;
}
cerr << "the winner is " << closest->text << endl;
return closest;
}
@ -330,7 +323,7 @@ Panner2d::on_expose_event (GdkEventExpose *event)
/* 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);
if (!panner->bypassed()) {
@ -357,7 +350,7 @@ Panner2d::on_expose_event (GdkEventExpose *event)
puck->position.cartesian (c);
cart_to_gtk (c);
x = (gint) floor (c.x);
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
0,height
*/
const uint32_t hoffset = (width - dimen)/2;
const uint32_t voffset = (height - dimen)/2;
c.x = (width / 2) * (c.x + 1);
c.y = (height / 2) * (1 - c.y);
c.x = hoffset + ((dimen / 2) * (c.x + 1));
c.y = voffset + ((dimen / 2) * (1 - c.y));
/* XXX z-axis not handled - 2D for now */
}
@ -571,8 +567,8 @@ Panner2d::cart_to_gtk (CartesianVector& c) const
void
Panner2d::gtk_to_cart (CartesianVector& c) const
{
c.x = (c.x / (width / 2.0)) - 1.0;
c.y = -((c.y / (height / 2.0)) - 1.0);
c.x = ((c.x / (dimen / 2.0)) - 1.0);
c.y = -((c.y / (dimen / 2.0)) - 1.0);
/* XXX z-axis not handled - 2D for now */
}

View File

@ -113,6 +113,7 @@ class Panner2d : public Gtk::DrawingArea
bool allow_target;
int width;
int height;
int dimen;
bool bypassflag;

View File

@ -78,8 +78,10 @@ class Panner : public PBD::Stateful, public PBD::ScopedConnectionList
virtual double width () 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 void set_bypassed (bool yn);

View File

@ -331,3 +331,13 @@ VBAPanner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
return _pannable->value_as_string (ac);
}
}
AngularVector
VBAPanner::signal_position (uint32_t n) const
{
if (n < _signals.size()) {
return _signals[n]->direction;
}
return AngularVector();
}

View File

@ -59,6 +59,7 @@ public:
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
PBD::AngularVector signal_position (uint32_t n) const;
private:
struct Signal {

View File

@ -45,9 +45,9 @@ using namespace std;
VBAPSpeakers::VBAPSpeakers (boost::shared_ptr<Speakers> s)
: _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 ();
}
@ -59,7 +59,9 @@ void
VBAPSpeakers::update ()
{
int dim = 2;
_speakers = parent->speakers();
for (vector<Speaker>::const_iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
if ((*i).angles().ele != 0.0) {
cerr << "\n\n\nSPEAKER " << (*i).id << " has ele = " << (*i).angles().ele << "\n\n\n\n";

View File

@ -51,6 +51,7 @@ public:
private:
static const double MIN_VOL_P_SIDE_LGTH = 0.01;
int _dimension;
boost::shared_ptr<Speakers> parent;
std::vector<Speaker> _speakers;
PBD::ScopedConnection speaker_connection;