X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fdecodetrace.h;h=96008b2b135503c41fa5193d24616b43b04e9718;hp=08558c98091af6668dca55c992df1784ee51c595;hb=33c62f44b72abab27bc141d66712ff0d1a2e395f;hpb=83c23cc9fa0d4501d9e6b8759251fa6337f5d491 diff --git a/pv/view/decodetrace.h b/pv/view/decodetrace.h index 08558c98..96008b2b 100644 --- a/pv/view/decodetrace.h +++ b/pv/view/decodetrace.h @@ -25,14 +25,14 @@ #include #include +#include #include -#include - #include +#include -struct srd_probe; +struct srd_channel; struct srd_decoder; class QComboBox; @@ -62,11 +62,11 @@ class DecodeTrace : public Trace Q_OBJECT private: - struct ProbeSelector + struct ChannelSelector { const QComboBox *_combo; - const boost::shared_ptr _decoder; - const srd_probe *_probe; + const std::shared_ptr _decoder; + const srd_channel *_pdch; }; private: @@ -74,6 +74,7 @@ private: static const QColor ErrorBgColour; static const QColor NoDecodeColour; + static const int ArrowSize; static const double EndCapWidth; static const int DrawPadding; @@ -82,12 +83,12 @@ private: public: DecodeTrace(pv::SigSession &session, - boost::shared_ptr decoder_stack, + std::shared_ptr decoder_stack, int index); bool enabled() const; - const boost::shared_ptr& decoder() const; + const std::shared_ptr& decoder() const; void set_view(pv::view::View *view); @@ -107,6 +108,14 @@ public: **/ 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 + **/ + void paint_fore(QPainter &p, int left, int right); + void populate_popup_form(QWidget *parent, QFormLayout *form); QMenu* create_context_menu(QWidget *parent); @@ -115,8 +124,7 @@ public: private: void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, - QColor text_colour, int text_height, int left, int right, - double samples_per_pixel, double pixels_offset, int y, + QColor text_colour, int text_height, int left, int right, int y, size_t base_colour) const; void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, @@ -131,27 +139,49 @@ private: int left, int right); void draw_unresolved_period(QPainter &p, int h, int left, - int right, double samples_per_pixel, double pixels_offset); + int right) const; + + double get_pixels_offset() const; + + double get_samples_per_pixel() const; + + /** + * Determines the start and end sample for a given pixel range. + * @param x_start the X coordinate of the start sample in the view + * @param x_end the X coordinate of the end sample in the view + * @return Returns a pair containing the start sample and the end + * sample that correspond to the start and end coordinates. + */ + std::pair get_sample_range(int x_start, int x_end) const; + + int get_row_at_point(const QPoint &point); + + const QString get_annotation_at_point(const QPoint &point); + + void hide_hover_annotation(); void create_decoder_form(int index, - boost::shared_ptr &dec, + std::shared_ptr &dec, QWidget *parent, QFormLayout *form); - QComboBox* create_probe_selector(QWidget *parent, - const boost::shared_ptr &dec, - const srd_probe *const probe); + QComboBox* create_channel_selector(QWidget *parent, + const std::shared_ptr &dec, + const srd_channel *const pdch); + + void commit_decoder_channels( + std::shared_ptr &dec); - void commit_decoder_probes( - boost::shared_ptr &dec); + void commit_channels(); - void commit_probes(); +public: + void hover_point_changed(); -private slots: +private Q_SLOTS: void on_new_decode_data(); void on_delete(); - void on_probe_selected(int); + void on_channel_selected(int); void on_stack_decoder(srd_decoder *decoder); @@ -161,16 +191,19 @@ private slots: private: pv::SigSession &_session; - boost::shared_ptr _decoder_stack; + std::shared_ptr _decoder_stack; uint64_t _decode_start, _decode_end; - std::list< boost::shared_ptr > + std::list< std::shared_ptr > _bindings; - std::list _probe_selectors; + std::list _channel_selectors; std::vector _decoder_forms; + std::vector _visible_rows; + int _text_height, _row_height; + QSignalMapper _delete_mapper, _show_hide_mapper; };