X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Fviewport.cpp;h=d81befae9cb69522ea3a52f82f6b85540bfa6d19;hb=HEAD;hp=d837067f8a72585e240461a8864ff5d85642ee28;hpb=b3f22de060b73f15ad3eb2dabee04a0b4f5d947e;p=pulseview.git diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp deleted file mode 100644 index d837067f..00000000 --- a/pv/view/viewport.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2012 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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 - */ - -#include "view.h" -#include "viewport.h" - -#include "../../sigsession.h" -#include "../../signal.h" - -#include - -#include - -using namespace boost; -using namespace std; - -namespace pv { -namespace view { - -Viewport::Viewport(View &parent) : - QWidget(&parent), - _view(parent) -{ - setMouseTracking(true); - setAutoFillBackground(true); - setBackgroundRole(QPalette::Base); -} - -int Viewport::get_total_height() const -{ - int height = 0; - BOOST_FOREACH(const shared_ptr s, - _view.session().get_signals()) { - assert(s); - height += View::SignalHeight; - } - - return height; -} - -void Viewport::paintEvent(QPaintEvent *event) -{ - const vector< shared_ptr > &sigs = - _view.session().get_signals(); - - QPainter p(this); - - // Plot the signal - int offset = -_view.v_offset(); - BOOST_FOREACH(const shared_ptr s, sigs) - { - assert(s); - - const QRect signal_rect(0, offset, - width(), View::SignalHeight); - - s->paint(p, signal_rect, _view.scale(), _view.offset()); - - offset += View::SignalHeight; - } - - p.end(); -} - -void Viewport::mousePressEvent(QMouseEvent *event) -{ - assert(event); - - _mouse_down_point = event->pos(); - _mouse_down_offset = _view.offset(); -} - -void Viewport::mouseMoveEvent(QMouseEvent *event) -{ - assert(event); - - if(event->buttons() & Qt::LeftButton) - { - _view.set_scale_offset(_view.scale(), - _mouse_down_offset + - (_mouse_down_point - event->pos()).x() * - _view.scale()); - } -} - -void Viewport::mouseReleaseEvent(QMouseEvent *event) -{ - assert(event); -} - -void Viewport::wheelEvent(QWheelEvent *event) -{ - assert(event); - _view.zoom(event->delta() / 120, event->x()); -} - -} // namespace view -} // namespace pv