SVN commit 707069 by weidendo: kcachegrind: arrow thickness relates to call cost now Take advantage of Qt4 painting features by adjusting the arrow thickness in the call graph according to the call cost (actually, thickness is logaritmic to cost). The same is done in the panner view, which makes the most used call chain quite obvious now. Consequently, the call cost itself is not so interesting any more as explicit annotation. More interesting is the call count now. Cost percentage is still visible in the icon. This somehow makes the call graph even less cleaner. IMHO looks quite cool now ;-) I already wanted to do this long ago, but this simply was not possible with Qt3, as it used the line drawing in the X server, and thus the thickness was not adjustable at all... M +26 -17 callgraphview.cpp M +9 -0 callgraphview.h --- trunk/KDE/kdesdk/kcachegrind/kcachegrind/callgraphview.cpp #707068:707069 @@ -1168,17 +1168,13 @@ CanvasEdgeLabel::CanvasEdgeLabel(CallGraphView* v, CanvasEdge* ce, int x, int y, int w, int h) : - QGraphicsRectItem(QRect(x, y, w, h)), _ce(ce), _view(v) + QGraphicsRectItem(QRect(x, y, w, h)), _ce(ce), _view(v), _percentage(0.0) { GraphEdge* e = ce->edge(); if (!e) return; - setPosition(1, DrawParams::TopCenter); - setText(1, QString("%1 x").arg(SubCost(e->count).pretty())); - - setPosition(0, DrawParams::BottomCenter); - + setPosition(1, DrawParams::BottomCenter); TraceCost* totalCost; if (_view->topLevel()->showExpanded()) { if (_view->activeFunction()) { @@ -1193,12 +1189,19 @@ double total = totalCost->subCost(_view->eventType()); double inclP = 100.0 * e->cost/ total; if (_view->topLevel()->showPercentage()) - setText(0, QString("%1 %") + setText(1, QString("%1 %") .arg(inclP, 0, 'f', Configuration::percentPrecision())); else - setText(0, SubCost(e->cost).pretty()); + setText(1, SubCost(e->cost).pretty()); + + setPosition(0, DrawParams::TopCenter); + SubCost count((e->count < 1.0) ? 1.0 : e->count); + setText(0, QString("%1 x").arg(count.pretty())); setPixmap(0, percentagePixmap(25, 10, (int)(inclP+.5), Qt::blue, true)); + _percentage = inclP; + if (_percentage > 100.0) _percentage = 100.0; + if (e->call() && (e->call()->isRecursion() || e->call()->inCycle())) { QString icon = "edit-undo"; KIconLoader* loader = KIconLoader::global(); @@ -1251,6 +1254,7 @@ { _label = 0; _arrow = 0; + _thickness = 0; setFlag(QGraphicsItem::ItemIsSelectable); } @@ -1264,6 +1268,9 @@ setToolTip(tip); if (_arrow) _arrow->setToolTip(tip); + + _thickness = log(l->percentage()); + if (_thickness < .9) _thickness = .9; } } @@ -1297,12 +1304,19 @@ void CanvasEdge::paint(QPainter* p, const QStyleOptionGraphicsItem* options, QWidget*) { - QPen pen = QPen(isSelected() ? Qt::red : Qt::black); - pen.setWidthF(1.0/options->levelOfDetail); + p->setRenderHint(QPainter::Antialiasing); - p->setRenderHint(QPainter::Antialiasing); + QPen pen = QPen(Qt::black); + pen.setWidthF(1.0/options->levelOfDetail * _thickness); p->setPen(pen); p->drawPath(path()); + + if (isSelected()) { + pen.setColor(Qt::red); + pen.setWidthF(1.0/options->levelOfDetail * _thickness/2.0); + p->setPen(pen); + p->drawPath(path()); + } } @@ -1414,13 +1428,8 @@ CallGraphView::~CallGraphView() { + clear(); delete _panningView; - //delete _tip; - - if (_scene) { - setScene(0); - delete _scene; - } } QString CallGraphView::whatsThis() const --- trunk/KDE/kdesdk/kcachegrind/kcachegrind/callgraphview.h #707068:707069 @@ -457,9 +457,16 @@ return CANVAS_EDGELABEL; } + double percentage() const + { + return _percentage; + } + private: CanvasEdge* _ce; CallGraphView* _view; + + double _percentage; }; @@ -530,6 +537,8 @@ CanvasEdgeLabel* _label; CanvasEdgeArrow* _arrow; Q3PointArray _points; + + double _thickness; };