diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-11-12 22:50:26 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-11-12 22:50:26 +0000 |
commit | fd81ae57a69185797767313ab73b8a595877fc85 (patch) | |
tree | 0d3f70b970901a9b64e2fcc4b7efe29b65fae069 /ui | |
parent | 6461057a521c4f2de5149435a7005dbda11b04ff (diff) | |
download | wireshark-fd81ae57a69185797767313ab73b8a595877fc85.tar.gz |
Highlight selected sequence diagram items.
svn path=/trunk/; revision=53294
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/sequence_diagram.cpp | 66 | ||||
-rw-r--r-- | ui/qt/sequence_diagram.h | 15 | ||||
-rw-r--r-- | ui/qt/sequence_dialog.cpp | 3 |
3 files changed, 69 insertions, 15 deletions
diff --git a/ui/qt/sequence_diagram.cpp b/ui/qt/sequence_diagram.cpp index 23b7b54fef..b88063c08d 100644 --- a/ui/qt/sequence_diagram.cpp +++ b/ui/qt/sequence_diagram.cpp @@ -29,6 +29,7 @@ #include <QFont> #include <QFontMetrics> +#include <QPalette> #include <QPen> #include <QPointF> @@ -57,7 +58,8 @@ SequenceDiagram::SequenceDiagram(QCPAxis *keyAxis, QCPAxis *valueAxis, QCPAxis * value_axis_(valueAxis), comment_axis_(commentAxis), data_(NULL), - sainfo_(NULL) + sainfo_(NULL), + selected_packet_(0) { data_ = new WSCPSeqDataMap(); // xaxis (value): Address @@ -75,7 +77,7 @@ SequenceDiagram::SequenceDiagram(QCPAxis *keyAxis, QCPAxis *valueAxis, QCPAxis * axis->setBasePen(QPen(Qt::NoPen)); } - value_axis_->grid()->setVisible(true); + value_axis_->grid()->setVisible(false); key_axis_->setRangeReversed(true); key_axis_->grid()->setVisible(false); @@ -137,6 +139,16 @@ void SequenceDiagram::setData(seq_analysis_info_t *sainfo) comment_axis_->setTickVectorLabels(com_labels); } +void SequenceDiagram::setSelectedPacket(int selected_packet) +{ + if (selected_packet > 0) { + selected_packet_ = selected_packet; + } else { + selected_packet_ = 0; + } + mParentPlot->replot(); +} + seq_analysis_item_t *SequenceDiagram::itemForPosY(int ypos) { double key_pos = qRound(key_axis_->pixelToCoord(ypos)); @@ -163,10 +175,55 @@ double SequenceDiagram::selectTest(const QPointF &pos, bool onlySelectable, QVar void SequenceDiagram::draw(QCPPainter *painter) { + QPen fg_pen; + qreal alpha = 0.50; + + // Lifelines (node lines) + painter->save(); + painter->setOpacity(alpha); + fg_pen = mainPen(); + fg_pen.setStyle(Qt::DashLine); + painter->setPen(fg_pen); + for (int ll_x = value_axis_->range().lower; ll_x < value_axis_->range().upper; ll_x++) { + QPoint ll_start(coordsToPixels(key_axis_->range().upper, ll_x).toPoint()); + QPoint ll_end(coordsToPixels(key_axis_->range().lower, ll_x).toPoint()); + painter->drawLine(ll_start, ll_end); + } + painter->restore(); + fg_pen = mainPen(); + WSCPSeqDataMap::const_iterator it; for (it = data_->constBegin(); it != data_->constEnd(); ++it) { double cur_key = it.key(); seq_analysis_item_t *sai = (seq_analysis_item_t *) it.value().value; + QPen fg_pen(mainPen()); + + if (sai->fd->num == selected_packet_) { + // Highlighted background + painter->save(); + QRect bg_rect( + QPoint(coordsToPixels(cur_key - 0.5, value_axis_->range().lower).toPoint()), + QPoint(coordsToPixels(cur_key + 0.5, value_axis_->range().upper).toPoint())); + QPalette sel_pal; + painter->fillRect(bg_rect, sel_pal.brush(QPalette::Highlight)); + fg_pen.setColor(sel_pal.color(QPalette::HighlightedText)); + + // Highlighted lifelines + painter->save(); + QPen hl_pen = fg_pen; + hl_pen.setStyle(Qt::DashLine); + painter->setPen(hl_pen); + painter->setOpacity(alpha); + for (int ll_x = value_axis_->range().lower; ll_x < value_axis_->range().upper; ll_x++) { + QPoint ll_start(coordsToPixels(cur_key - 0.5, ll_x).toPoint()); + QPoint ll_end(coordsToPixels(cur_key + 0.5, ll_x).toPoint()); + hl_pen.setDashOffset(bg_rect.top() - ll_start.x()); + painter->drawLine(ll_start, ll_end); + } + painter->restore(); + + painter->restore(); + } if (cur_key < key_axis_->range().lower || cur_key > key_axis_->range().upper) { continue; @@ -178,6 +235,7 @@ void SequenceDiagram::draw(QCPPainter *painter) continue; } + // Message if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) { painter->save(); @@ -196,8 +254,8 @@ void SequenceDiagram::draw(QCPPainter *painter) << arrow_end << QPoint(arrow_end.x() - (ah_size*3), arrow_end.y() + ah_size); - painter->setBrush(mainPen().color()); - painter->setPen(mainPen()); + painter->setBrush(fg_pen.color()); + painter->setPen(fg_pen); painter->drawLine(arrow_line); painter->drawPolygon(arrow_head); diff --git a/ui/qt/sequence_diagram.h b/ui/qt/sequence_diagram.h index 4dcb25c65a..9b966052e3 100644 --- a/ui/qt/sequence_diagram.h +++ b/ui/qt/sequence_diagram.h @@ -51,7 +51,6 @@ typedef QMap<double, WSCPSeqData> WSCPSeqDataMap; typedef QMapIterator<double, WSCPSeqData> WSCPSeqDataMapIterator; typedef QMutableMapIterator<double, WSCPSeqData> WSCPSeqDataMutableMapIterator; -// XXX Should we dispense with this class and simply add items to a graph instead? class SequenceDiagram : public QCPAbstractPlottable { Q_OBJECT @@ -59,25 +58,20 @@ public: explicit SequenceDiagram(QCPAxis *keyAxis, QCPAxis *valueAxis, QCPAxis *commentAxis); // getters: -// double width() const { return mWidth; } -// WSCPSeqDataMap *data() const { return mData; } // setters: -// void setWidth(double width); void setData(seq_analysis_info_t *sainfo); -// void setData(const QVector<double> &key, const QVector<double> &value); - seq_analysis_item_t *itemForPosY(int ypos); // non-property methods: -// void addData(const WSCPSeqDataMap &dataMap); -// void addData(const WSCPSeqData &data); -// void addData(double key, double value); -// void addData(const QVector<double> &keys, const QVector<double> &values); + seq_analysis_item_t *itemForPosY(int ypos); // reimplemented virtual methods: virtual void clearData() {} virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const; +public slots: + void setSelectedPacket(int selected_packet); + protected: virtual void draw(QCPPainter *painter); virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const; @@ -90,6 +84,7 @@ private: QCPAxis *comment_axis_; WSCPSeqDataMap *data_; seq_analysis_info_t *sainfo_; + guint32 selected_packet_; }; #endif // SEQUENCE_DIAGRAM_H diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp index 99e3b2ac6a..759b12dcf9 100644 --- a/ui/qt/sequence_dialog.cpp +++ b/ui/qt/sequence_dialog.cpp @@ -39,7 +39,6 @@ // To do: // - Add UTF8 to text dump -// - Selection highlighting // - Save to XMI? http://www.umlgraph.org/ // - Time: abs vs delta // - Hide nodes @@ -132,6 +131,8 @@ SequenceDialog::SequenceDialog(QWidget *parent, capture_file *cf, SequenceType t connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*))); + connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int))); + disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); fillDiagram(); |