projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5a0192d
)
View: Store CursorPair in a shared_ptr
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sun, 7 Dec 2014 00:38:07 +0000
(
00:38
+0000)
committer
Uwe Hermann
<uwe@hermann-uwe.de>
Wed, 10 Dec 2014 17:06:16 +0000
(18:06 +0100)
pv/view/cursor.cpp
patch
|
blob
|
history
pv/view/cursorheader.cpp
patch
|
blob
|
history
pv/view/view.cpp
patch
|
blob
|
history
pv/view/view.hpp
patch
|
blob
|
history
pv/view/viewport.cpp
patch
|
blob
|
history
diff --git
a/pv/view/cursor.cpp
b/pv/view/cursor.cpp
index f4a5df6f10f4b2e5321b97be12d3d1d825e0a116..836d0e93d758fd911e371ef5383eda291ffa41c6 100644
(file)
--- a/
pv/view/cursor.cpp
+++ b/
pv/view/cursor.cpp
@@
-81,9
+81,10
@@
QRectF Cursor::get_label_rect(const QRect &rect) const
shared_ptr<Cursor> Cursor::get_other_cursor() const
{
shared_ptr<Cursor> Cursor::get_other_cursor() const
{
- const CursorPair &cursors = view_.cursors();
- return (cursors.first().get() == this) ?
- cursors.second() : cursors.first();
+ const shared_ptr<CursorPair> cursors(view_.cursors());
+ assert(cursors);
+ return (cursors->first().get() == this) ?
+ cursors->second() : cursors->first();
}
} // namespace view
}
} // namespace view
diff --git
a/pv/view/cursorheader.cpp
b/pv/view/cursorheader.cpp
index 1a656eb19f5edac14b7595c7db6569fa45de0822..076b2a7fc2ecd677ea12b99e16d08f7f3f1c2910 100644
(file)
--- a/
pv/view/cursorheader.cpp
+++ b/
pv/view/cursorheader.cpp
@@
-71,14
+71,14
@@
void CursorHeader::paintEvent(QPaintEvent*)
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
+ // The cursor labels are not drawn with the arrows exactly on the
+ // bottom line of the widget, because then the selection shadow
+ // would be clipped away.
+ const QRect r = rect().adjusted(0, 0, 0, -BaselineOffset);
+
// Draw the cursors
// Draw the cursors
- if (view_.cursors_shown()) {
- // The cursor labels are not drawn with the arrows exactly on the
- // bottom line of the widget, because then the selection shadow
- // would be clipped away.
- const QRect r = rect().adjusted(0, 0, 0, -BaselineOffset);
- view_.cursors().draw_markers(p, r);
- }
+ if (view_.cursors_shown())
+ view_.cursors()->draw_markers(p, r);
}
void CursorHeader::mouseMoveEvent(QMouseEvent *e)
}
void CursorHeader::mouseMoveEvent(QMouseEvent *e)
@@
-107,13
+107,13
@@
void CursorHeader::mousePressEvent(QMouseEvent *e)
clear_selection();
if (view_.cursors_shown()) {
clear_selection();
if (view_.cursors_shown()) {
-
CursorPair &cursors = view_.cursors(
);
- if (cursors
.
first()->get_label_rect(
+
shared_ptr<CursorPair> cursors(view_.cursors()
);
+ if (cursors
->
first()->get_label_rect(
rect()).contains(e->pos()))
rect()).contains(e->pos()))
- grabbed_marker_ = cursors
.
first();
- else if (cursors
.
second()->get_label_rect(
+ grabbed_marker_ = cursors
->
first();
+ else if (cursors
->
second()->get_label_rect(
rect()).contains(e->pos()))
rect()).contains(e->pos()))
- grabbed_marker_ = cursors
.
second();
+ grabbed_marker_ = cursors
->
second();
}
if (shared_ptr<TimeMarker> m = grabbed_marker_.lock())
}
if (shared_ptr<TimeMarker> m = grabbed_marker_.lock())
diff --git
a/pv/view/view.cpp
b/pv/view/view.cpp
index 28408eee39db4723497d906ae8a21b02e901427d..4575d05e2b7dd0fc58009a4bc927892dbe52a9a3 100644
(file)
--- a/
pv/view/view.cpp
+++ b/
pv/view/view.cpp
@@
-104,7
+104,7
@@
View::View(Session &session, QWidget *parent) :
tick_period_(0.0),
tick_prefix_(0),
show_cursors_(false),
tick_period_(0.0),
tick_prefix_(0),
show_cursors_(false),
- cursors_(
*this
),
+ cursors_(
new CursorPair(*this)
),
hover_point_(-1, -1)
{
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
hover_point_(-1, -1)
{
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
@@
-121,9
+121,9
@@
View::View(Session &session, QWidget *parent) :
connect(&session_, SIGNAL(frame_ended()),
this, SLOT(data_updated()));
connect(&session_, SIGNAL(frame_ended()),
this, SLOT(data_updated()));
- connect(cursors_
.
first().get(), SIGNAL(time_changed()),
+ connect(cursors_
->
first().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
this, SLOT(marker_time_changed()));
- connect(cursors_
.
second().get(), SIGNAL(time_changed()),
+ connect(cursors_
->
second().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
connect(header_, SIGNAL(signals_moved()),
this, SLOT(marker_time_changed()));
connect(header_, SIGNAL(signals_moved()),
@@
-198,8
+198,8
@@
const Viewport* View::viewport() const
vector< shared_ptr<TimeItem> > View::time_items() const
{
vector< shared_ptr<TimeItem> > items;
vector< shared_ptr<TimeItem> > View::time_items() const
{
vector< shared_ptr<TimeItem> > items;
- items.push_back(cursors_
.
first());
- items.push_back(cursors_
.
second());
+ items.push_back(cursors_
->
first());
+ items.push_back(cursors_
->
second());
return items;
}
return items;
}
@@
-357,18
+357,13
@@
void View::show_cursors(bool show)
void View::centre_cursors()
{
const double time_width = scale_ * viewport_->width();
void View::centre_cursors()
{
const double time_width = scale_ * viewport_->width();
- cursors_
.
first()->set_time(offset_ + time_width * 0.4);
- cursors_
.
second()->set_time(offset_ + time_width * 0.6);
+ cursors_
->
first()->set_time(offset_ + time_width * 0.4);
+ cursors_
->
second()->set_time(offset_ + time_width * 0.6);
cursorheader_->update();
viewport_->update();
}
cursorheader_->update();
viewport_->update();
}
-CursorPair& View::cursors()
-{
- return cursors_;
-}
-
-const CursorPair& View::cursors() const
+std::shared_ptr<CursorPair> View::cursors() const
{
return cursors_;
}
{
return cursors_;
}
diff --git
a/pv/view/view.hpp
b/pv/view/view.hpp
index a23f284825d17534b6edcf11df3a2e302610d661..026c7683ffaef224c501ed94ad6cdbe586452742 100644
(file)
--- a/
pv/view/view.hpp
+++ b/
pv/view/view.hpp
@@
-159,12
+159,7
@@
public:
/**
* Returns a reference to the pair of cursors.
*/
/**
* Returns a reference to the pair of cursors.
*/
- CursorPair& cursors();
-
- /**
- * Returns a reference to the pair of cursors.
- */
- const CursorPair& cursors() const;
+ std::shared_ptr<CursorPair> cursors() const;
const QPoint& hover_point() const;
const QPoint& hover_point() const;
@@
-279,7
+274,7
@@
private:
unsigned int tick_prefix_;
bool show_cursors_;
unsigned int tick_prefix_;
bool show_cursors_;
-
CursorPair
cursors_;
+
std::shared_ptr<CursorPair>
cursors_;
QPoint hover_point_;
QPoint hover_point_;
diff --git
a/pv/view/viewport.cpp
b/pv/view/viewport.cpp
index f5f0ab59fb2f949caf1bef931b506d0d859b185a..75902af2bc7588ba08fc9d4b6fe883e886e108c8 100644
(file)
--- a/
pv/view/viewport.cpp
+++ b/
pv/view/viewport.cpp
@@
-68,7
+68,7
@@
void Viewport::paintEvent(QPaintEvent*)
p.setRenderHint(QPainter::Antialiasing);
if (view_.cursors_shown())
p.setRenderHint(QPainter::Antialiasing);
if (view_.cursors_shown())
- view_.cursors()
.
draw_viewport_background(p, rect());
+ view_.cursors()
->
draw_viewport_background(p, rect());
const RowItemPaintParams pp(0, width(), view_.scale(), view_.offset());
const RowItemPaintParams pp(0, width(), view_.scale(), view_.offset());
@@
-86,7
+86,7
@@
void Viewport::paintEvent(QPaintEvent*)
r->paint_fore(p, pp);
if (view_.cursors_shown())
r->paint_fore(p, pp);
if (view_.cursors_shown())
- view_.cursors()
.
draw_viewport_foreground(p, rect());
+ view_.cursors()
->
draw_viewport_foreground(p, rect());
p.end();
}
p.end();
}