Merge branch 'lammps:develop' into regression-tests

This commit is contained in:
Trung Nguyen
2023-11-13 15:08:05 -06:00
committed by GitHub
172 changed files with 28457 additions and 6285 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.16)
project(lammps-gui VERSION 1.5.9 LANGUAGES CXX)
project(lammps-gui VERSION 1.5.10 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)

View File

@ -31,6 +31,8 @@
#include <QTextStream>
#include <QVBoxLayout>
#include <cmath>
using namespace QtCharts;
ChartWindow::ChartWindow(const QString &_filename, QWidget *parent) :
@ -86,9 +88,9 @@ int ChartWindow::get_step() const
if (charts.size() > 0) {
auto *v = charts[0];
if (v)
return (int)v->get_step(v->get_count() - 1);
return (int)v->get_step(v->get_count() - 1);
else
return -1;
return -1;
} else {
return -1;
}
@ -300,20 +302,7 @@ void ChartViewer::add_data(int step, double data)
if (last_step < step) {
last_step = step;
series->append(step, data);
auto points = series->points();
qreal xmin = 1.0e100;
qreal xmax = -1.0e100;
qreal ymin = 1.0e100;
qreal ymax = -1.0e100;
for (auto &p : points) {
xmin = qMin(xmin, p.x());
xmax = qMax(xmax, p.x());
ymin = qMin(ymin, p.y());
ymax = qMax(ymax, p.y());
}
xaxis->setRange(xmin, xmax);
yaxis->setRange(ymin, ymax);
reset_zoom();
}
}
@ -333,6 +322,30 @@ void ChartViewer::reset_zoom()
ymin = qMin(ymin, p.y());
ymax = qMax(ymax, p.y());
}
// avoid (nearly) empty ranges
double deltax = xmax - xmin;
if ((deltax / ((xmax == 0.0) ? 1.0 : xmax)) < 1.0e-10) {
if ((xmin == 0.0) || (xmax == 0.0)) {
xmin = -0.025;
xmax = 0.025;
} else {
xmin -= 0.025 * fabs(xmin);
xmax += 0.025 * fabs(xmax);
}
}
double deltay = ymax - ymin;
if ((deltay / ((ymax == 0.0) ? 1.0 : ymax)) < 1.0e-10) {
if ((ymin == 0.0) || (ymax == 0.0)) {
ymin = -0.025;
ymax = 0.025;
} else {
ymin -= 0.025 * fabs(ymin);
ymax += 0.025 * fabs(ymax);
}
}
xaxis->setRange(xmin, xmax);
yaxis->setRange(ymin, ymax);
}

View File

@ -34,6 +34,7 @@
#include <QShortcut>
#include <QStringListModel>
#include <QTextBlock>
#include <QTextDocumentFragment>
#include <QUrl>
#include <string>
@ -424,12 +425,15 @@ void CodeEditor::setVarNameList()
LammpsWrapper *lammps = &qobject_cast<LammpsGui *>(parent())->lammps;
int nvar = lammps->id_count("variable");
char buffer[200];
constexpr int BUFLEN = 256;
char buffer[BUFLEN];
for (int i = 0; i < nvar; ++i) {
lammps->variable_info(i, buffer, 200);
if (strlen(buffer) == 1) vars << QString("$%1").arg(buffer);
vars << QString("${%1}").arg(buffer);
vars << QString("v_%1").arg(buffer);
memset(buffer, 0, BUFLEN);
if (lammps->variable_info(i, buffer, BUFLEN)) {
if (strlen(buffer) == 1) vars << QString("$%1").arg(buffer);
vars << QString("${%1}").arg(buffer);
vars << QString("v_%1").arg(buffer);
}
}
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
@ -680,16 +684,35 @@ void CodeEditor::contextMenuEvent(QContextMenuEvent *event)
QString page, help;
find_help(page, help);
// print augmented context menu if an entry was found
auto *menu = createStandardContextMenu();
menu->addSeparator();
auto action = menu->addAction(QString("Display available completions for '%1'").arg(help));
action->setIcon(QIcon(":/icons/expand-text.png"));
connect(action, &QAction::triggered, this, &CodeEditor::runCompletion);
if (textCursor().hasSelection()) {
auto action1 = menu->addAction("Comment out selection");
action1->setIcon(QIcon(":/icons/expand-text.png"));
connect(action1, &QAction::triggered, this, &CodeEditor::comment_selection);
auto action2 = menu->addAction("Uncomment selection");
action2->setIcon(QIcon(":/icons/expand-text.png"));
connect(action2, &QAction::triggered, this, &CodeEditor::uncomment_selection);
} else {
auto action1 = menu->addAction("Comment out line");
action1->setIcon(QIcon(":/icons/expand-text.png"));
connect(action1, &QAction::triggered, this, &CodeEditor::comment_line);
auto action2 = menu->addAction("Uncomment line");
action2->setIcon(QIcon(":/icons/expand-text.png"));
connect(action2, &QAction::triggered, this, &CodeEditor::uncomment_line);
}
menu->addSeparator();
// print augmented context menu if an entry was found
if (!help.isEmpty()) {
auto action = menu->addAction(QString("Display available completions for '%1'").arg(help));
action->setIcon(QIcon(":/icons/expand-text.png"));
connect(action, &QAction::triggered, this, &CodeEditor::runCompletion);
menu->addSeparator();
}
if (!page.isEmpty()) {
menu->addSeparator();
action = menu->addAction(QString("Reformat '%1' command").arg(help));
auto action = menu->addAction(QString("Reformat '%1' command").arg(help));
action->setIcon(QIcon(":/icons/format-indent-less-3.png"));
connect(action, &QAction::triggered, this, &CodeEditor::reformatCurrentLine);
@ -711,10 +734,10 @@ void CodeEditor::contextMenuEvent(QContextMenuEvent *event)
connect(action2, &QAction::triggered, this, &CodeEditor::open_help);
}
}
auto action3 = menu->addAction(QString("LAMMPS Manual"));
action3->setIcon(QIcon(":/icons/help-browser.png"));
action3->setData(QString());
connect(action3, &QAction::triggered, this, &CodeEditor::open_help);
auto action = menu->addAction(QString("LAMMPS Manual"));
action->setIcon(QIcon(":/icons/help-browser.png"));
action->setData(QString());
connect(action, &QAction::triggered, this, &CodeEditor::open_help);
menu->exec(event->globalPos());
delete menu;
@ -736,6 +759,78 @@ void CodeEditor::reformatCurrentLine()
}
}
void CodeEditor::comment_line()
{
auto cursor = textCursor();
cursor.movePosition(QTextCursor::StartOfLine);
cursor.insertText("#");
}
void CodeEditor::comment_selection()
{
auto cursor = textCursor();
auto text = cursor.selection().toPlainText();
auto lines = text.split('\n');
QString newtext;
for (auto line : lines) {
newtext.append('#');
newtext.append(line);
newtext.append('\n');
}
if (newtext.isEmpty()) newtext = "#\n";
cursor.insertText(newtext);
setTextCursor(cursor);
}
void CodeEditor::uncomment_selection()
{
auto cursor = textCursor();
auto text = cursor.selection().toPlainText();
auto lines = text.split('\n');
QString newtext;
for (auto line : lines) {
QString newline;
bool start = true;
for (auto letter : line) {
if (start && (letter == '#')) {
start = false;
continue;
}
if (start && !letter.isSpace()) start = false;
newline.append(letter);
}
newtext.append(newline);
newtext.append('\n');
}
cursor.insertText(newtext);
setTextCursor(cursor);
}
void CodeEditor::uncomment_line()
{
auto cursor = textCursor();
auto text = cursor.block().text();
QString newtext;
bool start = true;
for (auto letter : text) {
if (start && (letter == '#')) {
start = false;
continue;
}
if (start && !letter.isSpace()) start = false;
newtext.append(letter);
}
// perform edit but only if text has changed
if (QString::compare(text, newtext)) {
cursor.beginEditBlock();
cursor.movePosition(QTextCursor::StartOfLine);
cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor, 1);
cursor.insertText(newtext);
cursor.endEditBlock();
}
}
void CodeEditor::runCompletion()
{
QAbstractItemView *popup = nullptr;

View File

@ -81,6 +81,10 @@ private slots:
void reformatCurrentLine();
void runCompletion();
void insertCompletedCommand(const QString &completion);
void comment_selection();
void uncomment_selection();
void comment_line();
void uncomment_line();
private:
QWidget *lineNumberArea;

View File

@ -215,9 +215,11 @@ ImageViewer::ImageViewer(const QString &fileName, LammpsWrapper *_lammps, QWidge
combo->setToolTip("Select group to display");
combo->setObjectName("group");
int ngroup = lammps->id_count("group");
char gname[64];
constexpr int BUFLEN = 256;
char gname[BUFLEN];
for (int i = 0; i < ngroup; ++i) {
lammps->id_name("group", i, gname, 64);
memset(gname, 0, BUFLEN);
lammps->id_name("group", i, gname, BUFLEN);
combo->addItem(gname);
}

View File

@ -58,7 +58,7 @@
#endif
static const QString blank(" ");
static constexpr int BUFLEN = 128;
static constexpr int BUFLEN = 256;
LammpsGui::LammpsGui(QWidget *parent, const char *filename) :
QMainWindow(parent), ui(new Ui::LammpsGui), highlighter(nullptr), capturer(nullptr),
@ -778,11 +778,11 @@ void LammpsGui::logupdate()
if (varwindow) {
int nvar = lammps.id_count("variable");
char buffer[200];
char buffer[BUFLEN];
QString varinfo("\n");
for (int i = 0; i < nvar; ++i) {
lammps.variable_info(i, buffer, 200);
varinfo += buffer;
memset(buffer, 0, BUFLEN);
if (lammps.variable_info(i, buffer, BUFLEN)) varinfo += buffer;
}
if (nvar == 0) varinfo += " (none) ";

View File

@ -121,5 +121,9 @@ if(USE_SPGLIB)
target_link_libraries(phana PRIVATE SPGLIB::SYMSPG)
endif()
# add dependency when using local linear algebra lib
if(NOT LAPACK_FOUND OR NOT BLAS_FOUND OR USE_INTERNAL_LINALG)
add_dependencies(phana linalg)
endif()
target_link_libraries(phana PRIVATE tricubic ${LAPACK_LIBRARIES})
install(TARGETS phana EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR})