From 8e59a26ccf13de93ac681d761bad09cd6bcf0c90 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 22 Dec 2009 01:10:25 +0000 Subject: Add remove all and disconnect all to port matrix menu. Hide bundles whose channels are already represented by other, larger bundles. git-svn-id: svn://localhost/ardour2/branches/3.0@6381 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/port_group.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'gtk2_ardour/port_group.cc') diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 3b10ff1abf..9f5b73c68d 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -207,6 +207,55 @@ PortGroup::io_from_bundle (boost::shared_ptr b) const return (*i)->io; } +/** Remove bundles whose channels are already represented by other, larger bundles */ +void +PortGroup::remove_duplicates () +{ + BundleList::iterator i = _bundles.begin(); + while (i != _bundles.end()) { + + BundleList::iterator tmp = i; + ++tmp; + + bool remove = false; + + for (BundleList::iterator j = _bundles.begin(); j != _bundles.end(); ++j) { + + if (j->bundle->nchannels() > i->bundle->nchannels()) { + /* this bundle is larger */ + + uint32_t k = 0; + while (k < i->bundle->nchannels()) { + /* see if this channel on *i has an equivalent on *j */ + uint32_t l = 0; + while (l < j->bundle->nchannels() && i->bundle->channel_ports (k) != j->bundle->channel_ports (l)) { + ++l; + } + + if (l == j->bundle->nchannels()) { + /* it does not */ + break; + } + + ++k; + } + + if (k == i->bundle->nchannels ()) { + /* all channels on *i are represented by the larger bundle *j, so remove *i */ + remove = true; + break; + } + } + } + + if (remove) { + _bundles.erase (i); + } + + i = tmp; + } +} + /** PortGroupList constructor. */ @@ -398,6 +447,10 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups) other->add_bundle (make_bundle_from_ports (extra_other, inputs)); } + if (!allow_dups) { + system->remove_duplicates (); + } + add_group_if_not_empty (system); add_group_if_not_empty (bus); add_group_if_not_empty (track); -- cgit v1.2.3