summaryrefslogtreecommitdiff
path: root/ui/qt/sequence_diagram.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-10-27 22:23:27 +0000
committerGerald Combs <gerald@wireshark.org>2013-10-27 22:23:27 +0000
commit5c65e00ca7549a33c1a3616b7a302814ac024070 (patch)
tree2393f56edb8326f3624446bc2f01bcabd3670cfb /ui/qt/sequence_diagram.cpp
parent8e2f00bf3d3f390f1fbd83d1320d64174fbc9221 (diff)
downloadwireshark-5c65e00ca7549a33c1a3616b7a302814ac024070.tar.gz
Try to improve the appearance of the sequence diagram.
Use integer coordinates for the arrows and text. Add smooth_font_size() to qt_ui_utils which will hopefully adjust the size on Windows to something more readable. svn path=/trunk/; revision=52906
Diffstat (limited to 'ui/qt/sequence_diagram.cpp')
-rw-r--r--ui/qt/sequence_diagram.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/ui/qt/sequence_diagram.cpp b/ui/qt/sequence_diagram.cpp
index d5161e0146..0c8bfcd18a 100644
--- a/ui/qt/sequence_diagram.cpp
+++ b/ui/qt/sequence_diagram.cpp
@@ -25,6 +25,8 @@
#include "epan/addr_resolv.h"
+#include "qt_ui_utils.h"
+
#include <QFont>
#include <QFontMetrics>
#include <QPen>
@@ -82,6 +84,7 @@ SequenceDiagram::SequenceDiagram(QCPAxis *keyAxis, QCPAxis *valueAxis, QCPAxis *
QFont comment_font = comment_axis_->tickLabelFont();
comment_font.setPointSizeF(comment_font.pointSizeF() * 0.75);
+ smooth_font_size(comment_font);
comment_axis_->setTickLabelFont(comment_font);
comment_axis_->setSelectedTickLabelFont(QFont(comment_font.family(), comment_font.pointSizeF(), QFont::Bold));
// frame_label
@@ -177,17 +180,17 @@ void SequenceDiagram::draw(QCPPainter *painter)
QFontMetrics cfm(comment_axis_->tickLabelFont());
int dir_mul = (sai->src_node < sai->dst_node) ? 1 : -1;
double ah_size = (cfm.height() / 5) * dir_mul;
- QPointF arrow_start(coordsToPixels(cur_key, sai->src_node));
- QPointF arrow_end(coordsToPixels(cur_key, sai->dst_node));
- QLineF arrow_line(arrow_start, arrow_end);
- QPolygonF arrow_head;
+ QPoint arrow_start(coordsToPixels(cur_key, sai->src_node).toPoint());
+ QPoint arrow_end(coordsToPixels(cur_key, sai->dst_node).toPoint());
+ QLine arrow_line(arrow_start, arrow_end);
+ QPolygon arrow_head;
arrow_head
- << QPointF(arrow_end.x() - (ah_size*3), arrow_end.y() - ah_size)
+ << QPoint(arrow_end.x() - (ah_size*3), arrow_end.y() - ah_size)
<< arrow_end
- << QPointF(arrow_end.x() - (ah_size*3), arrow_end.y() + ah_size);
+ << QPoint(arrow_end.x() - (ah_size*3), arrow_end.y() + ah_size);
if (mainPen().style() != Qt::NoPen && mainPen().color().alpha() != 0) {
- double en = cfm.height() / 2.0;
+ double en_w = cfm.height() / 2.0;
painter->setBrush(mainPen().color());
painter->setPen(mainPen());
@@ -199,19 +202,19 @@ void SequenceDiagram::draw(QCPPainter *painter)
? arrow_start.x() : arrow_end.x();
double arrow_width = (arrow_end.x() - arrow_start.x()) * dir_mul;
QString arrow_label = cfm.elidedText(sai->frame_label, Qt::ElideRight, arrow_width);
- QPointF text_pt(comment_start + ((arrow_width - cfm.width(arrow_label)) / 2),
- arrow_start.y() - (en / 2));
+ QPoint text_pt(comment_start + ((arrow_width - cfm.width(arrow_label)) / 2),
+ arrow_start.y() - (en_w / 2));
painter->drawText(text_pt, arrow_label);
if (sai->port_src && sai->port_dst) {
QString port_num = QString::number(sai->port_src);
- text_pt = QPointF(arrow_start.x() - en - (cfm.width(port_num) * dir_mul),
- arrow_start.y() + (en / 2));
+ text_pt = QPoint(arrow_start.x() - en_w - (cfm.width(port_num) * dir_mul),
+ arrow_start.y() + (en_w / 2));
painter->drawText(text_pt, port_num);
port_num = QString::number(sai->port_dst);
- text_pt.setX(arrow_end.x() - en + (cfm.width(port_num) * dir_mul));
+ text_pt.setX(arrow_end.x() - en_w + (cfm.width(port_num) * dir_mul));
painter->drawText(text_pt, port_num);
}
}