From: Joel Holdsworth Date: Mon, 25 Aug 2014 22:29:00 +0000 (+0100) Subject: TraceGroup: Added skeleton X-Git-Tag: pulseview-0.3.0~473 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=722930c167711a4b59b4f4d5a9bab20d88b3f535 TraceGroup: Added skeleton --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ae482e6..d11f1430 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,7 @@ set(pulseview_SOURCES pv/view/signal.cpp pv/view/timemarker.cpp pv/view/trace.cpp + pv/view/tracegroup.cpp pv/view/tracepalette.cpp pv/view/view.cpp pv/view/viewport.cpp @@ -208,6 +209,7 @@ set(pulseview_HEADERS pv/view/signal.h pv/view/timemarker.h pv/view/trace.h + pv/view/tracegroup.h pv/view/view.h pv/view/viewport.h pv/widgets/colourbutton.h diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp new file mode 100644 index 00000000..2c49ae43 --- /dev/null +++ b/pv/view/tracegroup.cpp @@ -0,0 +1,115 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 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 + +#include + +#include "tracegroup.h" + +using std::shared_ptr; + +namespace pv { +namespace view { + +TraceGroup::~TraceGroup() +{ + _owner = nullptr; + clear_child_items(); +} + +bool TraceGroup::enabled() const +{ + return std::any_of(child_items().begin(), child_items().end(), + [](const shared_ptr &r) { return r->enabled(); }); +} + +pv::SigSession& TraceGroup::session() +{ + assert(_owner); + return _owner->session(); +} + +const pv::SigSession& TraceGroup::session() const +{ + assert(_owner); + return _owner->session(); +} + +pv::view::View* TraceGroup::view() +{ + assert(_owner); + return _owner->view(); +} + +const pv::view::View* TraceGroup::view() const +{ + assert(_owner); + return _owner->view(); +} + +void TraceGroup::paint_label(QPainter &p, int right, bool hover) +{ + (void)p; + (void)right; + (void)hover; +} + +QRectF TraceGroup::label_rect(int right) +{ + (void)right; + return QRectF(); +} + +bool TraceGroup::pt_in_label_rect(int left, int right, const QPoint &point) +{ + (void)left; + (void)right; + (void)point; + + return false; +} + +QMenu* TraceGroup::create_context_menu(QWidget *parent) +{ + (void)parent; + + return NULL; +} + +pv::widgets::Popup* TraceGroup::create_popup(QWidget *parent) +{ + (void)parent; + return NULL; +} + +int TraceGroup::owner_v_offset() const +{ + return v_offset() + _owner->owner_v_offset(); +} + +void TraceGroup::update_viewport() +{ + if (_owner) + _owner->update_viewport(); +} + +} // namespace view +} // namespace pv diff --git a/pv/view/tracegroup.h b/pv/view/tracegroup.h new file mode 100644 index 00000000..297afa82 --- /dev/null +++ b/pv/view/tracegroup.h @@ -0,0 +1,107 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 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 + */ + +#ifndef PULSEVIEW_PV_VIEW_TRACEGROUP_H +#define PULSEVIEW_PV_VIEW_TRACEGROUP_H + +#include "rowitem.h" +#include "rowitemowner.h" + +namespace pv { +namespace view { + +class TraceGroup : public RowItem, public RowItemOwner +{ + Q_OBJECT + +public: + /** + * Virtual destructor + */ + virtual ~TraceGroup(); + + /** + * Returns true if the item is visible and enabled. + */ + bool enabled() const; + + /** + * Returns the session of the onwer. + */ + pv::SigSession& session(); + + /** + * Returns the session of the onwer. + */ + const pv::SigSession& session() const; + + /** + * Returns the view of the owner. + */ + virtual pv::view::View* view(); + + /** + * Returns the view of the owner. + */ + virtual const pv::view::View* view() const; + + /** + * Paints the signal label. + * @param p the QPainter to paint into. + * @param right the x-coordinate of the right edge of the header + * area. + * @param hover true if the label is being hovered over by the mouse. + */ + void paint_label(QPainter &p, int right, bool hover); + + /** + * Computes the outline rectangle of a label. + * @param right the x-coordinate of the right edge of the header + * area. + * @return Returns the rectangle of the signal label. + */ + QRectF label_rect(int right); + + /** + * Determines if a point is in the header label rect. + * @param left the x-coordinate of the left edge of the header + * area. + * @param right the x-coordinate of the right edge of the header + * area. + * @param point the point to test. + */ + bool pt_in_label_rect(int left, int right, const QPoint &point); + + QMenu* create_context_menu(QWidget *parent); + + pv::widgets::Popup* create_popup(QWidget *parent); + + /** + * Returns the total vertical offset of this trace and all it's owners + */ + int owner_v_offset() const; + + void update_viewport(); +}; + +} // view +} // pv + +#endif // PULSEVIEW_PV_VIEW_TRACEGROUP_H