fix: The cursor line can't show when data is empty

This commit is contained in:
dreamsourcelabTAI 2023-03-16 19:47:36 +08:00
parent ebd5526d15
commit 991f497a61
11 changed files with 227 additions and 114 deletions

View File

@ -136,7 +136,9 @@ void DecoderOptionsDlg::load_options_view()
if (view)
{
int num = 1;
for (auto c : view->get_cursorList()){
auto &cursor_list = view->get_cursorList();
for (auto c : cursor_list){
//tr
QString curCursor = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR), "Cursor") +
QString::number(num);

View File

@ -50,16 +50,19 @@ RegionOptions::RegionOptions(view::View *view, SigSession *session, QWidget *par
_end_comboBox = new DsComboBox(this);
_start_comboBox->addItem(RegionStart);
_end_comboBox->addItem(RegionEnd);
if (_view) {
int index = 1;
for(std::list<view::Cursor*>::iterator i = _view->get_cursorList().begin();
i != _view->get_cursorList().end(); i++) {
auto &cursor_list = _view->get_cursorList();
for(auto i = cursor_list.begin(); i != cursor_list.end(); i++) {
QString curCursor = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_CURSOR), "Cursor")+QString::number(index);
_start_comboBox->addItem(curCursor);
_end_comboBox->addItem(curCursor);
index++;
}
}
hlayout->addWidget(new QLabel("Start: ", this));
hlayout->addWidget(_start_comboBox);
hlayout->addWidget(new QLabel(" ", this));

View File

@ -245,8 +245,9 @@ void MeasureDock::cursor_update()
int index = 1;
QString iconPath = GetIconPath();
for(std::list<Cursor*>::iterator i = _view.get_cursorList().begin();
i != _view.get_cursorList().end(); i++) {
auto &cursor_list = _view.get_cursorList();
for(auto i = cursor_list.begin();i != cursor_list.end(); i++) {
QString curCursor = QString::number(index);
QToolButton *del_btn = new QToolButton(_widget);
@ -286,8 +287,9 @@ void MeasureDock::cursor_moving()
//TimeMarker* grabbed_marker = _view.get_ruler()->get_grabbed_cursor();
if (_view.cursors_shown()) {
int index = 0;
for(std::list<Cursor*>::iterator i = _view.get_cursorList().begin();
i != _view.get_cursorList().end(); i++) {
auto &cursor_list = _view.get_cursorList();
for(auto i = cursor_list.begin(); i != cursor_list.end(); i++) {
QString _cur_text = _view.get_cm_time(index) + "/" + QString::number(_view.get_cursor_samples(index));
_curpos_label_list.at(index)->setText(_cur_text);
//_curvalue_label_list.at(index)->setText(_view.get_cm_value(index));
@ -470,7 +472,9 @@ void MeasureDock::del_edge_measure()
void MeasureDock::show_all_coursor()
{
if (_view.get_cursorList().empty()) {
auto &cursor_list = _view.get_cursorList();
if (cursor_list.empty()) {
dialogs::DSMessageBox msg(this);
msg.mBox()->setText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_INFORMATION), "Information"));
msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_PLEASE_INSERT_CURSOR),
@ -490,8 +494,8 @@ void MeasureDock::show_all_coursor()
int index = 0;
QGridLayout *glayout = new QGridLayout(&cursor_dlg);
for(std::list<Cursor*>::iterator i = _view.get_cursorList().begin();
i != _view.get_cursorList().end(); i++) {
for(auto i = cursor_list.begin(); i != cursor_list.end(); i++) {
QPushButton *cursor_btn = new QPushButton(QString::number(index+1), &cursor_dlg);
set_cursor_btn_color(cursor_btn);
glayout->addWidget(cursor_btn, index/4, index%4, 1, 1);
@ -525,8 +529,9 @@ void MeasureDock::set_se_cursor()
const view::Cursor* MeasureDock::find_cousor(int index)
{
int cur_index = 1;
for(std::list<Cursor*>::iterator i = _view.get_cursorList().begin();
i != _view.get_cursorList().end(); i++) {
auto &cursor_list = _view.get_cursorList();
for(auto i = cursor_list.begin(); i != cursor_list.end(); i++) {
if (cur_index == index) {
return (*i);
}
@ -538,6 +543,9 @@ const view::Cursor* MeasureDock::find_cousor(int index)
void MeasureDock::update_dist()
{
int dist_index = 0;
auto &cursor_list = _view.get_cursorList();
for (QVector<QPushButton *>::Iterator i = _dist_s_btn_vec.begin();
i != _dist_s_btn_vec.end(); i++) {
bool start_ret, end_ret;
@ -545,14 +553,14 @@ void MeasureDock::update_dist()
const unsigned int end = _dist_e_btn_vec[dist_index]->text().toInt(&end_ret) - 1;
if (start_ret) {
if (start + 1 > _view.get_cursorList().size()) {
if (start + 1 > cursor_list.size()) {
(*i)->setText(" ");
set_cursor_btn_color((*i));
start_ret = false;
}
}
if (end_ret) {
if (end + 1 > _view.get_cursorList().size()) {
if (end + 1 > cursor_list.size()) {
_dist_e_btn_vec[dist_index]->setText(" ");
set_cursor_btn_color(_dist_e_btn_vec[dist_index]);
end_ret = false;
@ -578,6 +586,8 @@ void MeasureDock::update_dist()
void MeasureDock::update_edge()
{
int edge_index = 0;
auto &cursor_list = _view.get_cursorList();
for (QVector<QPushButton *>::Iterator i = _edge_s_btn_vec.begin();
i != _edge_s_btn_vec.end(); i++) {
bool start_ret, end_ret;
@ -585,14 +595,14 @@ void MeasureDock::update_edge()
const unsigned int end = _edge_e_btn_vec[edge_index]->text().toInt(&end_ret) - 1;
if (start_ret) {
if (start + 1 > _view.get_cursorList().size()) {
if (start + 1 > cursor_list.size()) {
(*i)->setText(" ");
set_cursor_btn_color((*i));
start_ret = false;
}
}
if (end_ret) {
if (end + 1 > _view.get_cursorList().size()) {
if (end + 1 > cursor_list.size()) {
_edge_e_btn_vec[edge_index]->setText(" ");
set_cursor_btn_color(_edge_e_btn_vec[edge_index]);
end_ret = false;
@ -668,13 +678,19 @@ void MeasureDock::del_cursor()
{
int del_index = 0;
Cursor* cursor = NULL;
for (QVector <QToolButton *>::const_iterator i = _cursor_del_btn_vec.begin();
i != _cursor_del_btn_vec.end(); i++) {
auto &cursor_list = _view.get_cursorList();
for (auto i = _cursor_del_btn_vec.begin();
i != _cursor_del_btn_vec.end(); i++)
{
if ((*i)->isChecked()) {
int cur_index = 0;
std::list<Cursor*>::iterator ite = _view.get_cursorList().begin();
auto ite = cursor_list.begin();
while (cur_index++ != del_index)
ite++;
cursor = *ite;
break;
}
@ -683,7 +699,7 @@ void MeasureDock::del_cursor()
if (cursor)
_view.del_cursor(cursor);
if (_view.get_cursorList().empty())
if (cursor_list.empty())
_view.show_cursors(false);
cursor_update();

View File

@ -214,6 +214,8 @@ namespace pv
// Release the old device.
_device_agent.release();
_device_status = ST_INIT;
if (ds_active_device(dev_handle) != SR_OK)
{
dsv_err("%s", "Switch device error!");
@ -227,8 +229,6 @@ namespace pv
else
dsv_info("Switch to device \"%s\" done.", _device_agent.name().toUtf8().data());
_device_status = ST_INIT;
clear_all_decoder();
_view_data->clear();

View File

@ -658,14 +658,17 @@ void AnalogSignal::paint_hover_measure(QPainter &p, QColor fore, QColor back)
p.drawText(hover_rect, Qt::AlignCenter | Qt::AlignTop | Qt::TextDontClip, hover_str);
}
auto i = _view->get_cursorList().begin();
while (i != _view->get_cursorList().end()) {
auto &cursor_list = _view->get_cursorList();
auto i = cursor_list.begin();
while (i != cursor_list.end()) {
float pt_value;
const QPointF pt = get_point((*i)->index(), pt_value);
if (pt == QPointF(-1, -1)) {
i++;
continue;
}
QString pt_str = get_voltage(hw_offset - pt_value, 2);
if (pt.y() <= top || pt.y() >= bottom)
pt_str += "/out";

View File

@ -1292,8 +1292,10 @@ void DsoSignal::paint_hover_measure(QPainter &p, QColor fore, QColor back)
p.drawText(hover_rect, Qt::AlignCenter | Qt::AlignTop | Qt::TextDontClip, hover_str);
}
auto i = _view->get_cursorList().begin();
while (i != _view->get_cursorList().end()) {
auto &cursor_list = _view->get_cursorList();
auto i = cursor_list.begin();
while (i != cursor_list.end()) {
float pt_value;
const QPointF pt = get_point((*i)->index(), pt_value);
if (pt == QPointF(-1, -1)) {

View File

@ -419,8 +419,10 @@ void MathTrace::paint_hover_measure(QPainter &p, QColor fore, QColor back)
p.drawText(hover_rect, Qt::AlignCenter | Qt::AlignTop | Qt::TextDontClip, hover_str);
}
auto i = _view->get_cursorList().begin();
while (i != _view->get_cursorList().end()) {
auto &cursor_list = _view->get_cursorList();
auto i = cursor_list.begin();
while (i != cursor_list.end()) {
float pt_value;
const QPointF pt = get_point((*i)->index(), pt_value);
QString pt_str = get_voltage(pt_value, 2);

View File

@ -239,20 +239,25 @@ void Ruler::mousePressEvent(QMouseEvent *event)
{
if (event->button() & Qt::LeftButton) {
bool visible;
if (!_cursor_sel_visible & !_view.get_cursorList().empty()) {
auto &cursor_list = _view.get_cursorList();
if (!_cursor_sel_visible && cursor_list.size()) {
_view.show_cursors(true);
auto i = _view.get_cursorList().begin();
while (i != _view.get_cursorList().end()) {
auto i = cursor_list.begin();
while (i != cursor_list.end()) {
const QRect cursor_rect((*i)->get_label_rect(rect(), visible));
if ((*i)->get_close_rect(cursor_rect).contains(event->pos())) {
_view.del_cursor(*i);
if (_view.get_cursorList().empty()) {
if (cursor_list.empty()) {
_cursor_sel_visible = false;
_view.show_cursors(false);
}
_hitCursor = true;
break;
}
if (cursor_rect.contains(event->pos())) {
set_grabbed_cursor(*i);
_cursor_sel_visible = false;
@ -269,31 +274,40 @@ void Ruler::mousePressEvent(QMouseEvent *event)
void Ruler::mouseReleaseEvent(QMouseEvent *event)
{
bool updatedCursor = false;
if (event->button() & Qt::LeftButton) {
if (!_hitCursor && !_grabbed_marker) {
if (!_cursor_go_visible) {
if (!_cursor_sel_visible) {
_cursor_sel_x = event->pos().x();
_cursor_sel_visible = true;
} else {
}
else {
int overCursor;
auto &cursor_list = _view.get_cursorList();
uint64_t index = _view.pixel2index(_cursor_sel_x);
overCursor = in_cursor_sel_rect(event->pos());
if (overCursor == 0) {
_view.add_cursor(CursorColor[_view.get_cursorList().size() % 8], index);
_view.add_cursor(CursorColor[cursor_list.size() % 8], index);
_view.show_cursors(true);
updatedCursor = true;
} else if (overCursor > 0) {
auto i = _view.get_cursorList().begin();
while (--overCursor != 0)
i++;
}
else if (overCursor > 0) {
auto i = cursor_list.begin();
while (--overCursor != 0){
i++;
}
(*i)->set_index(index);
updatedCursor = true;
_view.cursor_moved();
}
_cursor_sel_visible = false;
}
} else {
}
else {
int overCursor;
overCursor = in_cursor_sel_rect(event->pos());
if (overCursor > 0) {
@ -325,13 +339,19 @@ void Ruler::mouseReleaseEvent(QMouseEvent *event)
} else {
int overCursor;
overCursor = in_cursor_sel_rect(event->pos());
auto &cursor_list = _view.get_cursorList();
if (overCursor > 0) {
auto i = _view.get_cursorList().begin();
while (--overCursor != 0)
auto i = cursor_list.begin();
while (--overCursor != 0){
i++;
}
_view.del_cursor(*i);
}
if (_view.get_cursorList().empty()) {
if (cursor_list.empty()) {
_cursor_sel_visible = false;
_view.show_cursors(false);
}
@ -455,15 +475,19 @@ void Ruler::draw_logic_tick_mark(QPainter &p)
} while (x < rect().right());
// Draw the cursors
if (!_view.get_cursorList().empty()) {
auto i = _view.get_cursorList().begin();
auto &cursor_list = _view.get_cursorList();
if (cursor_list.size()) {
auto i = cursor_list.begin();
int index = 1;
while (i != _view.get_cursorList().end()) {
while (i != cursor_list.end()) {
(*i)->paint_label(p, rect(), prefix, index, _view.session().is_stopped_status());
index++;
i++;
}
}
if (_view.trig_cursor_shown()) {
_view.get_trig_cursor()->paint_fix_label(p, rect(), prefix, 'T', _view.get_trig_cursor()->colour(), false);
}
@ -573,10 +597,13 @@ void Ruler::draw_osc_tick_mark(QPainter &p)
} while (x < rect().right());
// Draw the cursors
if (!_view.get_cursorList().empty()) {
auto i = _view.get_cursorList().begin();
auto &cursor_list = _view.get_cursorList();
if (!cursor_list.empty()) {
auto i = cursor_list.begin();
int index = 1;
while (i != _view.get_cursorList().end()) {
while (i != cursor_list.end()) {
(*i)->paint_label(p, rect(), prefix, index, _view.session().is_stopped_status());
index++;
i++;
@ -637,19 +664,24 @@ void Ruler::draw_cursor_sel(QPainter &p)
};
p.drawPolygon((_cursor_go_visible ? del_points : points), countof(points));
if (!_view.get_cursorList().empty()) {
auto &cursor_list = _view.get_cursorList();
if (!cursor_list.empty()) {
int index = 1;
auto i = _view.get_cursorList().begin();
while (i != _view.get_cursorList().end()) {
auto i = cursor_list.begin();
while (i != cursor_list.end()) {
const QRectF cursorRect = get_cursor_sel_rect(index);
p.setPen(QPen(Qt::black, 1, Qt::DotLine));
p.drawLine(cursorRect.left(), cursorRect.top() + 3,
cursorRect.left(), cursorRect.bottom() - 3);
p.setPen(QPen(Qt::NoPen));
if (in_cursor_sel_rect(pos) == index)
p.setBrush(View::Orange);
else
p.setBrush(CursorColor[(index - 1)%8]);
p.drawRect(cursorRect);
p.setPen(Qt::black);
p.drawText(cursorRect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(index));
@ -664,7 +696,9 @@ int Ruler::in_cursor_sel_rect(QPointF pos)
if (_cursor_sel_x == -1)
return -1;
for (unsigned int i = 0; i < _view.get_cursorList().size() + 1; i++) {
auto &cursor_list = _view.get_cursorList();
for (unsigned int i = 0; i < cursor_list.size() + 1; i++) {
const QRectF cursorRect = get_cursor_sel_rect(i);
if (cursorRect.contains(pos))
return i;

View File

@ -61,6 +61,7 @@ bool TimeMarker::grabbed()
{
return _grabbed;
}
void TimeMarker::set_grabbed(bool grabbed)
{
_grabbed = grabbed;
@ -83,7 +84,6 @@ void TimeMarker::paint(QPainter &p, const QRect &rect, const bool highlight, int
if (x <= rect.right()) {
QColor color = (order == -1) ? _colour : Ruler::CursorColor[order%8];
p.setPen((_grabbed | highlight) ? QPen(color.lighter(), 2, Qt::DashLine) : QPen(color, 1, Qt::DashLine));
//p.drawLine(QPoint(x, rect.top()), QPoint(x, rect.bottom()));
p.drawLine(QPoint(x, 0), QPoint(x, rect.bottom()));
}
}

View File

@ -172,8 +172,12 @@ void Viewport::doPaint()
if (_view.session().get_device()->get_work_mode() == LOGIC ||
_view.session().is_instant())
{
if (_view.session().is_stopped_status())
{
if (_view.session().is_init_status())
{
paintCursors(p);
}
else if (_view.session().is_stopped_status())
{
paintSignals(p, fore, back);
}
@ -208,6 +212,28 @@ void Viewport::doPaint()
p.end();
}
void Viewport::paintCursors(QPainter &p)
{
const QRect xrect = _view.get_view_rect();
auto &cursor_list = _view.get_cursorList();
if (_view.cursors_shown() && _type == TIME_VIEW) {
auto i = cursor_list.begin();
int index = 0;
while (i != cursor_list.end()) {
const int64_t cursorX = _view.index2pixel((*i)->index());
if (xrect.contains(_view.hover_point().x(), _view.hover_point().y()) &&
qAbs(cursorX - _view.hover_point().x()) <= HitCursorMargin)
(*i)->paint(p, xrect, 1, index, _view.session().is_stopped_status());
else
(*i)->paint(p, xrect, 0, index, _view.session().is_stopped_status());
i++;
index++;
}
}
}
void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
{
std::vector<Trace*> traces;
@ -245,28 +271,17 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
}
// plot cursors
//const QRect xrect = QRect(rect().left(), rect().top(), _view.get_view_width(), rect().height());
paintCursors(p);
const QRect xrect = _view.get_view_rect();
if (_view.cursors_shown() && _type == TIME_VIEW) {
auto i = _view.get_cursorList().begin();
int index = 0;
while (i != _view.get_cursorList().end()) {
const int64_t cursorX = _view.index2pixel((*i)->index());
if (xrect.contains(_view.hover_point().x(), _view.hover_point().y()) &&
qAbs(cursorX - _view.hover_point().x()) <= HitCursorMargin)
(*i)->paint(p, xrect, 1, index, _view.session().is_stopped_status());
else
(*i)->paint(p, xrect, 0, index, _view.session().is_stopped_status());
i++;
index++;
}
}
if (_view.xcursors_shown() && _type == TIME_VIEW) {
auto i = _view.get_xcursorList().begin();
auto &xcursor_list = _view.get_xcursorList();
auto i = xcursor_list.begin();
int index = 0;
bool hovered = false;
while (i != _view.get_xcursorList().end()) {
while (i != xcursor_list.end()) {
const double cursorX = xrect.left() + (*i)->value(XCursor::XCur_Y)*xrect.width();
const double cursorY0 = xrect.top() + (*i)->value(XCursor::XCur_X0)*xrect.height();
const double cursorY1 = xrect.top() + (*i)->value(XCursor::XCur_X1)*xrect.height();
@ -275,22 +290,27 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
(*i)->get_map_rect(xrect).contains(_view.hover_point()))) {
(*i)->paint(p, xrect, XCursor::XCur_All, index);
hovered = true;
} else if(!hovered && xrect.contains(_view.hover_point())) {
}
else if(!hovered && xrect.contains(_view.hover_point())) {
if (qAbs(cursorX - _view.hover_point().x()) <= HitCursorMargin &&
_view.hover_point().y() > min(cursorY0, cursorY1) &&
_view.hover_point().y() < max(cursorY0, cursorY1)) {
(*i)->paint(p, xrect, XCursor::XCur_Y, index);
hovered = true;
} else if (qAbs(cursorY0 - _view.hover_point().y()) <= HitCursorMargin) {
}
else if (qAbs(cursorY0 - _view.hover_point().y()) <= HitCursorMargin) {
(*i)->paint(p, xrect, XCursor::XCur_X0, index);
hovered = true;
} else if (qAbs(cursorY1 - _view.hover_point().y()) <= HitCursorMargin) {
}
else if (qAbs(cursorY1 - _view.hover_point().y()) <= HitCursorMargin) {
(*i)->paint(p, xrect, XCursor::XCur_X1, index);
hovered = true;
} else {
}
else {
(*i)->paint(p, xrect, XCursor::XCur_None, index);
}
} else {
}
else {
(*i)->paint(p, xrect, XCursor::XCur_None, index);
}
@ -556,7 +576,8 @@ void Viewport::mousePressEvent(QMouseEvent *event)
else if (_view.session().get_device()->get_work_mode() == DSO) {
if (_hover_hit) {
const int64_t index = _view.pixel2index(event->pos().x());
_view.add_cursor(view::Ruler::CursorColor[_view.get_cursorList().size() % 8], index);
auto &cursor_list = _view.get_cursorList();
_view.add_cursor(view::Ruler::CursorColor[cursor_list.size() % 8], index);
_view.show_cursors(true);
}
}
@ -590,13 +611,17 @@ void Viewport::mousePressEvent(QMouseEvent *event)
_action_type = CURS_MOVE;
}
}
if (_action_type == NO_ACTION && _view.cursors_shown()) {
auto i = _view.get_cursorList().begin();
while (i != _view.get_cursorList().end()) {
auto &cursor_list = _view.get_cursorList();
auto i = cursor_list.begin();
while (i != cursor_list.end()) {
const int64_t cursorX = _view.index2pixel((*i)->index());
if ((*i)->grabbed()) {
_view.get_ruler()->rel_grabbed_cursor();
} else if (qAbs(cursorX - event->pos().x()) <= HitCursorMargin) {
}
else if (qAbs(cursorX - event->pos().x()) <= HitCursorMargin) {
_view.get_ruler()->set_grabbed_cursor(*i);
_action_type = CURS_MOVE;
break;
@ -604,18 +629,20 @@ void Viewport::mousePressEvent(QMouseEvent *event)
i++;
}
}
if (_action_type == NO_ACTION && _view.xcursors_shown()) {
auto i = _view.get_xcursorList().begin();
auto &xcursor_list = _view.get_xcursorList();
auto i = xcursor_list.begin();
const QRect xrect = _view.get_view_rect();
while (i != _view.get_xcursorList().end()) {
while (i != xcursor_list.end()) {
const double cursorX = xrect.left() + (*i)->value(XCursor::XCur_Y)*xrect.width();
const double cursorY0 = xrect.top() + (*i)->value(XCursor::XCur_X0)*xrect.height();
const double cursorY1 = xrect.top() + (*i)->value(XCursor::XCur_X1)*xrect.height();
if ((*i)->get_close_rect(xrect).contains(_view.hover_point())) {
_view.del_xcursor(*i);
if (_view.get_xcursorList().empty())
if (xcursor_list.empty())
_view.show_xcursors(false);
break;
}
@ -636,6 +663,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
sig_looped = true;
}
}
s++;
if (s == sigs.end()) {
if (no_dsoSig) {
@ -751,9 +779,11 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
_curs_moved = true;
} else {
if (_view.xcursors_shown()) {
auto i = _view.get_xcursorList().begin();
auto &xcursor_list = _view.get_xcursorList();
auto i = xcursor_list.begin();
const QRect xrect = _view.get_view_rect();
while (i != _view.get_xcursorList().end()) {
while (i != xcursor_list.end()) {
if ((*i)->grabbed() != XCursor::XCur_None) {
if ((*i)->grabbed() == XCursor::XCur_Y) {
double rate = (_view.hover_point().x() - xrect.left()) * 1.0 / xrect.width();
@ -878,7 +908,8 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
}
}
}
} else if (_view.session().get_device()->get_work_mode() == DSO) {
}
else if (_view.session().get_device()->get_work_mode() == DSO) {
// priority 0
if (_action_type == NO_ACTION && _hover_hit) {
_action_type = DSO_YM;
@ -889,7 +920,8 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_dso_ym_start = event->pos().y();
}
}
} else if (_action_type == DSO_YM) {
}
else if (_action_type == DSO_YM) {
if (event->button() == Qt::LeftButton) {
_dso_ym_end = event->pos().y();
_action_type = NO_ACTION;
@ -897,7 +929,8 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_action_type = NO_ACTION;
_dso_ym_valid = false;
}
} else if (_action_type == DSO_TRIG_MOVE) {
}
else if (_action_type == DSO_TRIG_MOVE) {
if (_dso_trig_moved && event->button() == Qt::LeftButton) {
_drag_sig = NULL;
_action_type = NO_ACTION;
@ -910,13 +943,14 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
t->select(false);
}
}
} else if (_action_type == DSO_XM_STEP0) {
}
else if (_action_type == DSO_XM_STEP0) {
if (event->button() == Qt::LeftButton) {
_action_type = DSO_XM_STEP1;
_dso_xm_valid = true;
}
} else if (_action_type == DSO_XM_STEP1) {
}
else if (_action_type == DSO_XM_STEP1) {
if (event->button() == Qt::LeftButton) {
_dso_xm_index[1] = _view.pixel2index(event->pos().x());
const uint64_t max_index = max(_dso_xm_index[0], _dso_xm_index[1]);
@ -924,11 +958,13 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_dso_xm_index[1] = max_index;
_action_type = DSO_XM_STEP2;
} else if (event->button() == Qt::RightButton) {
}
else if (event->button() == Qt::RightButton) {
clear_dso_xm();
measure_updated();
}
} else if (_action_type == DSO_XM_STEP2) {
}
else if (_action_type == DSO_XM_STEP2) {
if (event->button() == Qt::LeftButton) {
_dso_xm_index[2] = _view.pixel2index(event->pos().x());
uint64_t max_index = max(_dso_xm_index[1], _dso_xm_index[2]);
@ -940,11 +976,13 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
_dso_xm_index[1] = max_index;
_action_type = NO_ACTION;
} else if (event->button() == Qt::RightButton) {
}
else if (event->button() == Qt::RightButton) {
clear_dso_xm();
measure_updated();
}
} else if (_action_type == CURS_MOVE) {
}
else if (_action_type == CURS_MOVE) {
if (_curs_moved && event->button() == Qt::LeftButton) {
_action_type = NO_ACTION;
_view.get_ruler()->rel_grabbed_cursor();
@ -953,44 +991,54 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
}
if (_xcurs_moved && event->button() == Qt::LeftButton) {
_action_type = NO_ACTION;
auto i = _view.get_xcursorList().begin();
while (i != _view.get_xcursorList().end()) {
auto &xcursor_list = _view.get_xcursorList();
auto i = xcursor_list.begin();
while (i != xcursor_list.end()) {
(*i)->rel_grabbed();
i++;
}
_xcurs_moved = false;
}
} else if (_action_type == LOGIC_EDGE) {
}
else if (_action_type == LOGIC_EDGE) {
_action_type = NO_ACTION;
_edge_rising = 0;
_edge_falling = 0;
} else if (_action_type == LOGIC_JUMP) {
}
else if (_action_type == LOGIC_JUMP) {
_action_type = NO_ACTION;
_edge_rising = 0;
_edge_falling = 0;
_edge_hit = false;
} else if (_action_type == LOGIC_MOVE) {
}
else if (_action_type == LOGIC_MOVE) {
if (_mouse_down_point == event->pos()) {
_drag_strength = 0;
_drag_timer.stop();
_action_type = NO_ACTION;
} else {
}
else {
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
if (_elapsed_time.elapsed() < 200 &&
abs(_drag_strength) < MinorDragOffsetUp &&
abs(strength) > MinorDragRateUp) {
_drag_timer.start(DragTimerInterval);
} else if (_elapsed_time.elapsed() < 200 &&
}
else if (_elapsed_time.elapsed() < 200 &&
abs(strength) > DragTimerInterval) {
_drag_strength = strength * 5;
_drag_timer.start(DragTimerInterval);
} else {
}
else {
_drag_strength = 0;
_drag_timer.stop();
_action_type = NO_ACTION;
}
}
} else if (_action_type == LOGIC_ZOOM) {
}
else if (_action_type == LOGIC_ZOOM) {
if (event->pos().x() != _mouse_down_point.x()) {
int64_t newOffset = _view.offset() + (min(event->pos().x(), _mouse_down_point.x()));
const double newScale = max(min(_view.scale() * abs(event->pos().x() - _mouse_down_point.x()) / _view.get_view_width(),
@ -1014,7 +1062,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
int mode = _view.session().get_device()->get_work_mode();
if (mode == LOGIC && _view.session().is_stopped_status())
if (mode == LOGIC)// && _view.session().is_stopped_status())
{
if (event->button() == Qt::RightButton) {
if (_view.scale() == _view.get_maxscale())
@ -1052,7 +1100,8 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
index = _view.pixel2index(curX);
}
_view.add_cursor(view::Ruler::CursorColor[_view.get_cursorList().size() % 8], index);
auto &cursor_list = _view.get_cursorList();
_view.add_cursor(view::Ruler::CursorColor[cursor_list.size() % 8], index);
_view.show_cursors(true);
}
@ -1080,7 +1129,8 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
uint64_t index;
const double curX = event->pos().x();
index = _view.pixel2index(curX);
_view.add_cursor(view::Ruler::CursorColor[_view.get_cursorList().size() % 8], index);
auto &cursor_list = _view.get_cursorList();
_view.add_cursor(view::Ruler::CursorColor[cursor_list.size() % 8], index);
_view.show_cursors(true);
}
}
@ -1680,12 +1730,10 @@ void Viewport::paintMeasure(QPainter &p, QColor fore, QColor back)
QString delta_text = _view.get_index_delta(_edge_start, _edge_end) +
"/" + QString::number(delta);
QFontMetrics fm = this->fontMetrics();
// const int rectW = fm.width(delta_text) + 60;
const int rectW = fm.boundingRect(delta_text).width() + 60;
const int rectH = fm.height() + 10;
//const int rectY = (_cur_aftY >= _cur_preY) ? _cur_preY_top : _cur_preY_bottom;
//const int rectX = (_cur_aftX >= _cur_preX) ? _cur_preX : _cur_preX - rectW;
const int rectY = (height() - _view.hover_point().y() < rectH + 20) ? _view.hover_point().y() - 10 - rectH : _view.hover_point().y() + 20;
const int rectX = (width() - _view.hover_point().x() < rectW) ? _view.hover_point().x() - rectW : _view.hover_point().x();
QRectF jump_rect = QRectF(rectX, rectY, rectW, rectH);
@ -1816,14 +1864,16 @@ void Viewport::add_cursor_y()
uint64_t index;
//const double curX = _menu_pos.x();
index = _view.pixel2index(_cur_preX);
_view.add_cursor(view::Ruler::CursorColor[_view.get_cursorList().size() % 8], index);
auto &cursor_list = _view.get_cursorList();
_view.add_cursor(view::Ruler::CursorColor[cursor_list.size() % 8], index);
_view.show_cursors(true);
}
void Viewport::add_cursor_x()
{
double ypos = (_cur_preY - _view.get_view_rect().top()) * 1.0 / _view.get_view_height();
_view.add_xcursor(view::Ruler::CursorColor[_view.get_cursorList().size() % 8], ypos, ypos);
auto &cursor_list = _view.get_cursorList();
_view.add_xcursor(view::Ruler::CursorColor[cursor_list.size() % 8], ypos, ypos);
_view.show_xcursors(true);
}

View File

@ -125,6 +125,7 @@ private:
void paintSignals(QPainter& p, QColor fore, QColor back);
void paintProgress(QPainter& p, QColor fore, QColor back);
void paintMeasure(QPainter &p, QColor fore, QColor back);
void paintCursors(QPainter &p);
void measure();
void start_trigger_timer(int msec);