pv/prop/binding/binding.cpp
pv/prop/binding/decoderoptions.cpp
pv/prop/binding/deviceoptions.cpp
- pv/toolbars/contextbar.cpp
pv/toolbars/samplingbar.cpp
pv/view/analogsignal.cpp
pv/view/cursor.cpp
pv/dialogs/about.h
pv/dialogs/connect.h
pv/dialogs/deviceoptions.h
- pv/toolbars/contextbar.h
pv/toolbars/samplingbar.h
pv/view/cursor.h
pv/view/decodesignal.h
#include "dialogs/about.h"
#include "dialogs/connect.h"
#include "dialogs/decoder.h"
-#include "toolbars/contextbar.h"
#include "toolbars/samplingbar.h"
#include "view/view.h"
setCentralWidget(_central_widget);
_view = new pv::view::View(_session, this);
- connect(_view, SIGNAL(selection_changed()), this,
- SLOT(view_selection_changed()));
_vertical_layout->addWidget(_view);
SLOT(run_stop()));
addToolBar(_sampling_bar);
- // Setup the context bar
- _context_bar = new toolbars::ContextBar(this);
- addToolBar(_context_bar);
-
// Set the title
setWindowTitle(QApplication::translate("MainWindow", "PulseView", 0,
QApplication::UnicodeUTF8));
_sampling_bar->set_capture_state((pv::SigSession::capture_state)state);
}
-void MainWindow::view_selection_changed()
-{
- assert(_context_bar);
-
- const list<weak_ptr<pv::view::SelectableItem> > items(
- _view->selected_items());
- _context_bar->set_selected_items(items);
-}
-
} // namespace pv
void capture_state_changed(int state);
- void view_selection_changed();
-
private:
DeviceManager &_device_manager;
QToolBar *_toolbar;
toolbars::SamplingBar *_sampling_bar;
- toolbars::ContextBar *_context_bar;
};
} // namespace pv
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * 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 <stdio.h>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/foreach.hpp>
-
-#include "contextbar.h"
-
-#include <pv/view/selectableitem.h>
-
-using namespace boost;
-using namespace std;
-
-namespace pv {
-namespace toolbars {
-
-ContextBar::ContextBar(QWidget *parent) :
- QToolBar(tr("Context Bar"), parent)
-{
-}
-
-void ContextBar::set_selected_items(const list<
- weak_ptr<pv::view::SelectableItem> > &items)
-{
- clear();
-
- if (items.empty())
- return;
-
- if (shared_ptr<pv::view::SelectableItem> item =
- items.front().lock()) {
-
- assert(item);
-
- const list<QAction*> actions(
- item->get_context_bar_actions());
- BOOST_FOREACH(QAction *action, actions) {
- assert(action);
- addAction(action);
- }
- }
-}
-
-} // namespace toolbars
-} // namespace pv
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * 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_TOOLBARS_CONTEXTBAR_H
-#define PULSEVIEW_PV_TOOLBARS_CONTEXTBAR_H
-
-#include <boost/weak_ptr.hpp>
-
-#include <QToolBar>
-
-#include <pv/view/selectableitem.h>
-
-namespace pv {
-namespace toolbars {
-
-class ContextBar : public QToolBar
-{
- Q_OBJECT
-
-public:
- ContextBar(QWidget *parent);
-
-public:
- void set_selected_items(const std::list<
- boost::weak_ptr<pv::view::SelectableItem> > &items);
-};
-
-} // namespace toolbars
-} // namespace pv
-
-#endif // PULSEVIEW_PV_TOOLBARS_CONTEXTBAR_H
{
}
-const list<QAction*> AnalogSignal::get_context_bar_actions()
-{
- list<QAction*> actions;
- actions.push_back(_name_action);
- return actions;
-}
-
void AnalogSignal::set_scale(float scale)
{
_scale = scale;
virtual ~AnalogSignal();
- const std::list<QAction*> get_context_bar_actions();
-
void set_scale(float scale);
/**
this, SLOT(on_new_decode_data()));
}
-void DecodeSignal::init_context_bar_actions(QWidget *parent)
-{
- (void)parent;
-}
-
bool DecodeSignal::enabled() const
{
return true;
}
}
-const list<QAction*> DecodeSignal::get_context_bar_actions()
-{
- list<QAction*> actions;
- return actions;
-}
-
QMenu* DecodeSignal::create_context_menu(QWidget *parent)
{
QMenu *const menu = Trace::create_context_menu(parent);
DecodeSignal(pv::SigSession &session,
boost::shared_ptr<pv::data::Decoder> decoder, int index);
- void init_context_bar_actions(QWidget *parent);
-
bool enabled() const;
void set_view(pv::view::View *view);
**/
void paint_mid(QPainter &p, int left, int right);
- const std::list<QAction*> get_context_bar_actions();
-
QMenu* create_context_menu(QWidget *parent);
private:
shared_ptr<data::Logic> data) :
Signal(session, probe),
_data(data),
- _separator(NULL),
_trigger_none(NULL),
_trigger_rising(NULL),
_trigger_high(NULL),
{
}
-void LogicSignal::init_context_bar_actions(QWidget *parent)
-{
- Signal::init_context_bar_actions(parent);
-
- _separator = new QAction(parent);
- _separator->setSeparator(true);
-
- _trigger_none = new QAction(QIcon(":/icons/trigger-none.svg"),
- tr("No trigger"), this);
- _trigger_none->setCheckable(true);
- connect(_trigger_none, SIGNAL(triggered()),
- this, SLOT(on_trigger_none()));
-
- _trigger_rising = new QAction(QIcon(":/icons/trigger-rising.svg"),
- tr("Trigger on rising edge"), this);
- _trigger_rising->setCheckable(true);
- connect(_trigger_rising, SIGNAL(triggered()),
- this, SLOT(on_trigger_rising()));
-
- _trigger_high = new QAction(QIcon(":/icons/trigger-low.svg"),
- tr("Trigger on high level"), this);
- _trigger_high->setCheckable(true);
- connect(_trigger_high, SIGNAL(triggered()),
- this, SLOT(on_trigger_high()));
-
- _trigger_falling = new QAction(QIcon(":/icons/trigger-falling.svg"),
- tr("Trigger on falling edge"), this);
- _trigger_falling->setCheckable(true);
- connect(_trigger_falling, SIGNAL(triggered()),
- this, SLOT(on_trigger_falling()));
-
- _trigger_low = new QAction(QIcon(":/icons/trigger-low.svg"),
- tr("Trigger on low level"), this);
- _trigger_low->setCheckable(true);
- connect(_trigger_low, SIGNAL(triggered()),
- this, SLOT(on_trigger_low()));
-
- _trigger_change = new QAction(QIcon(":/icons/trigger-change.svg"),
- tr("Trigger on rising or falling edge"), this);
- _trigger_change->setCheckable(true);
- connect(_trigger_change, SIGNAL(triggered()),
- this, SLOT(on_trigger_change()));
-}
-
boost::shared_ptr<pv::data::Logic> LogicSignal::data() const
{
return _data;
}
-const list<QAction*> LogicSignal::get_context_bar_actions()
-{
- GVariant *gvar;
- list<QAction*> actions;
-
- actions.push_back(_name_action);
-
- // Add the trigger actions
- const sr_dev_inst *const sdi = _session.get_device();
- if (sr_config_list(sdi->driver, SR_CONF_TRIGGER_TYPE,
- &gvar, sdi) == SR_OK) {
- const char *const trig_types =
- g_variant_get_string(gvar, NULL);
-
- if (trig_types && trig_types[0] != '\0') {
- actions.push_back(_separator);
-
- actions.push_back(_trigger_none);
-
- add_trigger_action(trig_types, 'r',
- _trigger_rising, actions);
- add_trigger_action(trig_types, '1',
- _trigger_high, actions);
- add_trigger_action(trig_types, 'f',
- _trigger_falling, actions);
- add_trigger_action(trig_types, '0',
- _trigger_low, actions);
- add_trigger_action(trig_types, 'c',
- _trigger_change, actions);
-
- update_trigger_actions();
- }
-
- g_variant_unref(gvar);
- }
-
- return actions;
-}
-
void LogicSignal::paint_back(QPainter &p, int left, int right)
{
if (_probe->enabled)
p.drawLines(lines, line - lines);
}
-void LogicSignal::add_trigger_action(const char *trig_types, char type,
- QAction *action, list<QAction*> &actions)
-{
- while(*trig_types)
- if(*trig_types++ == type) {
- actions.push_back(action);
- break;
- }
-}
-
void LogicSignal::update_trigger_actions()
{
const char cur_trigger = _probe->trigger ?
virtual ~LogicSignal();
- void init_context_bar_actions(QWidget *parent);
-
boost::shared_ptr<pv::data::Logic> data() const;
- const std::list<QAction*> get_context_bar_actions();
-
/**
* Paints the background layer of the signal with a QPainter
* @param p the QPainter to paint into.
bool level, double samples_per_pixel, double pixels_offset,
float x_offset, float y_offset);
- static void add_trigger_action(const char *trig_types, char type,
- QAction *action, std::list<QAction*> &actions);
-
void update_trigger_actions();
void set_trigger(char type);
private:
boost::shared_ptr<pv::data::Logic> _data;
- QAction *_separator;
-
QAction *_trigger_none;
QAction *_trigger_rising;
QAction *_trigger_high;
void select(bool select = true);
public:
- virtual void init_context_bar_actions(QWidget *parent) = 0;
-
- virtual const std::list<QAction*> get_context_bar_actions() = 0;
-
virtual QMenu* create_context_menu(QWidget *parent);
protected:
Signal::Signal(pv::SigSession &session, const sr_probe *const probe) :
Trace(session, probe->name),
_probe(probe),
- _name_action(NULL),
_name_widget(NULL),
_updating_name_widget(false)
{
assert(_probe);
}
-void Signal::init_context_bar_actions(QWidget *parent)
-{
- _name_widget = new QComboBox(parent);
- _name_widget->setEditable(true);
-
- _name_action = new QWidgetAction(parent);
- _name_action->setDefaultWidget(_name_widget);
-
- for(unsigned int i = 0; i < countof(ProbeNames); i++)
- _name_widget->insertItem(i, ProbeNames[i]);
- _name_widget->setEditText(_probe->name);
-
- connect(_name_widget, SIGNAL(editTextChanged(const QString&)),
- this, SLOT(on_text_changed(const QString&)));
-}
-
void Signal::set_name(QString name)
{
Trace::set_name(name);
Signal(pv::SigSession &session, const sr_probe *const probe);
public:
- virtual void init_context_bar_actions(QWidget *parent);
-
/**
* Sets the name of the signal.
*/
const sr_probe* probe() const;
-private:
virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
private slots:
protected:
const sr_probe *const _probe;
- QWidgetAction *_name_action;
QComboBox *_name_widget;
bool _updating_name_widget;
};
{
}
-void TimeMarker::init_context_bar_actions(QWidget *parent)
-{
- _value_widget = new QDoubleSpinBox(parent);
- _value_widget->setValue(_time);
- _value_widget->setDecimals(6);
- _value_widget->setSuffix("s");
- _value_widget->setSingleStep(1e-6);
-
- _value_action = new QWidgetAction(parent);
- _value_action->setDefaultWidget(_value_widget);
-
- connect(_value_widget, SIGNAL(valueChanged(double)),
- this, SLOT(on_value_changed(double)));
-}
-
double TimeMarker::time() const
{
return _time;
p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom()));
}
-const list<QAction*> TimeMarker::get_context_bar_actions()
-{
- list<QAction*> actions;
- actions.push_back(_value_action);
- return actions;
-}
-
void TimeMarker::on_value_changed(double value)
{
if (!_updating_value_widget) {
TimeMarker(View &view, const QColor &colour, double time);
public:
- virtual void init_context_bar_actions(QWidget *parent);
-
/**
* Gets the time of the marker.
*/
virtual void paint_label(QPainter &p, const QRect &rect,
unsigned int prefix) = 0;
- /**
- * Returns a list of context menu items to show in the context
- * bar.
- */
- const std::list<QAction*> get_context_bar_actions();
-
private slots:
void on_value_changed(double value);
const vector< shared_ptr<Trace> > traces(get_traces());
BOOST_FOREACH(shared_ptr<Trace> t, traces) {
t->set_view(this);
- t->init_context_bar_actions(NULL);
t->set_v_offset(offset);
offset += SignalHeight + 2 * SignalMargin;
}