Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
taskbus
提交
c3b50c3f
taskbus
项目概览
colorEagleStdio
/
taskbus
通知
159
Star
11
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
taskbus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c3b50c3f
编写于
6月 26, 2023
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
解决内存越界导致的崩溃
上级
f8b6233e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
88 addition
and
76 deletion
+88
-76
modules/sinks/sink_plots/dialogplots.cpp
modules/sinks/sink_plots/dialogplots.cpp
+88
-76
未找到文件。
modules/sinks/sink_plots/dialogplots.cpp
浏览文件 @
c3b50c3f
...
...
@@ -66,7 +66,7 @@ void DialogPlots::deal_package(QByteArray package)
return
;
const
subject_package_header
*
pheader
=
(
const
subject_package_header
*
)
package
.
constData
();
package
.
constData
();
if
(
m_plot_idxes
.
contains
(
pheader
->
subject_id
)
==
false
)
return
;
...
...
@@ -155,7 +155,7 @@ QVector<double> DialogPlots::flush_data(QByteArray package)
return
vec_res
;
const
subject_package_header
*
pheader
=
(
const
subject_package_header
*
)
package
.
constData
();
package
.
constData
();
if
(
m_plot_idxes
.
contains
(
pheader
->
subject_id
)
==
false
)
return
vec_res
;
...
...
@@ -173,83 +173,83 @@ QVector<double> DialogPlots::flush_data(QByteArray package)
{
case
0
:
pts
=
pheader
->
data_length
/
sizeof
(
quint8
)
/
channels
;
{
const
quint8
*
ptrRaw
=
(
const
quint8
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
quint8
*
ptrRaw
=
(
const
quint8
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
1
:
pts
=
pheader
->
data_length
/
sizeof
(
qint8
)
/
channels
;
{
const
qint8
*
ptrRaw
=
(
const
qint8
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
qint8
*
ptrRaw
=
(
const
qint8
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
2
:
pts
=
pheader
->
data_length
/
sizeof
(
quint16
)
/
channels
;
{
const
quint16
*
ptrRaw
=
(
const
quint16
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
quint16
*
ptrRaw
=
(
const
quint16
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
3
:
pts
=
pheader
->
data_length
/
sizeof
(
qint16
)
/
channels
;
{
const
qint16
*
ptrRaw
=
(
const
qint16
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
qint16
*
ptrRaw
=
(
const
qint16
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
4
:
pts
=
pheader
->
data_length
/
sizeof
(
quint32
)
/
channels
;
{
const
quint32
*
ptrRaw
=
(
const
quint32
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
quint32
*
ptrRaw
=
(
const
quint32
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
5
:
pts
=
pheader
->
data_length
/
sizeof
(
qint32
)
/
channels
;
{
const
qint32
*
ptrRaw
=
(
const
qint32
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
qint32
*
ptrRaw
=
(
const
qint32
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
6
:
pts
=
pheader
->
data_length
/
sizeof
(
quint64
)
/
channels
;
{
const
quint64
*
ptrRaw
=
(
const
quint64
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
quint64
*
ptrRaw
=
(
const
quint64
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
7
:
pts
=
pheader
->
data_length
/
sizeof
(
qint64
)
/
channels
;
{
const
qint64
*
ptrRaw
=
(
const
qint64
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
qint64
*
ptrRaw
=
(
const
qint64
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
8
:
pts
=
pheader
->
data_length
/
sizeof
(
float
)
/
channels
;
{
const
float
*
ptrRaw
=
(
const
float
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
float
*
ptrRaw
=
(
const
float
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
case
9
:
pts
=
pheader
->
data_length
/
sizeof
(
double
)
/
channels
;
{
const
double
*
ptrRaw
=
(
const
double
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
{
const
double
*
ptrRaw
=
(
const
double
*
)
rawdata
;
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
vec_res
<<
ptrRaw
[
i
];
}
break
;
default:
break
;
...
...
@@ -301,7 +301,10 @@ void DialogPlots::on_pushButton_reset_clicked()
if
(
min_y
<
new_min_y
)
new_min_y
=
min_y
,
needup_y
=
true
;
if
(
min_y
>
new_min_y
*
1.2
)
new_min_y
=
min_y
,
needup_y
=
true
;
if
(
max_x
>=
1e9
||
max_x
<-
1e9
||
max_y
>
1e9
||
max_y
<
-
1e9
||
max_x
-
min_x
<
1e-8
)
needup_x
=
false
,
needup_y
=
false
;
if
(
min_y
>=
1e9
||
min_y
<-
1e9
||
min_x
>
1e9
||
min_x
<
-
1e9
||
max_y
-
min_y
<
1e-8
)
needup_x
=
false
,
needup_y
=
false
;
if
(
needup_x
==
true
)
ax
->
setRange
(
new_min_x
,
new_max_x
);
...
...
@@ -367,7 +370,7 @@ void DialogPlots::timerEvent(QTimerEvent *event)
for
(
QList
<
QVector
<
double
>
>::
iterator
pit
=
avgList
.
begin
();
pit
!=
avgList
.
end
();
++
pit
)
{
for
(
int
i
=
0
;
i
<
pts
;
++
i
)
fdata
[
i
]
+=
pit
->
at
(
i
)
/
avgsz
;
fdata
[
i
]
+=
pit
->
at
(
i
)
/
(
avgsz
+
1e-14
)
;
}
double
max_x
=
0
,
max_y
=
fdata
[
0
];
...
...
@@ -382,7 +385,7 @@ void DialogPlots::timerEvent(QTimerEvent *event)
{
SpectroWidget
*
ws
=
m_chat_spec
[
subid
];
QVector
<
QPointF
>
vec_points
;
for
(
int
i
=
0
;
i
<
pts
;
i
+=
step
)
for
(
int
i
=
0
;
i
<
pts
/
channels
;
i
+=
step
)
{
double
x
,
y
;
if
(
channels
==
1
)
...
...
@@ -397,26 +400,30 @@ void DialogPlots::timerEvent(QTimerEvent *event)
if
(
y
<
min_y
)
min_y
=
y
;
}
serials
->
replace
(
vec_points
);
if
(
ws
)
if
(
!
(
max_x
>=
1e9
||
max_x
<-
1e9
||
max_y
>
1e9
||
max_y
<
-
1e9
||
max_x
-
min_x
<
1e-8
)
||
(
min_y
>=
1e9
||
min_y
<-
1e9
||
min_x
>
1e9
||
min_x
<
-
1e9
||
max_y
-
min_y
<
1e-8
)
)
{
QChart
*
ca
=
m_chars
[
subid
];
QValueAxis
*
axx
=
m_char_axis_x
[
subid
];
QValueAxis
*
axy
=
m_char_axis_y
[
subid
];
double
dmin
=
axx
->
min
();
double
dmax
=
axx
->
max
();
QRectF
r
=
ca
->
plotArea
();
ws
->
setMinMaxRange
(
axy
->
min
(),
axy
->
max
());
ws
->
append_data
(
vec_tmp
,
r
.
left
(),
r
.
right
(),
dmin
,
dmax
);
serials
->
replace
(
vec_points
);
if
(
ws
)
{
QChart
*
ca
=
m_chars
[
subid
];
QValueAxis
*
axx
=
m_char_axis_x
[
subid
];
QValueAxis
*
axy
=
m_char_axis_y
[
subid
];
double
dmin
=
axx
->
min
();
double
dmax
=
axx
->
max
();
QRectF
r
=
ca
->
plotArea
();
ws
->
setMinMaxRange
(
axy
->
min
(),
axy
->
max
());
ws
->
append_data
(
vec_tmp
,
r
.
left
(),
r
.
right
(),
dmin
,
dmax
);
}
}
...
...
@@ -438,8 +445,9 @@ void DialogPlots::timerEvent(QTimerEvent *event)
if
(
y
<
min_y
)
min_y
=
y
;
}
serials
->
replace
(
lstpts
);
if
(
!
(
max_x
>=
1e9
||
max_x
<-
1e9
||
max_y
>
1e9
||
max_y
<
-
1e9
||
max_x
-
min_x
<
1e-8
)
||
(
min_y
>=
1e9
||
min_y
<-
1e9
||
min_x
>
1e9
||
min_x
<
-
1e9
||
max_y
-
min_y
<
1e-8
))
serials
->
replace
(
lstpts
);
}
//QChart *chart = m_chars[subid];
...
...
@@ -465,6 +473,10 @@ void DialogPlots::timerEvent(QTimerEvent *event)
if
(
min_y
<
new_min_y
)
new_min_y
=
min_y
,
needup_y
=
true
;
if
(
min_y
>
new_min_y
*
1.2
)
new_min_y
=
min_y
,
needup_y
=
true
;
if
(
max_x
>=
1e9
||
max_x
<-
1e9
||
max_y
>
1e9
||
max_y
<
-
1e9
||
max_x
-
min_x
<
1e-8
)
needup_x
=
false
,
needup_y
=
false
;
if
(
min_y
>=
1e9
||
min_y
<-
1e9
||
min_x
>
1e9
||
min_x
<
-
1e9
||
max_y
-
min_y
<
1e-8
)
needup_x
=
false
,
needup_y
=
false
;
if
(
ui
->
checkBox_auto_reser
->
isChecked
()
||
needup_x
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录