]> sigrok.org Git - pulseview.git/blobdiff - pv/data/logic.cpp
Fix #684 by implementing snap-to-edge for TimeItem-based classes
[pulseview.git] / pv / data / logic.cpp
index 9ba8f2c3d6e1a70ed761f88ea57d27dfff9d38a8..b094a0c828334059029936cd48d40cbd22844dc8 100644 (file)
@@ -42,10 +42,9 @@ unsigned int Logic::num_channels() const
        return num_channels_;
 }
 
-void Logic::push_segment(
-       shared_ptr<LogicSegment> &segment)
+void Logic::push_segment(shared_ptr<LogicSegment> &segment)
 {
-       segments_.push_front(segment);
+       segments_.push_back(segment);
 }
 
 const deque< shared_ptr<LogicSegment> >& Logic::logic_segments() const
@@ -55,24 +54,44 @@ const deque< shared_ptr<LogicSegment> >& Logic::logic_segments() const
 
 vector< shared_ptr<Segment> > Logic::segments() const
 {
-       return vector< shared_ptr<Segment> >(
-               segments_.begin(), segments_.end());
+       return vector< shared_ptr<Segment> >(segments_.begin(), segments_.end());
+}
+
+uint32_t Logic::get_segment_count() const
+{
+       return (uint32_t)segments_.size();
 }
 
 void Logic::clear()
 {
        segments_.clear();
+
+       samples_cleared();
+}
+
+double Logic::get_samplerate() const
+{
+       if (segments_.empty())
+               return 1.0;
+
+       return segments_.front()->samplerate();
 }
 
 uint64_t Logic::max_sample_count() const
 {
        uint64_t l = 0;
-       for (std::shared_ptr<LogicSegment> s : segments_) {
+       for (shared_ptr<LogicSegment> s : segments_) {
                assert(s);
                l = max(l, s->get_sample_count());
        }
        return l;
 }
 
+void Logic::notify_samples_added(QObject* segment, uint64_t start_sample,
+       uint64_t end_sample)
+{
+       samples_added(segment, start_sample, end_sample);
+}
+
 } // namespace data
 } // namespace pv