Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Raptor Engineering Public Development
dsview
Commits
5bd97eb8
Commit
5bd97eb8
authored
8 years ago
by
DreamSourceLab
Browse files
Options
Download
Email Patches
Plain Diff
Add error display for decoder trace; Adjust comboBox width on contents
parent
d86c9558
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
47 deletions
+83
-47
DSView/pv/data/decoderstack.cpp
DSView/pv/data/decoderstack.cpp
+12
-9
DSView/pv/dock/measuredock.cpp
DSView/pv/dock/measuredock.cpp
+6
-0
DSView/pv/dock/protocoldock.cpp
DSView/pv/dock/protocoldock.cpp
+26
-14
DSView/pv/dock/protocoldock.h
DSView/pv/dock/protocoldock.h
+6
-1
DSView/pv/toolbars/samplingbar.cpp
DSView/pv/toolbars/samplingbar.cpp
+14
-0
DSView/pv/toolbars/samplingbar.h
DSView/pv/toolbars/samplingbar.h
+1
-0
DSView/pv/view/decodetrace.cpp
DSView/pv/view/decodetrace.cpp
+17
-22
DSView/pv/view/decodetrace.h
DSView/pv/view/decodetrace.h
+1
-1
No files found.
DSView/pv/data/decoderstack.cpp
View file @
5bd97eb8
...
...
@@ -499,6 +499,7 @@ void DecoderStack::decode_data(
uint64_t
entry_cnt
=
0
;
uint8_t
chunk_type
=
0
;
uint64_t
i
=
decode_start
;
char
*
error
=
NULL
;
while
(
!
boost
::
this_thread
::
interruption_requested
()
&&
i
<
decode_end
&&
!
_no_memory
)
{
...
...
@@ -509,8 +510,8 @@ void DecoderStack::decode_data(
chunk
=
_snapshot
->
get_samples
(
i
,
chunk_end
);
if
(
srd_session_send
(
session
,
chunk_type
,
i
,
chunk_end
,
chunk
,
(
chunk_end
-
i
)
*
unit_size
,
unit_size
)
!=
SRD_OK
)
{
_error_message
=
tr
(
"Decoder reported an
error
"
);
(
chunk_end
-
i
)
*
unit_size
,
unit_size
,
&
error
)
!=
SRD_OK
)
{
_error_message
=
QString
::
fromLocal8Bit
(
error
);
break
;
}
...
...
@@ -561,6 +562,8 @@ void DecoderStack::decode_data(
}
entry_cnt
++
;
}
if
(
error
)
g_free
(
error
);
decode_done
();
}
...
...
@@ -617,15 +620,15 @@ void DecoderStack::decode_proc()
srd_pd_output_callback_add
(
session
,
SRD_OUTPUT_ANN
,
DecoderStack
::
annotation_callback
,
this
);
srd_session_start
(
session
);
// do {
// decode_data(*sample_count, unit_size, session);
// } while(_error_message.isEmpty() && (sample_count = wait_for_data()));
//decode_data(*sample_count, unit_size, session);
decode_data
(
decode_start
,
decode_end
,
unit_size
,
session
);
char
*
error
=
NULL
;
if
(
srd_session_start
(
session
,
&
error
)
==
SRD_OK
)
decode_data
(
decode_start
,
decode_end
,
unit_size
,
session
);
else
_error_message
=
QString
::
fromLocal8Bit
(
error
);
// Destroy the session
if
(
error
)
g_free
(
error
);
srd_session_destroy
(
session
);
_decode_state
=
Stopped
;
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/dock/measuredock.cpp
View file @
5bd97eb8
...
...
@@ -92,6 +92,9 @@ MeasureDock::MeasureDock(QWidget *parent, View &view, SigSession &session) :
_t1_last_index
=
0
;
_t2_last_index
=
0
;
_t3_last_index
=
0
;
_t1_comboBox
->
setSizeAdjustPolicy
(
QComboBox
::
AdjustToContents
);
_t2_comboBox
->
setSizeAdjustPolicy
(
QComboBox
::
AdjustToContents
);
_t3_comboBox
->
setSizeAdjustPolicy
(
QComboBox
::
AdjustToContents
);
_cursor_layout
=
new
QGridLayout
(
_widget
);
_cursor_layout
->
addWidget
(
new
QLabel
(
tr
(
"T1: "
),
_widget
),
0
,
0
);
...
...
@@ -203,6 +206,9 @@ void MeasureDock::cursor_update()
index
++
;
}
_t1_comboBox
->
setMinimumWidth
(
_t1_comboBox
->
sizeHint
().
width
()
+
15
);
_t2_comboBox
->
setMinimumWidth
(
_t2_comboBox
->
sizeHint
().
width
()
+
15
);
_t3_comboBox
->
setMinimumWidth
(
_t3_comboBox
->
sizeHint
().
width
()
+
15
);
if
(
_t1_last_index
<
_t1_comboBox
->
count
())
_t1_comboBox
->
setCurrentIndex
(
_t1_last_index
);
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/dock/protocoldock.cpp
View file @
5bd97eb8
...
...
@@ -43,9 +43,11 @@
#include <QFuture>
#include <QProgressDialog>
#include <QtConcurrent/QtConcurrent>
#include <QSizePolicy>
#include <boost/foreach.hpp>
#include <boost/shared_ptr.hpp>
#include <algorithm>
namespace
pv
{
namespace
dock
{
...
...
@@ -154,21 +156,19 @@ ProtocolDock::ProtocolDock(QWidget *parent, SigSession &session) :
search_button
->
setFixedWidth
(
search_button
->
height
());
search_button
->
setDisabled
(
true
);
_search_edit
=
new
QLineEdit
(
_dn_widget
);
_search_edit
->
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
);
_search_edit
->
setPlaceholderText
(
tr
(
"search"
));
QHBoxLayout
*
search_layout
=
new
QHBoxLayout
();
search_layout
->
addWidget
(
search_button
);
search_layout
->
addStretch
();
search_layout
->
addStretch
(
1
);
search_layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
_search_edit
->
setLayout
(
search_layout
);
_search_edit
->
setTextMargins
(
search_button
->
width
(),
0
,
0
,
0
);
QSizePolicy
sp
=
_search_edit
->
sizePolicy
();
sp
.
setHorizontalStretch
(
1
);
_search_edit
->
setSizePolicy
(
sp
);
QHBoxLayout
*
dn_search_layout
=
new
QHBoxLayout
();
dn_search_layout
->
addWidget
(
_pre_button
,
0
,
Qt
::
AlignLeft
);
dn_search_layout
->
addWidget
(
_search_edit
,
0
,
Qt
::
AlignLeft
);
dn_search_layout
->
addWidget
(
_nxt_button
,
0
,
Qt
::
AlignRight
);
_
dn_search_layout
=
new
QHBoxLayout
();
_
dn_search_layout
->
addWidget
(
_pre_button
,
0
,
Qt
::
AlignLeft
);
_
dn_search_layout
->
addWidget
(
_search_edit
,
1
,
Qt
::
AlignLeft
);
_
dn_search_layout
->
addWidget
(
_nxt_button
,
0
,
Qt
::
AlignRight
);
_matchs_label
=
new
QLabel
(
_dn_widget
);
QHBoxLayout
*
dn_match_layout
=
new
QHBoxLayout
();
...
...
@@ -176,13 +176,13 @@ ProtocolDock::ProtocolDock(QWidget *parent, SigSession &session) :
dn_match_layout
->
addWidget
(
_matchs_label
,
0
,
Qt
::
AlignLeft
);
dn_match_layout
->
addStretch
(
1
);
QVBoxLayout
*
dn_layout
=
new
QVBoxLayout
();
dn_layout
->
addLayout
(
dn_title_layout
);
dn_layout
->
addLayout
(
dn_search_layout
);
dn_layout
->
addLayout
(
dn_match_layout
);
dn_layout
->
addWidget
(
_table_view
);
_
dn_layout
=
new
QVBoxLayout
();
_
dn_layout
->
addLayout
(
dn_title_layout
);
_
dn_layout
->
addLayout
(
_
dn_search_layout
);
_
dn_layout
->
addLayout
(
dn_match_layout
);
_
dn_layout
->
addWidget
(
_table_view
);
_dn_widget
->
setLayout
(
dn_layout
);
_dn_widget
->
setLayout
(
_
dn_layout
);
_dn_widget
->
setMinimumHeight
(
350
);
_split_widget
=
new
QSplitter
(
this
);
...
...
@@ -219,6 +219,18 @@ void ProtocolDock::paintEvent(QPaintEvent *)
// style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void
ProtocolDock
::
resizeEvent
(
QResizeEvent
*
event
)
{
int
width
=
this
->
visibleRegion
().
boundingRect
().
width
();
width
=
width
-
_dn_layout
->
margin
()
*
2
-
_dn_search_layout
->
margin
()
*
2
-
_dn_search_layout
->
spacing
()
*
2
-
_pre_button
->
width
()
-
_nxt_button
->
width
();
width
=
std
::
max
(
width
,
0
);
_search_edit
->
setMinimumWidth
(
width
);
QScrollArea
::
resizeEvent
(
event
);
}
int
ProtocolDock
::
decoder_name_cmp
(
const
void
*
a
,
const
void
*
b
)
{
return
strcmp
(((
const
srd_decoder
*
)
a
)
->
name
,
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/dock/protocoldock.h
View file @
5bd97eb8
...
...
@@ -64,10 +64,13 @@ public:
public:
ProtocolDock
(
QWidget
*
parent
,
SigSession
&
session
);
~
ProtocolDock
();
void
paintEvent
(
QPaintEvent
*
);
void
del_all_protocol
();
protected:
void
paintEvent
(
QPaintEvent
*
);
void
resizeEvent
(
QResizeEvent
*
);
signals:
void
protocol_updated
();
...
...
@@ -104,6 +107,8 @@ private:
QPushButton
*
_pre_button
;
QPushButton
*
_nxt_button
;
QLineEdit
*
_search_edit
;
QHBoxLayout
*
_dn_search_layout
;
QVBoxLayout
*
_dn_layout
;
QLabel
*
_matchs_label
;
QPushButton
*
_add_button
;
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/toolbars/samplingbar.cpp
View file @
5bd97eb8
...
...
@@ -31,6 +31,7 @@
#include <QAction>
#include <QDebug>
#include <QLabel>
#include <QAbstractItemView>
#include "samplingbar.h"
...
...
@@ -114,7 +115,11 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
_run_stop_button
.
setIcon
(
_icon_start
);
_instant_button
.
setIcon
(
_icon_instant
);
_device_selector
.
setSizeAdjustPolicy
(
QComboBox
::
AdjustToContents
);
_sample_rate
.
setSizeAdjustPolicy
(
QComboBox
::
AdjustToContents
);
_sample_count
.
setSizeAdjustPolicy
(
QComboBox
::
AdjustToContents
);
_device_selector
.
setMaximumWidth
(
ComboBoxMaxWidth
);
set_sampling
(
false
);
connect
(
&
_sample_count
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
on_samplecount_sel
(
int
)));
...
...
@@ -163,6 +168,9 @@ void SamplingBar::set_device_list(
_device_selector
.
addItem
(
title
,
qVariantFromValue
((
void
*
)
id
));
}
int
width
=
_device_selector
.
sizeHint
().
width
();
_device_selector
.
setFixedWidth
(
min
(
width
+
15
,
_device_selector
.
maximumWidth
()));
_device_selector
.
view
()
->
setMinimumWidth
(
width
+
30
);
// The selected device should have been in the list
assert
(
selected_index
!=
-
1
);
...
...
@@ -407,6 +415,10 @@ void SamplingBar::update_sample_rate_selector()
_sample_rate
.
show
();
g_variant_unref
(
gvar_list
);
}
_sample_rate
.
setMinimumWidth
(
_sample_rate
.
sizeHint
().
width
()
+
15
);
_sample_rate
.
view
()
->
setMinimumWidth
(
_sample_rate
.
sizeHint
().
width
()
+
30
);
_updating_sample_rate
=
false
;
g_variant_unref
(
gvar_dict
);
...
...
@@ -576,6 +588,8 @@ void SamplingBar::update_sample_count_selector()
_sample_count
.
show
();
g_variant_unref
(
gvar_list
);
}
_sample_count
.
setMinimumWidth
(
_sample_count
.
sizeHint
().
width
()
+
15
);
_sample_count
.
view
()
->
setMinimumWidth
(
_sample_count
.
sizeHint
().
width
()
+
30
);
_updating_sample_count
=
false
;
g_variant_unref
(
gvar_dict
);
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/toolbars/samplingbar.h
View file @
5bd97eb8
...
...
@@ -63,6 +63,7 @@ class SamplingBar : public QToolBar
private:
static
const
uint64_t
RecordLengths
[
19
];
static
const
uint64_t
DefaultRecordLength
;
static
const
int
ComboBoxMaxWidth
=
200
;
public:
SamplingBar
(
SigSession
&
session
,
QWidget
*
parent
);
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/decodetrace.cpp
View file @
5bd97eb8
...
...
@@ -240,6 +240,14 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
{
using
namespace
pv
::
data
::
decode
;
assert
(
_decoder_stack
);
const
QString
err
=
_decoder_stack
->
error_message
();
if
(
!
err
.
isEmpty
())
{
draw_error
(
p
,
err
,
left
,
right
);
return
;
}
const
double
scale
=
_view
->
scale
();
assert
(
scale
>
0
);
...
...
@@ -267,14 +275,6 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
const
int
annotation_height
=
_view
->
get_signalHeight
();
assert
(
_decoder_stack
);
const
QString
err
=
_decoder_stack
->
error_message
();
if
(
!
err
.
isEmpty
())
{
draw_error
(
p
,
err
,
left
,
right
);
return
;
}
// Iterate through the rows
assert
(
_view
);
int
y
=
get_y
()
-
(
_totalHeight
-
annotation_height
)
*
0.5
;
...
...
@@ -610,24 +610,19 @@ void DecodeTrace::draw_error(QPainter &p, const QString &message,
int
left
,
int
right
)
{
const
int
y
=
get_y
();
const
int
h
=
get_totalHeight
();
p
.
setPen
(
ErrorBgColour
.
darker
());
p
.
setBrush
(
ErrorBgColour
);
const
QRectF
bounding_rect
=
QRectF
(
left
,
INT_MIN
/
2
+
y
,
right
-
left
,
INT_MAX
);
const
QRectF
text_rect
=
p
.
boundingRect
(
bounding_rect
,
Qt
::
AlignCenter
,
message
);
const
float
r
=
text_rect
.
height
()
/
4
;
p
.
drawRoundedRect
(
text_rect
.
adjusted
(
-
r
,
-
r
,
r
,
r
),
r
,
r
,
Qt
::
AbsoluteSize
);
p
.
setPen
(
get_text_colour
());
const
QRectF
text_rect
(
left
,
y
-
h
/
2
+
0.5
,
right
-
left
,
h
);
const
QRectF
bounding_rect
=
p
.
boundingRect
(
text_rect
,
Qt
::
AlignCenter
,
message
);
p
.
setPen
(
Qt
::
red
);
QFont
font
=
p
.
font
();
font
.
setPointSize
(
DefaultFontSize
);
p
.
setFont
(
font
);
p
.
drawText
(
text_rect
,
message
);
if
(
bounding_rect
.
width
()
<
text_rect
.
width
())
p
.
drawText
(
text_rect
,
Qt
::
AlignCenter
,
tr
(
"Error: "
)
+
message
);
else
p
.
drawText
(
text_rect
,
Qt
::
AlignCenter
,
tr
(
"Error: ..."
));
}
void
DecodeTrace
::
draw_unshown_row
(
QPainter
&
p
,
int
y
,
int
h
,
int
left
,
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/decodetrace.h
View file @
5bd97eb8
...
...
@@ -89,7 +89,7 @@ private:
static
const
QColor
Colours
[
16
];
static
const
QColor
OutlineColours
[
16
];
static
const
int
DefaultFontSize
=
8
;
static
const
int
DefaultFontSize
=
10
;
static
const
int
ControlRectWidth
=
5
;
static
const
int
MaxAnnType
=
100
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment