projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RowItemOwner: Added depth() method
[pulseview.git]
/
pv
/
view
/
analogsignal.cpp
diff --git
a/pv/view/analogsignal.cpp
b/pv/view/analogsignal.cpp
index 64633717fb4b8098637901813421df24f83c3d30..a8d7b3e8113d6c514e9955fc9c897a65175977a3 100644
(file)
--- a/
pv/view/analogsignal.cpp
+++ b/
pv/view/analogsignal.cpp
@@
-20,19
+20,29
@@
#include <extdef.h>
#include <extdef.h>
-#include <math.h>
+#include <cassert>
+#include <cmath>
#include "analogsignal.h"
#include "pv/data/analog.h"
#include "pv/data/analogsnapshot.h"
#include "pv/view/view.h"
#include "analogsignal.h"
#include "pv/data/analog.h"
#include "pv/data/analogsnapshot.h"
#include "pv/view/view.h"
-using namespace boost;
-using namespace std;
+#include <libsigrok/libsigrok.hpp>
+
+using std::max;
+using std::make_pair;
+using std::min;
+using std::shared_ptr;
+using std::deque;
+
+using sigrok::Channel;
namespace pv {
namespace view {
namespace pv {
namespace view {
+const int AnalogSignal::NominalHeight = 80;
+
const QColor AnalogSignal::SignalColours[4] = {
QColor(0xC4, 0xA0, 0x00), // Yellow
QColor(0x87, 0x20, 0x7A), // Magenta
const QColor AnalogSignal::SignalColours[4] = {
QColor(0xC4, 0xA0, 0x00), // Yellow
QColor(0x87, 0x20, 0x7A), // Magenta
@@
-42,20
+52,27
@@
const QColor AnalogSignal::SignalColours[4] = {
const float AnalogSignal::EnvelopeThreshold = 256.0f;
const float AnalogSignal::EnvelopeThreshold = 256.0f;
-AnalogSignal::AnalogSignal(pv::SigSession &session, sr_probe *const probe,
+AnalogSignal::AnalogSignal(
+ pv::SigSession &session,
+ shared_ptr<Channel> channel,
shared_ptr<data::Analog> data) :
shared_ptr<data::Analog> data) :
- Signal(session,
probe
),
+ Signal(session,
channel
),
_data(data),
_scale(1.0f)
{
_data(data),
_scale(1.0f)
{
- _colour = SignalColours[
probe->index
% countof(SignalColours)];
+ _colour = SignalColours[
_channel->index()
% countof(SignalColours)];
}
AnalogSignal::~AnalogSignal()
{
}
}
AnalogSignal::~AnalogSignal()
{
}
-boost::shared_ptr<pv::data::SignalData> AnalogSignal::data() const
+shared_ptr<pv::data::SignalData> AnalogSignal::data() const
+{
+ return _data;
+}
+
+shared_ptr<pv::data::Analog> AnalogSignal::analog_data() const
{
return _data;
}
{
return _data;
}
@@
-65,26
+82,34
@@
void AnalogSignal::set_scale(float scale)
_scale = scale;
}
_scale = scale;
}
+std::pair<int, int> AnalogSignal::v_extents() const
+{
+ return make_pair(-NominalHeight / 2, NominalHeight / 2);
+}
+
void AnalogSignal::paint_back(QPainter &p, int left, int right)
{
void AnalogSignal::paint_back(QPainter &p, int left, int right)
{
- if (_
probe->enabled
)
- paint_axis(p, get_y(), left, right);
+ if (_
channel->enabled()
)
+ paint_axis(p, get_
visual_
y(), left, right);
}
void AnalogSignal::paint_mid(QPainter &p, int left, int right)
{
assert(_data);
assert(right >= left);
}
void AnalogSignal::paint_mid(QPainter &p, int left, int right)
{
assert(_data);
assert(right >= left);
+ assert(_owner);
+
+ const int y = get_visual_y();
-
assert(_view
);
-
const int y = _v_offset - _view->v_offset(
);
+
const View *const view = _owner->view(
);
+
assert(view
);
- const double scale =
_
view->scale();
+ const double scale = view->scale();
assert(scale > 0);
assert(scale > 0);
- const double offset =
_
view->offset();
+ const double offset = view->offset();
- if (!_
probe->enabled
)
+ if (!_
channel->enabled()
)
return;
const deque< shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
return;
const deque< shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
@@
-151,7
+176,6
@@
void AnalogSignal::paint_envelope(QPainter &p,
int y, int left, const int64_t start, const int64_t end,
const double pixels_offset, const double samples_per_pixel)
{
int y, int left, const int64_t start, const int64_t end,
const double pixels_offset, const double samples_per_pixel)
{
- using namespace Qt;
using pv::data::AnalogSnapshot;
AnalogSnapshot::EnvelopeSection e;
using pv::data::AnalogSnapshot;
AnalogSnapshot::EnvelopeSection e;
@@
-160,7
+184,7
@@
void AnalogSignal::paint_envelope(QPainter &p,
if (e.length < 2)
return;
if (e.length < 2)
return;
- p.setPen(QPen(NoPen));
+ p.setPen(QPen(
Qt::
NoPen));
p.setBrush(_colour);
QRectF *const rects = new QRectF[e.length];
p.setBrush(_colour);
QRectF *const rects = new QRectF[e.length];