_scale = scale;
}
-void AnalogSignal::paint(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);
+}
+
+void AnalogSignal::paint_mid(QPainter &p, int left, int right)
{
assert(_data);
assert(right >= left);
if (!_probe->enabled)
return;
- paint_axis(p, y, left, right);
-
const deque< shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
_data->get_snapshots();
if (snapshots.empty())
void set_scale(float scale);
/**
- * Paints the signal with a QPainter
+ * Paints the background layer of the signal with a QPainter
* @param p the QPainter to paint into.
* @param left the x-coordinate of the left edge of the signal.
* @param right the x-coordinate of the right edge of the signal.
**/
- void paint(QPainter &p, int left, int right);
+ void paint_back(QPainter &p, int left, int right);
+
+ /**
+ * Paints the mid-layer of the signal with a QPainter
+ * @param p the QPainter to paint into.
+ * @param left the x-coordinate of the left edge of the signal.
+ * @param right the x-coordinate of the right edge of the signal.
+ **/
+ void paint_mid(QPainter &p, int left, int right);
private:
void paint_trace(QPainter &p,
Trace::set_view(view);
}
-void DecodeSignal::paint(QPainter &p, int left, int right)
+void DecodeSignal::paint_back(QPainter &p, int left, int right)
+{
+ paint_axis(p, get_y(), left, right);
+}
+
+void DecodeSignal::paint_mid(QPainter &p, int left, int right)
{
using namespace pv::view::decode;
assert(_view);
- const int y = _v_offset - _view->v_offset();
+ const int y = get_y();
const double scale = _view->scale();
assert(scale > 0);
void set_view(pv::view::View *view);
/**
- * Paints the trace with a QPainter
+ * Paints the background layer of the trace with a QPainter
+ * @param p the QPainter to paint into.
+ * @param left the x-coordinate of the left edge of the signal.
+ * @param right the x-coordinate of the right edge of the signal.
+ **/
+ void paint_back(QPainter &p, int left, int right);
+
+ /**
+ * Paints the mid-layer of the trace with a QPainter
* @param p the QPainter to paint into.
* @param left the x-coordinate of the left edge of the signal
* @param right the x-coordinate of the right edge of the signal
**/
- void paint(QPainter &p, int left, int right);
+ void paint_mid(QPainter &p, int left, int right);
const std::list<QAction*> get_context_bar_actions();
return actions;
}
-void LogicSignal::paint(QPainter &p, int left, int right)
+void LogicSignal::paint_back(QPainter &p, int left, int right)
+{
+ if (_probe->enabled)
+ paint_axis(p, get_y(), left, right);
+}
+
+void LogicSignal::paint_mid(QPainter &p, int left, int right)
{
using pv::view::View;
if (!_probe->enabled)
return;
- paint_axis(p, y, left, right);
-
const float high_offset = y - View::SignalHeight + 0.5f;
const float low_offset = y + 0.5f;
const std::list<QAction*> get_context_bar_actions();
/**
- * Paints the signal with a QPainter
+ * Paints the background layer of the signal with a QPainter
* @param p the QPainter to paint into.
* @param left the x-coordinate of the left edge of the signal.
* @param right the x-coordinate of the right edge of the signal.
**/
- void paint(QPainter &p, int left, int right);
+ void paint_back(QPainter &p, int left, int right);
+
+ /**
+ * Paints the mid-layer of the signal with a QPainter
+ * @param p the QPainter to paint into.
+ * @param left the x-coordinate of the left edge of the signal.
+ * @param right the x-coordinate of the right edge of the signal.
+ **/
+ void paint_mid(QPainter &p, int left, int right);
private:
namespace pv {
namespace view {
-const QPen Signal::SignalAxisPen(QColor(128, 128, 128, 64));
-
const char *const ProbeNames[] = {
"CLK",
"DATA",
return _probe;
}
-void Signal::paint_axis(QPainter &p, int y, int left, int right)
-{
- p.setPen(SignalAxisPen);
- p.drawLine(QPointF(left, y + 0.5f), QPointF(right, y + 0.5f));
-}
-
void Signal::on_text_changed(const QString &text)
{
Trace::set_name(text);
#define PULSEVIEW_PV_SIGNAL_H
#include <QComboBox>
-#include <QPen>
#include <QWidgetAction>
#include <stdint.h>
{
Q_OBJECT
-private:
- static const QPen SignalAxisPen;
-
protected:
Signal(pv::SigSession &session, const sr_probe *const probe);
const sr_probe* probe() const;
-protected:
-
- /**
- * Paints a zero axis across the viewport.
- * @param p the QPainter to paint into.
- * @param y the y-offset of the axis.
- * @param left the x-coordinate of the left edge of the view.
- * @param right the x-coordinate of the right edge of the view.
- */
- void paint_axis(QPainter &p, int y, int left, int right);
-
private slots:
void on_text_changed(const QString &text);
namespace pv {
namespace view {
+const QPen Trace::AxisPen(QColor(128, 128, 128, 64));
const int Trace::LabelHitPadding = 2;
Trace::Trace(pv::SigSession &session, QString name) :
_view = view;
}
+void Trace::paint_back(QPainter &p, int left, int right)
+{
+ (void)p;
+ (void)left;
+ (void)right;
+}
+
+void Trace::paint_mid(QPainter &p, int left, int right)
+{
+ (void)p;
+ (void)left;
+ (void)right;
+}
+
+void Trace::paint_fore(QPainter &p, int left, int right)
+{
+ (void)p;
+ (void)left;
+ (void)right;
+}
+
void Trace::paint_label(QPainter &p, int right, bool hover)
{
assert(_view);
).contains(point);
}
+int Trace::get_y() const
+{
+ return _v_offset - _view->v_offset();
+}
+
+void Trace::paint_axis(QPainter &p, int y, int left, int right)
+{
+ p.setPen(AxisPen);
+ p.drawLine(QPointF(left, y + 0.5f), QPointF(right, y + 0.5f));
+}
+
void Trace::compute_text_size(QPainter &p)
{
_text_size = QSize(
#include <QColor>
#include <QPainter>
+#include <QPen>
#include <QRect>
#include <QString>
Q_OBJECT
private:
+ static const QPen AxisPen;
static const int LabelHitPadding;
protected:
virtual void set_view(pv::view::View *view);
/**
- * Paints the trace with a QPainter
+ * Paints the background layer of the trace with a QPainter
* @param p the QPainter to paint into.
* @param left the x-coordinate of the left edge of the signal
* @param right the x-coordinate of the right edge of the signal
**/
- virtual void paint(QPainter &p, int left, int right) = 0;
+ virtual void paint_back(QPainter &p, int left, int right);
+
+ /**
+ * Paints the mid-layer of the trace with a QPainter
+ * @param p the QPainter to paint into.
+ * @param left the x-coordinate of the left edge of the signal
+ * @param right the x-coordinate of the right edge of the signal
+ **/
+ virtual void paint_mid(QPainter &p, int left, int right);
+
+ /**
+ * Paints the foreground layer of the trace with a QPainter
+ * @param p the QPainter to paint into.
+ * @param left the x-coordinate of the left edge of the signal
+ * @param right the x-coordinate of the right edge of the signal
+ **/
+ virtual void paint_fore(QPainter &p, int left, int right);
/**
* Paints the signal label into a QGLWidget.
*/
bool pt_in_label_rect(int left, int right, const QPoint &point);
+protected:
+ /**
+ * Gets the y-offset of the axis.
+ */
+ int get_y() const;
+
+ /**
+ * Paints a zero axis across the viewport.
+ * @param p the QPainter to paint into.
+ * @param y the y-offset of the axis.
+ * @param left the x-coordinate of the left edge of the view.
+ * @param right the x-coordinate of the right edge of the view.
+ */
+ void paint_axis(QPainter &p, int y, int left, int right);
+
private:
/**
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
{
assert(t);
- t->paint(p, 0, width());
+ t->paint_back(p, 0, width());
}
+ BOOST_FOREACH(const shared_ptr<Trace> t, traces)
+ t->paint_mid(p, 0, width());
+
+ BOOST_FOREACH(const shared_ptr<Trace> t, traces)
+ t->paint_fore(p, 0, width());
+
if (_view.cursors_shown())
_view.cursors().draw_viewport_foreground(p, rect());