Commit 9d871219 authored by DreamSourceLab's avatar DreamSourceLab

add horizontal&vertical measure function @ DSO mode

parent 618f7c92
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
#include "../view/logicsignal.h" #include "../view/logicsignal.h"
#include "../data/signaldata.h" #include "../data/signaldata.h"
#include "../data/snapshot.h" #include "../data/snapshot.h"
#include "../devicemanager.h"
#include "../device/device.h"
#include "../device/file.h"
#include <QObject> #include <QObject>
#include <QPainter> #include <QPainter>
...@@ -64,21 +67,19 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) : ...@@ -64,21 +67,19 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) :
_duty_label = new QLabel("#####", _widget); _duty_label = new QLabel("#####", _widget);
_mouse_layout = new QGridLayout(); _mouse_layout = new QGridLayout();
_mouse_layout->addWidget(_fen_checkBox, 0, 0, 1, 2); _mouse_layout->addWidget(_fen_checkBox, 0, 0, 1, 4);
_mouse_layout->addWidget(new QLabel(tr("Width: "), _widget), 1, 0); _mouse_layout->addWidget(new QLabel(tr("W: "), _widget), 1, 0);
_mouse_layout->addWidget(_width_label, 1, 1); _mouse_layout->addWidget(_width_label, 1, 1);
_mouse_layout->addWidget(new QLabel(tr("Period: "), _widget), 2, 0); _mouse_layout->addWidget(new QLabel(tr("P: "), _widget), 1, 2);
_mouse_layout->addWidget(_period_label, 2, 1); _mouse_layout->addWidget(_period_label, 1, 3);
_mouse_layout->addWidget(new QLabel(tr("Frequency: "), _widget), 3, 0); _mouse_layout->addWidget(new QLabel(tr("F: "), _widget), 2, 2);
_mouse_layout->addWidget(_freq_label, 3, 1); _mouse_layout->addWidget(_freq_label, 2, 3);
_mouse_layout->addWidget(new QLabel(tr("Duty Cycle: "), _widget), 4, 0); _mouse_layout->addWidget(new QLabel(tr("D: "), _widget), 2, 0);
_mouse_layout->addWidget(_duty_label, 4, 1); _mouse_layout->addWidget(_duty_label, 2, 1);
_mouse_layout->addWidget(new QLabel(_widget), 0, 2); _mouse_layout->addWidget(new QLabel(_widget), 0, 4);
_mouse_layout->addWidget(new QLabel(_widget), 1, 2); _mouse_layout->addWidget(new QLabel(_widget), 1, 4);
_mouse_layout->addWidget(new QLabel(_widget), 2, 2); _mouse_layout->addWidget(new QLabel(_widget), 2, 4);
_mouse_layout->addWidget(new QLabel(_widget), 3, 2); _mouse_layout->setColumnStretch(5, 1);
_mouse_layout->addWidget(new QLabel(_widget), 4, 2);
_mouse_layout->setColumnStretch(2, 1);
_mouse_groupBox->setLayout(_mouse_layout); _mouse_groupBox->setLayout(_mouse_layout);
...@@ -86,12 +87,9 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) : ...@@ -86,12 +87,9 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) :
_t1_comboBox = new QComboBox(_widget); _t1_comboBox = new QComboBox(_widget);
_t2_comboBox = new QComboBox(_widget); _t2_comboBox = new QComboBox(_widget);
_t3_comboBox = new QComboBox(_widget); _t3_comboBox = new QComboBox(_widget);
_delta_label_t1t2 = new QLabel("#####", _widget); _delta_label_t1t2 = new QLabel("##########/##########", _widget);
_cnt_label_t1t2 = new QLabel("#####", _widget); _delta_label_t2t3 = new QLabel("##########/##########", _widget);
_delta_label_t2t3 = new QLabel("#####", _widget); _delta_label_t1t3 = new QLabel("##########/##########", _widget);
_cnt_label_t2t3 = new QLabel("#####", _widget);
_delta_label_t1t3 = new QLabel("#####", _widget);
_cnt_label_t1t3 = new QLabel("#####", _widget);
_t1_last_index = 0; _t1_last_index = 0;
_t2_last_index = 0; _t2_last_index = 0;
_t3_last_index = 0; _t3_last_index = 0;
...@@ -104,31 +102,25 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) : ...@@ -104,31 +102,25 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) :
_cursor_layout->addWidget(new QLabel(tr("T3: "), _widget), 2, 0); _cursor_layout->addWidget(new QLabel(tr("T3: "), _widget), 2, 0);
_cursor_layout->addWidget(_t3_comboBox, 2, 1); _cursor_layout->addWidget(_t3_comboBox, 2, 1);
_cursor_layout->addWidget(new QLabel(tr("|T2 - T1|: "), _widget), 3, 0); _cursor_layout->addWidget(new QLabel(tr("Time/Samples"), _widget), 3, 1, 1, 2);
_cursor_layout->addWidget(_delta_label_t1t2, 3, 1); _cursor_layout->addWidget(new QLabel(tr("|T2 - T1|: "), _widget), 4, 0);
_cursor_layout->addWidget(new QLabel(tr("Delta Samples: "), _widget), 3, 2); _cursor_layout->addWidget(_delta_label_t1t2, 4, 1, 1, 2);
_cursor_layout->addWidget(_cnt_label_t1t2, 3, 3);
_cursor_layout->addWidget(new QLabel(tr("|T3 - T2|: "), _widget), 4, 0); _cursor_layout->addWidget(new QLabel(tr("|T3 - T2|: "), _widget), 5, 0);
_cursor_layout->addWidget(_delta_label_t2t3, 4, 1); _cursor_layout->addWidget(_delta_label_t2t3, 5, 1, 1, 2);
_cursor_layout->addWidget(new QLabel(tr("Delta Samples: "), _widget), 4, 2);
_cursor_layout->addWidget(_cnt_label_t2t3, 4, 3);
_cursor_layout->addWidget(new QLabel(tr("|T3 - T1|: "), _widget), 5, 0); _cursor_layout->addWidget(new QLabel(tr("|T3 - T1|: "), _widget), 6, 0);
_cursor_layout->addWidget(_delta_label_t1t3, 5, 1); _cursor_layout->addWidget(_delta_label_t1t3, 6, 1, 1, 2);
_cursor_layout->addWidget(new QLabel(tr("Delta Samples: "), _widget), 5, 2);
_cursor_layout->addWidget(_cnt_label_t1t3, 5, 3);
_cursor_layout->addWidget(new QLabel(tr("Cursors"), _widget), 6, 0); _cursor_layout->addWidget(new QLabel(_widget), 7, 0);
_cursor_layout->addWidget(new QLabel(tr("Time/Samples"), _widget), 6, 1, 1, 4); _cursor_layout->addWidget(new QLabel(tr("Cursors"), _widget), 8, 0);
_cursor_layout->addWidget(new QLabel(tr("Time/Samples"), _widget), 8, 1, 1, 2);
_cursor_layout->addWidget(new QLabel(_widget), 0, 4); _cursor_layout->addWidget(new QLabel(_widget), 0, 2);
_cursor_layout->addWidget(new QLabel(_widget), 1, 4); _cursor_layout->addWidget(new QLabel(_widget), 1, 2);
_cursor_layout->addWidget(new QLabel(_widget), 2, 4); _cursor_layout->addWidget(new QLabel(_widget), 2, 2);
_cursor_layout->addWidget(new QLabel(_widget), 3, 4); _cursor_layout->setColumnStretch(2, 1);
_cursor_layout->addWidget(new QLabel(_widget), 4, 4);
_cursor_layout->setColumnStretch(4, 1);
_cursor_groupBox->setLayout(_cursor_layout); _cursor_groupBox->setLayout(_cursor_layout);
QVBoxLayout *layout = new QVBoxLayout(_widget); QVBoxLayout *layout = new QVBoxLayout(_widget);
...@@ -205,9 +197,8 @@ void MeasureDock::cursor_update() ...@@ -205,9 +197,8 @@ void MeasureDock::cursor_update()
_curpos_label_list.push_back(_curpos_label); _curpos_label_list.push_back(_curpos_label);
_space_label_list.push_back(_space_label); _space_label_list.push_back(_space_label);
_cursor_layout->addWidget(_cursor_pushButton, 6 + index, 0); _cursor_layout->addWidget(_cursor_pushButton, 8 + index, 0);
_cursor_layout->addWidget(_curpos_label, 6 + index, 1, 1, 4); _cursor_layout->addWidget(_curpos_label, 8 + index, 1, 1, 2);
_cursor_layout->addWidget(_space_label, 6 + index, 2);
connect(_cursor_pushButton, SIGNAL(clicked()), this, SLOT(goto_cursor())); connect(_cursor_pushButton, SIGNAL(clicked()), this, SLOT(goto_cursor()));
...@@ -255,28 +246,32 @@ void MeasureDock::cursor_moved() ...@@ -255,28 +246,32 @@ void MeasureDock::cursor_moved()
void MeasureDock::delta_update() void MeasureDock::delta_update()
{ {
QString delta_text;
_t1_last_index = std::max(_t1_comboBox->currentIndex(), 0); _t1_last_index = std::max(_t1_comboBox->currentIndex(), 0);
_t2_last_index = std::max(_t2_comboBox->currentIndex(), 0); _t2_last_index = std::max(_t2_comboBox->currentIndex(), 0);
_t3_last_index = std::max(_t3_comboBox->currentIndex(), 0); _t3_last_index = std::max(_t3_comboBox->currentIndex(), 0);
if (_t1_comboBox->count() != 0 && _t2_comboBox->count() != 0) { if (_t1_comboBox->count() != 0 && _t2_comboBox->count() != 0) {
uint64_t delta = abs(_view.get_cursor_samples(_t1_last_index) - uint64_t delta = abs(_view.get_cursor_samples(_t1_last_index) -
_view.get_cursor_samples(_t2_last_index)); _view.get_cursor_samples(_t2_last_index));
_delta_label_t1t2->setText(_view.get_cm_delta(_t1_last_index, _t2_last_index)); delta_text = _view.get_cm_delta(_t1_last_index, _t2_last_index) +
_cnt_label_t1t2->setText(QString::number(delta)); "/" + QString::number(delta);
_delta_label_t1t2->setText(delta_text);
} }
if (_t2_comboBox->count() != 0 && _t2_comboBox->count() != 0) { if (_t2_comboBox->count() != 0 && _t2_comboBox->count() != 0) {
uint64_t delta = abs(_view.get_cursor_samples(_t2_last_index) - uint64_t delta = abs(_view.get_cursor_samples(_t2_last_index) -
_view.get_cursor_samples(_t3_last_index)); _view.get_cursor_samples(_t3_last_index));
_delta_label_t2t3->setText(_view.get_cm_delta(_t2_last_index, _t3_last_index)); delta_text = _view.get_cm_delta(_t2_last_index, _t3_last_index) +
_cnt_label_t2t3->setText(QString::number(delta)); "/" + QString::number(delta);
_delta_label_t2t3->setText(delta_text);
} }
if (_t1_comboBox->count() != 0 && _t3_comboBox->count() != 0) { if (_t1_comboBox->count() != 0 && _t3_comboBox->count() != 0) {
uint64_t delta = abs(_view.get_cursor_samples(_t1_last_index) - uint64_t delta = abs(_view.get_cursor_samples(_t1_last_index) -
_view.get_cursor_samples(_t3_last_index)); _view.get_cursor_samples(_t3_last_index));
_delta_label_t1t3->setText(_view.get_cm_delta(_t1_last_index, _t3_last_index)); delta_text = _view.get_cm_delta(_t1_last_index, _t3_last_index) +
_cnt_label_t1t3->setText(QString::number(delta)); "/" + QString::number(delta);
_delta_label_t1t3->setText(delta_text);
} }
} }
......
...@@ -65,7 +65,6 @@ public: ...@@ -65,7 +65,6 @@ public:
~MeasureDock(); ~MeasureDock();
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
signals: signals:
private slots: private slots:
......
...@@ -206,7 +206,7 @@ void MainWindow::setup_ui() ...@@ -206,7 +206,7 @@ void MainWindow::setup_ui()
_measure_dock->setFeatures(QDockWidget::DockWidgetMovable); _measure_dock->setFeatures(QDockWidget::DockWidgetMovable);
_measure_dock->setAllowedAreas(Qt::RightDockWidgetArea); _measure_dock->setAllowedAreas(Qt::RightDockWidgetArea);
_measure_dock->setVisible(false); _measure_dock->setVisible(false);
dock::MeasureDock *_measure_widget = new dock::MeasureDock(_measure_dock, *_view, _session); _measure_widget = new dock::MeasureDock(_measure_dock, *_view, _session);
_measure_dock->setWidget(_measure_widget); _measure_dock->setWidget(_measure_widget);
// search dock // search dock
_search_dock=new QDockWidget(tr("Search..."), this); _search_dock=new QDockWidget(tr("Search..."), this);
......
...@@ -165,6 +165,7 @@ private: ...@@ -165,6 +165,7 @@ private:
dock::TriggerDock *_trigger_widget; dock::TriggerDock *_trigger_widget;
dock::DsoTriggerDock *_dso_trigger_widget; dock::DsoTriggerDock *_dso_trigger_widget;
QDockWidget *_measure_dock; QDockWidget *_measure_dock;
dock::MeasureDock *_measure_widget;
QDockWidget *_search_dock; QDockWidget *_search_dock;
dock::SearchDock * _search_widget; dock::SearchDock * _search_widget;
......
...@@ -278,7 +278,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) ...@@ -278,7 +278,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right)
const QRect r(left + ArrowSize * 2, y - row_height / 2, const QRect r(left + ArrowSize * 2, y - row_height / 2,
right - left, row_height); right - left, row_height);
const QString h(_cur_row_headings[i]); const QString h(_cur_row_headings[i]);
const int f = Qt::AlignLeft | Qt::AlignVCenter | const int f = Qt::AlignLeft | Qt::AlignBottom |
Qt::TextDontClip; Qt::TextDontClip;
// Draw the outline // Draw the outline
......
...@@ -198,6 +198,11 @@ void DsoSignal::set_scale(float scale) ...@@ -198,6 +198,11 @@ void DsoSignal::set_scale(float scale)
_scale = scale; _scale = scale;
} }
float DsoSignal::get_scale()
{
return _scale;
}
void DsoSignal::set_enable(bool enable) void DsoSignal::set_enable(bool enable)
{ {
if ((strcmp(_dev_inst->dev_inst()->driver->name, "DSLogic") == 0) && if ((strcmp(_dev_inst->dev_inst()->driver->name, "DSLogic") == 0) &&
...@@ -845,7 +850,9 @@ void DsoSignal::paint_trace(QPainter &p, ...@@ -845,7 +850,9 @@ void DsoSignal::paint_trace(QPainter &p,
const uint8_t *const samples = snapshot->get_samples(start, end, get_index()); const uint8_t *const samples = snapshot->get_samples(start, end, get_index());
assert(samples); assert(samples);
p.setPen(_colour); QColor trace_colour = _colour;
trace_colour.setAlpha(100);
p.setPen(trace_colour);
//p.setPen(QPen(_colour, 3, Qt::SolidLine)); //p.setPen(QPen(_colour, 3, Qt::SolidLine));
QPointF *points = new QPointF[sample_count]; QPointF *points = new QPointF[sample_count];
...@@ -899,7 +906,9 @@ void DsoSignal::paint_envelope(QPainter &p, ...@@ -899,7 +906,9 @@ void DsoSignal::paint_envelope(QPainter &p,
p.setPen(QPen(NoPen)); p.setPen(QPen(NoPen));
//p.setPen(QPen(_colour, 2, Qt::SolidLine)); //p.setPen(QPen(_colour, 2, Qt::SolidLine));
p.setBrush(_colour); QColor envelope_colour = _colour;
envelope_colour.setAlpha(150);
p.setBrush(envelope_colour);
QRectF *const rects = new QRectF[e.length]; QRectF *const rects = new QRectF[e.length];
QRectF *rect = rects; QRectF *rect = rects;
...@@ -1019,7 +1028,9 @@ void DsoSignal::paint_measure(QPainter &p) ...@@ -1019,7 +1028,9 @@ void DsoSignal::paint_measure(QPainter &p)
abs(_period) > 1000 ? QString::number(_period/1000, 'f', 2) + "uS" : QString::number(_period, 'f', 2) + "nS"; abs(_period) > 1000 ? QString::number(_period/1000, 'f', 2) + "uS" : QString::number(_period, 'f', 2) + "nS";
QString freq_string = abs(_period) > 1000000 ? QString::number(1000000000/_period, 'f', 2) + "Hz" : QString freq_string = abs(_period) > 1000000 ? QString::number(1000000000/_period, 'f', 2) + "Hz" :
abs(_period) > 1000 ? QString::number(1000000/_period, 'f', 2) + "kHz" : QString::number(1000/_period, 'f', 2) + "MHz"; abs(_period) > 1000 ? QString::number(1000000/_period, 'f', 2) + "kHz" : QString::number(1000/_period, 'f', 2) + "MHz";
p.setPen(_colour); QColor measure_colour = _colour;
measure_colour.setAlpha(180);
p.setPen(measure_colour);
p.drawText(QRectF(0, 100*index + UpMargin, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Max: ")+max_string+" "); p.drawText(QRectF(0, 100*index + UpMargin, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Max: ")+max_string+" ");
p.drawText(QRectF(0, 100*index + UpMargin + 20, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Min: ")+min_string+" "); p.drawText(QRectF(0, 100*index + UpMargin + 20, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Min: ")+min_string+" ");
p.drawText(QRectF(0, 100*index + UpMargin + 40, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Period: ")+period_string+" "); p.drawText(QRectF(0, 100*index + UpMargin + 40, get_view_rect().width()*0.9, 20), Qt::AlignRight | Qt::AlignVCenter, tr("Period: ")+period_string+" ");
......
...@@ -73,6 +73,7 @@ public: ...@@ -73,6 +73,7 @@ public:
void set_view(pv::view::View *view); void set_view(pv::view::View *view);
void set_scale(float scale); void set_scale(float scale);
float get_scale();
/** /**
* *
......
...@@ -43,7 +43,7 @@ const QColor Trace::dsRed = QColor(213, 15, 37, 255); ...@@ -43,7 +43,7 @@ const QColor Trace::dsRed = QColor(213, 15, 37, 255);
const QColor Trace::dsGreen = QColor(0, 153, 37, 200); const QColor Trace::dsGreen = QColor(0, 153, 37, 200);
const QColor Trace::dsGray = QColor(0x88, 0x8A, 0x85, 60); const QColor Trace::dsGray = QColor(0x88, 0x8A, 0x85, 60);
const QColor Trace::dsFore = QColor(0xff, 0xff, 0xff, 100); const QColor Trace::dsFore = QColor(0xff, 0xff, 0xff, 100);
const QColor Trace::dsBack = QColor(0x16, 0x18, 0x23, 255); const QColor Trace::dsBack = QColor(0x16, 0x18, 0x23, 180);
const QColor Trace::dsDisable = QColor(0x88, 0x8A, 0x85, 200); const QColor Trace::dsDisable = QColor(0x88, 0x8A, 0x85, 200);
const QColor Trace::dsActive = QColor(17, 133, 209, 255); const QColor Trace::dsActive = QColor(17, 133, 209, 255);
const QColor Trace::dsLightBlue = QColor(17, 133, 209, 150); const QColor Trace::dsLightBlue = QColor(17, 133, 209, 150);
......
...@@ -785,6 +785,21 @@ int View::get_view_width() ...@@ -785,6 +785,21 @@ int View::get_view_width()
return view_width; return view_width;
} }
int View::get_view_height()
{
int view_height = 0;
if (_session.get_device()->dev_inst()->mode == DSO) {
const vector< boost::shared_ptr<Signal> > sigs(_session.get_signals());
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
view_height = max((double)view_height, s->get_view_rect().height());
}
} else {
view_height = _viewport->width();
}
return view_height;
}
double View::get_min_offset() double View::get_min_offset()
{ {
return -(_scale * (get_view_width() * (1 - MaxViewRate))); return -(_scale * (get_view_width() * (1 - MaxViewRate)));
......
...@@ -175,6 +175,7 @@ public: ...@@ -175,6 +175,7 @@ public:
void on_state_changed(bool stop); void on_state_changed(bool stop);
int get_view_width(); int get_view_width();
int get_view_height();
void update_sample(bool instant); void update_sample(bool instant);
......
This diff is collapsed.
...@@ -51,8 +51,14 @@ public: ...@@ -51,8 +51,14 @@ public:
static const double HitCursorTimeMargin; static const double HitCursorTimeMargin;
static const int DragTimerInterval = 100; static const int DragTimerInterval = 100;
static const int MinorDragOffsetUp = 100; static const int MinorDragOffsetUp = 100;
static const int DsoMeasureStages = 3;
static const double MinorDragRateUp; static const double MinorDragRateUp;
static const double DragDamping; static const double DragDamping;
enum MeasureType {
NO_MEASURE,
LOGIC_FREQ,
DSO_FREQ
};
public: public:
explicit Viewport(View &parent); explicit Viewport(View &parent);
...@@ -133,10 +139,25 @@ private: ...@@ -133,10 +139,25 @@ private:
uint64_t _hover_index; uint64_t _hover_index;
bool _hover_hit; bool _hover_hit;
uint16_t _hover_sig_index;
double _hover_sig_value;
QTime _time; QTime _time;
QTimer _drag_timer; QTimer _drag_timer;
int _drag_strength; int _drag_strength;
bool _dso_xm;
int _dso_xm_stage;
int _dso_xm_y;
uint64_t _dso_xm_index[DsoMeasureStages];
bool _dso_ym;
bool _dso_ym_done;
uint16_t _dso_ym_sig_index;
double _dso_ym_sig_value;
uint64_t _dso_ym_index;
int _dso_ym_start;
int _dso_ym_end;
}; };
} // namespace view } // namespace view
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment