Add a time+layer equivalence check

This is more useful than exact_equivalent() since _start offset
may not match in some cases (compounds, import, record with different
capture latencies).

However shared group editing (range, copy/paste) does result in
consistent layers and matching position+length.
This commit is contained in:
Robin Gareus
2019-03-12 15:15:44 +01:00
parent eea603d998
commit d7314e0048
5 changed files with 19 additions and 1 deletions

View File

@@ -205,6 +205,7 @@ public:
bool size_equivalent (boost::shared_ptr<const Region>) const;
bool overlap_equivalent (boost::shared_ptr<const Region>) const;
bool enclosed_equivalent (boost::shared_ptr<const Region>) const;
bool layer_and_time_equivalent (boost::shared_ptr<const Region>) const;
bool region_list_equivalent (boost::shared_ptr<const Region>) const;
bool source_equivalent (boost::shared_ptr<const Region>) const;
bool any_source_equivalent (boost::shared_ptr<const Region>) const;

View File

@@ -631,7 +631,8 @@ typedef std::vector<boost::shared_ptr<Bundle> > BundleList;
enum RegionEquivalence {
Exact,
Enclosed,
Overlap
Overlap,
LayerTime
};
enum WaveformScale {

View File

@@ -694,6 +694,7 @@ setup_enum_writer ()
REGISTER_ENUM(Exact);
REGISTER_ENUM(Enclosed);
REGISTER_ENUM(Overlap);
REGISTER_ENUM(LayerTime);
REGISTER(_RegionEquivalence);
REGISTER_ENUM(Linear);

View File

@@ -846,6 +846,13 @@ Playlist::get_equivalent_regions (boost::shared_ptr<Region> other, vector<boost:
}
}
break;
case LayerTime:
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
if ((*i)->layer_and_time_equivalent (other)) {
results.push_back (*i);
}
}
break;
case Enclosed:
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
if ((*i)->enclosed_equivalent (other)) {

View File

@@ -1484,6 +1484,14 @@ Region::enclosed_equivalent (boost::shared_ptr<const Region> other) const
(first_sample() <= other->first_sample() && last_sample() >= other->last_sample()) ;
}
bool
Region::layer_and_time_equivalent (boost::shared_ptr<const Region> other) const
{
return _layer == other->_layer &&
_position == other->_position &&
_length == other->_length;
}
bool
Region::exact_equivalent (boost::shared_ptr<const Region> other) const
{