mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 16:40:42 +08:00
Compare commits
14 Commits
04b5cf519f
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5183339a2b | |||
| fe6fa48306 | |||
| 0c876d0c92 | |||
| 42bcc76aa4 | |||
| 93b569191c | |||
| aa74c16edf | |||
| 5d030042d5 | |||
| afc8c188c5 | |||
| ddc7245125 | |||
| bd04ef3199 | |||
| 23df8207d8 | |||
| d54df0b1b3 | |||
| a465cd5a1a | |||
| 84f7d81ea9 |
+31
-1
@@ -9,6 +9,7 @@
|
||||
#include <QtGui/QImageReader>
|
||||
#include <QtGui/QImageWriter>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QWheelEvent>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtPrintSupport/QPrintDialog>
|
||||
|
||||
@@ -19,6 +20,8 @@
|
||||
|
||||
QImageViewer::QImageViewer (QWidget* parent) : QWidget(parent) {
|
||||
|
||||
setFocusPolicy(Qt::StrongFocus); // So the widget can take focus and receive the +/-/ESC zoom keys.
|
||||
|
||||
_zoomFactor = 1.0;
|
||||
|
||||
// Setup the widgets
|
||||
@@ -34,6 +37,10 @@ QImageViewer::QImageViewer (QWidget* parent) : QWidget(parent) {
|
||||
_scrollArea->setWidget(_imageLabel);
|
||||
_scrollArea->setWidgetResizable(false);
|
||||
|
||||
// The scroll area consumes wheel events for scrolling, so watch its
|
||||
// viewport to catch Ctrl+wheel for zooming.
|
||||
_scrollArea->viewport()->installEventFilter(this);
|
||||
|
||||
layout->addWidget(_scrollArea);
|
||||
|
||||
clearImage();
|
||||
@@ -174,7 +181,30 @@ void QImageViewer::keyPressEvent (QKeyEvent* event) {
|
||||
}
|
||||
}
|
||||
|
||||
void QImageViewer::enterEvent (QEvent* event) {
|
||||
bool QImageViewer::eventFilter (QObject* object, QEvent* event) {
|
||||
|
||||
// Ctrl+wheel over the image zooms in or out. A plain wheel keeps
|
||||
// scrolling the image as usual.
|
||||
if (object == _scrollArea->viewport() && event->type() == QEvent::Wheel) {
|
||||
|
||||
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
|
||||
|
||||
if (wheelEvent->modifiers() & Qt::ControlModifier) {
|
||||
|
||||
if (wheelEvent->angleDelta().y() > 0) {
|
||||
zoomIn();
|
||||
}else if (wheelEvent->angleDelta().y() < 0) {
|
||||
zoomOut();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void QImageViewer::enterEvent (QEnterEvent* event) {
|
||||
|
||||
Q_UNUSED(event);
|
||||
|
||||
|
||||
+3
-2
@@ -38,8 +38,9 @@ class QImageViewer : public QWidget {
|
||||
|
||||
protected slots:
|
||||
void keyPressEvent (QKeyEvent* event);
|
||||
void enterEvent (QEvent* event);
|
||||
void leaveEvent (QEvent* event);
|
||||
bool eventFilter (QObject* object, QEvent* event) override;
|
||||
void enterEvent (QEnterEvent* event) override;
|
||||
void leaveEvent (QEvent* event) override;
|
||||
|
||||
private:
|
||||
QImage _image;
|
||||
|
||||
@@ -398,7 +398,10 @@ void SeerArrayVisualizerWidget::handleText (const QString& text) {
|
||||
|
||||
//qDebug() << text;
|
||||
|
||||
if (text.contains(QRegularExpression("^([0-9]+)\\^done,value="))) {
|
||||
static const QRegularExpression valueResponse = QRegularExpression("^([0-9]+)\\^done,value=");
|
||||
static const QRegularExpression memoryResponse = QRegularExpression("^([0-9]+)\\^done,memory=");
|
||||
static const QRegularExpression errorResponse = QRegularExpression("^([0-9]+)\\^error,msg=");
|
||||
if (text.contains(valueResponse)) {
|
||||
|
||||
// 11^done,value="1"
|
||||
// 11^done,value="0x7fffffffd538"
|
||||
@@ -430,8 +433,10 @@ void SeerArrayVisualizerWidget::handleText (const QString& text) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the variable address.
|
||||
// Set the variable address and read the memory there.
|
||||
setAVariableAddress(address);
|
||||
|
||||
readaMemory();
|
||||
}
|
||||
|
||||
if (id_text.toInt() == _aLengthId) {
|
||||
@@ -489,8 +494,10 @@ void SeerArrayVisualizerWidget::handleText (const QString& text) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the variable address.
|
||||
// Set the variable address and read the memory there.
|
||||
setBVariableAddress(address);
|
||||
|
||||
readbMemory();
|
||||
}
|
||||
|
||||
if (id_text.toInt() == _bLengthId) {
|
||||
@@ -523,7 +530,7 @@ void SeerArrayVisualizerWidget::handleText (const QString& text) {
|
||||
handlebRefreshButton();
|
||||
}
|
||||
|
||||
}else if (text.contains(QRegularExpression("^([0-9]+)\\^done,memory="))) {
|
||||
}else if (text.contains(memoryResponse)) {
|
||||
|
||||
// 3^done,memory=[{begin="0x0000000000613e70",offset="0x0000000000000000",end="0x0000000000613e71",contents="00"}]
|
||||
// 4^done,memory=[{begin="0x0000000000613e70",offset="0x0000000000000000",end="0x0000000000613ed4",contents="000000000000000000000000"}]
|
||||
@@ -628,7 +635,7 @@ void SeerArrayVisualizerWidget::handleText (const QString& text) {
|
||||
}
|
||||
}
|
||||
|
||||
}else if (text.contains(QRegularExpression("^([0-9]+)\\^error,msg="))) {
|
||||
}else if (text.contains(errorResponse)) {
|
||||
|
||||
// 12^error,msg="No symbol \"return\" in current context."
|
||||
// 13^error,msg="No symbol \"cout\" in current context."
|
||||
@@ -742,6 +749,26 @@ void SeerArrayVisualizerWidget::handleaRefreshButton () {
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-evaluate the variable's address first: it may have changed since the
|
||||
// last stop (or the variable may not have existed yet). The answer then
|
||||
// reads the memory at the fresh address. See readaMemory().
|
||||
emit evaluateVariableExpression(_aVariableId, aVariableNameLineEdit->text());
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handlebRefreshButton () {
|
||||
|
||||
if (bVariableNameLineEdit->text() == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-evaluate the variable's address first: it may have changed since the
|
||||
// last stop (or the variable may not have existed yet). The answer then
|
||||
// reads the memory at the fresh address. See readbMemory().
|
||||
emit evaluateVariableExpression(_bVariableId, bVariableNameLineEdit->text());
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::readaMemory () {
|
||||
|
||||
if (aVariableAddressLineEdit->text() == "") {
|
||||
return;
|
||||
}
|
||||
@@ -750,18 +777,25 @@ void SeerArrayVisualizerWidget::handleaRefreshButton () {
|
||||
return;
|
||||
}
|
||||
|
||||
// A null address can't be read (a std::vector before its construction,
|
||||
// for example). Keep the "0x0" visible but don't ask gdb.
|
||||
if (aVariableAddressLineEdit->text() == "0x0") {
|
||||
return;
|
||||
}
|
||||
|
||||
int bytes = aArrayLengthLineEdit->text().toInt() * Seer::typeBytes(aArrayDisplayFormatComboBox->currentText());
|
||||
|
||||
// Nothing to read yet (no length).
|
||||
if (bytes <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//qDebug() << _aMemoryId << aVariableAddressLineEdit->text() << aArrayLengthLineEdit->text() << aArrayDisplayFormatComboBox->currentText() << bytes;
|
||||
|
||||
emit evaluateMemoryExpression(_aMemoryId, aVariableAddressLineEdit->text(), bytes);
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handlebRefreshButton () {
|
||||
|
||||
if (bVariableNameLineEdit->text() == "") {
|
||||
return;
|
||||
}
|
||||
void SeerArrayVisualizerWidget::readbMemory () {
|
||||
|
||||
if (bVariableAddressLineEdit->text() == "") {
|
||||
return;
|
||||
@@ -771,8 +805,19 @@ void SeerArrayVisualizerWidget::handlebRefreshButton () {
|
||||
return;
|
||||
}
|
||||
|
||||
// A null address can't be read (a std::vector before its construction,
|
||||
// for example). Keep the "0x0" visible but don't ask gdb.
|
||||
if (bVariableAddressLineEdit->text() == "0x0") {
|
||||
return;
|
||||
}
|
||||
|
||||
int bytes = bArrayLengthLineEdit->text().toInt() * Seer::typeBytes(bArrayDisplayFormatComboBox->currentText());
|
||||
|
||||
// Nothing to read yet (no length).
|
||||
if (bytes <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//qDebug() << _bMemoryId << bVariableAddressLineEdit->text() << bArrayLengthLineEdit->text() << bArrayDisplayFormatComboBox->currentText() << bytes;
|
||||
|
||||
emit evaluateMemoryExpression(_bMemoryId, bVariableAddressLineEdit->text(), bytes);
|
||||
|
||||
@@ -76,6 +76,8 @@ class SeerArrayVisualizerWidget : public QWidget, protected Ui::SeerArrayVisuali
|
||||
void resizeEvent (QResizeEvent* event);
|
||||
|
||||
private:
|
||||
void readaMemory ();
|
||||
void readbMemory ();
|
||||
void createASeries ();
|
||||
void createBSeries ();
|
||||
|
||||
|
||||
@@ -238,8 +238,10 @@ void SeerMatrixVisualizerWidget::handleText (const QString& text) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the variable address.
|
||||
// Set the variable address and read the memory there.
|
||||
setVariableAddress(address);
|
||||
|
||||
readMemory();
|
||||
}
|
||||
|
||||
if (id_text.toInt() == _rowsId) {
|
||||
@@ -436,6 +438,14 @@ void SeerMatrixVisualizerWidget::handleRefreshButton () {
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-evaluate the variable's address first: it may have changed since the
|
||||
// last stop (or the variable may not have existed yet). The answer then
|
||||
// reads the memory at the fresh address. See readMemory().
|
||||
emit evaluateVariableExpression(_variableId, variableNameLineEdit->text());
|
||||
}
|
||||
|
||||
void SeerMatrixVisualizerWidget::readMemory () {
|
||||
|
||||
if (variableAddressLineEdit->text() == "") {
|
||||
return;
|
||||
}
|
||||
@@ -444,8 +454,19 @@ void SeerMatrixVisualizerWidget::handleRefreshButton () {
|
||||
return;
|
||||
}
|
||||
|
||||
// A null address can't be read (a matrix before its construction, for
|
||||
// example). Keep the "0x0" visible but don't ask gdb.
|
||||
if (variableAddressLineEdit->text() == "0x0") {
|
||||
return;
|
||||
}
|
||||
|
||||
int bytes = matrixRowsLineEdit->text().toInt() * matrixColumnsLineEdit->text().toInt() * Seer::typeBytes(matrixDisplayFormatComboBox->currentText());
|
||||
|
||||
// Nothing to read yet (no rows/columns).
|
||||
if (bytes <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// qDebug() << "Asking for" << bytes << "bytes of matrix data.";
|
||||
|
||||
emit evaluateMemoryExpression(_memoryId, variableAddressLineEdit->text(), bytes);
|
||||
|
||||
@@ -55,6 +55,8 @@ class SeerMatrixVisualizerWidget : public QWidget, protected Ui::SeerMatrixVisua
|
||||
void resizeEvent (QResizeEvent* event);
|
||||
|
||||
private:
|
||||
void readMemory ();
|
||||
|
||||
int _variableId;
|
||||
int _memoryId;
|
||||
int _rowsId;
|
||||
|
||||
@@ -43,6 +43,15 @@ const QString& SeerParallelStacksFrame::function () const {
|
||||
return _function;
|
||||
}
|
||||
|
||||
QString SeerParallelStacksFrame::functionOrAddr () const {
|
||||
|
||||
if (_function == "??") {
|
||||
return _addr;
|
||||
}
|
||||
|
||||
return _function;
|
||||
}
|
||||
|
||||
const QString& SeerParallelStacksFrame::arch () const {
|
||||
return _arch;
|
||||
}
|
||||
@@ -206,19 +215,26 @@ SeerParallelStacksStack SeerParallelStacksFillStack(const SeerParallelStacksNode
|
||||
stack.threadIds.append(t.id());
|
||||
}
|
||||
|
||||
if (node.function.function().isEmpty() == false) {
|
||||
stack.frames.append(node.function);
|
||||
}
|
||||
|
||||
if (node.children.size() == 1) {
|
||||
// Merge single child into this stack (chain of frames).
|
||||
// Keep the IDs from the leaf (most specific) node.
|
||||
// Children are deeper (more toward the top of the call stack) than
|
||||
// this node, so their frames go first — the resulting list reads
|
||||
// top of stack (innermost) to bottom of stack (outermost).
|
||||
auto child = SeerParallelStacksFillStack(node.children[0]);
|
||||
stack.frames += child.frames;
|
||||
stack.stacks = child.stacks;
|
||||
stack.threadCount = child.threadCount;
|
||||
stack.threadIds = child.threadIds;
|
||||
stack.frames = child.frames;
|
||||
stack.stacks = child.stacks;
|
||||
stack.threadCount = child.threadCount;
|
||||
stack.threadIds = child.threadIds;
|
||||
|
||||
if (node.function.function().isEmpty() == false) {
|
||||
stack.frames.append(node.function);
|
||||
}
|
||||
} else {
|
||||
if (node.function.function().isEmpty() == false) {
|
||||
stack.frames.append(node.function);
|
||||
}
|
||||
|
||||
for (const auto& childNode : node.children) {
|
||||
stack.stacks.append(SeerParallelStacksFillStack(childNode));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class SeerParallelStacksFrame {
|
||||
int level () const;
|
||||
const QString& addr () const;
|
||||
const QString& function () const;
|
||||
QString functionOrAddr () const;
|
||||
const QString& arch () const;
|
||||
const QString& from () const;
|
||||
const QString& file () const;
|
||||
|
||||
@@ -87,6 +87,12 @@ SeerParallelStacksStackBoxItem::SeerParallelStacksStackBoxItem(const SeerParalle
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
_hoverTimer = new QTimer(this);
|
||||
_hoverTimer->setSingleShot(true);
|
||||
_hoverTimer->setInterval(_kHoverDelayMs);
|
||||
|
||||
QObject::connect(_hoverTimer, &QTimer::timeout, this, &SeerParallelStacksStackBoxItem::handleShowPopup);
|
||||
|
||||
_headerLeft = QString("%1 Thread%2") .arg(stack.threadCount) .arg(stack.threadCount == 1 ? "" : "s");
|
||||
|
||||
_threadIds.resize(0);
|
||||
@@ -118,15 +124,15 @@ SeerParallelStacksStackBoxItem::SeerParallelStacksStackBoxItem(const SeerParalle
|
||||
QFont normFont;
|
||||
QFontMetrics normFm(normFont);
|
||||
|
||||
qreal headerW = boldFm.horizontalAdvance(_headerLeft) + boldFm.horizontalAdvance(_headerRight) + kHeaderGap;
|
||||
qreal headerW = boldFm.horizontalAdvance(_headerLeft) + boldFm.horizontalAdvance(_headerRight) + _kHeaderGap;
|
||||
qreal maxTextW = headerW;
|
||||
|
||||
for (const auto& frame : _stack.frames) {
|
||||
maxTextW = std::max(maxTextW, (qreal)normFm.horizontalAdvance(frame.function()));
|
||||
maxTextW = std::max(maxTextW, (qreal)normFm.horizontalAdvance(frame.functionOrAddr()));
|
||||
}
|
||||
|
||||
_width = maxTextW + 2 * kPadX;
|
||||
_height = kPadY + kRowH * (1 + (int)_stack.frames.size()) + kPadY;
|
||||
_width = maxTextW + 2 * _kPadX;
|
||||
_height = _kPadY + _kRowH * (1 + (int)_stack.frames.size()) + _kPadY;
|
||||
|
||||
qDebug() << _stack.stacks.size();
|
||||
}
|
||||
@@ -163,19 +169,19 @@ void SeerParallelStacksStackBoxItem::paint(QPainter* painter, const QStyleOption
|
||||
|
||||
QFont boldFont; boldFont.setBold(true);
|
||||
QFont normFont;
|
||||
const qreal innerW = _width - 2 * kPadX;
|
||||
qreal y = kPadY;
|
||||
const qreal innerW = _width - 2 * _kPadX;
|
||||
qreal y = _kPadY;
|
||||
|
||||
painter->setFont(boldFont);
|
||||
painter->setPen(colors.headerText);
|
||||
painter->drawText(QRectF(kPadX, y, innerW, kRowH), Qt::AlignLeft | Qt::AlignVCenter, _headerLeft);
|
||||
painter->drawText(QRectF(_kPadX, y, innerW, _kRowH), Qt::AlignLeft | Qt::AlignVCenter, _headerLeft);
|
||||
|
||||
if (!_headerRight.isEmpty()) {
|
||||
painter->setPen(colors.threadIdsText);
|
||||
painter->drawText(QRectF(kPadX, y, innerW, kRowH), Qt::AlignRight | Qt::AlignVCenter, _headerRight);
|
||||
painter->drawText(QRectF(_kPadX, y, innerW, _kRowH), Qt::AlignRight | Qt::AlignVCenter, _headerRight);
|
||||
}
|
||||
|
||||
y += kRowH;
|
||||
y += _kRowH;
|
||||
|
||||
painter->setPen(QPen(colors.divider, 1));
|
||||
painter->drawLine(QPointF(0, y), QPointF(_width, y));
|
||||
@@ -184,8 +190,8 @@ void SeerParallelStacksStackBoxItem::paint(QPainter* painter, const QStyleOption
|
||||
painter->setPen(colors.frameText);
|
||||
|
||||
for (const auto& frame : _stack.frames) {
|
||||
painter->drawText(QRectF(kPadX, y, innerW, kRowH), Qt::AlignLeft | Qt::AlignVCenter, frame.function());
|
||||
y += kRowH;
|
||||
painter->drawText(QRectF(_kPadX, y, innerW, _kRowH), Qt::AlignLeft | Qt::AlignVCenter, frame.functionOrAddr());
|
||||
y += _kRowH;
|
||||
}
|
||||
|
||||
if (_dragging) {
|
||||
@@ -269,37 +275,82 @@ void SeerParallelStacksStackBoxItem::hoverEnterEvent(QGraphicsSceneHoverEvent* e
|
||||
QGraphicsItem::hoverEnterEvent(event);
|
||||
|
||||
if (_popup == nullptr) {
|
||||
|
||||
QString frame;
|
||||
|
||||
if (_stack.frames.size() > 0) {
|
||||
frame = _stack.frames[0].function();
|
||||
}
|
||||
|
||||
_popup = new SeerParallelStacksPopupTableWidget();
|
||||
|
||||
for (const auto& id : _threadIds) {
|
||||
_popup->addRow(id, frame);
|
||||
}
|
||||
|
||||
QGraphicsView* view = scene()->views().first(); // scene() is always valid here
|
||||
|
||||
// Position below the item, aligned to its left edge
|
||||
QRectF sceneRect = mapToScene(boundingRect()).boundingRect();
|
||||
QPoint viewportPt = view->mapFromScene(sceneRect.bottomLeft());
|
||||
QPoint globalPt = view->viewport()->mapToGlobal(viewportPt);
|
||||
_popup->move(globalPt);
|
||||
|
||||
_popup->show();
|
||||
|
||||
// Connect things.
|
||||
QObject::connect(_popup, &SeerParallelStacksPopupTableWidget::mouseLeftPopup, this, &SeerParallelStacksStackBoxItem::handleDeletePopup);
|
||||
_hoverTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void SeerParallelStacksStackBoxItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) {
|
||||
|
||||
QGraphicsItem::hoverLeaveEvent(event);
|
||||
|
||||
// Cancel a pending popup if the mouse left before the delay elapsed.
|
||||
_hoverTimer->stop();
|
||||
|
||||
// A popup that's already showing stays up if the mouse just moved onto
|
||||
// it — give handleMaybeClosePopup() a moment to check for that.
|
||||
handleMaybeClosePopup();
|
||||
}
|
||||
|
||||
QRect SeerParallelStacksStackBoxItem::globalRect() const {
|
||||
|
||||
QGraphicsView* view = scene()->views().first(); // scene() is always valid here
|
||||
|
||||
QRectF sceneRect = mapToScene(boundingRect()).boundingRect();
|
||||
QPoint topLeft = view->viewport()->mapToGlobal(view->mapFromScene(sceneRect.topLeft()));
|
||||
QPoint bottomRight = view->viewport()->mapToGlobal(view->mapFromScene(sceneRect.bottomRight()));
|
||||
|
||||
return QRect(topLeft, bottomRight);
|
||||
}
|
||||
|
||||
void SeerParallelStacksStackBoxItem::handleShowPopup() {
|
||||
|
||||
if (_popup != nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString frame;
|
||||
|
||||
if (_stack.frames.size() > 0) {
|
||||
frame = _stack.frames[0].functionOrAddr();
|
||||
}
|
||||
|
||||
_popup = new SeerParallelStacksPopupTableWidget();
|
||||
|
||||
for (const auto& id : _threadIds) {
|
||||
_popup->addRow(id, frame);
|
||||
}
|
||||
|
||||
// Position below the item, aligned to its left edge
|
||||
_popup->move(globalRect().bottomLeft());
|
||||
|
||||
_popup->show();
|
||||
|
||||
QObject::connect(_popup, &SeerParallelStacksPopupTableWidget::mouseLeftPopup, this, &SeerParallelStacksStackBoxItem::handleMaybeClosePopup);
|
||||
}
|
||||
|
||||
void SeerParallelStacksStackBoxItem::handleMaybeClosePopup() {
|
||||
|
||||
if (_popup == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The mouse may have simply crossed from the node onto the popup (or
|
||||
// vice versa) — give that a moment to register before deciding the
|
||||
// mouse has truly left both, then re-check with the cursor's live
|
||||
// position rather than relying on possibly-stale hover state.
|
||||
QTimer::singleShot(_kCloseGraceMs, this, [this]() {
|
||||
|
||||
if (_popup == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool overNode = globalRect().contains(QCursor::pos());
|
||||
bool overPopup = _popup->frameGeometry().contains(QCursor::pos());
|
||||
|
||||
if (overNode == false && overPopup == false) {
|
||||
handleDeletePopup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void SeerParallelStacksStackBoxItem::handleDeletePopup() {
|
||||
@@ -358,7 +409,7 @@ QRectF SeerParallelStacksLiveEdge::boundingRect() const {
|
||||
QPointF f = _from->sceneBottom();
|
||||
QPointF t = _to->sceneTop();
|
||||
|
||||
qreal pad = kArrow + kVCtrl + 4;
|
||||
qreal pad = _kArrow + _kVCtrl + 4;
|
||||
|
||||
return QRectF(f, t).normalized().adjusted(-pad, -pad, pad, pad);
|
||||
}
|
||||
@@ -382,39 +433,8 @@ void SeerParallelStacksLiveEdge::paint(QPainter* painter, const QStyleOptionGrap
|
||||
QPointF from = _from->sceneBottom();
|
||||
QPointF to = _to->sceneTop();
|
||||
|
||||
/*
|
||||
// Bezier: control points pull vertically toward each other
|
||||
QPainterPath path;
|
||||
path.moveTo(from);
|
||||
path.cubicTo(from + QPointF(0, kVCtrl), to + QPointF(0, -kVCtrl), to);
|
||||
|
||||
painter->setPen(QPen(QColor(0x55, 0x55, 0x55), 1.5));
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawPath(path);
|
||||
|
||||
// Arrowhead at `to` pointing downward (into the parent box)
|
||||
// The tangent direction at the end of the cubic is (to - cp2)
|
||||
QPointF cp2 = to + QPointF(0, -kVCtrl);
|
||||
QPointF dir = to - cp2;
|
||||
double len = std::hypot(dir.x(), dir.y());
|
||||
if (len < 1e-6) return;
|
||||
dir /= len; // normalise
|
||||
|
||||
// Perpendicular
|
||||
QPointF perp(-dir.y(), dir.x());
|
||||
|
||||
QPointF a1 = to - dir * kArrow + perp * (kArrow * 0.5);
|
||||
QPointF a2 = to - dir * kArrow - perp * (kArrow * 0.5);
|
||||
|
||||
QPolygonF arrowHead;
|
||||
arrowHead << to << a1 << a2;
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(QColor(0x55, 0x55, 0x55));
|
||||
painter->drawPolygon(arrowHead);
|
||||
*/
|
||||
|
||||
// --- Arrowhead: tip touches the child box bottom (`from`),
|
||||
// base is kArrow further along toward `to`.
|
||||
// base is _kArrow further along toward `to`.
|
||||
// The bezier starts at the base so the line never overlaps the head.
|
||||
QPointF delta = to - from;
|
||||
double len = std::hypot(delta.x(), delta.y());
|
||||
@@ -425,16 +445,16 @@ void SeerParallelStacksLiveEdge::paint(QPainter* painter, const QStyleOptionGrap
|
||||
QPointF perp(-dir.y(), dir.x()); // perpendicular
|
||||
|
||||
QPointF tip = from; // touches child box
|
||||
QPointF base = from + dir * kArrow; // where the line begins
|
||||
QPointF base = from + dir * _kArrow; // where the line begins
|
||||
|
||||
QPointF a1 = base + perp * (kArrow * 0.5);
|
||||
QPointF a2 = base - perp * (kArrow * 0.5);
|
||||
QPointF a1 = base + perp * (_kArrow * 0.5);
|
||||
QPointF a2 = base - perp * (_kArrow * 0.5);
|
||||
|
||||
// Bezier runs from the arrowhead base to the parent box top.
|
||||
QPainterPath path;
|
||||
|
||||
path.moveTo(base);
|
||||
path.cubicTo(base + QPointF(0, kVCtrl), to + QPointF(0, -kVCtrl), to);
|
||||
path.cubicTo(base + QPointF(0, _kVCtrl), to + QPointF(0, -_kVCtrl), to);
|
||||
|
||||
const QColor color = edgeColor();
|
||||
|
||||
@@ -641,15 +661,6 @@ SeerParallelStacksPopupTableWidget::SeerParallelStacksPopupTableWidget(QWidget*
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(6, 6, 6, 6);
|
||||
layout->addWidget(_table);
|
||||
|
||||
_closeTimer = new QTimer(this);
|
||||
_closeTimer->setSingleShot(true); // Ensures it only fires once
|
||||
_closeTimer->setInterval(1500); // Delay
|
||||
|
||||
// Connect things.
|
||||
QObject::connect(_closeTimer, &QTimer::timeout, this, &SeerParallelStacksPopupTableWidget::handleCloseTimer);
|
||||
|
||||
_closeTimer->start();
|
||||
}
|
||||
|
||||
void SeerParallelStacksPopupTableWidget::addRow (int threadid, const QString& frame) {
|
||||
@@ -673,31 +684,13 @@ void SeerParallelStacksPopupTableWidget::addRow (int threadid, const QString& fr
|
||||
_table->resizeColumnToContents(1);
|
||||
}
|
||||
|
||||
void SeerParallelStacksPopupTableWidget::enterEvent(QEnterEvent* event) {
|
||||
|
||||
// If the user moves the cursor into the table, cancel the timer.
|
||||
if (_closeTimer->isActive()) {
|
||||
_closeTimer->stop();
|
||||
}
|
||||
|
||||
QFrame::enterEvent(event);
|
||||
}
|
||||
|
||||
void SeerParallelStacksPopupTableWidget::leaveEvent(QEvent* event) {
|
||||
|
||||
// If the user leaves the table, ask for the table to be closed.
|
||||
QFrame::leaveEvent(event);
|
||||
|
||||
emit mouseLeftPopup();
|
||||
}
|
||||
|
||||
void SeerParallelStacksPopupTableWidget::handleCloseTimer() {
|
||||
|
||||
// If the user doesn't move the cursor into the table in the default time,
|
||||
// ask the table to be closed.
|
||||
emit mouseLeftPopup();
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// SeerParallelStacksPopupTableWidget
|
||||
// ================================================================
|
||||
|
||||
@@ -52,26 +52,32 @@ class SeerParallelStacksStackBoxItem : public QObject, public QGraphicsItem {
|
||||
void hoverLeaveEvent (QGraphicsSceneHoverEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void handleDeletePopup ();
|
||||
void handleDeletePopup ();
|
||||
void handleShowPopup ();
|
||||
void handleMaybeClosePopup ();
|
||||
|
||||
private:
|
||||
// Global (screen) rect this box occupies, used to test whether the
|
||||
// cursor is still over the node.
|
||||
QRect globalRect () const;
|
||||
|
||||
QVector<SeerParallelStacksLiveEdge*> _edges; // non-owning
|
||||
QVector<int> _threadIds;
|
||||
SeerParallelStacksStack _stack;
|
||||
QString _headerLeft;
|
||||
QString _headerRight;
|
||||
qreal _width = 0;
|
||||
qreal _height = 0;
|
||||
SeerParallelStacksPopupTableWidget* _popup = 0;
|
||||
|
||||
bool _dragging = false;
|
||||
qreal _width = 0;
|
||||
qreal _height = 0;
|
||||
SeerParallelStacksPopupTableWidget* _popup = 0;
|
||||
QTimer* _hoverTimer = 0;
|
||||
static constexpr int _kHoverDelayMs = 1000;
|
||||
static constexpr int _kCloseGraceMs = 150;
|
||||
bool _dragging = false;
|
||||
QPointF _dragOffset;
|
||||
|
||||
QVector<SeerParallelStacksLiveEdge*> _edges; // non-owning
|
||||
|
||||
static constexpr qreal kPadX = 12;
|
||||
static constexpr qreal kPadY = 8;
|
||||
static constexpr qreal kRowH = 20;
|
||||
static constexpr qreal kHeaderGap = 16;
|
||||
static constexpr qreal _kPadX = 12;
|
||||
static constexpr qreal _kPadY = 8;
|
||||
static constexpr qreal _kRowH = 20;
|
||||
static constexpr qreal _kHeaderGap = 16;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
@@ -82,7 +88,7 @@ class SeerParallelStacksLiveEdge : public QGraphicsItem {
|
||||
|
||||
public:
|
||||
SeerParallelStacksLiveEdge(SeerParallelStacksStackBoxItem* from, SeerParallelStacksStackBoxItem* to, QGraphicsItem* parent = nullptr);
|
||||
~SeerParallelStacksLiveEdge() override;
|
||||
~SeerParallelStacksLiveEdge() override;
|
||||
|
||||
QRectF boundingRect () const override;
|
||||
QPainterPath shape () const override;
|
||||
@@ -95,11 +101,11 @@ class SeerParallelStacksLiveEdge : public QGraphicsItem {
|
||||
|
||||
|
||||
private:
|
||||
SeerParallelStacksStackBoxItem* _from; // child (bottom anchor)
|
||||
SeerParallelStacksStackBoxItem* _to; // parent (top anchor)
|
||||
SeerParallelStacksStackBoxItem* _from; // child (bottom anchor)
|
||||
SeerParallelStacksStackBoxItem* _to; // parent (top anchor)
|
||||
|
||||
static constexpr qreal kArrow = 8.0;
|
||||
static constexpr qreal kVCtrl = 60.0 * 0.4; // bezier control-point stretch
|
||||
static constexpr qreal _kArrow = 8.0;
|
||||
static constexpr qreal _kVCtrl = 60.0 * 0.4; // bezier control-point stretch
|
||||
};
|
||||
|
||||
|
||||
@@ -142,7 +148,8 @@ class SeerParallelStacksMiniMapWidget : public QWidget {
|
||||
};
|
||||
|
||||
// A frameless popup window that wraps a QTableWidget inside a small
|
||||
// bordered frame, and closes/deletes itself when the mouse leaves it.
|
||||
// bordered frame. Its lifetime is owned by the SeerParallelStacksStackBoxItem
|
||||
// that created it — it stays up for as long as the mouse is in that node.
|
||||
class SeerParallelStacksPopupTableWidget : public QFrame {
|
||||
|
||||
Q_OBJECT
|
||||
@@ -153,18 +160,13 @@ class SeerParallelStacksPopupTableWidget : public QFrame {
|
||||
void addRow (int threadid, const QString& function);
|
||||
|
||||
protected:
|
||||
void enterEvent (QEnterEvent* event) override;
|
||||
void leaveEvent (QEvent* event) override;
|
||||
|
||||
protected slots:
|
||||
void handleCloseTimer ();
|
||||
|
||||
signals:
|
||||
void mouseLeftPopup ();
|
||||
|
||||
private:
|
||||
QTableWidget* _table;
|
||||
QTimer* _closeTimer;
|
||||
};
|
||||
|
||||
class SeerParallelStacksGraphicsView : public QGraphicsView {
|
||||
|
||||
@@ -78,5 +78,6 @@ Available Quick keys while in the Image Visualizer:
|
||||
'+' zoom in
|
||||
'-' zoom out
|
||||
ESC reset to default zoom level.
|
||||
Ctrl+mouse wheel zoom in or out.
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user