mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 08:34:42 +08:00
Checkpoint: ArrayVisualizer.
This commit is contained in:
@@ -20,6 +20,17 @@ QZoomChartView::QZoomChartView (QChart* chart, QWidget* parent) : QChartView(cha
|
||||
|
||||
bool QZoomChartView::viewportEvent (QEvent* event) {
|
||||
|
||||
// Disable ToolTip events in the ChartView. They interfer with the 'length' arguments
|
||||
// of the QToolTip::showText() function.
|
||||
// https://bugreports.qt.io/browse/QTBUG-56427
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ToolTip:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QChartView::viewportEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "SeerUtl.h"
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QToolTip>
|
||||
#include <QtGui/QIntValidator>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtPrintSupport/QPrinter>
|
||||
@@ -25,16 +26,16 @@ SeerArrayVisualizerWidget::SeerArrayVisualizerWidget (QWidget* parent) : QWidget
|
||||
setWindowTitle("Seer Array Visualizer");
|
||||
|
||||
arrayLengthLineEdit->setValidator(new QIntValidator(1, 9999999, this));
|
||||
columnCountSpinBox->setValue(arrayTableWidget->elementsPerLine());
|
||||
arrayOffsetLineEdit->setValidator(new QIntValidator(0, 9999999, this));
|
||||
arrayStrideLineEdit->setValidator(new QIntValidator(1, 9999999, this));
|
||||
|
||||
arrayDisplayFormatComboBox->setCurrentIndex(0);
|
||||
handleArrayDisplayFormatComboBox(0);
|
||||
|
||||
// XXX Test
|
||||
// A single series chart.
|
||||
QChart* chart = new QChart;
|
||||
chart->legend()->hide();
|
||||
chart->createDefaultAxes();
|
||||
chart->setTitle("Simple line chart example");
|
||||
chart->legend()->setVisible(true);
|
||||
chart->legend()->setAlignment(Qt::AlignBottom);
|
||||
|
||||
@@ -46,8 +47,11 @@ SeerArrayVisualizerWidget::SeerArrayVisualizerWidget (QWidget* parent) : QWidget
|
||||
QObject::connect(arrayLengthLineEdit, &QLineEdit::returnPressed, this, &SeerArrayVisualizerWidget::handleRefreshButton);
|
||||
QObject::connect(variableNameLineEdit, &QLineEdit::returnPressed, this, &SeerArrayVisualizerWidget::handleVariableNameLineEdit);
|
||||
QObject::connect(arrayDisplayFormatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SeerArrayVisualizerWidget::handleArrayDisplayFormatComboBox);
|
||||
QObject::connect(columnCountSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &SeerArrayVisualizerWidget::handleColumnCountSpinBox);
|
||||
QObject::connect(arrayTableWidget, &SeerArrayWidget::dataChanged, this, &SeerArrayVisualizerWidget::handleDataChanged);
|
||||
QObject::connect(splitter, &QSplitter::splitterMoved, this, &SeerArrayVisualizerWidget::handleSplitterMoved);
|
||||
QObject::connect(titleLineEdit, &QLineEdit::returnPressed, this, &SeerArrayVisualizerWidget::handleTitleLineEdit);
|
||||
QObject::connect(pointsCheckBox, &QCheckBox::clicked, this, &SeerArrayVisualizerWidget::handlePointsCheckBox);
|
||||
QObject::connect(labelsCheckBox, &QCheckBox::clicked, this, &SeerArrayVisualizerWidget::handleLabelsCheckBox);
|
||||
|
||||
// Restore window settings.
|
||||
readSettings();
|
||||
@@ -252,11 +256,6 @@ void SeerArrayVisualizerWidget::handleArrayDisplayFormatComboBox (int index) {
|
||||
}
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handleColumnCountSpinBox (int value) {
|
||||
|
||||
arrayTableWidget->setElementsPerLine(value);
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handleDataChanged () {
|
||||
|
||||
if (_series) {
|
||||
@@ -267,6 +266,8 @@ void SeerArrayVisualizerWidget::handleDataChanged () {
|
||||
|
||||
_series = new QLineSeries;
|
||||
_series->setName(variableName());
|
||||
_series->setPointsVisible(false);
|
||||
_series->setPointLabelsVisible(false);
|
||||
|
||||
const QVector<double>& values = arrayTableWidget->arrayValues();
|
||||
|
||||
@@ -274,6 +275,8 @@ void SeerArrayVisualizerWidget::handleDataChanged () {
|
||||
_series->append(i, values[i]);
|
||||
}
|
||||
|
||||
QObject::connect(_series, &QLineSeries::hovered, this, &SeerArrayVisualizerWidget::handleSeriesHovered);
|
||||
|
||||
arrayChartView->chart()->addSeries(_series);
|
||||
arrayChartView->chart()->createDefaultAxes();
|
||||
}
|
||||
@@ -282,9 +285,10 @@ void SeerArrayVisualizerWidget::writeSettings() {
|
||||
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup("arrayvisualizerwindow");
|
||||
settings.setValue("size", size());
|
||||
settings.endGroup();
|
||||
settings.beginGroup("arrayvisualizerwindow"); {
|
||||
settings.setValue("size", size());
|
||||
settings.setValue("splitter", splitter->saveState());
|
||||
} settings.endGroup();
|
||||
|
||||
//qDebug() << size();
|
||||
}
|
||||
@@ -293,9 +297,10 @@ void SeerArrayVisualizerWidget::readSettings() {
|
||||
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup("arrayvisualizerwindow");
|
||||
resize(settings.value("size", QSize(800, 400)).toSize());
|
||||
settings.endGroup();
|
||||
settings.beginGroup("arrayvisualizerwindow"); {
|
||||
resize(settings.value("size", QSize(800, 400)).toSize());
|
||||
splitter->restoreState(settings.value("splitter").toByteArray());
|
||||
} settings.endGroup();
|
||||
|
||||
//qDebug() << size();
|
||||
}
|
||||
@@ -307,3 +312,40 @@ void SeerArrayVisualizerWidget::resizeEvent (QResizeEvent* event) {
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handleSplitterMoved (int pos, int index) {
|
||||
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handleSeriesHovered (const QPointF& point, bool state) {
|
||||
|
||||
//qDebug() << "QPointF=" << point << "State=" << state << "MapToPosition=" << arrayChartView->chart()->mapToPosition(point) << "MapFromScene=" << arrayChartView->mapFromScene(arrayChartView->chart()->mapToPosition(point));
|
||||
|
||||
if (state) {
|
||||
QToolTip::showText(arrayChartView->mapToGlobal(arrayChartView->mapFromScene(arrayChartView->chart()->mapToPosition(point))), QString("%1 / %2").arg(point.x()).arg(point.y()), this, QRect(), 10000);
|
||||
}else{
|
||||
QToolTip::hideText();
|
||||
}
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handleTitleLineEdit () {
|
||||
|
||||
arrayChartView->chart()->setTitle(titleLineEdit->text());
|
||||
|
||||
titleLineEdit->setText("");
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handlePointsCheckBox () {
|
||||
|
||||
if (_series) {
|
||||
_series->setPointsVisible(pointsCheckBox->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
void SeerArrayVisualizerWidget::handleLabelsCheckBox () {
|
||||
|
||||
if (_series) {
|
||||
_series->setPointLabelsVisible(labelsCheckBox->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,12 @@ class SeerArrayVisualizerWidget : public QWidget, protected Ui::SeerArrayVisuali
|
||||
void handleRefreshButton ();
|
||||
void handleVariableNameLineEdit ();
|
||||
void handleArrayDisplayFormatComboBox (int index);
|
||||
void handleColumnCountSpinBox (int value);
|
||||
void handleDataChanged ();
|
||||
void handleSplitterMoved (int pos, int index);
|
||||
void handleSeriesHovered (const QPointF& point, bool state);
|
||||
void handleTitleLineEdit ();
|
||||
void handlePointsCheckBox ();
|
||||
void handleLabelsCheckBox ();
|
||||
|
||||
protected:
|
||||
void writeSettings ();
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<string>variable name</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -40,21 +40,59 @@
|
||||
<property name="placeholderText">
|
||||
<string>variable address</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="arrayLengthLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Number of elements to display.</string>
|
||||
<string>Total number of elements in array.</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string># Elements</string>
|
||||
<string># elements</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="arrayOffsetLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Element offset into array.</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>array offset</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="arrayStrideLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Element stride between array values..</string>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>array stride</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -105,19 +143,6 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="columnCountSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>Number of columns in display.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="refreshToolButton">
|
||||
<property name="toolTip">
|
||||
@@ -137,9 +162,9 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>100</verstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
@@ -148,18 +173,70 @@
|
||||
<widget class="SeerArrayWidget" name="arrayTableWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>25</horstretch>
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QZoomChartView" name="arrayChartView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>75</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="25,0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QZoomChartView" name="arrayChartView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>100</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="titleLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set chart title.</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>chart title</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="pointsCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Show chart data points.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Points</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="labelsCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Show chart data labels.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Labels</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -199,7 +199,7 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) {
|
||||
QObject::connect(leftCenterRightSplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
|
||||
QObject::connect(sourceLibraryVariableManagerSplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
|
||||
QObject::connect(codeManagerLogTabsSplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
|
||||
QObject::connect(stackThreadManagersplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
|
||||
QObject::connect(stackThreadManagerSplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
|
||||
QObject::connect(manualCommandComboBox, QOverload<int>::of(&QComboBox::activated), this, &SeerGdbWidget::handleManualCommandChanged);
|
||||
QObject::connect(_gdbOutputLog, &SeerLogWidget::logEnabledChanged, this, &SeerGdbWidget::handleLogOuputChanged);
|
||||
QObject::connect(_seerOutputLog, &SeerLogWidget::logEnabledChanged, this, &SeerGdbWidget::handleLogOuputChanged);
|
||||
@@ -1543,7 +1543,7 @@ void SeerGdbWidget::writeSettings () {
|
||||
settings.setValue("leftCenterRightSplitter", leftCenterRightSplitter->saveState());
|
||||
settings.setValue("codeManagerLogTabsSplitter", codeManagerLogTabsSplitter->saveState());
|
||||
settings.setValue("sourceLibraryVariableManagerSplitter", sourceLibraryVariableManagerSplitter->saveState());
|
||||
settings.setValue("stackThreadManagersplitter", stackThreadManagersplitter->saveState());
|
||||
settings.setValue("stackThreadManagerSplitter", stackThreadManagerSplitter->saveState());
|
||||
} settings.endGroup();
|
||||
|
||||
settings.beginGroup("consolewindow"); {
|
||||
@@ -1589,7 +1589,7 @@ void SeerGdbWidget::readSettings () {
|
||||
leftCenterRightSplitter->restoreState(settings.value("leftCenterRightSplitter").toByteArray());
|
||||
codeManagerLogTabsSplitter->restoreState(settings.value("codeManagerLogTabsSplitter").toByteArray());
|
||||
sourceLibraryVariableManagerSplitter->restoreState(settings.value("sourceLibraryVariableManagerSplitter").toByteArray());
|
||||
stackThreadManagersplitter->restoreState(settings.value("stackThreadManagersplitter").toByteArray());
|
||||
stackThreadManagerSplitter->restoreState(settings.value("stackThreadManagerSplitter").toByteArray());
|
||||
} settings.endGroup();
|
||||
|
||||
settings.beginGroup("consolewindow"); {
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QSplitter" name="stackThreadManagersplitter">
|
||||
<widget class="QSplitter" name="stackThreadManagerSplitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>20</horstretch>
|
||||
|
||||
Reference in New Issue
Block a user