QColor(0x72, 0x9F, 0xCF) // Blue
};
+const QColor DecodeSignal::ErrorBgColour = QColor(0xEF, 0x29, 0x29);
+
DecodeSignal::DecodeSignal(pv::SigSession &session,
boost::shared_ptr<pv::data::Decoder> decoder, int index) :
Trace(session, QString(decoder->get_decoder()->name)),
{
using namespace pv::view::decode;
+ assert(_decoder);
+ const QString err = _decoder->error_message();
+ if (!err.isEmpty()) {
+ draw_error(p, err, left, right);
+ return;
+ }
+
assert(_view);
const int y = get_y();
return menu;
}
+void DecodeSignal::draw_error(QPainter &p, const QString &message,
+ int left, int right)
+{
+ const int y = get_y();
+
+ p.setPen(ErrorBgColour.darker());
+ p.setBrush(ErrorBgColour);
+
+ const QRectF bounding_rect =
+ QRectF(left, INT_MIN / 2 + y, right - left, INT_MAX);
+ const QRectF text_rect = p.boundingRect(bounding_rect,
+ Qt::AlignCenter, message);
+ const float r = text_rect.height() / 4;
+
+ p.drawRoundedRect(text_rect.adjusted(-r, -r, r, r), r, r,
+ Qt::AbsoluteSize);
+
+ p.setPen(get_text_colour());
+ p.drawText(text_rect, message);
+}
+
void DecodeSignal::on_new_decode_data()
{
if (_view)
private:
static const QColor DecodeColours[4];
+ static const QColor ErrorBgColour;
public:
DecodeSignal(pv::SigSession &session,
void delete_pressed();
+private:
+ void draw_error(QPainter &p, const QString &message,
+ int left, int right);
+
private slots:
void on_new_decode_data();