forked from Ivasoft/DSView
update: the cursor key type change to uint64
This commit is contained in:
@@ -53,6 +53,8 @@ namespace dialogs {
|
||||
DecoderOptionsDlg::DecoderOptionsDlg(QWidget *parent)
|
||||
:DSDialog(parent)
|
||||
{
|
||||
_cursor1 = 0;
|
||||
_cursor2 = 0;
|
||||
}
|
||||
|
||||
DecoderOptionsDlg::~DecoderOptionsDlg()
|
||||
@@ -126,9 +128,9 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace)
|
||||
{
|
||||
int num = 1;
|
||||
for (auto c : view->get_cursorList()){
|
||||
QString curCursor = tr("Cursor") + QString::number(num);
|
||||
_start_comboBox->addItem(curCursor, QVariant(c->get_key()));
|
||||
_end_comboBox->addItem(curCursor, QVariant(c->get_key()));
|
||||
QString curCursor = tr("Cursor ") + QString::number(num);
|
||||
_start_comboBox->addItem(curCursor, QVariant((quint64)c->get_key()));
|
||||
_end_comboBox->addItem(curCursor, QVariant((quint64)c->get_key()));
|
||||
|
||||
if (c->get_key() == _cursor1)
|
||||
dex1 = num;
|
||||
@@ -140,18 +142,9 @@ void DecoderOptionsDlg::load_options(view::DecodeTrace *trace)
|
||||
}
|
||||
|
||||
if (dex1 == 0)
|
||||
_cursor1 = "";
|
||||
_cursor1 = 0;
|
||||
if (dex2 == 0)
|
||||
_cursor2 = "";
|
||||
|
||||
if (dex1 > dex2 && false){
|
||||
int tmp = dex1;
|
||||
dex1 = dex2;
|
||||
dex2 = tmp;
|
||||
QString tmp_s = _cursor1;
|
||||
_cursor1 = _cursor2;
|
||||
_cursor1 = tmp_s;
|
||||
}
|
||||
_cursor2 = 0;
|
||||
|
||||
_start_comboBox->setCurrentIndex(dex1);
|
||||
_end_comboBox->setCurrentIndex(dex2);
|
||||
@@ -280,33 +273,33 @@ void DecoderOptionsDlg::update_decode_range()
|
||||
|
||||
if (index1 == 0) {
|
||||
decode_start = 0;
|
||||
_cursor1 = "";
|
||||
_cursor1 = 0;
|
||||
|
||||
} else {
|
||||
_cursor1 = _start_comboBox->itemData(index1).toString();
|
||||
_cursor1 = _start_comboBox->itemData(index1).toULongLong();
|
||||
int cusrsor_index = view->get_cursor_index_by_key(_cursor1);
|
||||
if (cusrsor_index != -1){
|
||||
decode_start = view->get_cursor_samples(cusrsor_index);
|
||||
}
|
||||
else{
|
||||
decode_start = 0;
|
||||
_cursor1 = "";
|
||||
_cursor1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (index2 == 0) {
|
||||
decode_end = last_samples;
|
||||
_cursor2 = "";
|
||||
_cursor2 = 0;
|
||||
|
||||
} else {
|
||||
_cursor2 = _end_comboBox->itemData(index2).toString();
|
||||
_cursor2 = _end_comboBox->itemData(index2).toULongLong();
|
||||
int cusrsor_index = view->get_cursor_index_by_key(_cursor2);
|
||||
if (cusrsor_index != -1){
|
||||
decode_end = view->get_cursor_samples(cusrsor_index);
|
||||
}
|
||||
else{
|
||||
decode_end = last_samples;
|
||||
_cursor2 = "";
|
||||
_cursor2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +424,7 @@ void DecoderOptionsDlg::commit_decoder_probes(data::decode::Decoder *dec)
|
||||
|
||||
void DecoderOptionsDlg::on_accept()
|
||||
{
|
||||
if (_cursor1 != "" && _cursor1 == _cursor2){
|
||||
if (_cursor1 > 0 && _cursor1 == _cursor2){
|
||||
MsgBox::Show("error", "Invalid cursor index for sample range!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ public:
|
||||
DecoderOptionsDlg(QWidget *parent);
|
||||
~DecoderOptionsDlg();
|
||||
|
||||
inline void set_cursor_range(QString cursor1, QString cursor2)
|
||||
inline void set_cursor_range(uint64_t cursor1, uint64_t cursor2)
|
||||
{
|
||||
_cursor1 = cursor1;
|
||||
_cursor2 = cursor2;
|
||||
}
|
||||
|
||||
inline void get_cursor_range(QString &cursor1, QString &cursor2)
|
||||
inline void get_cursor_range(uint64_t &cursor1, uint64_t &cursor2)
|
||||
{
|
||||
cursor1 = _cursor1;
|
||||
cursor2 = _cursor2;
|
||||
@@ -109,8 +109,8 @@ private:
|
||||
DsComboBox *_start_comboBox;
|
||||
DsComboBox *_end_comboBox;
|
||||
view::DecodeTrace *_trace;
|
||||
QString _cursor1;
|
||||
QString _cursor2;
|
||||
uint64_t _cursor1; //cursor key
|
||||
uint64_t _cursor2;
|
||||
std::vector<ProbeSelector> _probe_selectors;
|
||||
};
|
||||
|
||||
|
||||
@@ -47,9 +47,11 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
||||
_config_button = NULL;
|
||||
_cali_button = NULL;
|
||||
|
||||
setTitle(tr("Device Options"));
|
||||
|
||||
_props_box = new QGroupBox(tr("Mode"), this);
|
||||
_props_box->setLayout(get_property_form(_props_box));
|
||||
_layout.addWidget(_props_box);
|
||||
//_layout.addWidget(_props_box);
|
||||
|
||||
_dynamic_box = new QGroupBox(dynamic_widget(_dynamic_layout),
|
||||
this);
|
||||
@@ -61,8 +63,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, DevInst *dev_inst) :
|
||||
_layout.addWidget(&_button_box);
|
||||
|
||||
layout()->addLayout(&_layout);
|
||||
setTitle(tr("Device Options"));
|
||||
|
||||
|
||||
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
//connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect(_dev_inst, SIGNAL(device_updated()), this, SLOT(reject()));
|
||||
|
||||
@@ -31,12 +31,8 @@
|
||||
#include <QPointF>
|
||||
#include <QRect>
|
||||
#include <QRectF>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <ctime>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../dsvdef.h"
|
||||
|
||||
namespace pv {
|
||||
@@ -57,16 +53,6 @@ Cursor::Cursor(View &view, QColor color, uint64_t index) :
|
||||
TimeMarker(view, color, index),
|
||||
_other(*this)
|
||||
{
|
||||
static bool bSpeed = false;
|
||||
if (!bSpeed){
|
||||
bSpeed = true;
|
||||
srand(std::time(NULL));
|
||||
}
|
||||
|
||||
// make a rand key
|
||||
char buf[8+1];
|
||||
make_rand_str(buf, 8);
|
||||
_key = QString(buf);
|
||||
}
|
||||
|
||||
QRect Cursor::get_label_rect(const QRect &rect, bool &visible, bool has_hoff)
|
||||
@@ -179,16 +165,6 @@ void Cursor::compute_text_size(QPainter &p, unsigned int prefix)
|
||||
_text_size = p.boundingRect(QRect(), 0,
|
||||
Ruler::format_real_time(_index, _view.session().cur_snap_samplerate())).size();
|
||||
}
|
||||
|
||||
void Cursor::make_rand_str(char *buf, int len)
|
||||
{
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
buf[i] = 'a' + rand() % 26;
|
||||
}
|
||||
|
||||
buf[len] = 0;
|
||||
}
|
||||
|
||||
} // namespace view
|
||||
} // namespace pv
|
||||
|
||||
@@ -83,14 +83,10 @@ public:
|
||||
unsigned int prefix, QChar label, QColor color, bool has_hoff);
|
||||
|
||||
public:
|
||||
inline QString get_key(){
|
||||
return _key;
|
||||
inline uint64_t get_key(){
|
||||
return (uint64_t)this;
|
||||
}
|
||||
|
||||
inline void set_key(QString key){
|
||||
_key = key;
|
||||
}
|
||||
|
||||
|
||||
inline uint64_t get_index()
|
||||
{
|
||||
return _index;
|
||||
@@ -99,12 +95,9 @@ public:
|
||||
private:
|
||||
void compute_text_size(QPainter &p, unsigned int prefix);
|
||||
|
||||
void make_rand_str(char *buf, int len);
|
||||
|
||||
private:
|
||||
const Cursor &_other;
|
||||
QSizeF _text_size;
|
||||
QString _key;
|
||||
};
|
||||
|
||||
} // namespace view
|
||||
|
||||
@@ -135,6 +135,8 @@ DecodeTrace::DecodeTrace(pv::SigSession *session,
|
||||
_decoder_stack = decoder_stack;
|
||||
_session = session;
|
||||
_delete_flag = false;
|
||||
_decode_cursor1 = 0;
|
||||
_decode_cursor2 = 0;
|
||||
|
||||
connect(_decoder_stack, SIGNAL(new_decode_data()), this, SLOT(on_new_decode_data()));
|
||||
|
||||
@@ -656,13 +658,13 @@ void DecodeTrace::frame_ended()
|
||||
|
||||
if (_decode_start > last_samples) {
|
||||
_decode_start = 0;
|
||||
_decode_cursor1 = "";
|
||||
_decode_cursor1 = 0;
|
||||
}
|
||||
|
||||
if (_decode_cursor2 == "" ||
|
||||
if (_decode_cursor2 == 0 ||
|
||||
_decode_end > last_samples) {
|
||||
_decode_end = last_samples;
|
||||
_decode_cursor2 = "";
|
||||
_decode_cursor2 = 0;
|
||||
}
|
||||
|
||||
for(auto &dec : _decoder_stack->stack()) {
|
||||
|
||||
@@ -193,8 +193,8 @@ private:
|
||||
uint64_t _decode_start;
|
||||
uint64_t _decode_end;
|
||||
|
||||
QString _decode_cursor1; // the cursor key name, sample start index
|
||||
QString _decode_cursor2;
|
||||
uint64_t _decode_cursor1; // the cursor key, sample start index
|
||||
uint64_t _decode_cursor2;
|
||||
|
||||
QFormLayout *_pub_input_layer;
|
||||
int _progress;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "../data/logicsnapshot.h"
|
||||
#include "../dialogs/calibration.h"
|
||||
#include "../dialogs/lissajousoptions.h"
|
||||
#include "../dsvdef.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
@@ -99,6 +100,9 @@ View::View(SigSession *session, pv::toolbars::SamplingBar *sampling_bar, QWidget
|
||||
{
|
||||
assert(session);
|
||||
|
||||
_trig_cursor = NULL;
|
||||
_search_cursor = NULL;
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
|
||||
// trace viewport map
|
||||
@@ -189,6 +193,11 @@ View::View(SigSession *session, pv::toolbars::SamplingBar *sampling_bar, QWidget
|
||||
connect(_header, SIGNAL(header_updated()),this, SLOT(header_updated()));
|
||||
}
|
||||
|
||||
View::~View(){
|
||||
DESTROY_OBJECT(_trig_cursor);
|
||||
DESTROY_OBJECT(_search_cursor);
|
||||
}
|
||||
|
||||
void View::show_wait_trigger()
|
||||
{
|
||||
_time_viewport->show_wait_trigger();
|
||||
@@ -993,6 +1002,14 @@ void View::del_cursor(Cursor* cursor)
|
||||
cursor_update();
|
||||
}
|
||||
|
||||
void View::clear_cursors()
|
||||
{
|
||||
for (auto c : _cursorList){
|
||||
delete c;
|
||||
}
|
||||
_cursorList.clear();
|
||||
}
|
||||
|
||||
void View::set_cursor_middle(int index)
|
||||
{
|
||||
assert(index < (int)_cursorList.size());
|
||||
@@ -1321,7 +1338,7 @@ void View::set_receive_len(uint64_t len)
|
||||
_fft_viewport->set_receive_len(len);
|
||||
}
|
||||
|
||||
int View::get_cursor_index_by_key(QString key)
|
||||
int View::get_cursor_index_by_key(uint64_t key)
|
||||
{
|
||||
int dex = 0;
|
||||
for (auto c : _cursorList){
|
||||
|
||||
@@ -105,6 +105,8 @@ public:
|
||||
public:
|
||||
explicit View(SigSession *session, pv::toolbars::SamplingBar *sampling_bar, QWidget *parent = 0);
|
||||
|
||||
~View();
|
||||
|
||||
SigSession& session();
|
||||
|
||||
/**
|
||||
@@ -176,6 +178,7 @@ public:
|
||||
std::list<Cursor*>& get_cursorList();
|
||||
void add_cursor(QColor color, uint64_t index);
|
||||
void del_cursor(Cursor* cursor);
|
||||
void clear_cursors();
|
||||
void set_cursor_middle(int index);
|
||||
|
||||
Cursor* get_trig_cursor();
|
||||
@@ -239,7 +242,7 @@ public:
|
||||
double index2pixel(uint64_t index, bool has_hoff = true);
|
||||
uint64_t pixel2index(double pixel);
|
||||
|
||||
int get_cursor_index_by_key(QString key);
|
||||
int get_cursor_index_by_key(uint64_t key);
|
||||
|
||||
signals:
|
||||
void hover_point_changed();
|
||||
|
||||
Reference in New Issue
Block a user