forked from Ivasoft/DSView
v0.3
This commit is contained in:
110
DSLogic-gui/pv/view/dsldial.cpp
Normal file
110
DSLogic-gui/pv/view/dsldial.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#include "dsldial.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
dslDial::dslDial(quint64 div, quint64 step,
|
||||
QVector<quint64> value, QVector<QString> unit)
|
||||
{
|
||||
assert(div > 0);
|
||||
assert(step > 0);
|
||||
assert((quint64)value.count() == div);
|
||||
assert(unit.count() > 0);
|
||||
|
||||
_div = div;
|
||||
_step = step;
|
||||
_value = value;
|
||||
_unit = unit;
|
||||
_sel = 0;
|
||||
}
|
||||
|
||||
dslDial::~dslDial()
|
||||
{
|
||||
}
|
||||
|
||||
void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor)
|
||||
{
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.setPen(dialColor);
|
||||
p.setBrush(dialColor);
|
||||
|
||||
int dialStartAngle = 225 * 16;
|
||||
int dialSpanAngle = -270 * 16;
|
||||
|
||||
// draw dial arc
|
||||
p.drawArc(dialRect, dialStartAngle, dialSpanAngle);
|
||||
// draw ticks
|
||||
p.save();
|
||||
p.translate(dialRect.center());
|
||||
p.rotate(45);
|
||||
for (quint64 i = 0; i < _div; i++) {
|
||||
// draw major ticks
|
||||
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+8);
|
||||
// draw minor ticks
|
||||
for (quint64 j = 0; (j < 5) && (i < _div - 1); j++) {
|
||||
p.drawLine(0, dialRect.width()/2+3, 0, dialRect.width()/2+5);
|
||||
p.rotate(54.0/(_div-1));
|
||||
}
|
||||
}
|
||||
// draw pointer
|
||||
p.rotate(90+270.0/(_div-1)*_sel);
|
||||
p.drawEllipse(-3, -3, 6, 6);
|
||||
p.drawLine(3, 0, 0, dialRect.width()/2-3);
|
||||
p.drawLine(-3, 0, 0, dialRect.width()/2-3);
|
||||
p.restore();
|
||||
// draw value
|
||||
quint64 displayValue = _value[_sel];
|
||||
quint64 displayIndex = 0;
|
||||
while(displayValue / _step >= 1) {
|
||||
displayValue = displayValue / _step;
|
||||
displayIndex++;
|
||||
}
|
||||
QString pText = QString::number(displayValue) + _unit[displayIndex] + "/div";
|
||||
QFontMetrics fm(p.font());
|
||||
p.drawText(QRectF(dialRect.left(), dialRect.bottom()-dialRect.width()*0.3+fm.height()*0.5, dialRect.width(), fm.height()), Qt::AlignCenter, pText);
|
||||
|
||||
}
|
||||
|
||||
void dslDial::set_sel(quint64 sel)
|
||||
{
|
||||
assert(sel < _div);
|
||||
|
||||
_sel = sel;
|
||||
}
|
||||
|
||||
quint64 dslDial::get_sel()
|
||||
{
|
||||
return _sel;
|
||||
}
|
||||
|
||||
bool dslDial::isMin()
|
||||
{
|
||||
if(_sel == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dslDial::isMax()
|
||||
{
|
||||
if(_sel == _div - 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
quint64 dslDial::get_value()
|
||||
{
|
||||
return _value[_sel];
|
||||
}
|
||||
|
||||
bool dslDial::set_value(quint64 value)
|
||||
{
|
||||
assert(_value.contains(value));
|
||||
_sel = _value.indexOf(value, 0);
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
48
DSLogic-gui/pv/view/dsldial.h
Normal file
48
DSLogic-gui/pv/view/dsldial.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef DSLOGIC_PV_VIEW_DSLDIAL_H
|
||||
#define DSLOGIC_PV_VIEW_DSLDIAL_H
|
||||
|
||||
#include <QRect>
|
||||
#include <QPainter>
|
||||
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
class dslDial
|
||||
{
|
||||
public:
|
||||
dslDial(quint64 div, quint64 step,
|
||||
QVector<quint64> value, QVector<QString> unit);
|
||||
virtual ~dslDial();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Paints the dial with a QPainter
|
||||
* @param p the QPainter to paint into.
|
||||
* @param dialRect the rectangle to draw the dial at.
|
||||
**/
|
||||
void paint(QPainter &p, QRectF dialRect, QColor dialColor);
|
||||
|
||||
// set/get current select
|
||||
void set_sel(quint64 sel);
|
||||
quint64 get_sel();
|
||||
|
||||
// boundary detection
|
||||
bool isMin();
|
||||
bool isMax();
|
||||
|
||||
// get current value
|
||||
quint64 get_value();
|
||||
bool set_value(quint64 value);
|
||||
|
||||
private:
|
||||
quint64 _div;
|
||||
quint64 _step;
|
||||
QVector<quint64> _value;
|
||||
QVector<QString> _unit;
|
||||
quint64 _sel;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
#endif // DSLOGIC_PV_VIEW_DSLDIAL_H
|
||||
@@ -35,21 +35,26 @@ namespace pv {
|
||||
namespace view {
|
||||
|
||||
const QColor DsoSignal::SignalColours[4] = {
|
||||
QColor(17, 133, 209, 255), // dsBlue
|
||||
QColor(238, 178, 17, 255), // dsYellow
|
||||
QColor(213, 15, 37, 255), // dsRed
|
||||
QColor(0, 153, 37, 255) // dsGreen
|
||||
QColor(238, 178, 17, 200), // dsYellow
|
||||
QColor(0, 153, 37, 200), // dsGreen
|
||||
QColor(213, 15, 37, 200), // dsRed
|
||||
QColor(17, 133, 209, 200) // dsBlue
|
||||
|
||||
};
|
||||
|
||||
const float DsoSignal::EnvelopeThreshold = 256.0f;
|
||||
|
||||
DsoSignal::DsoSignal(QString name, boost::shared_ptr<data::Dso> data,
|
||||
int probe_index, int order) :
|
||||
int probe_index, int order, uint64_t vdiv, uint64_t timebase, bool coupling, bool active) :
|
||||
Signal(name, probe_index, DS_DSO, order),
|
||||
_data(data)
|
||||
{
|
||||
_colour = SignalColours[probe_index % countof(SignalColours)];
|
||||
_scale = _signalHeight * 1.0f / 256;
|
||||
_scale = _windowHeight * 1.0f / 256;
|
||||
_vDial->set_value(vdiv);
|
||||
_hDial->set_value(timebase);
|
||||
_acCoupling = coupling;
|
||||
_active = active;
|
||||
}
|
||||
|
||||
DsoSignal::~DsoSignal()
|
||||
@@ -76,28 +81,27 @@ void DsoSignal::set_scale(float scale)
|
||||
}
|
||||
|
||||
void DsoSignal::paint(QPainter &p, int y, int left, int right, double scale,
|
||||
double offset)
|
||||
double offset)
|
||||
{
|
||||
assert(scale > 0);
|
||||
assert(_data);
|
||||
assert(right >= left);
|
||||
|
||||
//paint_axis(p, y, left, right);
|
||||
|
||||
const deque< boost::shared_ptr<pv::data::DsoSnapshot> > &snapshots =
|
||||
_data->get_snapshots();
|
||||
if (snapshots.empty())
|
||||
return;
|
||||
|
||||
_scale = _signalHeight * 1.0f / 256;
|
||||
_scale = _windowHeight * 1.0f / 256;
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot =
|
||||
snapshots.front();
|
||||
|
||||
if ((unsigned int)get_index() >= snapshot->get_channel_num())
|
||||
const uint16_t number_channels = snapshot->get_channel_num();
|
||||
if ((unsigned int)get_index() >= number_channels)
|
||||
return;
|
||||
|
||||
const double pixels_offset = offset / scale;
|
||||
const double samplerate = _data->get_samplerate();
|
||||
const double samplerate = _data->get_samplerate();
|
||||
const double start_time = _data->get_start_time();
|
||||
const int64_t last_sample = max((int64_t)(snapshot->get_sample_count() - 1), (int64_t)0);
|
||||
const double samples_per_pixel = samplerate * scale;
|
||||
@@ -112,7 +116,7 @@ void DsoSignal::paint(QPainter &p, int y, int left, int right, double scale,
|
||||
if (samples_per_pixel < EnvelopeThreshold)
|
||||
paint_trace(p, snapshot, y, left,
|
||||
start_sample, end_sample,
|
||||
pixels_offset, samples_per_pixel);
|
||||
pixels_offset, samples_per_pixel, number_channels);
|
||||
else
|
||||
paint_envelope(p, snapshot, y, left,
|
||||
start_sample, end_sample,
|
||||
@@ -121,13 +125,13 @@ void DsoSignal::paint(QPainter &p, int y, int left, int right, double scale,
|
||||
|
||||
void DsoSignal::paint_trace(QPainter &p,
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot,
|
||||
int y, int left, const int64_t start, const int64_t end,
|
||||
const double pixels_offset, const double samples_per_pixel)
|
||||
int y, int left, const int64_t start, const int64_t end,
|
||||
const double pixels_offset, const double samples_per_pixel, uint64_t num_channels)
|
||||
{
|
||||
const int64_t sample_count = end - start;
|
||||
|
||||
if (sample_count > 0) {
|
||||
const uint16_t *const samples = snapshot->get_samples(start, end);
|
||||
const uint8_t *const samples = snapshot->get_samples(start, end, get_index());
|
||||
assert(samples);
|
||||
|
||||
p.setPen(_colour);
|
||||
@@ -136,11 +140,11 @@ void DsoSignal::paint_trace(QPainter &p,
|
||||
QPointF *points = new QPointF[sample_count];
|
||||
QPointF *point = points;
|
||||
|
||||
for (int64_t sample = start; sample != end; sample++) {
|
||||
for (int64_t sample = start; sample < end; sample++) {
|
||||
const float x = (sample / samples_per_pixel - pixels_offset) + left;
|
||||
uint16_t offset = samples[sample - start];
|
||||
uint8_t offset = samples[(sample - start)*num_channels];
|
||||
*point++ = QPointF(x,
|
||||
y - ((get_index() == 0) ? offset & 0x00ff : offset >> 8) * _scale);
|
||||
y - offset * _scale);
|
||||
}
|
||||
|
||||
p.drawPolyline(points, point - points);
|
||||
|
||||
@@ -47,7 +47,8 @@ private:
|
||||
|
||||
public:
|
||||
DsoSignal(QString name,
|
||||
boost::shared_ptr<pv::data::Dso> data, int probe_index, int order);
|
||||
boost::shared_ptr<pv::data::Dso> data, int probe_index, int order,
|
||||
uint64_t vdiv, uint64_t timebase, bool coupling, bool active);
|
||||
|
||||
virtual ~DsoSignal();
|
||||
|
||||
@@ -63,8 +64,8 @@ public:
|
||||
* @param offset the time to show at the left hand edge of
|
||||
* the view in seconds.
|
||||
**/
|
||||
void paint(QPainter &p, int y, int left, int right, double scale,
|
||||
double offset);
|
||||
void paint(QPainter &p, int y, int left, int right, double scale,
|
||||
double offset);
|
||||
|
||||
const std::vector< std::pair<uint64_t, bool> > cur_edges() const;
|
||||
|
||||
@@ -83,7 +84,8 @@ private:
|
||||
void paint_trace(QPainter &p,
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot,
|
||||
int y, int left, const int64_t start, const int64_t end,
|
||||
const double pixels_offset, const double samples_per_pixel);
|
||||
const double pixels_offset, const double samples_per_pixel,
|
||||
uint64_t num_channels);
|
||||
|
||||
void paint_envelope(QPainter &p,
|
||||
const boost::shared_ptr<pv::data::DsoSnapshot> &snapshot,
|
||||
|
||||
@@ -50,7 +50,7 @@ GroupSignal::GroupSignal(QString name, boost::shared_ptr<data::Group> data,
|
||||
_data(data)
|
||||
{
|
||||
_colour = SignalColours[probe_index_list.front() % countof(SignalColours)];
|
||||
_scale = _signalHeight * 1.0f / std::pow(2.0, static_cast<double>(probe_index_list.size()));
|
||||
_scale = _signalHeight * 1.0f / pow(2, probe_index_list.size());
|
||||
}
|
||||
|
||||
GroupSignal::~GroupSignal()
|
||||
@@ -77,13 +77,13 @@ void GroupSignal::set_scale(float scale)
|
||||
}
|
||||
|
||||
void GroupSignal::paint(QPainter &p, int y, int left, int right, double scale,
|
||||
double offset)
|
||||
double offset)
|
||||
{
|
||||
assert(scale > 0);
|
||||
assert(_data);
|
||||
assert(right >= left);
|
||||
|
||||
_scale = _signalHeight * 1.0f / std::pow(2.0, static_cast<int>(_index_list.size()));
|
||||
_scale = _signalHeight * 1.0f / pow(2, _index_list.size());
|
||||
paint_axis(p, y, left, right);
|
||||
|
||||
const deque< boost::shared_ptr<pv::data::GroupSnapshot> > &snapshots =
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QStyleOption>
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
@@ -46,14 +47,6 @@ using namespace std;
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
const int Header::COLOR = 1;
|
||||
const int Header::NAME = 2;
|
||||
const int Header::POSTRIG = 3;
|
||||
const int Header::HIGTRIG = 4;
|
||||
const int Header::NEGTRIG = 5;
|
||||
const int Header::LOWTRIG = 6;
|
||||
const int Header::LABEL = 7;
|
||||
|
||||
Header::Header(View &parent) :
|
||||
QWidget(&parent),
|
||||
_view(parent),
|
||||
@@ -90,7 +83,7 @@ int Header::get_nameEditWidth()
|
||||
return 0;
|
||||
}
|
||||
|
||||
boost::shared_ptr<pv::view::Signal> Header::get_mouse_over_signal(
|
||||
boost::shared_ptr<pv::view::Signal> Header::get_mSig(
|
||||
int &action,
|
||||
const QPoint &pt)
|
||||
{
|
||||
@@ -185,17 +178,18 @@ void Header::mousePressEvent(QMouseEvent *event)
|
||||
make_pair(s, s->get_v_offset()));
|
||||
|
||||
// Select the signal if it has been clicked
|
||||
const boost::shared_ptr<Signal> mouse_over_signal =
|
||||
get_mouse_over_signal(action, event->pos());
|
||||
if (action == COLOR && mouse_over_signal) {
|
||||
const boost::shared_ptr<Signal> mSig =
|
||||
get_mSig(action, event->pos());
|
||||
if (action == Signal::COLOR && mSig) {
|
||||
_colorFlag = true;
|
||||
} else if (action == NAME && mouse_over_signal) {
|
||||
} else if (action == Signal::NAME && mSig) {
|
||||
_nameFlag = true;
|
||||
} else if (action == LABEL && mouse_over_signal) {
|
||||
if (mouse_over_signal->selected())
|
||||
mouse_over_signal->select(false);
|
||||
} else if (action == Signal::LABEL && mSig) {
|
||||
if (mSig->selected())
|
||||
mSig->select(false);
|
||||
else {
|
||||
mouse_over_signal->select(true);
|
||||
if (mSig->get_type() != Signal::DS_DSO)
|
||||
mSig->select(true);
|
||||
|
||||
if (~QApplication::keyboardModifiers() &
|
||||
Qt::ControlModifier)
|
||||
@@ -204,37 +198,91 @@ void Header::mousePressEvent(QMouseEvent *event)
|
||||
// Add the signal to the drag list
|
||||
if (event->button() & Qt::LeftButton)
|
||||
_drag_sigs.push_back(
|
||||
make_pair(mouse_over_signal,
|
||||
mouse_over_signal->get_v_offset()));
|
||||
make_pair(mSig,
|
||||
(mSig->get_type() == Signal::DS_DSO) ? mSig->get_zeroPos() : mSig->get_v_offset()));
|
||||
}
|
||||
mouse_over_signal->set_old_v_offset(mouse_over_signal->get_v_offset());
|
||||
} else if (action == POSTRIG && mouse_over_signal) {
|
||||
if (mouse_over_signal->get_trig() == POSTRIG)
|
||||
mouse_over_signal->set_trig(0);
|
||||
mSig->set_old_v_offset(mSig->get_v_offset());
|
||||
} else if (action == Signal::POSTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::POSTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mouse_over_signal->set_trig(POSTRIG);
|
||||
} else if (action == HIGTRIG && mouse_over_signal) {
|
||||
if (mouse_over_signal->get_trig() == HIGTRIG)
|
||||
mouse_over_signal->set_trig(0);
|
||||
mSig->set_trig(Signal::POSTRIG);
|
||||
} else if (action == Signal::HIGTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::HIGTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mouse_over_signal->set_trig(HIGTRIG);
|
||||
} else if (action == NEGTRIG && mouse_over_signal) {
|
||||
if (mouse_over_signal->get_trig() == NEGTRIG)
|
||||
mouse_over_signal->set_trig(0);
|
||||
mSig->set_trig(Signal::HIGTRIG);
|
||||
} else if (action == Signal::NEGTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::NEGTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mouse_over_signal->set_trig(NEGTRIG);
|
||||
} else if (action == LOWTRIG && mouse_over_signal) {
|
||||
if (mouse_over_signal->get_trig() == LOWTRIG)
|
||||
mouse_over_signal->set_trig(0);
|
||||
mSig->set_trig(Signal::NEGTRIG);
|
||||
} else if (action == Signal::LOWTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::LOWTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mouse_over_signal->set_trig(LOWTRIG);
|
||||
mSig->set_trig(Signal::LOWTRIG);
|
||||
} else if (action == Signal::EDGETRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::EDGETRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mSig->set_trig(Signal::EDGETRIG);
|
||||
} else if (action == Signal::VDIAL && mSig) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
s->set_hDialActive(false);
|
||||
if (s != mSig) {
|
||||
s->set_vDialActive(false);
|
||||
}
|
||||
}
|
||||
mSig->set_vDialActive(!mSig->get_vDialActive());
|
||||
} else if (action == Signal::HDIAL && mSig) {
|
||||
if (mSig->get_hDialActive()) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
s->set_vDialActive(false);
|
||||
s->set_hDialActive(false);
|
||||
}
|
||||
} else {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
s->set_vDialActive(false);
|
||||
s->set_hDialActive(true);
|
||||
}
|
||||
}
|
||||
} else if (action == Signal::CHEN && mSig) {
|
||||
int channel;
|
||||
if (mSig->get_index() == 0) {
|
||||
bool last = 1;
|
||||
channel = 0;
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
if (s->get_index() != 0 && s->get_active()) {
|
||||
QMessageBox msg(this);
|
||||
msg.setText("Tips");
|
||||
msg.setInformativeText("If only one channel want, Channel0 has a higher maximum sample rate!");
|
||||
msg.setStandardButtons(QMessageBox::Ok);
|
||||
msg.setIcon(QMessageBox::Information);
|
||||
msg.exec();
|
||||
s->set_active(!s->get_active());
|
||||
last = 0;
|
||||
channel = s->get_index();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (last)
|
||||
mSig->set_active(!mSig->get_active());
|
||||
} else {
|
||||
mSig->set_active(!mSig->get_active());
|
||||
channel = mSig->get_index();
|
||||
}
|
||||
ch_changed(channel);
|
||||
} else if (action == Signal::ACDC && mSig) {
|
||||
mSig->set_acCoupling(!mSig->get_acCoupling());
|
||||
acdc_changed(mSig->get_index());
|
||||
}
|
||||
|
||||
if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
// Unselect all other signals because the Ctrl is not
|
||||
// pressed
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
|
||||
if (s != mouse_over_signal)
|
||||
if (s != mSig)
|
||||
s->select(false);
|
||||
}
|
||||
update();
|
||||
@@ -247,15 +295,15 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
// judge for color / name / trigger / move
|
||||
int action;
|
||||
const boost::shared_ptr<Signal> mouse_over_signal =
|
||||
get_mouse_over_signal(action, event->pos());
|
||||
if (mouse_over_signal){
|
||||
if (action == COLOR && _colorFlag) {
|
||||
_context_signal = mouse_over_signal;
|
||||
const boost::shared_ptr<Signal> mSig =
|
||||
get_mSig(action, event->pos());
|
||||
if (mSig){
|
||||
if (action == Signal::COLOR && _colorFlag) {
|
||||
_context_signal = mSig;
|
||||
changeColor(event);
|
||||
_view.set_need_update(true);
|
||||
} else if (action == NAME && _nameFlag) {
|
||||
_context_signal = mouse_over_signal;
|
||||
} else if (action == Signal::NAME && _nameFlag) {
|
||||
_context_signal = mSig;
|
||||
changeName(event);
|
||||
}
|
||||
}
|
||||
@@ -270,6 +318,42 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
|
||||
_view.normalize_layout();
|
||||
}
|
||||
|
||||
void Header::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
assert(event);
|
||||
|
||||
if (event->orientation() == Qt::Vertical) {
|
||||
const vector< shared_ptr<Signal> > sigs(
|
||||
_view.session().get_signals());
|
||||
// Vertical scrolling
|
||||
double shift = event->delta() / 20.0;
|
||||
if (shift > 1.0) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
if (s->get_vDialActive()) {
|
||||
if(s->go_vDialNext())
|
||||
vDial_changed(s->get_index());
|
||||
break;
|
||||
} else if (s->get_hDialActive()) {
|
||||
if(s->go_hDialNext())
|
||||
hDial_changed(0);
|
||||
}
|
||||
}
|
||||
} else if (shift < -1.0) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
if (s->get_vDialActive()) {
|
||||
if(s->go_vDialPre())
|
||||
vDial_changed(s->get_index());
|
||||
break;
|
||||
} else if (s->get_hDialActive()) {
|
||||
if(s->go_hDialPre())
|
||||
hDial_changed(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void Header::move(QMouseEvent *event)
|
||||
{
|
||||
bool _moveValid = false;
|
||||
@@ -439,24 +523,31 @@ void Header::mouseMoveEvent(QMouseEvent *event)
|
||||
i != _drag_sigs.end(); i++) {
|
||||
const boost::shared_ptr<Signal> sig((*i).first);
|
||||
if (sig) {
|
||||
const int y = (*i).second + delta;
|
||||
const int y_snap =
|
||||
((y + View::SignalSnapGridSize / 2) /
|
||||
View::SignalSnapGridSize) *
|
||||
View::SignalSnapGridSize;
|
||||
if (y_snap != sig->get_v_offset()) {
|
||||
_moveFlag = true;
|
||||
sig->set_v_offset(y_snap);
|
||||
int y = (*i).second + delta;
|
||||
if (sig->get_type() != Signal::DS_DSO) {
|
||||
const int y_snap =
|
||||
((y + View::SignalSnapGridSize / 2) /
|
||||
View::SignalSnapGridSize) *
|
||||
View::SignalSnapGridSize;
|
||||
if (y_snap != sig->get_v_offset()) {
|
||||
_moveFlag = true;
|
||||
sig->set_v_offset(y_snap);
|
||||
}
|
||||
// Ensure the signal is selected
|
||||
sig->select(true);
|
||||
} else {
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y > height())
|
||||
y = height();
|
||||
sig->set_zeroPos(y);
|
||||
sig->select(false);
|
||||
signals_moved();
|
||||
}
|
||||
// Ensure the signal is selected
|
||||
sig->select(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//signals_moved();
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -470,10 +561,9 @@ void Header::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
int action;
|
||||
|
||||
const boost::shared_ptr<Signal> s = get_mouse_over_signal(action, _mouse_point);
|
||||
const boost::shared_ptr<Signal> s = get_mSig(action, _mouse_point);
|
||||
|
||||
//if (!s || action != LABEL)
|
||||
if (!s || !s->selected() || action != LABEL)
|
||||
if (!s || !s->selected() || action != Signal::LABEL)
|
||||
return;
|
||||
|
||||
QMenu menu(this);
|
||||
|
||||
@@ -47,16 +47,7 @@ public:
|
||||
Header(View &parent);
|
||||
|
||||
private:
|
||||
static const int COLOR;
|
||||
static const int NAME;
|
||||
static const int POSTRIG;
|
||||
static const int HIGTRIG;
|
||||
static const int NEGTRIG;
|
||||
static const int LOWTRIG;
|
||||
static const int LABEL;
|
||||
|
||||
private:
|
||||
boost::shared_ptr<pv::view::Signal> get_mouse_over_signal(
|
||||
boost::shared_ptr<pv::view::Signal> get_mSig(
|
||||
int &action,
|
||||
const QPoint &pt);
|
||||
|
||||
@@ -65,13 +56,10 @@ private:
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent * event);
|
||||
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
void leaveEvent(QEvent *event);
|
||||
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
|
||||
void move(QMouseEvent *event);
|
||||
@@ -93,8 +81,11 @@ private slots:
|
||||
|
||||
signals:
|
||||
void signals_moved();
|
||||
|
||||
void header_updated();
|
||||
void vDial_changed(quint16);
|
||||
void hDial_changed(quint16);
|
||||
void acdc_changed(quint16);
|
||||
void ch_changed(quint16);
|
||||
|
||||
private:
|
||||
View &_view;
|
||||
|
||||
@@ -33,26 +33,67 @@
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
const int Signal::SquareWidth = 20;
|
||||
const int Signal::Margin = 5;
|
||||
|
||||
const int Signal::COLOR = 1;
|
||||
const int Signal::NAME = 2;
|
||||
const int Signal::POSTRIG = 3;
|
||||
const int Signal::HIGTRIG = 4;
|
||||
const int Signal::NEGTRIG = 5;
|
||||
const int Signal::LOWTRIG = 6;
|
||||
const int Signal::LABEL = 7;
|
||||
|
||||
const QColor Signal::dsBlue = QColor(17, 133, 209, 255);
|
||||
const QColor Signal::dsYellow = QColor(238, 178, 17, 255);
|
||||
const QColor Signal::dsRed = QColor(213, 15, 37, 255);
|
||||
const QColor Signal::dsGreen = QColor(0, 153, 37, 255);
|
||||
const QColor Signal::dsGray = QColor(0x88, 0x8A, 0x85, 100);
|
||||
const QColor Signal::dsDisable = QColor(0x88, 0x8A, 0x85, 200);
|
||||
const QColor Signal::dsActive = QColor(17, 133, 209, 255);
|
||||
const QColor Signal::dsLightBlue = QColor(17, 133, 209, 150);
|
||||
const QColor Signal::dsLightRed = QColor(213, 15, 37, 150);
|
||||
const QPen Signal::SignalAxisPen = QColor(128, 128, 128, 64);
|
||||
|
||||
const QPen Signal::SignalAxisPen(QColor(128, 128, 128, 64));
|
||||
const uint64_t Signal::vDialValue[Signal::vDialValueCount] = {
|
||||
5,
|
||||
10,
|
||||
20,
|
||||
50,
|
||||
100,
|
||||
200,
|
||||
500,
|
||||
1000,
|
||||
2000,
|
||||
5000,
|
||||
};
|
||||
const QString Signal::vDialUnit[Signal::vDialUnitCount] = {
|
||||
"mv",
|
||||
"v",
|
||||
};
|
||||
|
||||
const uint64_t Signal::hDialValue[Signal::hDialValueCount] = {
|
||||
10,
|
||||
20,
|
||||
50,
|
||||
100,
|
||||
200,
|
||||
500,
|
||||
1000,
|
||||
2000,
|
||||
5000,
|
||||
10000,
|
||||
20000,
|
||||
50000,
|
||||
100000,
|
||||
200000,
|
||||
500000,
|
||||
1000000,
|
||||
2000000,
|
||||
5000000,
|
||||
10000000,
|
||||
20000000,
|
||||
50000000,
|
||||
100000000,
|
||||
200000000,
|
||||
500000000,
|
||||
1000000000,
|
||||
};
|
||||
const QString Signal::hDialUnit[Signal::hDialUnitCount] = {
|
||||
"ns",
|
||||
"us",
|
||||
"ms",
|
||||
"s",
|
||||
};
|
||||
|
||||
Signal::Signal(QString name, int index, int type, int order) :
|
||||
_type(type),
|
||||
@@ -62,9 +103,37 @@ Signal::Signal(QString name, int index, int type, int order) :
|
||||
_v_offset(0),
|
||||
_signalHeight(30),
|
||||
_selected(false),
|
||||
_trig(0)
|
||||
_trig(0),
|
||||
_vDialActive(false),
|
||||
_hDialActive(false),
|
||||
_acCoupling(false),
|
||||
_active(true),
|
||||
_windowHeight(0)
|
||||
{
|
||||
_index_list.push_back(index);
|
||||
if (_type == DS_DSO) {
|
||||
QVector<uint64_t> vValue;
|
||||
QVector<QString> vUnit;
|
||||
QVector<uint64_t> hValue;
|
||||
QVector<QString> hUnit;
|
||||
for(quint64 i = 0; i < Signal::vDialValueCount; i++)
|
||||
vValue.append(Signal::vDialValue[i]);
|
||||
for(quint64 i = 0; i < Signal::vDialUnitCount; i++)
|
||||
vUnit.append(Signal::vDialUnit[i]);
|
||||
|
||||
for(quint64 i = 0; i < Signal::hDialValueCount; i++)
|
||||
hValue.append(Signal::hDialValue[i]);
|
||||
for(quint64 i = 0; i < Signal::hDialUnitCount; i++)
|
||||
hUnit.append(Signal::hDialUnit[i]);
|
||||
|
||||
_vDial = new dslDial(vDialValueCount, vDialValueStep, vValue, vUnit);
|
||||
_hDial = new dslDial(hDialValueCount, hDialValueStep, hValue, hUnit);
|
||||
_vDial->set_sel(0);
|
||||
_hDial->set_sel(0);
|
||||
|
||||
_trig_vpos = 0;
|
||||
_trig_en = true;
|
||||
}
|
||||
}
|
||||
|
||||
Signal::Signal(QString name, std::list<int> index_list, int type, int order, int sec_index) :
|
||||
@@ -76,8 +145,32 @@ Signal::Signal(QString name, std::list<int> index_list, int type, int order, int
|
||||
_v_offset(0),
|
||||
_signalHeight(30),
|
||||
_selected(false),
|
||||
_trig(0)
|
||||
_trig(0),
|
||||
_vDialActive(false),
|
||||
_hDialActive(false),
|
||||
_acCoupling(false),
|
||||
_active(true)
|
||||
{
|
||||
if (_type == DS_DSO) {
|
||||
QVector<uint64_t> vValue;
|
||||
QVector<QString> vUnit;
|
||||
QVector<uint64_t> hValue;
|
||||
QVector<QString> hUnit;
|
||||
for(quint64 i = 0; i < Signal::vDialValueCount; i++)
|
||||
vValue.append(Signal::vDialValue[i]);
|
||||
for(quint64 i = 0; i < Signal::vDialUnitCount; i++)
|
||||
vUnit.append(Signal::vDialUnit[i]);
|
||||
|
||||
for(quint64 i = 0; i < Signal::hDialValueCount; i++)
|
||||
hValue.append(Signal::hDialValue[i]);
|
||||
for(quint64 i = 0; i < Signal::hDialUnitCount; i++)
|
||||
hUnit.append(Signal::hDialUnit[i]);
|
||||
|
||||
_vDial = new dslDial(Signal::vDialValueCount, Signal::vDialValueStep, vValue, vUnit);
|
||||
_hDial = new dslDial(Signal::hDialValueCount, Signal::hDialValueStep, hValue, hUnit);
|
||||
_vDial->set_sel(0);
|
||||
_hDial->set_sel(0);
|
||||
}
|
||||
}
|
||||
|
||||
int Signal::get_type() const
|
||||
@@ -104,7 +197,7 @@ int Signal::get_leftWidth() const
|
||||
|
||||
int Signal::get_rightWidth() const
|
||||
{
|
||||
return 2 * Margin + 4 * SquareWidth + 1.5 * SquareWidth;
|
||||
return 2 * Margin + SquareNum * SquareWidth + 1.5 * SquareWidth;
|
||||
}
|
||||
|
||||
int Signal::get_headerHeight() const
|
||||
@@ -217,31 +310,174 @@ void Signal::set_trig(int trig)
|
||||
ds_trigger_probe_set(_index_list.front(), 'F', 'X');
|
||||
else if (trig == LOWTRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), '0', 'X');
|
||||
else if (trig == EDGETRIG)
|
||||
ds_trigger_probe_set(_index_list.front(), 'C', 'X');
|
||||
}
|
||||
|
||||
bool Signal::get_vDialActive() const
|
||||
{
|
||||
return _vDialActive;
|
||||
}
|
||||
|
||||
void Signal::set_vDialActive(bool active)
|
||||
{
|
||||
_vDialActive = active;
|
||||
}
|
||||
|
||||
bool Signal::go_vDialPre()
|
||||
{
|
||||
assert(_type == DS_DSO);
|
||||
|
||||
if (!_vDial->isMin()) {
|
||||
_vDial->set_sel(_vDial->get_sel() - 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Signal::go_vDialNext()
|
||||
{
|
||||
assert(_type == DS_DSO);
|
||||
|
||||
if (!_vDial->isMax()) {
|
||||
_vDial->set_sel(_vDial->get_sel() + 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Signal::get_hDialActive() const
|
||||
{
|
||||
return _hDialActive;
|
||||
}
|
||||
|
||||
void Signal::set_hDialActive(bool active)
|
||||
{
|
||||
_hDialActive = active;
|
||||
}
|
||||
|
||||
bool Signal::go_hDialPre()
|
||||
{
|
||||
assert(_type == DS_DSO);
|
||||
|
||||
if (!_hDial->isMin()) {
|
||||
_hDial->set_sel(_hDial->get_sel() - 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Signal::go_hDialNext()
|
||||
{
|
||||
assert(_type == DS_DSO);
|
||||
|
||||
if (!_hDial->isMax()) {
|
||||
_hDial->set_sel(_hDial->get_sel() + 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t Signal::get_vDialValue() const
|
||||
{
|
||||
return _vDial->get_value();
|
||||
}
|
||||
|
||||
uint64_t Signal::get_hDialValue() const
|
||||
{
|
||||
return _hDial->get_value();
|
||||
}
|
||||
|
||||
uint16_t Signal::get_vDialSel() const
|
||||
{
|
||||
return _vDial->get_sel();
|
||||
}
|
||||
|
||||
uint16_t Signal::get_hDialSel() const
|
||||
{
|
||||
return _hDial->get_sel();
|
||||
}
|
||||
|
||||
bool Signal::get_acCoupling() const
|
||||
{
|
||||
return _acCoupling;
|
||||
}
|
||||
|
||||
void Signal::set_acCoupling(bool coupling)
|
||||
{
|
||||
_acCoupling = coupling;
|
||||
}
|
||||
|
||||
bool Signal::get_active() const
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
void Signal::set_active(bool active)
|
||||
{
|
||||
_active = active;
|
||||
}
|
||||
|
||||
int Signal::get_zeroPos() const
|
||||
{
|
||||
return _zeroPos;
|
||||
}
|
||||
|
||||
void Signal::set_zeroPos(int pos)
|
||||
{
|
||||
_zeroPos = pos;
|
||||
}
|
||||
|
||||
int Signal::get_windowHeight() const
|
||||
{
|
||||
return _windowHeight;
|
||||
}
|
||||
|
||||
void Signal::set_windowHeight(int height)
|
||||
{
|
||||
_windowHeight = height;
|
||||
}
|
||||
|
||||
int Signal::get_trig_vpos() const
|
||||
{
|
||||
return _trig_vpos;
|
||||
}
|
||||
|
||||
void Signal::set_trig_vpos(int value)
|
||||
{
|
||||
_trig_vpos = value;
|
||||
}
|
||||
|
||||
void Signal::paint_label(QPainter &p, int y, int right, bool hover, int action)
|
||||
{
|
||||
compute_text_size(p);
|
||||
|
||||
const QRectF color_rect = get_rect("color", y, right);
|
||||
const QRectF name_rect = get_rect("name", y, right);
|
||||
const QRectF posTrig_rect = get_rect("posTrig", y, right);
|
||||
const QRectF higTrig_rect = get_rect("higTrig", y, right);
|
||||
const QRectF negTrig_rect = get_rect("negTrig", y, right);
|
||||
const QRectF lowTrig_rect = get_rect("lowTrig", y, right);
|
||||
const QRectF label_rect = get_rect("label", y, right);
|
||||
const QRectF label_rect = get_rect("label", (_type == DS_DSO) ? _zeroPos : y, right);
|
||||
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
// Paint the ColorButton
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(_colour);
|
||||
p.setBrush(_active ? _colour : dsDisable);
|
||||
p.drawRect(color_rect);
|
||||
|
||||
// Paint the signal name
|
||||
p.setPen(Qt::black);
|
||||
p.setPen(_active ? Qt::black : dsDisable);
|
||||
p.drawText(name_rect, Qt::AlignLeft | Qt::AlignVCenter, _name);
|
||||
|
||||
// Paint the trigButton
|
||||
if (_type == DS_LOGIC) {
|
||||
if (_type == DS_LOGIC) {
|
||||
const QRectF posTrig_rect = get_rect("posTrig", y, right);
|
||||
const QRectF higTrig_rect = get_rect("higTrig", y, right);
|
||||
const QRectF negTrig_rect = get_rect("negTrig", y, right);
|
||||
const QRectF lowTrig_rect = get_rect("lowTrig", y, right);
|
||||
const QRectF edgeTrig_rect = get_rect("edgeTrig", y, right);
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(((hover && action == POSTRIG) || (_trig == POSTRIG)) ?
|
||||
dsYellow :
|
||||
@@ -259,6 +495,10 @@ void Signal::paint_label(QPainter &p, int y, int right, bool hover, int action)
|
||||
dsYellow :
|
||||
dsBlue);
|
||||
p.drawRect(lowTrig_rect);
|
||||
p.setBrush(((hover && action == EDGETRIG) || (_trig == EDGETRIG)) ?
|
||||
dsYellow :
|
||||
dsBlue);
|
||||
p.drawRect(edgeTrig_rect);
|
||||
|
||||
p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
|
||||
p.setBrush(Qt::transparent);
|
||||
@@ -268,6 +508,8 @@ void Signal::paint_label(QPainter &p, int y, int right, bool hover, int action)
|
||||
higTrig_rect.right(), higTrig_rect.bottom() - 3);
|
||||
p.drawLine(negTrig_rect.right(), negTrig_rect.top() + 3,
|
||||
negTrig_rect.right(), negTrig_rect.bottom() - 3);
|
||||
p.drawLine(lowTrig_rect.right(), lowTrig_rect.top() + 3,
|
||||
lowTrig_rect.right(), lowTrig_rect.bottom() - 3);
|
||||
|
||||
p.setPen(QPen(Qt::white, 2, Qt::SolidLine));
|
||||
p.setBrush(Qt::transparent);
|
||||
@@ -290,6 +532,17 @@ void Signal::paint_label(QPainter &p, int y, int right, bool hover, int action)
|
||||
|
||||
p.drawLine(lowTrig_rect.left() + 5, lowTrig_rect.bottom() - 5,
|
||||
lowTrig_rect.right() - 5, lowTrig_rect.bottom() - 5);
|
||||
|
||||
p.drawLine(edgeTrig_rect.left() + 5, edgeTrig_rect.top() + 5,
|
||||
edgeTrig_rect.center().x() - 2, edgeTrig_rect.top() + 5);
|
||||
p.drawLine(edgeTrig_rect.center().x() + 2 , edgeTrig_rect.top() + 5,
|
||||
edgeTrig_rect.right() - 5, edgeTrig_rect.top() + 5);
|
||||
p.drawLine(edgeTrig_rect.center().x(), edgeTrig_rect.top() + 7,
|
||||
edgeTrig_rect.center().x(), edgeTrig_rect.bottom() - 7);
|
||||
p.drawLine(edgeTrig_rect.left() + 5, edgeTrig_rect.bottom() - 5,
|
||||
edgeTrig_rect.center().x() - 2, edgeTrig_rect.bottom() - 5);
|
||||
p.drawLine(edgeTrig_rect.center().x() + 2, edgeTrig_rect.bottom() - 5,
|
||||
edgeTrig_rect.right() - 5, edgeTrig_rect.bottom() - 5);
|
||||
} else if (_type == DS_GROUP || _type == DS_PROTOCOL) {
|
||||
const QRectF group_index_rect = get_rect("groupIndex", y, right);
|
||||
QString index_string;
|
||||
@@ -311,40 +564,92 @@ void Signal::paint_label(QPainter &p, int y, int right, bool hover, int action)
|
||||
}
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(group_index_rect, Qt::AlignRight | Qt::AlignVCenter, index_string);
|
||||
} else if (_type == DS_DSO) {
|
||||
const QRectF vDial_rect = get_rect("vDial", y, right);
|
||||
const QRectF hDial_rect = get_rect("hDial", y, right);
|
||||
const QRectF acdc_rect = get_rect("acdc", y, right);
|
||||
const QRectF chEn_rect = get_rect("chEn", y, right);
|
||||
|
||||
QColor vDial_color = _vDialActive ? dsActive : dsDisable;
|
||||
QColor hDial_color = _hDialActive ? dsActive : dsDisable;
|
||||
_vDial->paint(p, vDial_rect, vDial_color);
|
||||
_hDial->paint(p, hDial_rect, hDial_color);
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush((hover && action == CHEN) ? _colour.darker() : _colour);
|
||||
p.drawRect(chEn_rect);
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(chEn_rect, Qt::AlignCenter | Qt::AlignVCenter, _active ? "EN" : "DIS");
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(_active ? ((hover && action == ACDC) ? _colour.darker() : _colour) : dsDisable);
|
||||
p.drawRect(acdc_rect);
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(acdc_rect, Qt::AlignCenter | Qt::AlignVCenter, _acCoupling ? "AC" : "DC");
|
||||
}
|
||||
|
||||
// Paint the label
|
||||
const QPointF points[] = {
|
||||
label_rect.topLeft(),
|
||||
label_rect.topRight(),
|
||||
QPointF(right, y),
|
||||
label_rect.bottomRight(),
|
||||
label_rect.bottomLeft()
|
||||
};
|
||||
if (_active) {
|
||||
const QPointF points[] = {
|
||||
label_rect.topLeft(),
|
||||
label_rect.topRight(),
|
||||
QPointF(right, (_type == DS_DSO) ? _zeroPos : y),
|
||||
label_rect.bottomRight(),
|
||||
label_rect.bottomLeft()
|
||||
};
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(((hover && action == LABEL) || _selected) ? dsYellow : dsBlue);
|
||||
p.drawPolygon(points, countof(points));
|
||||
p.setPen(Qt::transparent);
|
||||
if (_type == DS_DSO)
|
||||
p.setBrush(((hover && action == LABEL) || _selected) ? _colour.darker() : _colour);
|
||||
else
|
||||
p.setBrush(((hover && action == LABEL) || _selected) ? dsYellow : dsBlue);
|
||||
p.drawPolygon(points, countof(points));
|
||||
|
||||
if ((hover && action == LABEL) || _selected) {
|
||||
p.setPen(QPen(dsBlue, 2, Qt::DotLine));
|
||||
p.setPen(QPen(Qt::blue, 1, Qt::DotLine));
|
||||
p.setBrush(Qt::transparent);
|
||||
p.drawPoint(label_rect.right(), label_rect.top() + 4);
|
||||
p.drawPoint(label_rect.right(), label_rect.top() + 8);
|
||||
p.drawPoint(label_rect.right(), label_rect.top() + 12);
|
||||
p.drawPoint(label_rect.right(), label_rect.top() + 16);
|
||||
}
|
||||
p.drawLine(label_rect.right(), label_rect.top() + 3,
|
||||
label_rect.right(), label_rect.bottom() - 3);
|
||||
|
||||
// Paint the text
|
||||
p.setPen(Qt::white);
|
||||
if (_type == DS_GROUP)
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "G");
|
||||
else if (_type == DS_ANALOG)
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "A");
|
||||
else if (_type == DS_PROTOCOL)
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "D");
|
||||
else
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(_index_list.front()));
|
||||
// Paint the text
|
||||
p.setPen(Qt::white);
|
||||
if (_type == DS_GROUP)
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "G");
|
||||
else if (_type == DS_ANALOG)
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "A");
|
||||
else if (_type == DS_PROTOCOL)
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "D");
|
||||
else
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(_index_list.front()));
|
||||
}
|
||||
}
|
||||
|
||||
void Signal::paint_trig(QPainter &p, int left, int right, bool hover)
|
||||
{
|
||||
if (_type == DS_DSO) {
|
||||
const QRectF label_rect = get_rect("dsoTrig", -1, right);
|
||||
// Paint the trig line
|
||||
if (_trig_en) {
|
||||
const QPointF points[] = {
|
||||
QPointF(right - label_rect.width()*1.5, _trig_vpos),
|
||||
label_rect.topLeft(),
|
||||
label_rect.topRight(),
|
||||
label_rect.bottomRight(),
|
||||
label_rect.bottomLeft()
|
||||
};
|
||||
|
||||
p.setPen(Qt::transparent);
|
||||
p.setBrush(_colour);
|
||||
p.drawPolygon(points, countof(points));
|
||||
|
||||
// paint the _trig_vpos line
|
||||
p.setPen(QPen(_colour, hover ? 2 : 1, Qt::DashLine));
|
||||
p.drawLine(left, _trig_vpos, right - label_rect.width()*1.5, _trig_vpos);
|
||||
|
||||
// Paint the text
|
||||
p.setPen(Qt::white);
|
||||
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, "T");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Signal::pt_in_rect(int y, int right, const QPoint &point)
|
||||
@@ -355,11 +660,17 @@ int Signal::pt_in_rect(int y, int right, const QPoint &point)
|
||||
const QRectF higTrig = get_rect("higTrig", y, right);
|
||||
const QRectF negTrig = get_rect("negTrig", y, right);
|
||||
const QRectF lowTrig = get_rect("lowTrig", y, right);
|
||||
const QRectF label = get_rect("label", y, right);
|
||||
const QRectF edgeTrig = get_rect("edgeTrig", y, right);
|
||||
const QRectF label = get_rect("label", (_type == DS_DSO) ? _zeroPos : y, right);
|
||||
const QRectF vDial = get_rect("vDial", y, right);
|
||||
const QRectF hDial = get_rect("hDial", y, right);
|
||||
const QRectF chEn = get_rect("chEn", y, right);
|
||||
const QRectF acdc = get_rect("acdc", y, right);
|
||||
const QRectF dsoTrig = get_rect("dsoTrig", 0, right);
|
||||
|
||||
if (color.contains(point))
|
||||
if (color.contains(point) && _active)
|
||||
return COLOR;
|
||||
else if (name.contains(point))
|
||||
else if (name.contains(point) && _active)
|
||||
return NAME;
|
||||
else if (posTrig.contains(point) && _type == DS_LOGIC)
|
||||
return POSTRIG;
|
||||
@@ -369,8 +680,20 @@ int Signal::pt_in_rect(int y, int right, const QPoint &point)
|
||||
return NEGTRIG;
|
||||
else if (lowTrig.contains(point) && _type == DS_LOGIC)
|
||||
return LOWTRIG;
|
||||
else if (label.contains(point))
|
||||
else if (edgeTrig.contains(point) && _type == DS_LOGIC)
|
||||
return EDGETRIG;
|
||||
else if (label.contains(point) && _active)
|
||||
return LABEL;
|
||||
else if (vDial.contains(point) && _type == DS_DSO && _active)
|
||||
return VDIAL;
|
||||
else if (hDial.contains(point) && _type == DS_DSO && _active)
|
||||
return HDIAL;
|
||||
else if (chEn.contains(point) && _type == DS_DSO)
|
||||
return CHEN;
|
||||
else if (acdc.contains(point) && _type == DS_DSO && _active)
|
||||
return ACDC;
|
||||
else if (dsoTrig.contains(point) && _type == DS_DSO && _active)
|
||||
return DSOTRIG;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -392,7 +715,8 @@ QRectF Signal::get_rect(const char *s, int y, int right)
|
||||
{
|
||||
const QSizeF color_size(SquareWidth, SquareWidth);
|
||||
const QSizeF name_size(right - get_leftWidth() - get_rightWidth(), SquareWidth);
|
||||
const QSizeF label_size(_text_size.width() + Margin, SquareWidth);
|
||||
//const QSizeF label_size(_text_size.width() + Margin, SquareWidth);
|
||||
const QSizeF label_size(SquareWidth, SquareWidth);
|
||||
|
||||
if (!strcmp(s, "name"))
|
||||
return QRectF(
|
||||
@@ -402,38 +726,68 @@ QRectF Signal::get_rect(const char *s, int y, int right)
|
||||
else if (!strcmp(s, "label"))
|
||||
return QRectF(
|
||||
right - 1.5f * label_size.width(),
|
||||
y - label_size.height() / 2,
|
||||
y - SquareWidth / 2,
|
||||
label_size.width(), label_size.height());
|
||||
else if (!strcmp(s, "posTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + Margin,
|
||||
y - color_size.height() / 2,
|
||||
color_size.width(), color_size.height());
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "higTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth + Margin,
|
||||
y - color_size.height() / 2,
|
||||
color_size.width(), color_size.height());
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "negTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 2 * SquareWidth + Margin,
|
||||
y - color_size.height() / 2,
|
||||
color_size.width(), color_size.height());
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "lowTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 3 * SquareWidth + Margin,
|
||||
y - color_size.height() / 2,
|
||||
color_size.width(), color_size.height());
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "edgeTrig"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + 4 * SquareWidth + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
else if (!strcmp(s, "groupIndex"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + Margin,
|
||||
y - color_size.height() / 2,
|
||||
color_size.width() * 4, color_size.height());
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * SquareNum, SquareWidth);
|
||||
else if (!strcmp(s, "vDial"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y - SquareWidth * SquareNum,
|
||||
SquareWidth * (SquareNum-1), SquareWidth * (SquareNum-1));
|
||||
else if (!strcmp(s, "hDial"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.5 + Margin,
|
||||
y + SquareWidth * 1.5,
|
||||
SquareWidth * (SquareNum-1), SquareWidth * (SquareNum-1));
|
||||
else if (!strcmp(s, "chEn"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*0.75 + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * 1.5, SquareWidth);
|
||||
else if (!strcmp(s, "acdc"))
|
||||
return QRectF(
|
||||
get_leftWidth() + name_size.width() + SquareWidth*2.75 + Margin,
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth * 1.5, SquareWidth);
|
||||
else if (!strcmp(s, "dsoTrig"))
|
||||
return QRectF(
|
||||
right - label_size.width(),
|
||||
_trig_vpos - SquareWidth / 2,
|
||||
label_size.width(), label_size.height());
|
||||
else
|
||||
return QRectF(
|
||||
2,
|
||||
y - color_size.height() / 2,
|
||||
color_size.width(), color_size.height());
|
||||
y - SquareWidth / 2,
|
||||
SquareWidth, SquareWidth);
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <list>
|
||||
|
||||
#include "libsigrok4DSLogic/libsigrok.h"
|
||||
#include "dsldial.h"
|
||||
|
||||
namespace pv {
|
||||
|
||||
@@ -56,26 +57,47 @@ namespace view {
|
||||
class Signal
|
||||
{
|
||||
private:
|
||||
static const int SquareWidth;
|
||||
static const int Margin;
|
||||
static const int SquareWidth = 20;
|
||||
static const int Margin = 3;
|
||||
static const int SquareNum = 5;
|
||||
|
||||
static const int COLOR;
|
||||
static const int NAME;
|
||||
static const int POSTRIG;
|
||||
static const int HIGTRIG;
|
||||
static const int NEGTRIG;
|
||||
static const int LOWTRIG;
|
||||
static const int LABEL;
|
||||
static const uint64_t vDialValueCount = 10;
|
||||
static const uint64_t vDialValueStep = 1000;
|
||||
static const uint64_t vDialUnitCount = 2;
|
||||
static const uint64_t hDialValueCount = 25;
|
||||
static const uint64_t hDialValueStep = 1000;
|
||||
static const uint64_t hDialUnitCount = 4;
|
||||
static const uint64_t vDialValue[vDialValueCount];
|
||||
static const QString vDialUnit[vDialUnitCount];
|
||||
|
||||
static const uint64_t hDialValue[hDialValueCount];
|
||||
static const QString hDialUnit[hDialUnitCount];
|
||||
|
||||
public:
|
||||
static const int COLOR = 1;
|
||||
static const int NAME = 2;
|
||||
static const int POSTRIG = 3;
|
||||
static const int HIGTRIG = 4;
|
||||
static const int NEGTRIG = 5;
|
||||
static const int LOWTRIG = 6;
|
||||
static const int EDGETRIG = 7;
|
||||
static const int LABEL = 8;
|
||||
static const int VDIAL = 9;
|
||||
static const int HDIAL = 10;
|
||||
static const int CHEN = 11;
|
||||
static const int ACDC = 12;
|
||||
static const int DSOTRIG = 13;
|
||||
|
||||
static const QColor dsBlue;
|
||||
static const QColor dsYellow;
|
||||
static const QColor dsRed;
|
||||
static const QColor dsGreen;
|
||||
static const QColor dsGray;
|
||||
static const QColor dsDisable;
|
||||
static const QColor dsActive;
|
||||
static const QColor dsLightBlue;
|
||||
static const QColor dsLightRed;
|
||||
static const QPen SignalAxisPen;
|
||||
static const QPen SignalAxisPen;
|
||||
|
||||
enum {DS_LOGIC = 0, DS_ANALOG, DS_GROUP, DS_PROTOCOL, DS_DSO};
|
||||
|
||||
@@ -166,6 +188,32 @@ public:
|
||||
int get_trig() const;
|
||||
void set_trig(int trig);
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
bool get_vDialActive() const;
|
||||
void set_vDialActive(bool active);
|
||||
bool get_hDialActive() const;
|
||||
void set_hDialActive(bool active);
|
||||
bool go_vDialPre();
|
||||
bool go_vDialNext();
|
||||
bool go_hDialPre();
|
||||
bool go_hDialNext();
|
||||
uint64_t get_vDialValue() const;
|
||||
uint64_t get_hDialValue() const;
|
||||
uint16_t get_vDialSel() const;
|
||||
uint16_t get_hDialSel() const;
|
||||
bool get_acCoupling() const;
|
||||
void set_acCoupling(bool coupling);
|
||||
bool get_active() const;
|
||||
void set_active(bool active);
|
||||
int get_zeroPos() const;
|
||||
void set_zeroPos(int pos);
|
||||
int get_windowHeight() const;
|
||||
void set_windowHeight(int height);
|
||||
void set_trig_vpos(int value);
|
||||
int get_trig_vpos() const;
|
||||
|
||||
/**
|
||||
* Paints the signal with a QPainter
|
||||
* @param p the QPainter to paint into.
|
||||
@@ -177,7 +225,7 @@ public:
|
||||
* the view in seconds.
|
||||
**/
|
||||
virtual void paint(QPainter &p, int y, int left, int right,
|
||||
double scale, double offset) = 0;
|
||||
double scale, double offset) = 0;
|
||||
|
||||
virtual const std::vector< std::pair<uint64_t, bool> > cur_edges() const = 0;
|
||||
|
||||
@@ -200,9 +248,12 @@ public:
|
||||
* area.
|
||||
* @param hover true if the label is being hovered over by the mouse.
|
||||
*/
|
||||
virtual void paint_label(QPainter &p, int y, int right,
|
||||
virtual void paint_label(QPainter &p, int y, int right,
|
||||
bool hover, int action);
|
||||
|
||||
virtual void paint_trig(QPainter &p, int left, int right,
|
||||
bool hover);
|
||||
|
||||
/**
|
||||
* Determines if a point is in the header rect.
|
||||
* 1 - in color rect
|
||||
@@ -221,6 +272,16 @@ public:
|
||||
int pt_in_rect(int y, int right,
|
||||
const QPoint &point);
|
||||
|
||||
/**
|
||||
* Computes the outline rectangle of a label.
|
||||
* @param p the QPainter to lay out text with.
|
||||
* @param y the y-coordinate of the signal.
|
||||
* @param right the x-coordinate of the right edge of the header
|
||||
* area.
|
||||
* @return Returns the rectangle of the signal label.
|
||||
*/
|
||||
QRectF get_rect(const char *s, int y, int right);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@@ -239,16 +300,6 @@ private:
|
||||
*/
|
||||
void compute_text_size(QPainter &p);
|
||||
|
||||
/**
|
||||
* Computes the outline rectangle of a label.
|
||||
* @param p the QPainter to lay out text with.
|
||||
* @param y the y-coordinate of the signal.
|
||||
* @param right the x-coordinate of the right edge of the header
|
||||
* area.
|
||||
* @return Returns the rectangle of the signal label.
|
||||
*/
|
||||
QRectF get_rect(const char *s, int y, int right);
|
||||
|
||||
protected:
|
||||
int _type;
|
||||
std::list<int> _index_list;
|
||||
@@ -266,6 +317,17 @@ protected:
|
||||
int _trig;
|
||||
|
||||
QSizeF _text_size;
|
||||
dslDial *_vDial;
|
||||
dslDial *_hDial;
|
||||
bool _vDialActive;
|
||||
bool _hDialActive;
|
||||
bool _acCoupling;
|
||||
bool _active;
|
||||
int _zeroPos;
|
||||
int _windowHeight;
|
||||
|
||||
int _trig_vpos;
|
||||
bool _trig_en;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
||||
@@ -105,6 +105,14 @@ View::View(SigSession &session, QWidget *parent) :
|
||||
this, SLOT(on_signals_moved()));
|
||||
connect(_header, SIGNAL(header_updated()),
|
||||
this, SLOT(header_updated()));
|
||||
connect(_header, SIGNAL(vDial_changed(quint16)),
|
||||
this, SLOT(vDial_changed(quint16)));
|
||||
connect(_header, SIGNAL(hDial_changed(quint16)),
|
||||
this, SLOT(hDial_changed(quint16)));
|
||||
connect(_header, SIGNAL(acdc_changed(quint16)),
|
||||
this, SLOT(acdc_changed(quint16)));
|
||||
connect(_header, SIGNAL(ch_changed(quint16)),
|
||||
this, SLOT(ch_changed(quint16)));
|
||||
|
||||
setViewportMargins(headerWidth(), RulerHeight, 0, 0);
|
||||
setViewport(_viewport);
|
||||
@@ -176,8 +184,20 @@ void View::zoom(double steps, int offset)
|
||||
_preOffset = _offset;
|
||||
|
||||
const double cursor_offset = _offset + _scale * offset;
|
||||
_scale *= pow(3.0/2.0, -steps);
|
||||
_scale = max(min(_scale, _maxscale), _minscale);
|
||||
if (_session.get_device()->mode != DSO) {
|
||||
_scale *= pow(3.0/2.0, -steps);
|
||||
_scale = max(min(_scale, _maxscale), _minscale);
|
||||
} else {
|
||||
const vector< shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
if (steps > 0.5) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
|
||||
s->go_hDialNext();
|
||||
} else if(steps < -0.5) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
|
||||
s->go_hDialPre();
|
||||
}
|
||||
_scale = sigs.at(0)->get_hDialValue() * pow(10, -9) * Viewport::NumSpanX / _viewport->width();
|
||||
}
|
||||
_offset = cursor_offset - _scale * offset;
|
||||
const double MinOffset = -(_scale * (_viewport->width() * (1 - MaxViewRate)));
|
||||
const double MaxOffset = _data_length * 1.0f / _session.get_last_sample_rate() -
|
||||
@@ -185,6 +205,7 @@ void View::zoom(double steps, int offset)
|
||||
_offset = max(min(_offset, MaxOffset), MinOffset);
|
||||
|
||||
if (_scale != _preScale || _offset != _preOffset) {
|
||||
_header->update();
|
||||
_ruler->update();
|
||||
_viewport->update();
|
||||
update_scroll();
|
||||
@@ -199,7 +220,9 @@ void View::set_scale_offset(double scale, double offset)
|
||||
_preScale = _scale;
|
||||
_preOffset = _offset;
|
||||
|
||||
_scale = max(min(scale, _maxscale), _minscale);
|
||||
if (_session.get_device()->mode != DSO)
|
||||
_scale = max(min(scale, _maxscale), _minscale);
|
||||
|
||||
const double MinOffset = -(_scale * (_viewport->width() * (1 - MaxViewRate)));
|
||||
const double MaxOffset = _data_length * 1.0f / _session.get_last_sample_rate()
|
||||
- _scale * (_viewport->width() * MaxViewRate);
|
||||
@@ -380,9 +403,11 @@ void View::reset_signal_layout()
|
||||
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
BOOST_FOREACH(boost::shared_ptr<Signal> s, sigs) {
|
||||
s->set_signalHeight(SignalHeight);
|
||||
s->set_windowHeight(_viewport->height());
|
||||
//s->set_v_offset(offset);
|
||||
//offset += SignalHeight + 2 * SignalMargin;
|
||||
s->set_v_offset(offset + s->get_order() * _spanY);
|
||||
s->set_zeroPos(_viewport->height()*0.5);
|
||||
}
|
||||
normalize_layout();
|
||||
}
|
||||
@@ -439,7 +464,7 @@ int View::headerWidth()
|
||||
int maxNameWidth = 0;
|
||||
int maxLeftWidth = 0;
|
||||
int maxRightWidth = 0;
|
||||
|
||||
|
||||
QFont font = QApplication::font();
|
||||
QFontMetrics fm(font);
|
||||
int fontWidth=fm.width("A");
|
||||
@@ -518,7 +543,8 @@ void View::data_updated()
|
||||
// Get the new data length
|
||||
_data_length = max(_session.get_total_sample_len(), (quint64)1000);
|
||||
_maxscale = (_data_length * 1.0f / _session.get_last_sample_rate()) / (_viewport->width() * MaxViewRate);
|
||||
_scale = min(_scale, _maxscale);
|
||||
if(_session.get_device()->mode != DSO)
|
||||
_scale = min(_scale, _maxscale);
|
||||
|
||||
setViewportMargins(headerWidth(), RulerHeight, 0, 0);
|
||||
update_margins();
|
||||
@@ -555,7 +581,9 @@ void View::sample_rate_changed(quint64 sample_rate)
|
||||
{
|
||||
assert(sample_rate > 0);
|
||||
|
||||
_scale = (1.0f / sample_rate) / WellPixelsPerSample;
|
||||
if (_session.get_device()->mode != DSO)
|
||||
_scale = (1.0f / sample_rate) / WellPixelsPerSample;
|
||||
|
||||
_minscale = (1.0f / sample_rate) / (_viewport->width() * MaxViewRate);
|
||||
_offset = 0;
|
||||
_preScale = _scale;
|
||||
@@ -574,7 +602,8 @@ void View::marker_time_changed()
|
||||
void View::on_signals_moved()
|
||||
{
|
||||
update_scroll();
|
||||
signals_moved();
|
||||
_viewport->update();
|
||||
//signals_moved();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -704,5 +733,39 @@ void View::on_state_changed(bool stop)
|
||||
_viewport->stop_trigger_timer();
|
||||
}
|
||||
|
||||
void View::vDial_changed(uint16_t channel)
|
||||
{
|
||||
if (channel == 0)
|
||||
_session.set_dso_ctrl(SR_CONF_VDIV0);
|
||||
else
|
||||
_session.set_dso_ctrl(SR_CONF_VDIV1);
|
||||
}
|
||||
|
||||
void View::hDial_changed(uint16_t channel)
|
||||
{
|
||||
const vector< shared_ptr<Signal> > sigs(_session.get_signals());
|
||||
_session.set_dso_ctrl(SR_CONF_TIMEBASE);
|
||||
_scale = sigs.at(channel)->get_hDialValue() * pow(10, -9) * Viewport::NumSpanX / _viewport->width();
|
||||
_ruler->update();
|
||||
_viewport->update();
|
||||
update_scroll();
|
||||
}
|
||||
|
||||
void View::acdc_changed(uint16_t channel)
|
||||
{
|
||||
if (channel == 0)
|
||||
_session.set_dso_ctrl(SR_CONF_COUPLING0);
|
||||
else
|
||||
_session.set_dso_ctrl(SR_CONF_COUPLING1);
|
||||
}
|
||||
|
||||
void View::ch_changed(uint16_t channel)
|
||||
{
|
||||
if (channel == 0)
|
||||
_session.set_dso_ctrl(SR_CONF_EN_CH0);
|
||||
else
|
||||
_session.set_dso_ctrl(SR_CONF_EN_CH1);
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
@@ -187,7 +187,8 @@ private:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
public slots:
|
||||
void set_measure_en(int enable);
|
||||
void set_measure_en(int enable);
|
||||
void hDial_changed(quint16 channel);
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -209,6 +210,10 @@ private slots:
|
||||
|
||||
void set_trig_pos(quint64 trig_pos);
|
||||
|
||||
void vDial_changed(quint16 channel);
|
||||
void acdc_changed(quint16 channel);
|
||||
void ch_changed(quint16 channel);
|
||||
|
||||
private:
|
||||
|
||||
SigSession &_session;
|
||||
|
||||
@@ -105,19 +105,19 @@ void Viewport::paintEvent(QPaintEvent *event)
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
if (_view.session().get_device()->mode == LOGIC) {
|
||||
switch(_view.session().get_capture_state()) {
|
||||
case SigSession::Init:
|
||||
break;
|
||||
switch(_view.session().get_capture_state()) {
|
||||
case SigSession::Init:
|
||||
break;
|
||||
|
||||
case SigSession::Stopped:
|
||||
paintSignals(p);
|
||||
break;
|
||||
case SigSession::Stopped:
|
||||
paintSignals(p);
|
||||
break;
|
||||
|
||||
case SigSession::Running:
|
||||
//p.setRenderHint(QPainter::Antialiasing);
|
||||
paintProgress(p);
|
||||
break;
|
||||
}
|
||||
case SigSession::Running:
|
||||
//p.setRenderHint(QPainter::Antialiasing);
|
||||
paintProgress(p);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
paintSignals(p);
|
||||
}
|
||||
@@ -161,8 +161,8 @@ void Viewport::paintEvent(QPaintEvent *event)
|
||||
p.setPen(Signal::dsGray);
|
||||
p.setPen(Qt::DotLine);
|
||||
|
||||
const double spanY =height() * 1.0f / 8;
|
||||
for (i = 1; i < 9; i++) {
|
||||
const double spanY =height() * 1.0f / 10;
|
||||
for (i = 1; i < 11; i++) {
|
||||
const double posY = spanY * i;
|
||||
p.drawLine(0, posY, width(), posY);
|
||||
const double miniSpanY = spanY / 5;
|
||||
@@ -210,8 +210,9 @@ void Viewport::paintSignals(QPainter &p)
|
||||
p.setRenderHint(QPainter::Antialiasing, false);
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
assert(s);
|
||||
s->paint(dbp, s->get_v_offset() - v_offset, 0, width(),
|
||||
_view.scale(), _view.offset());
|
||||
if (s->get_active())
|
||||
s->paint(dbp, ((s->get_type() == Signal::DS_DSO) ? s->get_zeroPos() + height()*0.5 : s->get_v_offset() - v_offset), 0, width(),
|
||||
_view.scale(), _view.offset());
|
||||
}
|
||||
// p.setRenderHint(QPainter::Antialiasing);
|
||||
// BOOST_FOREACH(const boost::shared_ptr<Signal> s, pro_sigs) {
|
||||
@@ -223,6 +224,13 @@ void Viewport::paintSignals(QPainter &p)
|
||||
}
|
||||
p.drawPixmap(0, 0, pixmap);
|
||||
|
||||
// plot trig line in DSO mode
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
assert(s);
|
||||
if (s->get_active() && s->get_type() == Signal::DS_DSO)
|
||||
s->paint_trig(p, 0, width(), qAbs(_mouse_point.y() - s->get_trig_vpos()) <= HitCursorMargin );
|
||||
}
|
||||
|
||||
// plot cursors
|
||||
if (_view.cursors_shown()) {
|
||||
list<Cursor*>::iterator i = _view.get_cursorList().begin();
|
||||
@@ -391,6 +399,20 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
||||
// if (!_view.get_ruler()->get_grabbed_cursor()) {
|
||||
// _zoom_rect_visible = true;
|
||||
// }
|
||||
|
||||
const vector< shared_ptr<Signal> > sigs(_view.session().get_signals());
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
assert(s);
|
||||
if (s->get_active() &&
|
||||
s->get_type() == Signal::DS_DSO &&
|
||||
qAbs(_mouse_point.y() - s->get_trig_vpos()) <= HitCursorMargin) {
|
||||
if (_drag_sig)
|
||||
_drag_sig.reset();
|
||||
else
|
||||
_drag_sig = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -398,7 +420,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
||||
void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
assert(event);
|
||||
|
||||
_mouse_point = event->pos();
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
_zoom_rect = QRectF(_mouse_down_point, event->pos());
|
||||
_zoom_rect_visible = true;
|
||||
@@ -409,16 +431,35 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
_mouse_down_offset +
|
||||
(_mouse_down_point - event->pos()).x() *
|
||||
_view.scale());
|
||||
|
||||
measure();
|
||||
}
|
||||
|
||||
if (!(event->buttons() || Qt::NoButton)) {
|
||||
if (_drag_sig) {
|
||||
uint16_t trig_value = 0;
|
||||
int vpos = _mouse_point.y();
|
||||
if (vpos < 0)
|
||||
vpos = 0;
|
||||
else if (vpos > height())
|
||||
vpos = height();
|
||||
_drag_sig->set_trig_vpos(vpos);
|
||||
|
||||
const vector< shared_ptr<Signal> > sigs(_view.session().get_signals());
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
assert(s);
|
||||
if (s->get_active() &&
|
||||
s->get_type() == Signal::DS_DSO) {
|
||||
trig_value += (((uint16_t)(255 - s->get_trig_vpos()*1.0/height()*255)) << 8*s->get_index());
|
||||
}
|
||||
}
|
||||
sr_config_set(_view.session().get_device(),
|
||||
SR_CONF_TRIGGER_VALUE, g_variant_new_uint16(trig_value));
|
||||
}
|
||||
|
||||
TimeMarker* grabbed_marker = _view.get_ruler()->get_grabbed_cursor();
|
||||
if (_view.cursors_shown() && grabbed_marker) {
|
||||
grabbed_marker->set_time(_view.offset() + _view.hover_point().x() * _view.scale());
|
||||
}
|
||||
|
||||
measure();
|
||||
}
|
||||
|
||||
@@ -472,6 +513,7 @@ void Viewport::wheelEvent(QWheelEvent *event)
|
||||
void Viewport::leaveEvent(QEvent *)
|
||||
{
|
||||
_measure_shown = false;
|
||||
_mouse_point = QPoint(-1, -1);
|
||||
//_view.show_cursors(false);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
#ifndef DSLOGIC_PV_VIEW_VIEWPORT_H
|
||||
#define DSLOGIC_PV_VIEW_VIEWPORT_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
#include <stdint.h>
|
||||
@@ -35,13 +38,14 @@ class SigSession;
|
||||
namespace pv {
|
||||
namespace view {
|
||||
|
||||
class Signal;
|
||||
class View;
|
||||
|
||||
class Viewport : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
public:
|
||||
static const int HitCursorMargin;
|
||||
static const int NumSpanY;
|
||||
static const int NumMiniSpanY;
|
||||
@@ -88,6 +92,7 @@ private:
|
||||
View &_view;
|
||||
|
||||
quint64 _total_receive_len;
|
||||
QPoint _mouse_point;
|
||||
QPoint _mouse_down_point;
|
||||
double _mouse_down_offset;
|
||||
double _curScale;
|
||||
@@ -115,6 +120,8 @@ private:
|
||||
QTimer trigger_timer;
|
||||
bool triggered;
|
||||
int timer_cnt;
|
||||
|
||||
boost::shared_ptr<Signal> _drag_sig;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
||||
Reference in New Issue
Block a user