forked from qt-creator/qt-creator
Debugger: Use primitive internal widget instead of matplotview
This practically removes any functionality beyond plain plot display, but does that at least reliably, cross-platform, without dependency on 3rd party python packages. Change-Id: Iaff2f78595394522f32264c642df20dd48b83f8b Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -114,11 +114,15 @@ ImageViewer::ImageViewer(QWidget *parent)
|
||||
connect(m_imageWidget, &ImageWidget::clicked, this, &ImageViewer::clicked);
|
||||
}
|
||||
|
||||
void ImageViewer::setImage(const QImage &i)
|
||||
void ImageViewer::setImage(const QImage &image)
|
||||
{
|
||||
m_imageWidget->setImage(i);
|
||||
m_info = tr("Size: %1x%2, %3 byte, format: %4, depth: %5")
|
||||
.arg(i.width()).arg(i.height()).arg(i.byteCount()).arg(i.format()).arg(i.depth());
|
||||
m_imageWidget->setImage(image);
|
||||
clicked(QString());
|
||||
}
|
||||
|
||||
void ImageViewer::setInfo(const QString &info)
|
||||
{
|
||||
m_info = info;
|
||||
clicked(QString());
|
||||
}
|
||||
|
||||
@@ -165,4 +169,77 @@ void ImageViewer::contextMenuEvent(QContextMenuEvent *ev)
|
||||
openImageViewer(image);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
PlotViewer::PlotViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PlotViewer::setData(const PlotViewer::Data &data)
|
||||
{
|
||||
m_data = data;
|
||||
update();
|
||||
}
|
||||
|
||||
void PlotViewer::setInfo(const QString &description)
|
||||
{
|
||||
m_info = description;
|
||||
update();
|
||||
}
|
||||
|
||||
void PlotViewer::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter pain(this);
|
||||
|
||||
const int n = int(m_data.size());
|
||||
const int w = width();
|
||||
const int h = height();
|
||||
const int b = 10; // Border width.
|
||||
|
||||
pain.fillRect(rect(), Qt::white);
|
||||
|
||||
double ymin = 0;
|
||||
double ymax = 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const double v = m_data.at(i);
|
||||
if (v < ymin)
|
||||
ymin = v;
|
||||
else if (v > ymax)
|
||||
ymax = v;
|
||||
}
|
||||
|
||||
const double d = ymin == ymax ? (h / 2 - b) : (ymax - ymin);
|
||||
const int k = 1; // Length of cross marker arms.
|
||||
|
||||
for (int i = 0; i + 1 < n; ++i) {
|
||||
// Lines between points.
|
||||
const int x1 = b + i * (w - 2 * b) / (n - 1);
|
||||
const int x2 = b + (i + 1) * (w - 2 * b) / (n - 1);
|
||||
const int y1 = h - (b + int((m_data[i] - ymin) * (h - 2 * b) / d));
|
||||
const int y2 = h - (b + int((m_data[i + 1] - ymin) * (h - 2 * b) / d));
|
||||
pain.drawLine(x1, y1, x2, y2);
|
||||
|
||||
if (i == 0) {
|
||||
// Little cross marker on first point
|
||||
pain.drawLine(x1 - k, y1 - k, x1 + k, y1 + k);
|
||||
pain.drawLine(x1 + k, y1 - k, x1 - k, y1 + k);
|
||||
}
|
||||
// ... and all subsequent points.
|
||||
pain.drawLine(x2 - k, y2 - k, x2 + k, y2 + k);
|
||||
pain.drawLine(x2 + k, y2 - k, x2 - k, y2 + k);
|
||||
}
|
||||
|
||||
if (n) {
|
||||
pain.drawText(10, 10,
|
||||
QString::fromLatin1("%5 items. X: %1..%2, Y: %3...%4").arg(0).arg(n).arg(ymin).arg(ymax).arg(n));
|
||||
} else {
|
||||
pain.drawText(10, 10,
|
||||
QString::fromLatin1("Container is empty"));
|
||||
}
|
||||
}
|
||||
|
||||
#include "imageviewer.moc"
|
||||
|
||||
Reference in New Issue
Block a user