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
a11e8a04
Commit
a11e8a04
authored
5 years ago
by
DreamSourceLab
Browse files
Options
Download
Email Patches
Plain Diff
Fix ruler and cursor issue in DSO mode
parent
771f2c56
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
135 additions
and
15 deletions
+135
-15
DSView/pv/view/cursor.cpp
DSView/pv/view/cursor.cpp
+5
-4
DSView/pv/view/cursor.h
DSView/pv/view/cursor.h
+2
-2
DSView/pv/view/ruler.cpp
DSView/pv/view/ruler.cpp
+124
-6
DSView/pv/view/ruler.h
DSView/pv/view/ruler.h
+1
-0
DSView/pv/view/timemarker.h
DSView/pv/view/timemarker.h
+1
-1
DSView/pv/view/viewport.cpp
DSView/pv/view/viewport.cpp
+2
-2
No files found.
DSView/pv/view/cursor.cpp
View file @
a11e8a04
...
...
@@ -85,7 +85,7 @@ QRect Cursor::get_close_rect(const QRect &rect) const
}
void
Cursor
::
paint_label
(
QPainter
&
p
,
const
QRect
&
rect
,
unsigned
int
prefix
,
int
index
)
unsigned
int
prefix
,
int
index
,
bool
has_hoff
)
{
assert
(
index
>
0
);
...
...
@@ -93,7 +93,7 @@ void Cursor::paint_label(QPainter &p, const QRect &rect,
bool
visible
;
compute_text_size
(
p
,
prefix
);
const
QRect
r
(
get_label_rect
(
rect
,
visible
));
const
QRect
r
(
get_label_rect
(
rect
,
visible
,
has_hoff
));
if
(
!
visible
)
return
;
const
QRect
close
(
get_close_rect
(
r
));
...
...
@@ -153,8 +153,9 @@ void Cursor::paint_fix_label(QPainter &p, const QRect &rect,
p
.
drawPolygon
(
points
,
countof
(
points
));
p
.
setPen
(
Qt
::
white
);
p
.
drawText
(
r
,
Qt
::
AlignCenter
|
Qt
::
AlignVCenter
,
Ruler
::
format_real_time
(
_index
,
_view
.
session
().
cur_snap_samplerate
()));
if
(
has_hoff
)
p
.
drawText
(
r
,
Qt
::
AlignCenter
|
Qt
::
AlignVCenter
,
Ruler
::
format_real_time
(
_index
,
_view
.
session
().
cur_snap_samplerate
()));
const
QRect
arrowRect
=
QRect
(
r
.
bottomLeft
().
x
(),
r
.
bottomLeft
().
y
(),
r
.
width
(),
ArrowSize
);
p
.
drawText
(
arrowRect
,
Qt
::
AlignCenter
|
Qt
::
AlignVCenter
,
label
);
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/cursor.h
View file @
a11e8a04
...
...
@@ -74,8 +74,8 @@ public:
* @param rect The rectangle of the ruler client area.
* @param prefix The index of the SI prefix to use.
*/
void
paint_label
(
QPainter
&
p
,
const
QRect
&
rect
,
unsigned
int
prefix
,
int
index
);
void
paint_label
(
QPainter
&
p
,
const
QRect
&
rect
,
unsigned
int
prefix
,
int
index
,
bool
has_hoff
);
void
paint_fix_label
(
QPainter
&
p
,
const
QRect
&
rect
,
unsigned
int
prefix
,
QChar
label
,
QColor
color
,
bool
has_hoff
);
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/ruler.cpp
View file @
a11e8a04
...
...
@@ -175,7 +175,10 @@ void Ruler::paintEvent(QPaintEvent*)
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
o
,
&
p
,
this
);
// Draw tick mark
draw_logic_tick_mark
(
p
);
if
(
_view
.
session
().
get_device
()
->
dev_inst
()
->
mode
==
DSO
)
draw_osc_tick_mark
(
p
);
else
draw_logic_tick_mark
(
p
);
p
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
// Draw the hover mark
...
...
@@ -340,11 +343,126 @@ void Ruler::draw_logic_tick_mark(QPainter &p)
// Find tick spacing, and number formatting that does not cause
// value to collide.
if
(
_view
.
session
().
get_device
()
->
dev_inst
()
->
mode
==
DSO
)
{
_min_period
=
_view
.
session
().
get_device
()
->
get_time_base
()
*
std
::
pow
(
10.0
,
-
9.0
);
}
else
{
_min_period
=
cur_period_scale
*
abs_min_period
;
_min_period
=
cur_period_scale
*
abs_min_period
;
const
int
order
=
(
int
)
floorf
(
log10f
(
scale
*
_view
.
get_view_width
()));
//const double order_decimal = pow(10, order);
const
unsigned
int
prefix
=
(
order
-
FirstSIPrefixPower
)
/
3
;
_cur_prefix
=
prefix
;
assert
(
prefix
<
countof
(
SIPrefixes
));
typical_width
=
p
.
boundingRect
(
0
,
0
,
INT_MAX
,
INT_MAX
,
AlignLeft
|
AlignTop
,
format_time
(
offset
*
scale
,
prefix
)).
width
()
+
MinValueSpacing
;
do
{
tick_period
+=
_min_period
;
}
while
(
typical_width
>
tick_period
/
scale
);
const
int
text_height
=
p
.
boundingRect
(
0
,
0
,
INT_MAX
,
INT_MAX
,
AlignLeft
|
AlignTop
,
"8"
).
height
();
// Draw the tick marks
QColor
fore
(
QWidget
::
palette
().
color
(
QWidget
::
foregroundRole
()));
fore
.
setAlpha
(
View
::
ForeAlpha
);
p
.
setPen
(
fore
);
const
double
minor_tick_period
=
tick_period
/
MinPeriodScale
;
const
int
minor_order
=
(
int
)
floorf
(
log10f
(
minor_tick_period
));
//const double minor_order_decimal = pow(10, minor_order);
const
unsigned
int
minor_prefix
=
(
minor_order
-
FirstSIPrefixPower
)
/
3
;
assert
(
minor_prefix
<
countof
(
SIPrefixes
));
const
double
first_major_division
=
floor
(
offset
*
scale
/
tick_period
);
const
double
first_minor_division
=
floor
(
offset
*
scale
/
minor_tick_period
+
1
);
const
double
t0
=
first_major_division
*
tick_period
;
int
division
=
(
int
)
round
(
first_minor_division
-
first_major_division
*
MinPeriodScale
)
-
1
;
const
int
major_tick_y1
=
text_height
+
ValueMargin
*
3
;
const
int
tick_y2
=
height
();
const
int
minor_tick_y1
=
(
major_tick_y1
+
tick_y2
)
/
2
;
int
x
;
const
double
inc_text_width
=
p
.
boundingRect
(
0
,
0
,
INT_MAX
,
INT_MAX
,
AlignLeft
|
AlignTop
,
format_time
(
minor_tick_period
,
minor_prefix
)).
width
()
+
MinValueSpacing
;
do
{
const
double
t
=
t0
+
division
*
minor_tick_period
;
const
double
major_t
=
t0
+
floor
(
division
/
MinPeriodScale
)
*
tick_period
;
x
=
t
/
scale
-
offset
;
if
(
division
%
MinPeriodScale
==
0
)
{
// Draw a major tick
p
.
drawText
(
x
,
2
*
ValueMargin
,
0
,
text_height
,
AlignCenter
|
AlignTop
|
TextDontClip
,
format_time
(
t
,
prefix
));
p
.
drawLine
(
QPoint
(
x
,
major_tick_y1
),
QPoint
(
x
,
tick_y2
));
}
else
{
// Draw a minor tick
if
(
minor_tick_period
/
scale
>
2
*
typical_width
)
p
.
drawText
(
x
,
2
*
ValueMargin
,
0
,
text_height
,
AlignCenter
|
AlignTop
|
TextDontClip
,
format_time
(
t
,
prefix
));
//else if ((tick_period / scale > width() / 4) && (minor_tick_period / scale > inc_text_width))
else
if
(
minor_tick_period
/
scale
>
1.1
*
inc_text_width
||
tick_period
/
scale
>
_view
.
get_view_width
())
p
.
drawText
(
x
,
2
*
ValueMargin
,
0
,
minor_tick_y1
+
ValueMargin
,
AlignCenter
|
AlignTop
|
TextDontClip
,
format_time
(
t
-
major_t
,
minor_prefix
));
p
.
drawLine
(
QPoint
(
x
,
minor_tick_y1
),
QPoint
(
x
,
tick_y2
));
}
division
++
;
}
while
(
x
<
rect
().
right
());
// Draw the cursors
if
(
!
_view
.
get_cursorList
().
empty
())
{
list
<
Cursor
*>::
iterator
i
=
_view
.
get_cursorList
().
begin
();
int
index
=
1
;
while
(
i
!=
_view
.
get_cursorList
().
end
())
{
(
*
i
)
->
paint_label
(
p
,
rect
(),
prefix
,
index
,
_view
.
session
().
get_capture_state
()
==
SigSession
::
Stopped
);
index
++
;
i
++
;
}
}
if
(
_view
.
trig_cursor_shown
())
{
_view
.
get_trig_cursor
()
->
paint_fix_label
(
p
,
rect
(),
prefix
,
'T'
,
_view
.
get_trig_cursor
()
->
colour
(),
false
);
}
if
(
_view
.
search_cursor_shown
())
{
_view
.
get_search_cursor
()
->
paint_fix_label
(
p
,
rect
(),
prefix
,
'S'
,
_view
.
get_search_cursor
()
->
colour
(),
true
);
}
}
void
Ruler
::
draw_osc_tick_mark
(
QPainter
&
p
)
{
using
namespace
Qt
;
const
double
MinValueSpacing
=
16.0
;
const
int
ValueMargin
=
5
;
double
typical_width
;
double
tick_period
=
0
;
double
scale
=
_view
.
scale
();
//int64_t offset = _view.offset();
int64_t
offset
=
0
;
// Find tick spacing, and number formatting that does not cause
// value to collide.
_min_period
=
_view
.
session
().
get_device
()
->
get_time_base
()
*
std
::
pow
(
10.0
,
-
9.0
);
const
int
order
=
(
int
)
floorf
(
log10f
(
scale
*
_view
.
get_view_width
()));
//const double order_decimal = pow(10, order);
const
unsigned
int
prefix
=
(
order
-
FirstSIPrefixPower
)
/
3
;
...
...
@@ -433,7 +551,7 @@ void Ruler::draw_logic_tick_mark(QPainter &p)
list
<
Cursor
*>::
iterator
i
=
_view
.
get_cursorList
().
begin
();
int
index
=
1
;
while
(
i
!=
_view
.
get_cursorList
().
end
())
{
(
*
i
)
->
paint_label
(
p
,
rect
(),
prefix
,
index
);
(
*
i
)
->
paint_label
(
p
,
rect
(),
prefix
,
index
,
_view
.
session
().
get_capture_state
()
==
SigSession
::
Stopped
);
index
++
;
i
++
;
}
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/ruler.h
View file @
a11e8a04
...
...
@@ -79,6 +79,7 @@ private:
private:
void
draw_logic_tick_mark
(
QPainter
&
p
);
void
draw_osc_tick_mark
(
QPainter
&
p
);
/**
* Draw a hover arrow under the cursor position.
*/
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/timemarker.h
View file @
a11e8a04
...
...
@@ -101,7 +101,7 @@ public:
* @param prefix The SI prefix to paint time value with.
*/
virtual
void
paint_label
(
QPainter
&
p
,
const
QRect
&
rect
,
unsigned
int
prefix
,
int
index
)
=
0
;
unsigned
int
prefix
,
int
index
,
bool
has_hoff
)
=
0
;
signals:
void
time_changed
();
...
...
This diff is collapsed.
Click to expand it.
DSView/pv/view/viewport.cpp
View file @
a11e8a04
...
...
@@ -245,9 +245,9 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
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
);
(
*
i
)
->
paint
(
p
,
xrect
,
1
,
index
,
_view
.
session
().
get_capture_state
()
==
SigSession
::
Stopped
);
else
(
*
i
)
->
paint
(
p
,
xrect
,
0
,
index
);
(
*
i
)
->
paint
(
p
,
xrect
,
0
,
index
,
_view
.
session
().
get_capture_state
()
==
SigSession
::
Stopped
);
i
++
;
index
++
;
}
...
...
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