<file>icons/trigger-falling.svg</file>
<file>icons/trigger-high.svg</file>
<file>icons/trigger-low.svg</file>
+ <file>icons/trigger-marker-change.svg</file>
+ <file>icons/trigger-marker-falling.svg</file>
+ <file>icons/trigger-marker-high.svg</file>
+ <file>icons/trigger-marker-low.svg</file>
+ <file>icons/trigger-marker-rising.svg</file>
<file>icons/trigger-none.svg</file>
<file>icons/trigger-rising.svg</file>
<file>icons/zoom-fit.png</file>
QColor(0xEE, 0xEE, 0xEC), // White
};
+QColor LogicSignal::TriggerMarkerBackgroundColour = QColor(0xED, 0xD4, 0x00);
+const int LogicSignal::TriggerMarkerPadding = 2;
+const char* LogicSignal::TriggerMarkerIcons[8] = {
+ nullptr,
+ ":/icons/trigger-marker-low.svg",
+ ":/icons/trigger-marker-high.svg",
+ ":/icons/trigger-marker-rising.svg",
+ ":/icons/trigger-marker-falling.svg",
+ ":/icons/trigger-marker-change.svg",
+ nullptr,
+ nullptr
+};
+
+QCache<QString, const QIcon> LogicSignal::icon_cache_;
+QCache<QString, const QPixmap> LogicSignal::pixmap_cache_;
+
LogicSignal::LogicSignal(
pv::Session &session,
shared_ptr<Device> device,
delete[] cap_lines;
}
+void LogicSignal::paint_fore(QPainter &p, int left, int right)
+{
+ (void)left;
+
+ // Draw the trigger marker
+ if (!trigger_match_)
+ return;
+
+ const int y = get_visual_y();
+ const vector<int32_t> trig_types = get_trigger_types();
+ for (int32_t type_id : trig_types) {
+ const TriggerMatchType *const type =
+ TriggerMatchType::get(type_id);
+ if (trigger_match_ != type || type_id < 0 ||
+ (size_t)type_id >= countof(TriggerMarkerIcons) ||
+ !TriggerMarkerIcons[type_id])
+ continue;
+
+ const QPixmap *const pixmap = get_pixmap(
+ TriggerMarkerIcons[type_id]);
+ if (!pixmap)
+ continue;
+
+ const int pad = TriggerMarkerPadding;
+ const QSize size = pixmap->size();
+ const QPoint point(
+ right - size.width() - pad * 2,
+ y - (SignalHeight + size.height()) / 2);
+
+ p.setPen(QPen(Qt::NoPen));
+ p.setBrush(TriggerMarkerBackgroundColour);
+ p.drawRoundedRect(QRect(point, size).adjusted(
+ -pad, -pad, pad, pad), pad, pad);
+ p.drawPixmap(point, *pixmap);
+
+ break;
+ }
+}
+
void LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
vector< pair<int64_t, bool> > &edges, bool level,
double samples_per_pixel, double pixels_offset, float x_offset,
session_.session()->set_trigger(
new_trigger->stages().empty() ? nullptr : new_trigger);
+
+ if (owner_)
+ owner_->appearance_changed(false, true);
}
const QIcon* LogicSignal::get_icon(const char *path)
return icon;
}
+const QPixmap* LogicSignal::get_pixmap(const char *path)
+{
+ const QPixmap *pixmap = pixmap_cache_.take(path);
+ if (!pixmap) {
+ pixmap = new QPixmap(path);
+ pixmap_cache_.insert(path, pixmap);
+ }
+
+ return pixmap;
+}
+
void LogicSignal::on_trigger()
{
QAction *action;
static const QColor SignalColours[10];
+ static QColor TriggerMarkerBackgroundColour;
+ static const int TriggerMarkerPadding;
+ static const char* TriggerMarkerIcons[8];
+
public:
LogicSignal(pv::Session &session,
std::shared_ptr<sigrok::Device> device,
**/
void paint_mid(QPainter &p, int left, int right);
+ /**
+ * Paints the foreground 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
+ **/
+ virtual void paint_fore(QPainter &p, int left, int right);
+
private:
void paint_caps(QPainter &p, QLineF *const lines,
std::vector< std::pair<int64_t, bool> > &edges,
void modify_trigger();
static const QIcon* get_icon(const char *path);
+ static const QPixmap* get_pixmap(const char *path);
private Q_SLOTS:
void on_trigger();
QAction *trigger_change_;
static QCache<QString, const QIcon> icon_cache_;
+ static QCache<QString, const QPixmap> pixmap_cache_;
};
} // namespace view