]> sigrok.org Git - pulseview.git/blobdiff - pv/view/analogsignal.cpp
Switch segment storage from single vector to vector of arrays
[pulseview.git] / pv / view / analogsignal.cpp
index 0d38314dfa270e95cdbcb906a01b4f0d025f5004..41f46dfcc75b414e47fbf8dd6bf47d2d7ff8502a 100644 (file)
@@ -14,8 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <extdef.h>
@@ -48,7 +47,8 @@ using std::shared_ptr;
 using std::deque;
 
 namespace pv {
-namespace view {
+namespace views {
+namespace TraceView {
 
 const QColor AnalogSignal::SignalColours[4] = {
        QColor(0xC4, 0xA0, 0x00),       // Yellow
@@ -240,26 +240,25 @@ void AnalogSignal::paint_trace(QPainter &p,
        int y, int left, const int64_t start, const int64_t end,
        const double pixels_offset, const double samples_per_pixel)
 {
-       const int64_t sample_count = end - start;
-
-       const float *const samples = segment->get_samples(start, end);
-       assert(samples);
-
        p.setPen(base_->colour());
 
-       QPointF *points = new QPointF[sample_count];
+       QPointF *points = new QPointF[end - start];
        QPointF *point = points;
 
+       pv::data::SegmentAnalogDataIterator* it =
+               segment->begin_sample_iteration(start);
+
        for (int64_t sample = start; sample != end; sample++) {
                const float x = (sample / samples_per_pixel -
                        pixels_offset) + left;
-               *point++ = QPointF(x,
-                       y - samples[sample - start] * scale_);
+
+               *point++ = QPointF(x, y - *((float*)it->value) * scale_);
+               segment->continue_sample_iteration(it, 1);
        }
+       segment->end_sample_iteration(it);
 
        p.drawPolyline(points, point - points);
 
-       delete[] samples;
        delete[] points;
 }
 
@@ -385,5 +384,6 @@ void AnalogSignal::on_resolution_changed(int index)
                owner_->row_item_appearance_changed(false, true);
 }
 
-} // namespace view
+} // namespace TraceView
+} // namespace views
 } // namespace pv