display panel with number or warnings and lines in output window, button for jumping to next warning
This commit is contained in:
@ -281,7 +281,11 @@ This text would normally be seen in the command-line window.
|
|||||||
LAMMPS-GUI captures the screen output from LAMMPS as it is generated and
|
LAMMPS-GUI captures the screen output from LAMMPS as it is generated and
|
||||||
updates the *Output* window regularly during a run. If there are any
|
updates the *Output* window regularly during a run. If there are any
|
||||||
warnings or errors in the LAMMPS output, they are highlighted by using
|
warnings or errors in the LAMMPS output, they are highlighted by using
|
||||||
bold text colored in red.
|
bold text colored in red. There is a small panel at the bottom center
|
||||||
|
of the *Output* window showing how many warnings and errors were
|
||||||
|
detected and how many lines the entire output has. By clicking on the
|
||||||
|
button on the right with the warning symbol, you can jump to the next
|
||||||
|
line with a warning or error.
|
||||||
|
|
||||||
By default, the *Output* window is replaced each time a run is started.
|
By default, the *Output* window is replaced each time a run is started.
|
||||||
The runs are counted and the run number for the current run is displayed
|
The runs are counted and the run number for the current run is displayed
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 78 KiB |
@ -17,17 +17,22 @@
|
|||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTextDocument>
|
||||||
|
|
||||||
// workaround for Qt-5.12
|
// workaround for Qt-5.12
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||||
namespace QColorConstants {
|
namespace QColorConstants {
|
||||||
const QColor Red = QColor::fromRgb(0xff, 0x00, 0x00);
|
const QColor Red = QColor::fromRgb(0xff, 0x00, 0x00);
|
||||||
} // namespace QColorConstants
|
} // namespace QColorConstants
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FlagWarnings::FlagWarnings(QTextDocument *parent) :
|
FlagWarnings::FlagWarnings(QLabel *label, QTextDocument *parent) :
|
||||||
QSyntaxHighlighter(parent), isWarning(QStringLiteral("^(ERROR|WARNING).*$"))
|
QSyntaxHighlighter(parent), isWarning(QStringLiteral("^(ERROR|WARNING).*$")), summary(label),
|
||||||
|
document(parent)
|
||||||
{
|
{
|
||||||
|
nwarnings = nlines = 0;
|
||||||
|
|
||||||
formatWarning.setForeground(QColorConstants::Red);
|
formatWarning.setForeground(QColorConstants::Red);
|
||||||
formatWarning.setFontWeight(QFont::Bold);
|
formatWarning.setFontWeight(QFont::Bold);
|
||||||
}
|
}
|
||||||
@ -39,6 +44,16 @@ void FlagWarnings::highlightBlock(const QString &text)
|
|||||||
|
|
||||||
auto match = isWarning.match(text);
|
auto match = isWarning.match(text);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
|
++nwarnings;
|
||||||
setFormat(match.capturedStart(0), match.capturedLength(0), formatWarning);
|
setFormat(match.capturedStart(0), match.capturedLength(0), formatWarning);
|
||||||
}
|
}
|
||||||
|
if (document && summary) {
|
||||||
|
summary->setText(
|
||||||
|
QString("%1 Warnings / Errors - %2 Lines").arg(nwarnings).arg(document->lineCount()));
|
||||||
|
summary->repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// c-basic-offset: 4
|
||||||
|
// End:
|
||||||
|
|||||||
@ -18,11 +18,15 @@
|
|||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QTextDocument;
|
||||||
|
|
||||||
class FlagWarnings : public QSyntaxHighlighter {
|
class FlagWarnings : public QSyntaxHighlighter {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FlagWarnings(QTextDocument *parent = 0);
|
FlagWarnings(QLabel *label = 0, QTextDocument *parent = 0);
|
||||||
|
int get_nwarnings() const { return nwarnings; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void highlightBlock(const QString &text) override;
|
void highlightBlock(const QString &text) override;
|
||||||
@ -30,6 +34,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QRegularExpression isWarning;
|
QRegularExpression isWarning;
|
||||||
QTextCharFormat formatWarning;
|
QTextCharFormat formatWarning;
|
||||||
|
QLabel *summary;
|
||||||
|
QTextDocument *document;
|
||||||
|
int nwarnings, nlines;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
|
|||||||
BIN
tools/lammps-gui/icons/warning.png
Normal file
BIN
tools/lammps-gui/icons/warning.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@ -58,6 +58,7 @@
|
|||||||
<description>
|
<description>
|
||||||
Update Tutorial menu entries to cover all 8 tutorials
|
Update Tutorial menu entries to cover all 8 tutorials
|
||||||
Highlight warnings and error messages in Output window
|
Highlight warnings and error messages in Output window
|
||||||
|
Make Tutorial wizards more compact
|
||||||
</description>
|
</description>
|
||||||
</release>
|
</release>
|
||||||
<release version="1.6.11" timestamp="1725080055">
|
<release version="1.6.11" timestamp="1725080055">
|
||||||
|
|||||||
@ -1244,7 +1244,7 @@ void LammpsGui::do_run(bool use_buffer)
|
|||||||
logwindow->setCenterOnScroll(true);
|
logwindow->setCenterOnScroll(true);
|
||||||
logwindow->moveCursor(QTextCursor::End);
|
logwindow->moveCursor(QTextCursor::End);
|
||||||
logwindow->setWindowTitle(
|
logwindow->setWindowTitle(
|
||||||
QString("LAMMPS-GUI - Output - %2 - Run %3").arg(current_file).arg(run_counter));
|
QString("LAMMPS-GUI - Output - %1 - Run %2").arg(current_file).arg(run_counter));
|
||||||
logwindow->setWindowIcon(QIcon(":/icons/lammps-icon-128x128.png"));
|
logwindow->setWindowIcon(QIcon(":/icons/lammps-icon-128x128.png"));
|
||||||
QFont text_font;
|
QFont text_font;
|
||||||
text_font.fromString(settings.value("textfont", text_font.toString()).toString());
|
text_font.fromString(settings.value("textfont", text_font.toString()).toString());
|
||||||
|
|||||||
@ -73,6 +73,7 @@
|
|||||||
<file>icons/utilities-terminal.png</file>
|
<file>icons/utilities-terminal.png</file>
|
||||||
<file>icons/vdw-style.png</file>
|
<file>icons/vdw-style.png</file>
|
||||||
<file>icons/vmd.png</file>
|
<file>icons/vmd.png</file>
|
||||||
|
<file>icons/warning.png</file>
|
||||||
<file>icons/window-close.png</file>
|
<file>icons/window-close.png</file>
|
||||||
<file>icons/x-office-drawing.png</file>
|
<file>icons/x-office-drawing.png</file>
|
||||||
<file>icons/yaml-file-icon.png</file>
|
<file>icons/yaml-file-icon.png</file>
|
||||||
|
|||||||
@ -20,13 +20,18 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
#include <QSpacerItem>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
@ -39,7 +44,29 @@ LogWindow::LogWindow(const QString &_filename, QWidget *parent) :
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
resize(settings.value("logx", 500).toInt(), settings.value("logy", 320).toInt());
|
resize(settings.value("logx", 500).toInt(), settings.value("logy", 320).toInt());
|
||||||
|
|
||||||
warnings = new FlagWarnings(document());
|
summary = new QLabel("0 Warnings / Errors - 0 Lines");
|
||||||
|
summary->setMargin(1);
|
||||||
|
|
||||||
|
auto *frame = new QFrame;
|
||||||
|
frame->setAutoFillBackground(true);
|
||||||
|
frame->setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||||
|
frame->setLineWidth(2);
|
||||||
|
|
||||||
|
auto *button = new QPushButton(QIcon(":/icons/warning.png"), "");
|
||||||
|
button->setToolTip("Jump to next warning");
|
||||||
|
connect(button, &QPushButton::released, this, &LogWindow::next_warning);
|
||||||
|
|
||||||
|
auto *spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
auto *panel = new QHBoxLayout(frame);
|
||||||
|
auto *grid = new QGridLayout(this);
|
||||||
|
|
||||||
|
panel->addWidget(summary);
|
||||||
|
panel->addWidget(button);
|
||||||
|
|
||||||
|
grid->addItem(spacer, 0, 0, 1, 3);
|
||||||
|
grid->addWidget(frame, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
warnings = new FlagWarnings(summary, document());
|
||||||
|
|
||||||
auto *action = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_S), this);
|
auto *action = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_S), this);
|
||||||
connect(action, &QShortcut::activated, this, &LogWindow::save_as);
|
connect(action, &QShortcut::activated, this, &LogWindow::save_as);
|
||||||
@ -56,6 +83,7 @@ LogWindow::LogWindow(const QString &_filename, QWidget *parent) :
|
|||||||
LogWindow::~LogWindow()
|
LogWindow::~LogWindow()
|
||||||
{
|
{
|
||||||
delete warnings;
|
delete warnings;
|
||||||
|
delete summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogWindow::closeEvent(QCloseEvent *event)
|
void LogWindow::closeEvent(QCloseEvent *event)
|
||||||
@ -84,6 +112,22 @@ void LogWindow::stop_run()
|
|||||||
if (main) main->stop_run();
|
if (main) main->stop_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogWindow::next_warning()
|
||||||
|
{
|
||||||
|
auto *doc = document();
|
||||||
|
auto regex = QRegularExpression(QStringLiteral("^(ERROR|WARNING).*$"));
|
||||||
|
|
||||||
|
if (warnings->get_nwarnings() > 0) {
|
||||||
|
// wrap around search
|
||||||
|
if (!this->find(regex)) {
|
||||||
|
this->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||||
|
this->find(regex);
|
||||||
|
}
|
||||||
|
// move cursor to unselect
|
||||||
|
this->moveCursor(QTextCursor::NextBlock, QTextCursor::MoveAnchor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LogWindow::save_as()
|
void LogWindow::save_as()
|
||||||
{
|
{
|
||||||
QString defaultname = filename + ".log";
|
QString defaultname = filename + ".log";
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
class FlagWarnings;
|
class FlagWarnings;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
class LogWindow : public QPlainTextEdit {
|
class LogWindow : public QPlainTextEdit {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -30,6 +31,7 @@ private slots:
|
|||||||
void quit();
|
void quit();
|
||||||
void save_as();
|
void save_as();
|
||||||
void stop_run();
|
void stop_run();
|
||||||
|
void next_warning();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
@ -41,6 +43,7 @@ private:
|
|||||||
QString filename;
|
QString filename;
|
||||||
static const QString yaml_regex;
|
static const QString yaml_regex;
|
||||||
FlagWarnings *warnings;
|
FlagWarnings *warnings;
|
||||||
|
QLabel *summary;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user