projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change QApplication::translate to tr, removing deprecated UTF8 parameter
[pulseview.git]
/
pv
/
view
/
cursorpair.cpp
diff --git
a/pv/view/cursorpair.cpp
b/pv/view/cursorpair.cpp
index d8af3d76f319e19596e406f2b4aa9deca1f24685..d319a7b1bffc3b69e67e937c46a3b0a38aee1747 100644
(file)
--- a/
pv/view/cursorpair.cpp
+++ b/
pv/view/cursorpair.cpp
@@
-20,41
+20,36
@@
#include "cursorpair.h"
#include "cursorpair.h"
-#include "ruler.h"
#include "view.h"
#include "view.h"
+#include "pv/util.h"
+#include <cassert>
#include <algorithm>
#include <algorithm>
-using namespace std;
+using std::max;
+using std::make_pair;
+using std::min;
+using std::shared_ptr;
+using std::pair;
namespace pv {
namespace view {
const int CursorPair::DeltaPadding = 8;
namespace pv {
namespace view {
const int CursorPair::DeltaPadding = 8;
-CursorPair::CursorPair(
const
View &view) :
- _first(
view, 0.0, _second
),
- _second(
view, 1.0, _first
),
+CursorPair::CursorPair(View &view) :
+ _first(
new Cursor(view, 0.0)
),
+ _second(
new Cursor(view, 1.0)
),
_view(view)
{
}
_view(view)
{
}
-
const Cursor&
CursorPair::first() const
+
shared_ptr<Cursor>
CursorPair::first() const
{
return _first;
}
{
return _first;
}
-Cursor& CursorPair::first()
-{
- return _first;
-}
-
-const Cursor& CursorPair::second() const
-{
- return _second;
-}
-
-Cursor& CursorPair::second()
+shared_ptr<Cursor> CursorPair::second() const
{
return _second;
}
{
return _second;
}
@@
-82,6
+77,9
@@
QRectF CursorPair::get_label_rect(const QRect &rect) const
void CursorPair::draw_markers(QPainter &p,
const QRect &rect, unsigned int prefix)
{
void CursorPair::draw_markers(QPainter &p,
const QRect &rect, unsigned int prefix)
{
+ assert(_first);
+ assert(_second);
+
compute_text_size(p, prefix);
QRectF delta_rect(get_label_rect(rect));
compute_text_size(p, prefix);
QRectF delta_rect(get_label_rect(rect));
@@
-102,12
+100,12
@@
void CursorPair::draw_markers(QPainter &p,
p.setPen(Cursor::TextColour);
p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
p.setPen(Cursor::TextColour);
p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
-
Ruler::format_time(_second.time() - _first.
time(), prefix, 2));
+
pv::util::format_time(_second->time() - _first->
time(), prefix, 2));
}
// Paint the cursor markers
}
// Paint the cursor markers
- _first
.
paint_label(p, rect, prefix);
- _second
.
paint_label(p, rect, prefix);
+ _first
->
paint_label(p, rect, prefix);
+ _second
->
paint_label(p, rect, prefix);
}
void CursorPair::draw_viewport_background(QPainter &p,
}
void CursorPair::draw_viewport_background(QPainter &p,
@@
-128,21
+126,30
@@
void CursorPair::draw_viewport_background(QPainter &p,
void CursorPair::draw_viewport_foreground(QPainter &p,
const QRect &rect)
{
void CursorPair::draw_viewport_foreground(QPainter &p,
const QRect &rect)
{
- _first.paint(p, rect);
- _second.paint(p, rect);
+ assert(_first);
+ assert(_second);
+
+ _first->paint(p, rect);
+ _second->paint(p, rect);
}
void CursorPair::compute_text_size(QPainter &p, unsigned int prefix)
{
}
void CursorPair::compute_text_size(QPainter &p, unsigned int prefix)
{
- _text_size = p.boundingRect(QRectF(), 0, Ruler::format_time(
- _second.time() - _first.time(), prefix, 2)).size();
+ assert(_first);
+ assert(_second);
+
+ _text_size = p.boundingRect(QRectF(), 0, pv::util::format_time(
+ _second->time() - _first->time(), prefix, 2)).size();
}
pair<float, float> CursorPair::get_cursor_offsets() const
{
}
pair<float, float> CursorPair::get_cursor_offsets() const
{
+ assert(_first);
+ assert(_second);
+
return pair<float, float>(
return pair<float, float>(
- (_first
.
time() - _view.offset()) / _view.scale(),
- (_second
.
time() - _view.offset()) / _view.scale());
+ (_first
->
time() - _view.offset()) / _view.scale(),
+ (_second
->
time() - _view.offset()) / _view.scale());
}
} // namespace view
}
} // namespace view