forked from Ivasoft/DSView
add: Reduce the rolling trigger sensitivity of logic analyzer
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "sigsession.h"
|
#include "sigsession.h"
|
||||||
@@ -35,7 +36,8 @@
|
|||||||
AppControl::AppControl()
|
AppControl::AppControl()
|
||||||
{
|
{
|
||||||
sr_ctx = NULL;
|
sr_ctx = NULL;
|
||||||
|
_topWindow = NULL;
|
||||||
|
|
||||||
_device_manager = new pv::DeviceManager();
|
_device_manager = new pv::DeviceManager();
|
||||||
_session = new pv::SigSession(_device_manager);
|
_session = new pv::SigSession(_device_manager);
|
||||||
}
|
}
|
||||||
@@ -149,3 +151,11 @@ const char *AppControl::GetLastError()
|
|||||||
sr_log_loglevel_set(level);
|
sr_log_loglevel_set(level);
|
||||||
srd_log_loglevel_set(level);
|
srd_log_loglevel_set(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AppControl::TopWindowIsMaximized()
|
||||||
|
{
|
||||||
|
if (_topWindow != NULL){
|
||||||
|
return _topWindow->isMaximized();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct sr_context;
|
struct sr_context;
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
namespace pv{
|
namespace pv{
|
||||||
class DeviceManager;
|
class DeviceManager;
|
||||||
@@ -54,11 +55,23 @@ public:
|
|||||||
|
|
||||||
void SetLogLevel(int level);
|
void SetLogLevel(int level);
|
||||||
|
|
||||||
inline pv::SigSession* GetSession()
|
inline pv::SigSession* GetSession(){
|
||||||
{ return _session;}
|
return _session;
|
||||||
|
}
|
||||||
|
|
||||||
inline pv::DeviceManager& GetDeviceManager()
|
inline pv::DeviceManager& GetDeviceManager(){
|
||||||
{ return *_device_manager;}
|
return *_device_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetTopWindow(QWidget *w){
|
||||||
|
_topWindow = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QWidget* GetTopWindow(){
|
||||||
|
return _topWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TopWindowIsMaximized();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string _open_file_name;
|
std::string _open_file_name;
|
||||||
@@ -68,4 +81,5 @@ private:
|
|||||||
struct sr_context *sr_ctx;
|
struct sr_context *sr_ctx;
|
||||||
pv::DeviceManager *_device_manager;
|
pv::DeviceManager *_device_manager;
|
||||||
pv::SigSession *_session;
|
pv::SigSession *_session;
|
||||||
|
QWidget *_topWindow;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -62,23 +62,6 @@ namespace DecoderDataFormat
|
|||||||
|
|
||||||
namespace app
|
namespace app
|
||||||
{
|
{
|
||||||
QWidget* get_app_window_instance(QWidget *ins, bool bSet){
|
|
||||||
|
|
||||||
static QWidget *g_ins = NULL;
|
|
||||||
if (bSet){
|
|
||||||
g_ins = ins;
|
|
||||||
}
|
|
||||||
return g_ins;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_app_top_window(QWidget* w){
|
|
||||||
QWidget *top =get_app_window_instance(NULL, NULL);
|
|
||||||
if (top && top == w){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_utf8(QTextStream &stream){
|
void set_utf8(QTextStream &stream){
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
stream.setEncoding(QStringConverter::Utf8);
|
stream.setEncoding(QStringConverter::Utf8);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class QTextStream;
|
|||||||
|
|
||||||
#define RELEASE_ARRAY(a) for (auto ptr : (a)){delete ptr;} (a).clear();
|
#define RELEASE_ARRAY(a) for (auto ptr : (a)){delete ptr;} (a).clear();
|
||||||
|
|
||||||
#define ABS_VAL(x) (x>0?x:-x)
|
#define ABS_VAL(x) ((x) > 0 ? (x) : -(x))
|
||||||
|
|
||||||
namespace DecoderDataFormat
|
namespace DecoderDataFormat
|
||||||
{
|
{
|
||||||
@@ -71,10 +71,6 @@ namespace DecoderDataFormat
|
|||||||
|
|
||||||
namespace app
|
namespace app
|
||||||
{
|
{
|
||||||
QWidget* get_app_window_instance(QWidget *ins, bool bSet);
|
|
||||||
|
|
||||||
bool is_app_top_window(QWidget* w);
|
|
||||||
|
|
||||||
void set_utf8(QTextStream &stream);
|
void set_utf8(QTextStream &stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "dsvdef.h"
|
#include "dsvdef.h"
|
||||||
#include "config/appconfig.h"
|
#include "config/appconfig.h"
|
||||||
#include "ui/msgbox.h"
|
#include "ui/msgbox.h"
|
||||||
|
#include "appcontrol.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -61,6 +62,8 @@ MainFrame::MainFrame()
|
|||||||
_titleBar = NULL;
|
_titleBar = NULL;
|
||||||
_mainWindow = NULL;
|
_mainWindow = NULL;
|
||||||
|
|
||||||
|
AppControl::Instance()->SetTopWindow(this);
|
||||||
|
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
// Make this a borderless window which can't
|
// Make this a borderless window which can't
|
||||||
// be resized or moved via the window system
|
// be resized or moved via the window system
|
||||||
@@ -77,8 +80,6 @@ MainFrame::MainFrame()
|
|||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/icons/logo.svg"), QSize(), QIcon::Normal, QIcon::Off);
|
icon.addFile(QString::fromUtf8(":/icons/logo.svg"), QSize(), QIcon::Normal, QIcon::Off);
|
||||||
setWindowIcon(icon);
|
setWindowIcon(icon);
|
||||||
|
|
||||||
app::get_app_window_instance(this, true);
|
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
_titleBar = new toolbars::TitleBar(true, this);
|
_titleBar = new toolbars::TitleBar(true, this);
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
_msg(NULL)
|
_msg(NULL)
|
||||||
{
|
{
|
||||||
_control = AppControl::Instance();
|
_control = AppControl::Instance();
|
||||||
_control->GetSession()->set_callback(this);
|
_control->GetSession()->set_callback(this);
|
||||||
_bFirstLoad = true;
|
_bFirstLoad = true;
|
||||||
|
|
||||||
setup_ui();
|
setup_ui();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "../config/appconfig.h"
|
#include "../config/appconfig.h"
|
||||||
|
#include "../appcontrol.h"
|
||||||
|
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
|
|
||||||
@@ -192,7 +193,8 @@ void TitleBar::mousePressEvent(QMouseEvent* event)
|
|||||||
{
|
{
|
||||||
int x = event->pos().x();
|
int x = event->pos().x();
|
||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
bool bTopWidow = app::is_app_top_window(_parent);
|
|
||||||
|
bool bTopWidow = AppControl::Instance()->GetTopWindow() == _parent;
|
||||||
bool bClick = (x >= 6 && y >= 5 && x <= width() - 6); //top window need resize hit check
|
bool bClick = (x >= 6 && y >= 5 && x <= width() - 6); //top window need resize hit check
|
||||||
|
|
||||||
if (!bTopWidow || bClick ){
|
if (!bTopWidow || bClick ){
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
|
#include "../appcontrol.h"
|
||||||
|
|
||||||
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||||
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No);
|
//QMessageBox::information(NULL, "Title", "Content",QMessageBox::Yes|QMessageBox::No);
|
||||||
@@ -40,7 +41,7 @@ void MsgBox::Show(const char *title, const char *text, QWidget *parent)
|
|||||||
str.append(text);
|
str.append(text);
|
||||||
|
|
||||||
if (parent == NULL){
|
if (parent == NULL){
|
||||||
parent = app::get_app_window_instance(NULL, false);
|
parent = AppControl::Instance()->GetTopWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
pv::dialogs::DSMessageBox msg(parent, title);
|
pv::dialogs::DSMessageBox msg(parent, title);
|
||||||
@@ -59,8 +60,8 @@ bool MsgBox::Confirm(const char *text, QWidget *parent)
|
|||||||
str.append("\n");
|
str.append("\n");
|
||||||
str.append(text);
|
str.append(text);
|
||||||
|
|
||||||
if (parent == NULL){
|
if (parent == NULL){
|
||||||
parent = app::get_app_window_instance(NULL, false);
|
parent = AppControl::Instance()->GetTopWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
pv::dialogs::DSMessageBox msg(parent, "Question");
|
pv::dialogs::DSMessageBox msg(parent, "Question");
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include "../config/appconfig.h"
|
#include "../config/appconfig.h"
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
|
#include "../appcontrol.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -88,6 +89,7 @@ Viewport::Viewport(View &parent, View_type type) :
|
|||||||
_edge_hit = false;
|
_edge_hit = false;
|
||||||
transfer_started = false;
|
transfer_started = false;
|
||||||
timer_cnt = 0;
|
timer_cnt = 0;
|
||||||
|
_clickX = 0;
|
||||||
|
|
||||||
// drag inertial
|
// drag inertial
|
||||||
_drag_strength = 0;
|
_drag_strength = 0;
|
||||||
@@ -499,6 +501,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
assert(event);
|
assert(event);
|
||||||
|
|
||||||
|
_clickX = event->globalPos().x();
|
||||||
_mouse_down_point = event->pos();
|
_mouse_down_point = event->pos();
|
||||||
_mouse_down_offset = _view.offset();
|
_mouse_down_offset = _view.offset();
|
||||||
_drag_strength = 0;
|
_drag_strength = 0;
|
||||||
@@ -757,6 +760,9 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
|||||||
void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
assert(event);
|
assert(event);
|
||||||
|
|
||||||
|
bool quickScroll = AppConfig::Instance()._appOptions.quickScroll;
|
||||||
|
bool isMaxWindow = AppControl::Instance()->TopWindowIsMaximized();
|
||||||
|
|
||||||
if (_type != TIME_VIEW){
|
if (_type != TIME_VIEW){
|
||||||
update();
|
update();
|
||||||
@@ -769,7 +775,22 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
_view.session().get_capture_state() == SigSession::Stopped) {
|
_view.session().get_capture_state() == SigSession::Stopped) {
|
||||||
//priority 1
|
//priority 1
|
||||||
//try to quick scroll view...
|
//try to quick scroll view...
|
||||||
if (_action_type == NO_ACTION && AppConfig::Instance()._appOptions.quickScroll) {
|
int curX = event->globalPos().x();
|
||||||
|
int moveLong = ABS_VAL(curX - _clickX);
|
||||||
|
int maxWidth = this->geometry().width();
|
||||||
|
float mvk = (float) moveLong / (float)maxWidth;
|
||||||
|
|
||||||
|
if (quickScroll){
|
||||||
|
quickScroll = false;
|
||||||
|
if (isMaxWindow && mvk > 0.5f){
|
||||||
|
quickScroll = true;
|
||||||
|
}
|
||||||
|
else if (!isMaxWindow && mvk > 0.6f){
|
||||||
|
quickScroll = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_action_type == NO_ACTION && quickScroll) {
|
||||||
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
|
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
|
||||||
if (_elapsed_time.elapsed() < 200 &&
|
if (_elapsed_time.elapsed() < 200 &&
|
||||||
abs(_drag_strength) < MinorDragOffsetUp &&
|
abs(_drag_strength) < MinorDragOffsetUp &&
|
||||||
|
|||||||
@@ -217,10 +217,11 @@ private:
|
|||||||
int _dso_ym_start;
|
int _dso_ym_start;
|
||||||
int _dso_ym_end;
|
int _dso_ym_end;
|
||||||
|
|
||||||
int _waiting_trig;
|
int _waiting_trig;
|
||||||
bool _dso_trig_moved;
|
bool _dso_trig_moved;
|
||||||
bool _curs_moved;
|
bool _curs_moved;
|
||||||
bool _xcurs_moved;
|
bool _xcurs_moved;
|
||||||
|
int _clickX;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace view
|
} // namespace view
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ class Decoder(srd.Decoder):
|
|||||||
|
|
||||||
# 解码函数,解码任务开始时由c底层代码调用
|
# 解码函数,解码任务开始时由c底层代码调用
|
||||||
# 这里不断循环等待所有采样数据被处理完成
|
# 这里不断循环等待所有采样数据被处理完成
|
||||||
# 下面的未例代码是想以一对向上边沿和向下边沿,输出它们的样品位置差值,
|
# 下面的示例代码是解析某一通道的数据,从向上边沿开始到向下边沿结束,输出它们的样品位置差值,
|
||||||
# 同时奇数次显示第二行,偶数次显示在第一行,我们只要指定了annotations里定义的序号
|
# 奇数次显示第二行,偶数次显示在第一行,我们只指定annotations里定义的序号
|
||||||
# 软件会自动根据annotation_rows的设置,决定显示在哪一行
|
# 软件会自动根据annotation_rows的设置,决定显示在哪一行
|
||||||
def decode(self):
|
def decode(self):
|
||||||
# 次数计数
|
# 次数计数
|
||||||
|
|||||||
Reference in New Issue
Block a user